.bd-shell {
  --bd-shell-header-height: 56px;
  --bd-shell-guide-width: 240px;
  --bd-shell-surface: #ffffff;
  --bd-shell-border: #e5e5e5;
  --bd-shell-text: #0f0f0f;
  --bd-shell-muted: #606060;
  --bd-shell-hover: #f2f2f2;
  --bd-shell-active: #0f0f0f;
  --bd-shell-active-text: #ffffff;
  color: var(--bd-shell-text);
}

.bd-shell__skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1300;
  padding: 8px 12px;
  border-radius: 999px;
  background: #0f0f0f;
  color: #fff;
  transform: translateY(-200%);
  transition: transform 0.18s ease;
}

.bd-shell__skip:focus {
  transform: translateY(0);
}

.bd-shell__header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 1100;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  height: var(--bd-shell-header-height);
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--bd-shell-border);
  backdrop-filter: blur(14px);
}

.bd-shell__header-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.bd-shell__icon-button,
.bd-shell__pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.bd-shell__icon-button {
  width: 40px;
  height: 40px;
}

.bd-shell__icon-button[data-bd-shell-account-toggle] {
  padding: 0;
}

.bd-shell__pill-button {
  min-height: 36px;
  padding: 0 14px;
  background: #f2f2f2;
  font-weight: 500;
}

.bd-shell__icon-button:hover,
.bd-shell__pill-button:hover,
.bd-shell__menu-link:hover,
.bd-shell__guide-link:hover,
.bd-shell__guide-toggle:hover {
  background: var(--bd-shell-hover);
}

.bd-shell__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.bd-shell__brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.bd-shell__brand-mark {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.bd-shell__brand-name {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.bd-shell__brand-region {
  font-size: 1.1rem;
  color: var(--bd-shell-muted);
}

.bd-shell__search-toggle-mobile {
  display: none;
}

.bd-shell__search {
  display: flex;
  justify-content: center;
}

.bd-shell__search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  width: min(100%, 720px);
  gap: 8px;
}

.bd-shell__search-field {
  display: flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid #d3d3d3;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.bd-shell__search-field input,
.bd-shell__mobile-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 0 16px;
  color: inherit;
}

.bd-shell__search-submit {
  width: 64px;
  height: 40px;
  border: 1px solid #d3d3d3;
  border-radius: 999px;
  background: #f8f8f8;
}

.bd-shell__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bd-shell__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.bd-shell__mobile-search {
  position: fixed;
  z-index: 1200;
  top: var(--bd-shell-header-height);
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--bd-shell-surface);
  border-bottom: 1px solid var(--bd-shell-border);
}

.bd-shell__mobile-search[hidden] {
  display: none !important;
}

.bd-shell__guide {
  position: fixed;
  top: var(--bd-shell-header-height);
  left: 0;
  bottom: 0;
  z-index: 1000;
  width: var(--bd-shell-guide-width);
  overflow-y: auto;
  padding: 12px;
  background: var(--bd-shell-surface);
  border-right: 1px solid var(--bd-shell-border);
}

.bd-shell__guide-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--bd-shell-border);
}

.bd-shell__guide-section:last-child {
  border-bottom: 0;
}

.bd-shell__section-title {
  margin: 0 0 8px;
  padding: 0 12px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--bd-shell-muted);
}

.bd-shell__guide-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bd-shell__guide-item + .bd-shell__guide-item {
  margin-top: 2px;
}

.bd-shell__guide-link {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}

.bd-shell__guide-link.is-active {
  background: var(--bd-shell-hover);
  color: var(--bd-shell-text);
  font-weight: 600;
}

.bd-shell__guide-icon,
.bd-shell__guide-avatar {
  width: 24px;
  height: 24px;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 24px;
}

.bd-shell__guide-icon {
  color: currentColor;
  border-radius: 0;
}

.bd-shell__guide-avatar {
  border-radius: 50%;
}

.bd-shell__guide-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bd-shell__guide-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ea6ff;
}

.bd-shell__guide-copy {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bd-shell__page-content {
  min-height: 100vh;
  padding-top: calc(var(--bd-shell-header-height) + 16px);
  padding-left: calc(var(--bd-shell-guide-width) + 16px);
}

.bd-shell__page-content--preview {
  padding-right: 16px;
  padding-bottom: 40px;
}

.layout-preview {
  padding: 0 8px 32px;
}

.layout-preview__panel {
  border: 1px solid var(--bd-shell-border);
  border-radius: 24px;
  padding: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfb 100%);
}

.layout-preview__eyebrow {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--bd-shell-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.layout-preview__hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.layout-preview__hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 3vw, 4.4rem);
  line-height: 1.05;
}

.layout-preview__hero p {
  margin: 12px 0 0;
  max-width: 62rem;
  color: var(--bd-shell-muted);
  font-size: 1.5rem;
  line-height: 1.7;
}

