/* Flimmer on the web — CONTRACT §4.13 and §7. The tokens are Theme.swift's;
   no colour below is invented except the drawn-art palettes, which arrive as
   custom properties from artwork.js. Cinema dark, paper-calm: posters do the
   talking and the one accent is the projector bulb. */

:root {
  --ink: #0a0a0c;
  --surface: #141418;
  --surface-raised: #1e1e24;
  --hairline: #2a2a32;
  --bulb: #ffb454;
  --bulb-dim: #8a6234;
  --bulb-light: #ffe2b0;
  --text: #f4f2ee;
  --text-2: #9c9aa4;
  --text-3: #85838d;
  --on-bulb: #1a1208;

  --radius-card: 14px;
  --radius-sheet: 20px;
  --radius-badge: 8px;

  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;

  /* §7.4: a spring (response 0.35, damping 0.86), sampled; never a bounce. */
  --spring: cubic-bezier(0.2, 0.9, 0.25, 1);
  --spring-ms: 420ms;
  --fade-ms: 200ms;

  --gutter: 20px;
  --poster-w: clamp(116px, 31vw, 150px);
  --tile-w: clamp(96px, 25vw, 120px);
  --topbar-h: 52px;
  --tabbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --spring: linear(0, 0.0412, 0.1377, 0.2592, 0.3859, 0.5062, 0.6136, 0.7054, 0.7812, 0.8419, 0.8892, 0.9251, 0.9517, 0.9709, 0.9842, 0.9932, 0.9989, 1.0024, 1.0042, 1.0049, 1.005, 1.0046, 1.0041, 1.0035, 1);
  }
}

@media (min-width: 900px) {
  :root {
    --gutter: 40px;
    --poster-w: 156px;
    --tile-w: 124px;
  }
}

/* ------------------------------------------------------------------------ */
/* Base                                                                      */
/* ------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
  color-scheme: dark;
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  scrollbar-color: var(--hairline) transparent;
}

html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ink);
  color: var(--text);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

[hidden] { display: none !important; }

button, input, a { font: inherit; color: inherit; }
button { touch-action: manipulation; }
a { color: var(--bulb); text-decoration: none; touch-action: manipulation; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { display: block; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--bulb);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only, .sr-only-input {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 50;
  inset-block-start: calc(var(--safe-top) + 8px);
  inset-inline-start: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bulb);
  color: var(--on-bulb);
  font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

.wordmark {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
}

.noscript { padding: 40px 24px; color: var(--text-2); text-align: center; }

/* ------------------------------------------------------------------------ */
/* Boot                                                                      */
/* ------------------------------------------------------------------------ */

.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
}
.boot-mark { width: 64px; height: auto; }
.boot-word { margin: 0; font: 600 26px/1 var(--serif); color: var(--text); }

