/* The Watch and Cinema palette is shared by the rest of the app. */
:root {
  --site-bg: #090d14;
  --site-surface: #101722;
  --site-raised: #1a2535;
  --site-line: #293344;
  --site-text: #f3f5fa;
  --site-muted: #b4c0d0;
  --site-accent: #c1f46c;
  --site-font: system-ui, sans-serif;
  --site-radius: 16px;
  background: var(--site-bg);
}

:root[data-custom-accent="true"] { --site-accent: var(--accent); }

:is(html.route-pending body, body:not(:has(#watch-view:not([hidden]), #cinema-view:not([hidden], .cinema-docked)))) {
  --bg: var(--site-bg);
  --surface: var(--site-surface);
  --raised: var(--site-raised);
  --selected: #232e3e;
  --border: var(--site-line);
  --divider: var(--site-line);
  --text: var(--site-text);
  --bright: var(--site-text);
  --muted: var(--site-muted);
  --accent: var(--site-accent);
  --ui: var(--site-font);
  --terminal: var(--site-font);
  --glow: none;
  font: 400 15px/1.5 var(--site-font);

  > .shell {
    display: flex;
    flex-direction: column;
    width: min(100% - 48px, 1480px);
    min-height: 100vh;
    margin-inline: auto;
    padding: 0;
    border: 0;
  }

  .topbar.panel {
    display: flex;
    flex-wrap: nowrap;
    min-height: 72px;
    gap: 12px 20px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--site-line);
    background: var(--site-bg);
  }

  .topbar .brand { flex: 0 1 auto; }

  .topbar .topnav {
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
    order: initial;
    font: 600 14px/1.2 var(--site-font);
  }

  .topnav a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    border: 0;
    border-radius: 999px;
    color: var(--site-muted);
    white-space: nowrap;
  }

  .workspace {
    display: grid;
    flex: 1;
    grid-template-columns: 212px minmax(0, 1fr);
    align-items: start;
    gap: clamp(20px, 3vw, 48px);
    margin: 24px 0 32px;
  }

  .sidebar {
    display: flex;
    min-height: 0;
    border: 1px solid var(--site-line);
    border-radius: var(--site-radius);
    background: var(--site-surface);
  }

  .sidebar nav { display: grid; gap: 2px; padding: 10px; }
  .sidebar nav:not(:has(a:not([hidden]))) { display: none; }
  .sidebar nav a {
    gap: 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    color: var(--site-muted);
    font-weight: 600;
  }
  .sidebar nav .icon { width: 18px; height: 18px; flex-shrink: 0; }
  .sidebar section, .side-bottom { padding: 16px; }
  .sidebar section:first-of-type { border-top: 0; }
  .sidebar nav:has(a:not([hidden])) + section { border-top: 1px solid var(--site-line); }
  .sidebar h2, #site-footer-title { color: var(--site-text); font: 650 13px/1.4 var(--site-font); }
  .sidebar .channel-row { margin-top: 12px; color: var(--site-text); }
  .sidebar .channel-row small, .side-bottom small { font-size: 12px; }
  .sidebar .tags { gap: 6px; }
  .sidebar .tags span {
    padding: 3px 8px;
    border: 0;
    border-radius: 999px;
    background: var(--site-raised);
    color: var(--site-muted);
    font-size: 12px;
  }
  .sidebar .side-note p { margin-top: 6px; font-size: 13px; }
  .sidebar .side-note .terminal { margin-top: 12px; color: var(--site-muted); }
  .side-bottom { border-top: 1px solid var(--site-line); }
  .side-bottom a {
    display: flex;
    align-items: center;
    min-height: 44px;
    margin: 8px 0 -6px;
    color: var(--site-muted);
    font-size: 13px;
  }

  .topnav a:hover, .sidebar nav a:hover {
    background: var(--site-raised);
    color: var(--site-text);
    text-decoration: none;
  }
  .topnav a[aria-current="page"] { background: var(--site-text); color: var(--site-bg); }
  .sidebar a[aria-current="page"] { background: var(--site-raised); color: var(--site-text); }
  .side-bottom a[aria-current="page"] { background: none; }

  @media (min-width: 1101px) {
    .topnav :is([data-route="studio"], [data-route="analytics"]), .site-footer a { display: none; }
  }

  @media (max-width: 1100px) {
    .topbar.panel {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      grid-template-areas: "brand tools" "nav nav";
      gap: 2px 8px;
    }
    .topbar .brand { grid-area: brand; justify-self: start; max-width: 100%; }
    .topbar .top-tools { grid-area: tools; margin-left: 0; }
    .topbar .topnav { grid-area: nav; width: 100%; justify-content: center; flex-wrap: wrap; }
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .workspace > .sidebar { display: none; }
  }

  @media (max-width: 960px) {
    > .shell { width: calc(100% - 24px); }
    .workspace { margin-top: 18px; }
  }

  @media (max-width: 700px) {
    .topbar .topnav.account-signed-in { display: none; }
  }

  @media (max-width: 480px) {
    .topnav a { padding-inline: 7px; font-size: 13px; }
  }
}