.layout-preview__stat {
  display: grid;
  gap: 12px;
  padding: 20px;
  border-radius: 20px;
  background: #0f0f0f;
  color: #fff;
}

.layout-preview__stat strong {
  font-size: 3.2rem;
  line-height: 1;
}

.layout-preview__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.layout-preview__card {
  padding: 18px;
  border-radius: 18px;
  background: #f8f8f8;
}

.layout-preview__card h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

.layout-preview__card p {
  margin: 0;
  color: var(--bd-shell-muted);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .bd-shell__header {
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 0 0;
  }

  .bd-shell__search {
    display: none;
  }

  .bd-shell__actions {
    justify-self: end;
  }

  .bd-shell__search-toggle-mobile {
    display: inline-flex;
  }

  .bd-shell__guide {
    display: none;
  }

  .bd-shell__page-content {
    padding-left: 0;
    padding-top: calc(var(--bd-shell-header-height) + 12px);
  }

  .layout-preview__hero,
  .layout-preview__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .bd-shell__actions .bd-shell__pill-button span {
    display: none;
  }

  .layout-preview__panel {
    padding: 22px 18px;
  }
}

/* ── Popup dropdowns (Create & Account) ── */

.bd-shell__popup {
  position: fixed;
  z-index: 2202;
  outline: none;
  background: var(--bd-shell-surface, #ffffff);
  border-radius: 12px;
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.bd-shell__popup[hidden] {
  display: none !important;
}

.bd-shell__popup--create {
  max-width: 220px;
}

.bd-shell__popup--account {
  max-width: 300px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
}

.yt-compose-modal {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  isolation: isolate;
}

html:has(body.yt-compose-open),
body.yt-compose-open {
  overflow: hidden;
}

body.yt-compose-open::after,
body:has(.bd-voice-modal:not([hidden]))::after,
body:has(.Dashboard-Modal:not([hidden]))::after,
body:has(.report-modal-backdrop:not([hidden]))::after,
body:has(.work-share-modal-overlay:not([hidden]))::after,
body:has(.artwork-dialog-backdrop:not([hidden]))::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.56);
  pointer-events: none;
  z-index: 9999;
}

.yt-compose-modal[hidden] {
  display: none !important;
}

.yt-compose-modal__backdrop {
  position: fixed;
  inset: 0;
  border: 0;
  background: transparent;
}

.yt-compose-modal__content {
  position: relative;
  z-index: 1;
  width: min(100%, 1120px);
  max-width: 100%;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  overflow: auto;
  padding: 24px;
}

.yt-compose-modal__content[data-compose-view="gallery-register"] {
  width: min(100%, 600px);
}

.yt-compose-modal__content[data-compose-view="work-register"] {
  width: min(100%, 960px);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.yt-compose-modal__loading,
.yt-compose-modal__error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  color: #0f0f0f;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
  text-align: center;
}

/* ── Popup internals: fill missing tag-based YouTube styles ── */

/* 1. Dropdown content container (= ytd-multi-page-menu-renderer) */
.bd-shell__popup > div > [slot="dropdown-content"] {
  display: flex;
  flex-direction: column;
  background: var(--yt-spec-menu-background, #fff);
  overflow-x: hidden;
}

/* 2. Compact-link wrapper (= ytd-compact-link-renderer host) */
.bd-shell__popup [compact-link-style] {
  --paper-item-min-height: 40px;
  display: block;
}

/* 3. Paper-item row (= tp-yt-paper-item inside compact-link) */
.bd-shell__popup [style-target="host"].ytd-compact-link-renderer {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  min-height: var(--paper-item-min-height, 48px);
  height: var(--paper-item-min-height, 48px);
  padding: 0 36px 0 16px;
  color: var(--yt-compact-link-color, var(--yt-spec-text-primary, #0f0f0f));
  position: relative;
  line-height: 2rem;
}

/* 4. Items with secondary icon get symmetric padding */
.bd-shell__popup [has-secondary] [style-target="host"].ytd-compact-link-renderer {
  padding: 0 16px;
}

/* 5. Account header (= ytd-active-account-header-renderer) */
.bd-shell__popup section[enable-handles-account-menu-switcher] {
  border-bottom: 1px solid var(--yt-spec-outline, rgba(0, 0, 0, 0.1));
  box-sizing: border-box;
  position: relative;
  padding: 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.bd-shell__popup section[enable-handles-account-menu-switcher] .yt-img-shadow {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50%;
  object-fit: cover;
}

.bd-shell__popup #account-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f0f0f;
}

.bd-shell__popup #channel-handle {
  display: block;
  font-size: 0.85rem;
  color: #606060;
  margin-top: 2px;
}

.bd-shell__popup #manage-account {
  display: block;
  margin-top: 6px;
}

.bd-shell__popup #manage-account a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bd-chat-accent, #6800EA);
  text-decoration: none;
}