/* ------------------------------------------------------------------------ */
/* Controls                                                                  */
/* ------------------------------------------------------------------------ */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 160ms var(--spring), background-color var(--fade-ms) ease, opacity var(--fade-ms) ease;
}
.button:hover { text-decoration: none; }
.button:active:not(:disabled) { transform: scale(0.97); }
.button--wide { width: 100%; }
.button--primary { background: var(--bulb); color: var(--on-bulb); }
.button--primary:hover:not(:disabled) { background: #ffbe6a; }
/* §7.3a: a disabled primary is a quiet raised control, never translucent amber. */
.button:disabled, .button[aria-disabled="true"] { background: var(--surface-raised); color: var(--text-3); cursor: default; }
.button--secondary { background: var(--surface-raised); color: var(--text); }
.button--secondary:hover:not(:disabled) { background: #26262e; }
.button--quiet { background: transparent; color: var(--bulb); box-shadow: inset 0 0 0 1px var(--hairline); }
.button--quiet:hover:not(:disabled) { background: var(--surface-raised); }
.button--danger { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1px var(--hairline); }
.button--danger:hover:not(:disabled) { background: var(--surface-raised); }
.button--apple { background: var(--text); color: #000; }
.button--apple:hover { background: #fff; }
.button--apple .icon { width: 18px; height: 18px; margin-top: -2px; }

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--bulb);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.text-button:disabled { color: var(--text-3); cursor: default; }
.text-button:active:not(:disabled) { opacity: 0.7; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon[data-fill] { stroke: none; }
.icon--accent { color: var(--bulb); }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background-color var(--fade-ms) ease, color var(--fade-ms) ease, transform 160ms var(--spring);
}
.icon-button:hover { color: var(--text); background: var(--surface-raised); }
.icon-button:active { transform: scale(0.92); }

.field { display: grid; gap: 8px; margin-bottom: 14px; }
.field-label { color: var(--text-2); font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--ink);
  color: var(--text);
  /* 17 px: iOS never zooms into a field this size. */
  font-size: 17px;
  transition: border-color var(--fade-ms) ease, box-shadow var(--fade-ms) ease;
}
.input::placeholder { color: var(--text-3); }
.input:focus-visible { outline: none; border-color: var(--bulb); box-shadow: 0 0 0 3px rgba(255, 180, 84, 0.18); }
.input:disabled { opacity: 0.6; }
/* Addresses and codes read left to right in every language. */
.input[type="email"] { direction: ltr; }
[dir="rtl"] .input[type="email"] { text-align: right; }
.input--code {
  direction: ltr;
  font: 600 28px/1 ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.42em;
  text-align: center;
  padding-inline-start: calc(14px + 0.42em);
}

.form-error {
  margin: -2px 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 180, 84, 0.08);
  color: var(--bulb-light);
  font-size: 14px;
}
.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 15px;
}
.fine-print { color: var(--text-3); font-size: 13px; line-height: 1.55; }
.lede { color: var(--text-2); font-size: 16px; line-height: 1.6; margin: 0 0 20px; }
.stack { display: grid; gap: 10px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-3);
  font-size: 13px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }

.card {
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-radius: var(--radius-card);
}

.switch-row { display: flex; align-items: center; gap: 16px; margin: 6px 0 18px; }
.switch-label { flex: 1; display: grid; gap: 2px; cursor: pointer; }
.switch-title { font-weight: 600; }
.switch-hint { color: var(--text-3); font-size: 13px; }
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 999px;
  background: var(--surface-raised);
  box-shadow: inset 0 0 0 1px var(--hairline);
  cursor: pointer;
  transition: background-color 220ms ease;
}
.switch::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: transform 280ms var(--spring);
}
.switch:checked { background: var(--bulb); box-shadow: none; }
.switch:checked::after { transform: translateX(20px); }
[dir="rtl"] .switch:checked::after { transform: translateX(-20px); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-badge);
  background: var(--surface-raised);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--bulb);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------------ */
/* Signed out, first profile, "Who's watching?"                               */
/* ------------------------------------------------------------------------ */

.signin {
  min-height: 100dvh;
  display: grid;
  align-items: center;
  padding: calc(var(--safe-top) + 32px) max(var(--gutter), var(--safe-right)) calc(var(--safe-bottom) + 32px) max(var(--gutter), var(--safe-left));
}
.signin-column { width: 100%; max-width: 26.5rem; margin: 0 auto; }
.signin-column--centred { text-align: center; display: grid; justify-items: center; }
.signin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.signin-brand .wordmark { font-size: 30px; }
.signin-mark { width: 44px; height: auto; }
.signin-column--centred .signin-mark { width: 52px; margin-bottom: 24px; }
.signin-title {
  margin: 0 0 12px;
  font: 600 clamp(30px, 7.5vw, 38px)/1.12 var(--serif);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.signin-card { padding: 22px; margin: 6px 0 20px; }
.signin-card .lede { font-size: 15px; }
.code-links { display: grid; justify-items: start; gap: 0; margin-top: 8px; }
.code-links .text-button:disabled { font-variant-numeric: tabular-nums; }
.site-links { display: flex; gap: 20px; margin-top: 8px; font-size: 14px; }
.site-links a { color: var(--text-2); min-height: 44px; display: inline-flex; align-items: center; }

.picker {
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 32px;
  padding: calc(var(--safe-top) + 40px) var(--gutter) calc(var(--safe-bottom) + 40px);
  text-align: center;
}
.picker-title { margin: 0; font: 600 clamp(30px, 6vw, 42px)/1.1 var(--serif); }
.profile-tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 132px));
  justify-content: center;
  gap: 22px;
  width: min(100%, 720px);
}
.profile-tile {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 6px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  transition: transform 200ms var(--spring);
}
.profile-tile:active { transform: scale(0.96); }
.profile-tile:hover .avatar--large { box-shadow: 0 0 0 2px var(--bulb-dim); }
.profile-tile-name { font-weight: 600; overflow-wrap: anywhere; }
.picker-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px 20px; }

.avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-raised);
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--sans);
  user-select: none;
  -webkit-user-select: none;
}
.avatar--small { width: 32px; height: 32px; font-size: 18px; }
.avatar--medium { width: 44px; height: 44px; font-size: 24px; }
.avatar--large { width: 104px; height: 104px; font-size: 54px; transition: box-shadow var(--fade-ms) ease; }
.avatar--option { width: 52px; height: 52px; font-size: 28px; transition: box-shadow var(--fade-ms) ease, transform 180ms var(--spring); }

.avatar-picker { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
.avatar-picker legend { margin-bottom: 10px; padding: 0; }
.avatar-options { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 10px; }
.avatar-option { display: grid; place-items: center; cursor: pointer; }
.avatar-option:active .avatar--option { transform: scale(0.94); }
.avatar-option input:checked + .avatar--option { box-shadow: 0 0 0 2px var(--bulb); background: #2a2218; }
.avatar-option input:focus-visible + .avatar--option { outline: 2px solid var(--bulb); outline-offset: 3px; }

/* ------------------------------------------------------------------------ */
/* The shell                                                                 */
/* ------------------------------------------------------------------------ */

.shell { min-height: 100dvh; }

.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) max(12px, var(--safe-right)) 0 max(var(--gutter), var(--safe-left));
  background: rgba(10, 10, 12, 0.78);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  backdrop-filter: saturate(1.6) blur(20px);
  border-bottom: 0.5px solid rgba(42, 42, 50, 0.6);
}
.topbar .wordmark { font-size: 20px; }
.topbar-tools { display: flex; align-items: center; gap: 2px; }
.avatar-button .avatar { transition: box-shadow var(--fade-ms) ease; }
.avatar-button:hover { background: transparent; }
.avatar-button:hover .avatar { box-shadow: 0 0 0 2px var(--bulb-dim); }

.tabbar {
  position: fixed;
  z-index: 10;
  inset: auto 0 0 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: rgba(10, 10, 12, 0.82);
  -webkit-backdrop-filter: saturate(1.6) blur(20px);
  backdrop-filter: saturate(1.6) blur(20px);
  border-top: 0.5px solid rgba(42, 42, 50, 0.6);
}
.tabbar-links { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); height: var(--tabbar-h); }
.tabbar-link {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: color var(--fade-ms) ease;
}
.tabbar-link:hover { text-decoration: none; color: var(--text-2); }
.tabbar-link .icon { width: 24px; height: 24px; transition: transform 200ms var(--spring); }
.tabbar-link:active .icon { transform: scale(0.88); }
.tabbar-link[aria-current="page"] { color: var(--bulb); }
.tabbar-link[aria-current="page"] .icon { fill: rgba(255, 180, 84, 0.16); }

.sidebar { display: none; }

