/* shell.css (U-SHELL): band, announcement bar, top bar, tabs + keycaps, account menu, bottom nav, hint bar, sheets,
   sign-in sheet, toasts, and the shared tile focus state (PLAN 7.5, 7.6; research/ui.md 3.1, 3.5, 3.6, 4, 5).
   Values come from tokens.css only. No inline styles: dynamic values arrive as custom properties through CSSOM. */

:root { --topbar-h: 56px; }
@media (min-width: 600px) { :root { --topbar-h: 72px; } }

html {
  scroll-padding-top: calc(var(--topbar-h) + var(--s-2));
  scroll-padding-bottom: calc(var(--mini-h) + var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom, 0px));
}
body { position: relative; }

/* ---------- band: the blurred cover on top (3.1) ---------- */
.band {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--band-h);
  z-index: var(--z-band);
  overflow: hidden;
  background-color: var(--art);
  pointer-events: none;
  contain: strict;
}
.band-layer {
  position: absolute;
  inset: 0;
  background-color: var(--layer-art, var(--art));
  background-image: var(--band-img, none);
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(28px) saturate(1.15);
  transform: scale(1.25);
  opacity: 0;
  transition: opacity var(--dur-band) var(--ease-out);
  will-change: opacity;
}
.band-layer:not([data-img]) {
  /* no cover: a soft two-tone wash of the art colour instead of a flat block */
  background-image: radial-gradient(120% 140% at 18% 0%, rgba(255, 255, 255, .16), transparent 60%),
    radial-gradient(90% 120% at 85% 100%, rgba(0, 0, 0, .22), transparent 70%);
  filter: none;
  transform: none;
}
.band-layer.is-in { opacity: 1; }
.band::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, var(--scrim-top) 0%, var(--scrim-bottom) 100%);
}
:root[data-perf="low"] .band-layer { filter: none; transform: none; background-image: none; }