body > .shell :is(.topbar, .sidebar).panel {
  border-image: none;
  box-shadow: none;
  animation: none;
}

body > .shell :is(.topbar, .sidebar).panel::before,
body > .shell :is(.topbar, .sidebar).panel::after { content: none; }

.topbar .brand {
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  color: var(--site-accent);
}

.topbar .brand > .brand-mark { width: 32px; height: 32px; }
.topbar .brand > div { min-width: 0; }

.topbar .brand .wordmark {
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 28px;
  text-shadow: none;
}

.topbar .brand small { display: none; }

.topbar .top-tools {
  gap: 6px;
  flex: 0 0 auto;
  font: 600 13px/1.3 var(--site-font);
  color: var(--site-text);
}

.topbar :is(.header-menu > summary, .account-tools > a, .site-edit-toggle) {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 11px;
  border: 1px solid var(--site-line);
  border-radius: 999px;
  background: transparent;
  color: var(--site-text);
  font: inherit;
}

.topbar .account-tools > a { display: inline-flex; align-items: center; justify-content: center; }
.topbar .account-tools > .primary {
  background: var(--site-text);
  border-color: var(--site-text);
  color: var(--site-bg);
}
.topbar :is(.header-menu > summary, .account-tools > a:not(.primary), .site-edit-toggle):hover,
.topbar :is(.header-menu[open] > summary, .site-edit-toggle[aria-pressed="true"]) {
  background: var(--site-raised);
  border-color: var(--site-line);
  text-decoration: none;
}
.topbar .account-tools > .primary:hover {
  background: var(--site-muted);
  border-color: var(--site-muted);
  text-decoration: none;
}
.topbar .account-menu summary > .tag {
  padding: 3px 6px;
  border: 0;
  border-radius: 999px;
  background: var(--site-raised);
  color: var(--site-muted);
  font: 600 10px/1.4 var(--site-font);
}
.topbar .account-tools > a[aria-current="page"] { border-color: var(--site-accent); }
.topbar img.account-avatar { border-color: var(--site-line); }

.topbar .header-menu > div {
  top: calc(100% + 8px);
  width: min(278px, calc(100vw - 24px));
  min-width: 0;
  max-height: min(480px, calc(100dvh - 136px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--site-line);
  border-radius: var(--site-radius);
  background: var(--site-surface);
  color: var(--site-text);
  box-shadow: none;
  font-weight: 400;
}
.topbar .header-menu a, .topbar .account-menu-account > button {
  padding: 10px;
  border: 0;
  border-radius: 8px;
  color: var(--site-muted);
  font: inherit;
  text-align: left;
}
.topbar .header-menu :is(a, .account-menu-account > button):hover,
.topbar .header-menu a[aria-current="page"] {
  background: var(--site-raised);
  color: var(--site-text);
  text-decoration: none;
}

.topbar .account-menu-navigation {
  gap: 2px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--site-line);
}
.topbar .account-menu-navigation a { gap: 10px; }