.main-column { min-width: 0; }
.content {
  min-height: 60vh;
  padding: 4px max(var(--gutter), var(--safe-right)) calc(var(--tabbar-h) + var(--safe-bottom) + 40px) max(var(--gutter), var(--safe-left));
  view-transition-name: content;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px max(var(--gutter), var(--safe-right)) 0 max(var(--gutter), var(--safe-left));
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  color: var(--text-2);
  font-size: 14px;
}
.status-banner .icon { width: 18px; height: 18px; color: var(--text-3); }
.status-banner--warning { color: var(--bulb-light); }
.status-banner--warning .icon { color: var(--bulb); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 28px 14px 22px;
    border-inline-end: 0.5px solid var(--hairline);
    background: linear-gradient(180deg, #0d0d10, var(--ink));
  }
  .sidebar .brand { padding: 0 10px; }
  .sidebar-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
  .sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 10px;
    color: var(--text-2);
    font-weight: 500;
    transition: background-color var(--fade-ms) ease, color var(--fade-ms) ease;
  }
  .sidebar-link:hover { text-decoration: none; background: var(--surface); color: var(--text); }
  .sidebar-link[aria-current="page"] { background: var(--surface-raised); color: var(--text); }
  .sidebar-link[aria-current="page"] .icon { color: var(--bulb); }
  .sidebar-foot { margin-top: auto; display: grid; gap: 4px; }
  .sidebar-profile, .sidebar-settings {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-2);
    text-align: start;
    cursor: pointer;
    transition: background-color var(--fade-ms) ease, color var(--fade-ms) ease;
  }
  .sidebar-profile:hover, .sidebar-settings:hover { background: var(--surface); color: var(--text); }
  .sidebar-profile-name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-settings .icon { margin-inline: 5px; }
  .main-column { max-width: 1320px; }
  .content { padding: 28px var(--gutter) 72px; }
  .status-banner { margin: 20px var(--gutter) 0; }
}

/* ------------------------------------------------------------------------ */
/* Screens                                                                   */
/* ------------------------------------------------------------------------ */

.screen-header { padding: 18px 0 2px; }
.screen-header--hidden { padding: 0; }
.screen-title { margin: 0; font: 600 clamp(30px, 6vw, 36px)/1.1 var(--serif); letter-spacing: -0.01em; }

.shelf { margin-top: 26px; }
.shelf:first-of-type { margin-top: 14px; }
.shelf-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.shelf-title { margin: 0; font: 600 21px/1.2 var(--serif); }
.shelf-tools { display: flex; align-items: center; gap: 2px; }
.shelf-scroll { width: 36px; height: 36px; display: none; }
.shelf-scroll .icon { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .shelf-scroll { display: inline-grid; }
}

.shelf-row {
  list-style: none;
  display: flex;
  gap: 14px;
  margin: 0 calc(-1 * max(var(--gutter), var(--safe-right))) 0 calc(-1 * max(var(--gutter), var(--safe-left)));
  padding: 8px max(var(--gutter), var(--safe-right)) 14px max(var(--gutter), var(--safe-left));
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: max(var(--gutter), var(--safe-left));
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.shelf-row::-webkit-scrollbar { display: none; }
.shelf-item { flex: none; scroll-snap-align: start; }
.shelf-row--poster .shelf-item { width: var(--poster-w); }
.shelf-row--tile .shelf-item { width: var(--tile-w); }

.item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: start;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.item-art { position: relative; display: block; border-radius: var(--radius-card); transition: transform 280ms var(--spring), box-shadow 280ms ease; }
.item:active .item-art { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .item:hover .item-art { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(0, 0, 0, 0.9); }
}
.item:focus-visible { outline: none; }
.item:focus-visible .item-art { outline: 2px solid var(--bulb); outline-offset: 3px; }
.item-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.item-meta { margin-top: -3px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.item--tile .item-title { -webkit-line-clamp: 1; }

.progress {
  position: absolute;
  inset: auto 10px 9px 10px;
  height: 3px;
  border-radius: 2px;
  background: rgba(244, 242, 238, 0.24);
  overflow: hidden;
}
.progress-bar {
  display: block;
  height: 100%;
  width: calc(var(--progress, 0) * 100%);
  border-radius: inherit;
  background: var(--bulb);
}
.progress--detail { position: relative; inset: auto; display: block; height: 4px; margin: 4px 0 18px; background: var(--surface-raised); }

.chips { display: flex; gap: 8px; margin: 14px calc(-1 * var(--gutter)) 4px; padding: 4px var(--gutter); overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--fade-ms) ease, color var(--fade-ms) ease, transform 160ms var(--spring);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--ink); box-shadow: none; }