.bd-shell__popup #manage-account a:hover {
  text-decoration: underline;
}

/* 6. Toggle-theme row (= ytd-toggle-theme-compact-link-renderer) */
.bd-shell__popup #items > [role="link"]:not([compact-link-style]) {
  --paper-item-min-height: 40px;
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 40px;
  color: var(--yt-spec-text-primary, #0f0f0f);
  cursor: pointer;
  padding: 0 16px;
}

/* 7. Hover effect for menu items */
.bd-shell__popup [style-target="host"].ytd-compact-link-renderer:hover,
.bd-shell__popup #items > [role="link"]:not([compact-link-style]):hover {
  background-color: var(--yt-spec-additive-background, rgba(0, 0, 0, 0.05));
}

/* ── Notification popup ── */

.bd-shell__popup--notification {
  max-width: 480px;
  width: 480px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
}

.bd-shell__notification-badge {
  position: absolute;
  top: 4px;
  right: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.bd-shell__notification-empty {
  padding: 40px 16px;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

.bd-shell__notification-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  border-bottom: 1px solid var(--yt-spec-outline, rgba(0, 0, 0, 0.1));
}

.bd-shell__notification-title {
  font-family: "Roboto", sans-serif;
  font-weight: 400;
  color: var(--yt-spec-text-primary, #0f0f0f);
  margin: 0;
}

.bd-shell__notification-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--yt-spec-text-primary, #0f0f0f);
}

.bd-shell__notification-toggle:hover {
  background-color: var(--yt-spec-additive-background, rgba(0, 0, 0, 0.05));
}

.bd-shell__notification-toggle svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.bd-shell__notification-toggle.is-off {
  color: var(--yt-spec-text-secondary, #606060);
}

.bd-shell__notification-toggle .notification-icon-on,
.bd-shell__notification-toggle .notification-icon-off {
  pointer-events: none;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.bd-shell__notification-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bd-shell__notification-readall {
  border: 1px solid #d9d9d9;
  background: #fff;
  color: #0f0f0f;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.bd-shell__notification-readall:hover {
  background: #f2f2f2;
  border-color: #c8c8c8;
}

/* ── 스낵바 ── */
.bd-snackbar {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #323232;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  z-index: 99999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.bd-snackbar.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bd-shell__notification-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--yt-spec-text-secondary, #606060);
}

.bd-shell__notification-empty p {
  margin: 0 0 8px;
  font-weight: 400;
  color: var(--yt-spec-text-primary, #0f0f0f);
}

.bd-shell__notification-empty span {
  line-height: 2rem;
}

.bd-shell__notification-list {
  display: flex;
  flex-direction: column;
}

.bd-shell__notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  text-decoration: none;
  color: var(--yt-spec-text-primary, #0f0f0f);
  transition: background 0.15s ease;
}

.bd-shell__notification-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

.bd-shell__notification-item.is-unread {
  background: color-mix(in srgb, var(--bd-chat-accent, #6800EA) 6%, white);
}

.bd-shell__notification-item.is-unread:hover {
  background: color-mix(in srgb, var(--bd-chat-accent, #6800EA) 10%, white);
}

.bd-shell__notification-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.bd-shell__notification-avatar--square {
  border-radius: 8px;
}

.bd-shell__notification-body {
  flex: 1;
  min-width: 0;
}

.bd-shell__notification-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--yt-spec-text-primary, #0f0f0f);
}

.bd-shell__notification-text strong {
  font-weight: 700;
}

.bd-shell__notification-time {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--yt-spec-text-secondary, #606060);
}

.bd-shell__notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bd-chat-accent, #6800EA);
  flex-shrink: 0;
  margin-top: 6px;
}

/* ── Popup responsive ── */
@media (max-width: 600px) {
  .bd-shell__popup--create,
  .bd-shell__popup--account,
  .bd-shell__popup--notification {
    position: fixed;
    top: var(--bd-shell-header-height) !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100vh - var(--bd-shell-header-height)) !important;
    max-height: none !important;
    border-radius: 0;
    box-shadow: none;
    overflow-y: auto;
    animation: shellPopupSlideUp 0.22s ease;
  }

  /* 인라인 style의 max-width/max-height 덮어쓰기 */
  .bd-shell__popup .style-scope.tp-yt-iron-dropdown {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
  }

  .bd-shell__popup [slot="dropdown-content"] {
    width: 100% !important;
    max-width: 100% !important;
    max-height: none !important;
    min-height: 100%;
  }

  /* 계정 헤더 모바일 확대 */
  .bd-shell__popup section[enable-handles-account-menu-switcher] {
    padding: 20px 16px;
    gap: 14px;
  }

  /* 메뉴 항목 터치 영역 확대 */
  .bd-shell__popup [style-target="host"].ytd-compact-link-renderer {
    min-height: 48px;
    height: 48px;
  }
}

@keyframes shellPopupSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