/* Cinema has no top navigation. On Watch, owner links live in the account menu. */
body:has(#cinema-view:not([hidden], .cinema-docked)) .topbar .account-menu-navigation { display: grid; }

@media (min-width: 701px) {
  body:has(#watch-view:not([hidden])) .topbar .account-menu-navigation:has([data-route="studio"]) { display: grid; }
  body:has(#watch-view:not([hidden])) .topbar .account-menu-navigation a:not([data-route="studio"], [data-route="analytics"]) { display: none; }
}

.topbar .accent-editor {
  min-width: 0;
  border-color: var(--site-line);
  margin: 4px 4px 8px;
}

.topbar .accent-editor > strong { color: var(--site-text); font: 650 14px/1.3 var(--site-font); }
.topbar .accent-wheel { max-width: 100%; border-color: var(--site-line); }
.topbar .accent-editor input:not([type="checkbox"]) {
  border: 1px solid var(--site-line);
  border-radius: 8px;
  background: var(--site-raised);
  color: var(--site-text);
  font-family: var(--site-font);
}

.topbar .accent-actions .button {
  border: 1px solid var(--site-line);
  border-radius: 999px;
  background: transparent;
  color: var(--site-text);
  box-shadow: none;
}

.topbar .accent-actions .button:hover { background: var(--site-raised); }
.topbar .crt-control { white-space: normal; border-radius: 8px; }
.topbar .crt-control:hover { background: var(--site-raised); }
.topbar .crt-control input { flex-shrink: 0; accent-color: var(--site-accent); }
.topbar .appearance-menu #motion-note { color: var(--site-muted); font: 12px/1.5 var(--site-font); }

.site-footer {
  align-items: center;
  justify-content: space-between;
  min-height: 55px;
  gap: 4px 16px;
  padding: 7px 0;
  border-top: 1px solid var(--site-line);
  color: var(--site-muted);
  font: 400 13px/1.5 var(--site-font);
  letter-spacing: normal;
}
.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--site-muted);
}
.site-footer a[aria-current="page"] { color: var(--site-text); }

#toast {
  border: 1px solid var(--site-line);
  border-radius: 12px;
  background: var(--site-raised);
  color: var(--site-text);
  font-family: var(--site-font);
}

:where(.topbar, .sidebar, .site-footer, .site-edit-bar, .site-inline-dialog) :focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 2px;
}

.site-edit-bar, .site-inline-dialog {
  --bg: var(--site-bg);
  --border: var(--site-line);
  --raised: var(--site-raised);
  --surface: var(--site-surface);
  --text: var(--site-text);
  --bright: var(--site-text);
  --muted: var(--site-muted);
  --ui: var(--site-font);
  --terminal: var(--site-font);
  border-radius: var(--site-radius);
  color: var(--site-text);
  font-family: var(--site-font);
}

@media (max-width: 700px) {
  .topbar .header-menu { position: static; }
  .topbar .header-menu > div { right: 0; }
  .topbar .appearance-menu summary { width: 44px; justify-content: center; padding: 0; }
  .topbar :is(.appearance-menu summary span, .account-menu summary > .tag) { display: none; }
}

@media (max-width: 480px) {
  .topbar .brand { gap: 4px; }
  .topbar .brand > .brand-mark { width: 24px; height: 24px; flex-basis: 24px; }
  .topbar .brand .wordmark { font-size: 20px; }
  .topbar .top-tools { gap: 4px; }
  .topbar .account-display-name { max-width: 68px; }
  .topbar .account-tools > a { padding-inline: 8px; }
}