.group { margin-top: 26px; }
.group-title { margin: 0 0 12px; font: 600 21px/1.2 var(--serif); }
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px 14px;
}
/* Three across on a phone, as in the app's grids. */
.grid--poster { grid-template-columns: repeat(auto-fill, minmax(min(var(--poster-w), 29%), 1fr)); }
.grid--tile { grid-template-columns: repeat(auto-fill, minmax(min(var(--tile-w), 28%), 1fr)); }
.grid .shelf-item { width: auto; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 0.5px solid var(--hairline);
}
.list-row:last-child { border-bottom: 0; }
.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: none;
  text-align: start;
  cursor: pointer;
}
.row-main:active { opacity: 0.75; }
.row-text { display: grid; gap: 2px; min-width: 0; }
.row-title { font-weight: 600; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.row-meta { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.row-action { flex: none; min-height: 44px; padding: 0 14px; font-size: 14px; }
/* A phone: the action sits under the title rather than squeezing it. */
@media (max-width: 559px) {
  .list-row { flex-wrap: wrap; row-gap: 0; padding-bottom: 12px; }
  .list-row .row-main { flex-basis: 100%; }
  .list-row .row-action { margin-inline-start: 62px; min-height: 40px; }
}
.profile-row .row-title { -webkit-line-clamp: 1; }

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 26rem;
  margin: 12vh auto 0;
  text-align: center;
}
.empty-mark { width: 44px; height: auto; margin-bottom: 10px; filter: grayscale(1); opacity: 0.28; }
.empty-title { margin: 0; font: 600 22px/1.25 var(--serif); }
.empty-body { margin: 0 0 12px; color: var(--text-2); }

/* Skeletons: the layout, quietly, never a spinner (§7.6). */
.skeleton { background: var(--surface); border-radius: var(--radius-card); }
.skeleton-line { width: 34%; height: 18px; margin: 14px 0 12px; border-radius: 6px; }
.skeleton-poster { aspect-ratio: 2 / 3; }
.skeleton-tile { aspect-ratio: 1; }
.shelf--skeleton .shelf-row { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: breathe 1.8s ease-in-out infinite; }
  @keyframes breathe { 50% { background: #18181d; } }
}

/* ------------------------------------------------------------------------ */
/* Artwork (§7.6): loading, loaded or drawn                                   */
/* ------------------------------------------------------------------------ */

.art {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--surface);
  container-type: inline-size;
  isolation: isolate;
}
.art--poster, .art--thumb { aspect-ratio: 2 / 3; }
.art--tile, .art--thumb-tile { aspect-ratio: 1; }
.art--thumb, .art--thumb-tile { width: 48px; flex: none; border-radius: 8px; }
.art--thumb-tile { width: 48px; }

.art-drawn {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--art-top), var(--art-bottom));
  opacity: 0;
  transition: opacity 260ms ease;
}
.art.is-drawn .art-drawn { opacity: 1; }
.art-texture, .art-floor { position: absolute; inset: 0; pointer-events: none; }
.art-floor { background: linear-gradient(180deg, transparent 50%, var(--art-floor)); }