/* ---------- announcement bar ---------- */
#announce-bar { position: relative; z-index: calc(var(--z-topbar) + 1); }
.announce-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 40px;
  padding: var(--s-1) var(--gutter);
  background: rgba(0, 0, 0, .38);
  color: var(--on-band);
  font-size: var(--fs-small);
  font-weight: var(--fw-small);
}
.announce-icon { display: inline-flex; flex: none; opacity: .9; }
.announce-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.announce-link { color: var(--on-band); font-weight: 700; white-space: nowrap; }
.announce-link:hover { color: var(--on-band); opacity: .85; }
.announce-close { width: 36px; height: 36px; flex: none; color: var(--on-band); }
.announce-close:hover { background: rgba(255, 255, 255, .14); }
.chip--new { background: var(--accent); color: #FFFFFF; }

/* ---------- top bar (5.1) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: block;
  min-height: 0;
  padding: 0;
  color: var(--on-band);
  transition: background-color var(--dur-ui) var(--ease-out), box-shadow var(--dur-ui) var(--ease-out);
}
.topbar[data-scrolled] {
  background-color: var(--scrim-top);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
:root[data-perf="low"] .topbar[data-scrolled] { background-color: rgba(8, 8, 12, .82); -webkit-backdrop-filter: none; backdrop-filter: none; }
.topbar-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--gutter);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.topbar-right { justify-content: flex-end; }
.topbar .brand {
  display: none;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--on-band);
  font-size: var(--fs-h3);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-clock {
  display: none;
  font-size: var(--fs-h3);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
@media (min-width: 1600px) { .topbar-clock { display: inline; } }
.topbar-search { color: var(--on-band); }
.topbar-search:hover { background: rgba(255, 255, 255, .14); color: var(--on-band); }
@media (min-width: 1024px) { .topbar-search { display: none; } }
.topbar :focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }

/* account button + menu */
.account { position: relative; display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px; height: 48px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--r-ctl);
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  transition: transform var(--dur-press) var(--ease-out);
}
.avatar:active { transform: scale(.96); }
.avatar--guest { background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .45); border-radius: var(--r-pill); width: 44px; height: 44px; }
.avatar--guest:hover { background: rgba(255, 255, 255, .26); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initials { font-weight: 800; font-size: 1.125rem; letter-spacing: .02em; }
.btn--pill-band { background: #FFFFFF; color: #111114; min-height: 40px; padding: 0 var(--s-4); white-space: nowrap; }
.btn--pill-band:hover { color: #111114; background: #EDEDF2; }

.account-menu {
  position: absolute;
  top: calc(100% + var(--s-2));
  left: 0;
  z-index: var(--z-sheet);
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  padding: var(--s-2);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-3);
  animation: menu-in var(--dur-ui) var(--ease-out);
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.account-menu :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-menu-head { display: grid; gap: 2px; padding: var(--s-3) var(--s-3) var(--s-2); }
.account-menu-head .chip { justify-self: start; }
.account-menu-name { font-weight: 700; font-size: var(--fs-label); overflow-wrap: anywhere; }
.account-menu-list { margin: 0; padding: 0; list-style: none; }
.account-menu-list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s-3);
  border-radius: var(--r-ctl);
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.account-menu-list a:hover { background: var(--surface-2); color: var(--ink); }
.account-menu-signout { width: 100%; margin-top: var(--s-2); }

/* theme picker (menu and anywhere else) */
.theme-picker { margin: var(--s-2) 0 0; padding: var(--s-2) var(--s-3) var(--s-3); border: 0; border-top: 1px solid var(--line); }
.theme-picker-legend { padding: var(--s-2) 0; font-size: var(--fs-micro); font-weight: var(--fw-micro); letter-spacing: var(--ls-micro); text-transform: uppercase; color: var(--ink-3); }
.theme-picker-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-1); padding: var(--s-1); border-radius: var(--r-ctl); background: var(--surface-2); }
.theme-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s-2) var(--s-1);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: var(--fs-small);
  font-weight: 600;
  cursor: pointer;
}
.theme-option input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.theme-option:has(input:checked) { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.theme-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- tabs (5.2) with keycaps ---------- */
.tabs { display: flex; align-items: center; gap: clamp(var(--s-2), 1.6vw, var(--s-6)); }
.tabs-list { display: flex; align-items: center; gap: clamp(var(--s-1), 2.4vw, 56px); margin: 0; padding: 0; list-style: none; }
.tabs .tab {
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--on-band);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, .25);
  transition: background-color var(--dur-ui) var(--ease-out);
}
.tabs .tab:hover { background: rgba(0, 0, 0, .22); color: var(--on-band); }
.tabs .tab[aria-current="page"] { background: var(--tab-pill); color: #FFFFFF; text-shadow: none; }
.tabs .tab:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
.tab-cap { display: inline-flex; color: #FFFFFF; }
.tab-cap .keycap rect { fill: #FFFFFF; fill-opacity: 1; stroke: #FFFFFF; }
.tab-cap .keycap path { stroke: rgba(0, 0, 0, .35); stroke-opacity: 1; }
.tab-cap .keycap text { fill: #111114; }
.tab-cap .bumper path:first-child { fill: #FFFFFF; fill-opacity: 1; stroke: #FFFFFF; }
.tab-cap .bumper path:last-child { stroke: #111114; }
@media (max-width: 1023px) {
  .tabs .tab { padding: 0 var(--s-4); font-size: var(--fs-label); min-height: 44px; }
}
@media (max-width: 767px) { .tab-cap { display: none; } }

/* phones: tabs move to the bottom nav, the top bar shows account, name and search */
@media (max-width: 599px) {
  .topbar-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-2); }
  .topbar .tabs { display: none; }
  .topbar .brand { display: block; }
  .topbar-left { display: contents; }
  .signin-link { min-height: 36px; padding: 0 var(--s-3); font-size: var(--fs-small); }
}

/* ---------- bottom nav (5.11, < 600 px) ---------- */
.bottomnav { display: none; }
@media (max-width: 599px) {
  .bottomnav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: var(--z-bottomnav);
    display: block;
    padding: 0 var(--s-2) env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  :root { --bottomnav-h: 56px; }
}
.bottomnav-list { display: flex; justify-content: space-around; margin: 0; padding: 0; list-style: none; }
.bottomnav-list li { flex: 1 1 0; }
.bottomnav .bottomnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 0 var(--s-1);
  border-radius: var(--r-ctl);
  background: none;
  color: var(--ink-3);
  font-weight: 600;
  text-decoration: none;
}
.bottomnav .bottomnav-item[aria-current="page"] { background: none; color: var(--accent); }
.bottomnav-label { font-size: var(--fs-micro); letter-spacing: .01em; }

/* ---------- hint bar (5.5) ---------- */
.hintbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-6);
  color: var(--ink);
  font-size: var(--fs-label);
  font-weight: var(--fw-label);
  line-height: 1.3;
}
.hintbar[data-empty] { display: none; }
.hint { display: inline-flex; align-items: center; gap: var(--s-2); }
.hint .glyph { flex: none; color: var(--ink); }
.hint .diamond circle { stroke: var(--accent); }
.hint .diamond circle[fill="currentColor"] { fill: var(--accent); }
:root[data-input="touch"] .hintbar { display: none; }
@media (max-width: 599px) { .hintbar { display: none; } }
@media (min-width: 600px) and (max-width: 1023px) { :root:not([data-input="kbd"]):not([data-input="pad"]) .hintbar { display: none; } }
.hintbar--floating {
  position: fixed;
  left: var(--gutter);
  bottom: calc(var(--mini-h) + var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-player);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--sh-2);
  font-size: var(--fs-small);
}
:root:not([data-input="kbd"]):not([data-input="pad"]) .hintbar--floating { display: none; }
html:not(:has(#player:not(:empty))) .hintbar--floating { bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px)); }

/* ---------- the shared tile focus state (3.5) ---------- */
.tile {
  position: relative;
  transition: transform var(--dur-focus) var(--ease-out), box-shadow var(--dur-focus) var(--ease-out);
}
.tile:focus-visible, .tile[data-focused] {
  z-index: var(--z-focus);
  transform: scale(1.06);
  box-shadow: var(--sh-2);
  outline: 3px solid #FFFFFF;
  outline-offset: -3px;
}
.tile:focus-visible::after, .tile[data-focused]::after {
  content: "";
  position: absolute;
  inset: -2px;
  border: 2px solid var(--ink);
  pointer-events: none;
}
[data-row] > :first-child > .tile, [data-row] > .tile:first-child { transform-origin: left center; }
@media (hover: hover) and (pointer: fine) {
  .tile:hover { z-index: var(--z-focus); transform: scale(1.06); box-shadow: var(--sh-2); }
}
:root[data-mode="tv"] .tile:focus-visible, :root[data-mode="tv"] .tile[data-focused] { outline-width: 4px; outline-offset: -4px; }
:root[data-mode="tv"] .tile:focus-visible::after { border-width: 3px; inset: -3px; }

/* ---------- sheets (5.12) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: rgba(8, 8, 12, .5);
  opacity: 0;
  transition: opacity var(--dur-ui) var(--ease-out);
}
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: relative;
  width: min(480px, 100%);
  max-height: min(85vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: var(--s-6);
  border-radius: var(--r-ctl);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--sh-3);
  transform: translateY(10px) scale(.985);
  transition: transform var(--dur-ui) var(--ease-out);
}
.sheet-backdrop.is-open .sheet { transform: none; }
.sheet-grip { display: none; }
.sheet :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 599px) {
  .sheet-backdrop { place-items: end stretch; padding: 0; }
  .sheet {
    width: 100%;
    max-height: 88vh;
    padding: var(--s-3) var(--gutter) calc(var(--s-5) + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }
  .sheet-grip { display: block; width: 40px; height: 4px; margin: 0 auto var(--s-4); border-radius: var(--r-pill); background: var(--surface-2); }
}
html.has-sheet { overflow: hidden; }

/* sign-in sheet */
.signin-sheet { display: grid; gap: var(--s-3); }
.signin-mark {
  display: grid;
  place-items: center;
  width: 56px; height: 56px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.signin-title { margin: var(--s-2) 0 0; font-size: var(--fs-h2); font-weight: 800; letter-spacing: var(--ls-h2); }
.signin-reason { margin: 0; color: var(--ink-2); }
.signin-points { display: grid; gap: var(--s-2); margin: var(--s-2) 0; padding: 0; list-style: none; color: var(--ink-2); font-size: var(--fs-small); }
.signin-points li { position: relative; padding-left: var(--s-5); }
.signin-points li::before {
  content: "";
  position: absolute;
  left: 2px; top: .45em;
  width: 10px; height: 6px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}
.signin-actions { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.signin-google { width: 100%; }
.signin-legal { margin: 0; }

/* ---------- toasts (5.13) ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-toast);
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  width: max-content;
  max-width: calc(100vw - 2 * var(--gutter));
  transform: translateX(-50%);
  pointer-events: none;
}
html:has(#player:not(:empty)) .toasts { bottom: calc(var(--mini-h) + var(--bottomnav-h) + var(--s-4) + env(safe-area-inset-bottom, 0px)); }
.toast {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  max-width: 100%;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--sh-2);
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-ui) var(--ease-out), transform var(--dur-ui) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; }
.toast-text { min-width: 0; overflow-wrap: anywhere; }
.toast-action { flex: none; padding: var(--s-1) var(--s-2); border: 0; border-radius: var(--r-pill); background: transparent; color: inherit; font-weight: 700; text-decoration: underline; }
.toast-action:focus-visible { outline: 2px solid var(--bg); outline-offset: 2px; }

/* ---------- glyphs and icons ---------- */
.glyph, .icon { display: inline-block; flex: none; vertical-align: middle; }
.glyph text { font-family: var(--font); }
.eq { color: var(--accent); }
.eq-bar { transform-box: fill-box; transform-origin: bottom; animation: eq 1s var(--ease-io) infinite alternate; }
.eq-bar--1 { animation-delay: -.3s; }
.eq-bar--2 { animation-delay: -.6s; }
.eq-bar--3 { animation-delay: -.15s; }
@keyframes eq { from { transform: scaleY(.3); } to { transform: scaleY(1); } }

/* skip links: the player one only while the player shows something (index.js sets [hidden]) */
.skip-link:focus { z-index: calc(var(--z-toast) + 1); }

/* ---------- reduced motion (3.6): no scale, no slide, no view transitions ---------- */
@media (prefers-reduced-motion: reduce) {
  .tile, .tile:hover, .tile:focus-visible, .tile[data-focused] { transform: none; transition: box-shadow var(--dur-focus) linear; }
  .band-layer { transition: opacity 120ms linear; }
  .sheet, .sheet-backdrop.is-open .sheet { transform: none; }
  .toast { transform: none; }
  .account-menu { animation: none; }
  .eq-bar { animation: none; transform: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