.motif-rings .art-texture {
  background: repeating-radial-gradient(circle at calc(78% + 18% * var(--art-jitter)) 62%,
    transparent 0 calc(13cqw - 1px), var(--art-ink) calc(13cqw - 1px) 13cqw);
  -webkit-mask-image: radial-gradient(circle at calc(78% + 18% * var(--art-jitter)) 62%, #000 0 100cqw, transparent 100cqw);
  mask-image: radial-gradient(circle at calc(78% + 18% * var(--art-jitter)) 62%, #000 0 100cqw, transparent 100cqw);
}
.motif-horizon .art-texture {
  background:
    radial-gradient(circle at calc(58% + 20% * var(--art-jitter)) 38%, var(--art-sun) 0 calc(17cqw + 6cqw * var(--art-jitter)), transparent calc(17cqw + 6cqw * var(--art-jitter) + 0.5px)),
    linear-gradient(var(--art-ink), var(--art-ink)) 0 46% / 100% 1px no-repeat,
    linear-gradient(var(--art-ink), var(--art-ink)) 0 52% / 100% 1px no-repeat,
    linear-gradient(var(--art-ink), var(--art-ink)) 0 59.5% / 100% 1px no-repeat,
    linear-gradient(var(--art-ink), var(--art-ink)) 0 68.5% / 100% 1px no-repeat;
}
.art--tile.motif-horizon .art-texture, .art--thumb-tile.motif-horizon .art-texture { background-position: center, 0 62%, 0 67%, 0 73%, 0 80%; }
.motif-hatch .art-texture {
  background: repeating-linear-gradient(45deg, var(--art-ink) 0 1px, transparent 1px 7cqw);
  -webkit-mask-image: linear-gradient(180deg, #000, transparent 55%);
  mask-image: linear-gradient(180deg, #000, transparent 55%);
}
.motif-contours .art-texture {
  background: repeating-radial-gradient(ellipse 160% 48% at calc(40% + 20% * var(--art-jitter)) -18%,
    transparent 0 calc(8.5cqw - 1px), var(--art-ink) calc(8.5cqw - 1px) 8.5cqw);
  -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 62%);
  mask-image: linear-gradient(180deg, #000 30%, transparent 62%);
}

.art-type {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: max(4px, 4cqw);
  padding: max(8px, 9cqw);
}
.art-rule { display: block; width: max(12px, 14cqw); height: max(1px, 1.2cqw); background: var(--art-accent); }
.art-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  color: var(--art-type);
  font: 600 max(10px, 13.5cqw)/1.12 var(--serif);
  overflow-wrap: anywhere;
  hyphens: auto;
}
.art-monogram {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--art-type);
  font: 600 40cqw/1 var(--serif);
  letter-spacing: -0.02em;
}
.art--thumb .art-monogram, .art--thumb-tile .art-monogram { font-size: 36cqw; }

.art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 280ms ease;
}
.art.is-loaded img { opacity: 1; }
/* A channel logo sits whole on its plate, never cropped or stretched (§7.2). */
.art--tile img, .art--thumb-tile img { object-fit: contain; padding: 16%; }
.art--tile.is-loaded, .art--thumb-tile.is-loaded { background: var(--surface-raised); }
/* Loading: a still, quiet silhouette of the mark — it never spins. */
.art.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("/app/brand-mark.svg") center 44% / 26% auto no-repeat;
  filter: grayscale(1);
  opacity: 0.1;
}

/* ------------------------------------------------------------------------ */
/* Sheets                                                                    */
/* ------------------------------------------------------------------------ */

dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 640px;
  max-height: calc(100dvh - var(--safe-top) - 16px);
  height: auto;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
  transform: translateY(calc(100% + 24px));
  transition: transform var(--spring-ms) var(--spring);
}
dialog.sheet.is-open { transform: translateY(var(--drag, 0px)); }
dialog.sheet.is-dragging { transition: none; }
dialog.sheet::backdrop {
  background: rgba(0, 0, 0, 0);
  -webkit-backdrop-filter: blur(0);
  backdrop-filter: blur(0);
  transition: background-color 300ms ease, backdrop-filter 300ms ease;
}
dialog.sheet.is-open::backdrop {
  background: rgba(0, 0, 0, 0.56);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.sheet-panel {
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 0.5px solid var(--hairline);
  border-bottom: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: 0 -20px 60px -20px rgba(0, 0, 0, 0.8);
  padding-bottom: calc(var(--safe-bottom) + 20px);
}
.sheet-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding-block: 16px 8px;
  padding-inline: 22px 12px;
  background: linear-gradient(180deg, var(--surface) 75%, rgba(20, 20, 24, 0));
  touch-action: none;
}
.sheet-grabber {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 38px;
  height: 5px;
  margin-left: -19px;
  border-radius: 3px;
  background: var(--hairline);
}
.sheet-title { margin: 6px 0 0; font: 600 22px/1.2 var(--serif); overflow-wrap: anywhere; }
.sheet-close { align-self: start; }
.sheet-body { padding: 4px 22px 0; }

@media (min-width: 900px) {
  dialog.sheet {
    inset: 0;
    width: min(760px, calc(100% - 64px));
    max-width: none;
    max-height: min(820px, calc(100dvh - 64px));
    margin: auto;
    transform: translateY(14px) scale(0.97);
    opacity: 0;
    transition: transform var(--spring-ms) var(--spring), opacity 220ms ease;
  }
  dialog.sheet.is-open { transform: none; opacity: 1; }
  dialog.sheet--profiles, dialog.sheet--settings { width: min(520px, calc(100% - 64px)); }
  .sheet-panel { border-radius: var(--radius-sheet); border-bottom: 0.5px solid var(--hairline); padding-bottom: 26px; box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.9); }
  .sheet-grabber { display: none; }
  .sheet-header { padding-block: 20px 8px; padding-inline: 28px 14px; touch-action: auto; }
  .sheet-body { padding: 4px 28px 0; }
}

/* Detail */
.detail { display: grid; grid-template-columns: 112px 1fr; gap: 18px; align-items: start; padding-top: 6px; }
.detail-art--tile { width: 112px; }
.detail-info { min-width: 0; }
.detail-facts { margin: 0 0 12px; color: var(--text-2); font-size: 15px; font-variant-numeric: tabular-nums; }
.detail-actions { margin: 8px 0 20px; }
.detail-action { justify-content: flex-start; padding: 0 16px; font-size: 15px; }
.detail-app { padding-top: 14px; border-top: 0.5px solid var(--hairline); }
.detail-plays { margin: 0; color: var(--text-2); font-size: 14px; line-height: 1.55; }
.detail-gone { padding: 8px 0 12px; }
@media (max-width: 480px) {
  .detail { grid-template-columns: 1fr; }
  .detail-art { width: 132px; }
  .detail-art--tile { width: 112px; }
}
@media (min-width: 900px) {
  .detail { grid-template-columns: 220px 1fr; gap: 28px; }
  .detail-art--tile { width: 180px; }
}

/* Profiles and settings */
.profile-list { margin: 0 0 6px; }
.profile-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 0.5px solid var(--hairline); }
.profile-row:last-child { border-bottom: 0; }
.profile-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  border: 0;
  background: none;
  text-align: start;
  cursor: pointer;
}
.profile-row-main:active { opacity: 0.75; }
.profile-row .button { min-height: 40px; padding: 0 14px; font-size: 14px; flex: none; }
.back-button { margin-block: -6px 8px; margin-inline-start: -4px; }
.back-button .icon { width: 18px; height: 18px; }
.profile-editor { padding-top: 2px; }

.settings-group { margin: 6px 0 22px; }
.settings-heading { margin: 0 0 8px; color: var(--text-3); font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; }
.settings-identity { margin: 0 0 10px; font-weight: 600; overflow-wrap: anywhere; }
.settings-list { margin: 0; display: grid; gap: 12px; }
.settings-row { padding: 12px 14px; border-radius: 12px; background: var(--ink); }
.settings-label { font-weight: 600; font-size: 15px; }
.settings-value { margin: 2px 0 0; color: var(--text-2); font-size: 14px; }
.sheet--settings .stack { margin-bottom: 26px; }

/* ------------------------------------------------------------------------ */
/* Toasts                                                                    */
/* ------------------------------------------------------------------------ */

.toasts {
  position: fixed;
  z-index: 30;
  inset: auto 0 calc(var(--tabbar-h) + var(--safe-bottom) + 12px) 0;
  display: grid;
  justify-items: center;
  padding: 0 12px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(100%, 460px);
  min-height: 52px;
  padding-block: 4px;
  padding-inline: 16px 4px;
  border-radius: 14px;
  background: var(--surface-raised);
  border: 0.5px solid var(--hairline);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 220ms ease, transform var(--spring-ms) var(--spring);
}
.toast.is-shown { opacity: 1; transform: none; }
.toast--warning { box-shadow: inset 3px 0 0 var(--bulb), 0 18px 40px -16px rgba(0, 0, 0, 0.9); }
.toast-message { flex: 1; margin: 0; font-size: 15px; line-height: 1.35; padding: 8px 0; }
.toast-undo {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--bulb);
  font-weight: 700;
  cursor: pointer;
}
.toast-undo:hover { background: rgba(255, 180, 84, 0.1); }
.toast-close { width: 40px; height: 40px; color: var(--text-3); }
.toast-close .icon { width: 18px; height: 18px; }
@media (min-width: 900px) {
  .toasts { inset-block: auto 28px; inset-inline: 248px 0; }
}

/* ------------------------------------------------------------------------ */
/* Motion: View Transitions, and Reduce Motion                                */
/* ------------------------------------------------------------------------ */

::view-transition-old(root), ::view-transition-new(root) { animation-duration: 240ms; }
::view-transition-old(content) { animation: vt-out 160ms ease both; }
::view-transition-new(content) { animation: vt-in var(--spring-ms) var(--spring) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(10px); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(content), ::view-transition-new(content),
  ::view-transition-old(root), ::view-transition-new(root) { animation: vt-fade 200ms ease both; }
  ::view-transition-old(content), ::view-transition-old(root) { animation-direction: reverse; }
  @keyframes vt-fade { from { opacity: 0; } }
  dialog.sheet, dialog.sheet.is-open { transform: none; }
  dialog.sheet { opacity: 0; transition: opacity 180ms ease; }
  dialog.sheet.is-open { opacity: 1; }
  .toast, .toast.is-shown { transform: none; }
  .item-art, .item:active .item-art, .item:hover .item-art, .button:active, .chip:active, .profile-tile:active { transform: none !important; }
  .switch::after { transition-duration: 1ms; }
}

/* The sheet title is focused on open (sheet.js) only to place the reader there. */
.sheet-title:focus { outline: none; }

/* ------------------------------------------------------------------------ */
/* Right to left, and scripts letter-spacing would break                      */
/* ------------------------------------------------------------------------ */

/* Safe-area insets are physical, so the top bar's asymmetric padding swaps by hand. */
[dir="rtl"] .topbar { padding-left: max(12px, var(--safe-left)); padding-right: max(var(--gutter), var(--safe-right)); }
[dir="rtl"] .icon--directional { transform: scaleX(-1); }
[dir="rtl"] .toast--warning { box-shadow: inset -3px 0 0 var(--bulb), 0 18px 40px -16px rgba(0, 0, 0, 0.9); }

/* Tracking pulls joined Arabic letters apart; CJK and Hangul need none. */
:lang(ar) .eyebrow, :lang(ar) .badge, :lang(ar) .settings-heading, :lang(ar) .field-label,
:lang(ar) .tabbar-link, :lang(ar) .screen-title, :lang(ar) .signin-title,
:lang(ja) .eyebrow, :lang(ko) .eyebrow, :lang(zh) .eyebrow,
:lang(ja) .settings-heading, :lang(ko) .settings-heading, :lang(zh) .settings-heading { letter-spacing: 0; }
:lang(ko) body, body:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }
/* A title in another script keeps its own direction (dir="auto") but lines up
   with the page's column rather than jumping to the far side of the card.
   (`text-align: match-parent` would say this, but Chrome resolves it against
   the title's own direction.) */
html[dir="ltr"] :is(.item-title, .row-title, .sidebar-profile-name, .sheet-title) { text-align: left; }
html[dir="rtl"] :is(.item-title, .row-title, .sidebar-profile-name, .sheet-title) { text-align: right; }
