/* Trailer Babu design system. MovieTrakr's tokens and rules (one accent,
   the shape rule, the --ease-* curves), plus trailer cards, the player and
   its sheet. Rules: docs/DESIGN-SYSTEM.md.
   Sections from MovieTrakr v1.12.0 assets/css/app.css are marked "(MovieTrakr)";
   re-sync them from there rather than editing them here.
   Order: fonts, tokens, base, buttons, shell, home, cards, player, film page,
   sheets, toasts, states, owner, motion prefs. */

/* ---------- Fonts (self-hosted, variable, OFL) (MovieTrakr) ---------- */
@font-face {
  font-family: "Big Shoulders";
  src: url("../fonts/big-shoulders-display-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Tokens (MovieTrakr) ---------- */
:root {
  color-scheme: dark light;

  --font-display: "Big Shoulders", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-ui: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Dark by default: the auditorium. */
  --bg: #0D1114;
  --bg-raised: #151A1F;
  --surface: #1C2329;
  --surface-2: #252D35;
  --line: rgb(214 225 235 / 0.09);
  --line-strong: rgb(214 225 235 / 0.17);
  --text: #EDEFF1;
  --text-2: #A7B0BA;
  --text-3: #808A95;
  --accent: #E8A33D;          /* marigold: the one accent */
  --accent-hover: #F0B055;
  --accent-ink: #0D1114;      /* text on accent */
  --accent-text: #F0B65E;     /* accent used as text */
  --accent-soft: rgb(232 163 61 / 0.16);
  --stub: #F4E6C8;            /* ticket stock */
  --stub-ink: #1B2026;
  --stamp-paper: #F2F4F5;
  --danger: #E5675F;
  --shadow-color: 210 45% 2%;
  --shadow-lg: 0 24px 48px -12px hsl(var(--shadow-color) / 0.7), 0 2px 8px hsl(var(--shadow-color) / 0.45);
  --scrim: rgb(6 8 10 / 0.62);
  --chrome: rgb(13 17 20 / 0.84);

  /* Shape rule: controls are pills or circles; containers are soft rectangles. */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  /* Motion (Emil Kowalski curves; see DESIGN-SYSTEM.md#motion) */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --topbar-h: 56px;
  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;

  /* Layers */
  --z-glow: 0;
  --z-content: 1;
  --z-nav: 20;
  --z-menu: 30;
  --z-toast: 40;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #EEF0F2;
    --bg-raised: #F8F9FA;
    --surface: #E2E6EA;
    --surface-2: #D5DBE0;
    --line: rgb(18 28 38 / 0.1);
    --line-strong: rgb(18 28 38 / 0.18);
    --text: #12171C;
    --text-2: #4A5562;
    --text-3: #5D6874;
    --accent-text: #8F5600;
    --accent-soft: rgb(232 163 61 / 0.22);
    --shadow-color: 212 22% 38%;
    --shadow-lg: 0 22px 44px -14px hsl(var(--shadow-color) / 0.45), 0 2px 6px hsl(var(--shadow-color) / 0.2);
    --scrim: rgb(18 24 30 / 0.42);
    --chrome: rgb(238 240 242 / 0.86);
  }
}

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

/* ---------- Base (includes the mobile-native baseline) (MovieTrakr) ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[hidden] { display: none !important; } /* component display rules must never beat the hidden attribute */
h1, h2, h3, p, figure, dl, dd { margin: 0; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select, textarea { font-size: 16px; } /* below 16px iOS zooms the page */

button, a, select, [role="tab"], .ticket {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

.icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.skip-link {
  position: fixed; left: 12px; top: calc(var(--safe-top) + 8px); z-index: 100;
  padding: 10px 14px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus-visible { transform: none; }

.wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text);
  text-decoration: none;
}

/* ---------- Buttons (MovieTrakr) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn .icon { width: 18px; height: 18px; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn--quiet { background: transparent; color: var(--text-2); padding: 0 12px; }
.btn--block { width: 100%; }
.btn[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
.btn--primary[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover { background: var(--accent-hover); }
  .btn--ghost:hover { background: var(--surface); }
  .btn--quiet:hover { color: var(--text); }
}


/* ---------- Shell: top bar, account menu, footer ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: 12px;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
  background: var(--bg);
  background: var(--chrome);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.topbar__end { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.brand .wordmark { white-space: nowrap; }
.topbar__mt { padding: 0 10px; }
/* Phones: the brand and Sign in come first; MovieTrakr stays in the footer and the account menu. */
@media (max-width: 419px) { .topbar__mt { display: none; } }
.account { position: relative; display: flex; align-items: center; min-height: 44px; }
.account__signin { padding: 0 16px; }
.avatar {
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent;
}
.avatar span {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 700; font-size: 15px;
  transition: transform 160ms var(--ease-out);
}
.avatar:active span { transform: scale(0.94); }

/* The account menu (MovieTrakr's .menu) */
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-menu);
  min-width: 248px; padding: 6px;
  background: var(--bg-raised); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  transform-origin: top right;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.menu[data-state="closed"] { opacity: 0; transform: scale(0.96); }
.menu__who { display: grid; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu__who span { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 44px; padding: 0 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text); text-align: left; font-weight: 500; text-decoration: none;
}
.menu__item:active { background: var(--surface); }
@media (hover: hover) and (pointer: fine) {
  .menu__item:hover { background: var(--surface); }
}

.page { max-width: 1320px; margin: 0 auto; padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 48px max(var(--gutter), env(safe-area-inset-left, 0px)); }

.footer {
  display: grid; gap: 10px;
  max-width: 1320px; margin: 0 auto;
  padding: 28px var(--gutter) calc(32px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  color: var(--text-3); font-size: 13px;
}
.footer a { color: var(--text-2); }
.footer__brand { color: var(--text-2); max-width: 60ch; }
.footer__brand .wordmark { display: block; margin-bottom: 4px; font-size: 1.3rem; }
.footer__credit { max-width: 70ch; }
.footer__version { font: 12px var(--font-mono); }

.kicker {
  color: var(--accent-text);
  font: 500 12px/1 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase;
}
.section-title { font: 800 clamp(1.8rem, 6vw, 2.4rem)/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.005em; }

/* ---------- Home: hero, language chips ---------- */
.hero { position: relative; display: grid; margin: 0 calc(var(--gutter) * -1); }
.hero__text {
  display: grid; gap: 10px; align-content: end;
  padding: 16px var(--gutter) 4px;
}
.hero__title {
  font: 800 clamp(2.4rem, 11vw, 5rem)/0.92 var(--font-display);
  text-transform: uppercase; letter-spacing: 0.005em; text-wrap: balance;
  overflow-wrap: anywhere;
}
.hero__title a { color: inherit; text-decoration: none; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
@media (min-width: 768px) {
  .hero { margin: 20px 0 0; border-radius: var(--r-lg); overflow: hidden; }
  /* Full width, shorter than 16:9 on wide screens (the artwork is cropped; a playing video is letterboxed). */
  .hero .player { border-radius: var(--r-lg); aspect-ratio: auto; width: 100%; height: min(72vh, 640px, 56.25vw); }
  .hero .player:not(.is-playing)::after {
    height: 75%;
    background: linear-gradient(to top, rgb(9 12 15 / 0.92), rgb(9 12 15 / 0.35) 55%, transparent);
  }
  .hero__text {
    position: absolute; left: 0; bottom: 0; z-index: 2;
    max-width: min(640px, 70%);
    padding: 0 32px 30px;
    color: #F2F4F5;
    pointer-events: none;
  }
  .hero__text > * { pointer-events: auto; }
  .hero__text .facts { color: rgb(242 244 245 / 0.78); }
  .hero__text .kicker { color: var(--accent); }
  .hero.is-playing .hero__text { position: static; max-width: none; padding: 16px 0 0; color: var(--text); }
  .hero.is-playing .hero__text .facts { color: var(--text-2); }
  .hero .player:not(.is-playing) .player__play { left: auto; right: 32px; top: auto; bottom: 30px; translate: none; }
}

.feed-head {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px;
  margin: 36px 0 14px;
}
.chips {
  display: flex; gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 18px; padding: 2px var(--gutter);
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
/* (MovieTrakr .chip, as links) */
.chip {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--text-2); text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip[aria-current="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
@media (hover: hover) and (pointer: fine) {
  .chip:hover:not([aria-current="true"]) { color: var(--text); background: var(--surface); }
}

/* ---------- Trailer cards ---------- */
.tgrid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px 16px; }
@media (min-width: 600px) { .tgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .tgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .tgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tgrid__more { display: flex; justify-content: center; margin-top: 28px; }

.tcard { position: relative; display: grid; gap: 10px; min-width: 0; }
.tcard__media {
  position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--r-md); background: var(--surface);
  color: #F2F4F5;
}
.tcard__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms var(--ease-out); }
.tcard__media::after {
  content: ""; position: absolute; inset: 45% 0 0 0;
  background: linear-gradient(to top, rgb(9 12 15 / 0.7), transparent);
  pointer-events: none;
}
.tcard__play {
  position: absolute; left: 12px; bottom: 12px; z-index: 1;
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: rgb(10 13 16 / 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.tcard__play .icon { width: 18px; height: 18px; margin-left: 2px; }
.tcard__kind {
  position: absolute; left: 60px; bottom: 21px; z-index: 1;
  font: 500 11.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
}
.tcard__yt { position: absolute; right: 12px; bottom: 19px; z-index: 1; font: 500 11px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.tcard__save {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #F2F4F5;
}
.tcard__save span {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgb(10 13 16 / 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform 160ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.tcard__save .icon { width: 18px; height: 18px; }
.tcard__save:active span { transform: scale(0.9); }
.tcard__save[aria-pressed="true"] span { background: var(--accent); color: var(--accent-ink); }
.tcard__body { display: grid; gap: 3px; min-width: 0; padding: 0 2px; }
.tcard__title { font-size: 16.5px; font-weight: 650; line-height: 1.3; }
.tcard__title a { color: inherit; text-decoration: none; }
.tcard__meta { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 13.5px; }
.tcard__meta span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard__ago { flex: none; color: var(--text-3); font: 500 12px/1.6 var(--font-mono); }
@media (hover: hover) and (pointer: fine) {
  .tcard__media:hover img { transform: scale(1.03); }
  .tcard__title a:hover { text-decoration: underline; text-underline-offset: 3px; }
}
.tcard--skeleton .tcard__media { display: block; }
.tcard--skeleton .skeleton--line { width: 70%; }
.tcard--skeleton .skeleton--line + .skeleton--line { width: 45%; }

/* ---------- Player: artwork with a play button, then the YouTube frame ---------- */
.player {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: var(--surface);
}
.player img, .player iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.player:not(.is-playing)::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 45%;
  background: linear-gradient(to top, var(--bg), transparent);
  pointer-events: none;
}
.player.is-playing { background: #000; }
.player__play {
  position: absolute; left: 50%; top: 50%; z-index: 1;
  translate: -50% -50%;
  display: inline-flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 22px 0 18px;
  border: 0; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 650; font-size: 15.5px; text-decoration: none;
  box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.6);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.player__play .icon { width: 20px; height: 20px; }
.player__play:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) {
  .player__play:hover { background: var(--accent-hover); }
}

.facts {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  color: var(--text-2); font: 500 12.5px/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em;
}
.facts span { display: inline-flex; align-items: center; gap: 6px; }

/* Versions: every trailer and teaser of a film */
.versions { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.version {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: center;
  width: 100%; min-height: 63px; padding: 4px; margin: 0;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--text); text-align: left; text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease;
}
.version img { width: 112px; aspect-ratio: 16 / 9; height: auto; border-radius: var(--r-sm); object-fit: cover; background: var(--surface); }
.version__text { display: grid; gap: 2px; min-width: 0; }
.version__name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version__meta { color: var(--text-3); font: 500 12px var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.version[aria-current="true"] { background: var(--surface); border-color: var(--line-strong); }
.version[aria-current="true"] .version__name::before { content: "Playing · "; color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) {
  .version:hover:not([aria-current="true"]) { background: var(--surface); }
}

/* ---------- Film page (title.php) ---------- */
.fpage { max-width: 1100px; margin: 0 auto; padding-bottom: 48px; }
.fpage .player { margin: 0 calc(var(--gutter) * -1); }
.fpage__head { display: grid; gap: 10px; padding-top: 16px; }
.fpage__title {
  font: 800 clamp(2.3rem, 10vw, 4.2rem)/0.92 var(--font-display);
  text-transform: uppercase; letter-spacing: 0.005em; text-wrap: balance; overflow-wrap: anywhere;
}
.fpage__original { color: var(--text-3); font-size: 14px; }
.fpage__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.fpage__overview { color: var(--text-2); max-width: 68ch; font-size: 16px; }
.fpage__section { display: grid; gap: 14px; margin-top: 36px; }
.fpage__h2 { font: 800 1.9rem/1 var(--font-display); text-transform: uppercase; }
@media (min-width: 768px) {
  .fpage .player { margin: 20px 0 0; border-radius: var(--r-lg); }
  .fpage__head { padding-top: 24px; }
  .fpage__versions { max-width: 720px; }
}

/* ---------- Sheets (MovieTrakr .sheet) ---------- */
.sheet {
  width: 100%; max-width: none; height: 100%; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: transparent; color: var(--text);
  overflow: hidden;
}
.sheet::backdrop { background: transparent; }
.sheet__scrim {
  position: fixed; inset: 0;
  background: var(--scrim);
  opacity: 0; transition: opacity 320ms ease;
}
.sheet[data-open] .sheet__scrim { opacity: 1; }
.sheet__panel {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--safe-top) - 28px);
  background: var(--bg-raised);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -12px 40px hsl(var(--shadow-color) / 0.5);
  transform: translateY(100%);
  transition: transform 460ms var(--ease-drawer);
}
.sheet[data-open] .sheet__panel { transform: translateY(0); }
.sheet[data-closing] .sheet__panel { transition-duration: 260ms; }
.sheet[data-closing] .sheet__scrim { transition-duration: 220ms; }
.sheet__handle { flex: none; display: grid; place-items: center; height: 26px; }
.sheet__handle::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--line-strong); }
.sheet__close {
  position: absolute; top: 10px; right: 10px; z-index: 3;
  display: grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: rgb(10 13 16 / 0.55); color: #F2F4F5;
}
.sheet__close:active { transform: scale(0.92); }
.sheet__close.sheet__close--plain { background: transparent; color: var(--text-2); }
.sheet__body {
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 20px calc(28px + var(--safe-bottom));
  display: grid; gap: 16px;
  grid-auto-rows: max-content; /* rows never shrink to fit (the video has overflow: hidden) */
}
@media (min-width: 768px) {
  .sheet__panel {
    left: 50%; top: 50%; bottom: auto; right: auto;
    width: min(880px, calc(100vw - 48px));
    max-height: min(92dvh, 900px);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    transform: translate(-50%, -48%) scale(0.96);
    opacity: 0;
    transition: transform 260ms var(--ease-out), opacity 260ms var(--ease-out);
  }
  .sheet[data-open] .sheet__panel { transform: translate(-50%, -50%); opacity: 1; }
  .sheet[data-closing] .sheet__panel { transition-duration: 180ms; }
  .sheet__handle { display: none; }
  .sheet__body { padding: 24px 28px 28px; }
  #signin-sheet .sheet__panel { width: min(520px, calc(100vw - 48px)); }
}

/* The player sheet: the video sits flush at the top. */
.psheet .sheet__body { padding-top: 0; }
.psheet .player { margin: 0 -20px; }
.psheet__head { display: grid; gap: 8px; }
.psheet__title { font: 800 2.2rem/0.94 var(--font-display); text-transform: uppercase; letter-spacing: 0.005em; text-wrap: balance; }
.psheet__title a { color: inherit; text-decoration: none; }
.psheet__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.psheet__overview { color: var(--text-2); max-width: 65ch; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.psheet__more { justify-self: start; margin-left: -12px; }
@media (min-width: 768px) {
  .psheet .player { margin: -24px -28px 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}

/* The sign-in sheet (MovieTrakr .signin) */
.signin { gap: 12px; padding-top: 8px; }
.signin__title { font: 800 2rem/1 var(--font-display); text-transform: uppercase; padding-right: 44px; }
.signin__lede { color: var(--text-2); max-width: 46ch; }
.signin__google { min-height: 44px; }
.signin__status { color: var(--text-2); font-size: 14px; }
.signin__status:empty { display: none; }
.signin__later { justify-self: start; margin-left: -12px; }
/* Google's sign-in frames draw in light mode; matching schemes keeps the frame transparent. */
iframe[src^="https://accounts.google.com/gsi/"] { color-scheme: light; }

/* ---------- Toasts (MovieTrakr) ---------- */
.toaster {
  position: fixed; z-index: var(--z-toast);
  left: 50%; bottom: calc(var(--safe-bottom) + 16px);
  width: min(440px, calc(100vw - 24px));
  transform: translateX(-50%);
  display: grid; align-content: start; pointer-events: none;
}
.toaster.sheet-toaster { top: calc(var(--safe-top) + 12px); bottom: auto; }
.sheet-toaster .toast[data-state] { transform: translateY(-100%); }
.toast {
  grid-area: 1 / 1;
  display: flex; align-items: center; gap: 12px;
  min-height: 50px; padding: 7px 7px 7px 16px;
  border-radius: var(--r-md);
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg);
  font-size: 14.5px; font-weight: 500;
  pointer-events: auto;
  transition: transform 400ms ease, opacity 400ms ease;
}
.toast[data-state="enter"] { transform: translateY(100%); opacity: 0; }
.toast[data-state="exit"] { transform: translateY(60%); opacity: 0; transition-duration: 200ms; }
.toast .icon { width: 20px; height: 20px; }
.toast--error .icon { color: var(--danger); }
.toast__text { flex: 1; }
.toast__action {
  height: 36px; padding: 0 14px;
  border: 0; border-radius: var(--r-pill);
  background: rgb(127 127 127 / 0.18); color: inherit;
  font-weight: 600; font-size: 14px; text-decoration: none; display: inline-flex; align-items: center;
}
.toast__action:active { transform: scale(0.96); }

/* ---------- States: empty, error, loading (MovieTrakr) ---------- */
.state { display: grid; justify-items: start; gap: 10px; padding: 28px 0 40px; max-width: 46ch; }
.state__title { font: 800 1.75rem/1 var(--font-display); text-transform: uppercase; }
.state__text { color: var(--text-2); }
.state .btn { margin-top: 6px; }
.grid-full { grid-column: 1 / -1; }
.skeleton { position: relative; overflow: hidden; background: var(--surface); }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.05), transparent);
  animation: shimmer 1.4s linear infinite;
}
@media (prefers-color-scheme: light) {
  .skeleton::after { background: linear-gradient(90deg, transparent, rgb(255 255 255 / 0.5), transparent); }
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton--line { height: 12px; border-radius: 6px; }

/* ---------- Owner page ---------- */
.owner { display: grid; gap: 28px; padding-top: 24px; }
.owner__run { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.owner__verdict { margin-top: 14px; }
.owner code { font: 13px var(--font-mono); color: var(--text); }
.owner__stats { display: flex; flex-wrap: wrap; gap: 8px 20px; color: var(--text-2); font: 500 13px var(--font-mono); }
.owner__list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.owner__row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.owner__name { font-weight: 600; overflow-wrap: anywhere; }
.owner__name a { color: inherit; }
.owner__meta { grid-column: 1; color: var(--text-3); font-size: 13px; }
.owner__row .btn { grid-row: 1 / span 2; grid-column: 2; }
.owner table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.owner th, .owner td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.owner th { color: var(--text-3); font: 500 12px var(--font-mono); text-transform: uppercase; letter-spacing: 0.05em; }
.owner__scroll { overflow-x: auto; }

/* ---------- Modern home: the buzz canvas (app/views/home-modern.php, assets/js/space.js) ---------- */
/* Phones: a ranked collage on grid paper (2 columns, 3 from 600px). Desktop,
   900px and up: space.js floats the top tiles and the tags on a first-screen
   canvas (.is-canvas), biggest in the middle; the rest continue below. */
.buzz { padding-bottom: 48px; }
.buzz__head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px;
  max-width: 1320px; margin: 0 auto; padding: 18px var(--gutter) 10px;
}
.buzz__hint { color: var(--text-3); font-size: 13.5px; }

.space {
  --paper: 32px;
  position: relative;
  padding: 4px var(--gutter) 20px;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: var(--paper) var(--paper);
  background-position: center top;
  border-block: 1px solid var(--line);
}

/* Tags: a scrolling row on phones; floating pills on the desktop canvas. */
.tags {
  display: flex; gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 14px; padding: 10px var(--gutter) 2px;
  overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity;
  scroll-padding-inline: var(--gutter); /* snapping keeps the gutter */
}
.tags::-webkit-scrollbar { display: none; }
.tag {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center;
  height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--bg-raised); color: var(--text-2); text-decoration: none; white-space: nowrap;
  font-size: 14px; font-weight: 500;
  transition: background-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out);
}
.tag--lang { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.tag--new { color: var(--accent-text); border-color: var(--accent-soft); }
.tag:active { transform: scale(0.96); }
.tag[aria-current="true"] { background: var(--text); color: var(--bg); border-color: transparent; }
@media (hover: hover) and (pointer: fine) {
  .tag:hover:not([aria-current="true"]) { color: var(--text); background: var(--surface); }
}

/* Tiles: the collage (flow) by default. */
.space__tiles {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px;
  max-width: 1320px; margin: 0 auto; padding: 0; list-style: none;
}
@media (min-width: 600px) { .space__tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 16px; } }
.tile { position: relative; min-width: 0; translate: 0 var(--jy, 0px); }
.tile--wide { grid-column: span 2; }
@media (min-width: 600px) { .tile--wide { grid-column: span 1; } .tile--xl { grid-column: span 2; } }
.tile__card {
  position: relative; display: grid; gap: 7px;
  color: var(--text); text-decoration: none;
}
.tile__card img {
  width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover;
  border-radius: var(--r-md); background: var(--surface);
  box-shadow: 0 10px 24px -14px hsl(var(--shadow-color) / 0.8);
  transition: transform 400ms var(--ease-out);
}
.tile__rank {
  position: absolute; left: 8px; top: 8px; z-index: 1;
  padding: 5px 9px; border-radius: var(--r-pill);
  background: var(--text); color: var(--bg);
  font: 600 11.5px/1 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.tile__media { position: relative; display: block; }
.tile__play {
  position: absolute; left: 8px; bottom: 8px; z-index: 1;
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: rgb(10 13 16 / 0.6); color: #F2F4F5;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.tile__play .icon { width: 16px; height: 16px; margin-left: 2px; }
.tile__text { display: grid; gap: 2px; min-width: 0; padding: 0 2px; }
.tile__title { font-weight: 650; font-size: 15px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile--xl .tile__title { font: 800 1.9rem/1 var(--font-display); text-transform: uppercase; white-space: normal; }
.tile__meta { color: var(--text-3); font: 500 11.5px/1.5 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__save {
  position: absolute; top: 2px; right: 2px; z-index: 2;
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: #F2F4F5;
}
.tile__save span {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: rgb(10 13 16 / 0.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: transform 160ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.tile__save .icon { width: 17px; height: 17px; }
.tile__save:active span { transform: scale(0.9); }
.tile__save[aria-pressed="true"] span { background: var(--accent); color: var(--accent-ink); }
@media (hover: hover) and (pointer: fine) {
  .tile__card:hover img { transform: scale(1.02); }
}
.tile--skeleton .tile__card img, .tile--skeleton .skeleton--media { aspect-ratio: 16 / 9; border-radius: var(--r-md); }

/* Desktop canvas (space.js adds .is-canvas and positions .is-placed tiles and the tags). */
@media (min-width: 900px) {
  .space { padding-inline: 24px; }
  .space__tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile--xl { grid-column: span 2; }
  .space.is-canvas { padding-top: var(--canvas-h); }
  .space.is-canvas .tags { position: static; display: block; height: 0; margin: 0; padding: 0; overflow: visible; }
  .space.is-canvas .tag,
  .space.is-canvas .tile.is-placed {
    position: absolute; left: 0; top: 0;
    will-change: transform;
  }
  .space.is-canvas .tile.is-placed { width: var(--w); translate: none; z-index: 1; }
  .space.is-canvas .tile.is-placed:hover,
  .space.is-canvas .tile.is-placed:focus-within { z-index: 3; }
  /* Placed tiles carry their title on the artwork. */
  .space.is-canvas .is-placed .tile__card { display: block; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-lg); }
  .space.is-canvas .is-placed .tile__card img { border-radius: 0; box-shadow: none; }
  .space.is-canvas .is-placed .tile__card::after {
    content: ""; position: absolute; inset: 40% 0 0 0;
    background: linear-gradient(to top, rgb(9 12 15 / 0.85), transparent);
    pointer-events: none;
  }
  .space.is-canvas .is-placed .tile__text {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
    padding: 0 12px 10px 54px; color: #F2F4F5;
  }
  .space.is-canvas .is-placed .tile__meta { color: rgb(242 244 245 / 0.75); }
  /* Titles may take two lines on the artwork, never more. */
  .space.is-canvas .is-placed .tile__title {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .space.is-canvas .is-placed .tile__play { bottom: 10px; left: 10px; z-index: 2; }
  .space.is-canvas .tile--xl.is-placed .tile__text { padding: 0 18px 16px 70px; }
  .space.is-canvas .tile--xl.is-placed .tile__title { font-size: 2.4rem; }
  .space.is-canvas .tile--xl.is-placed .tile__play { width: 44px; height: 44px; left: 16px; bottom: 16px; }
  .space.is-canvas .tile--s.is-placed .tile__text { padding: 0 8px 7px 8px; }
  .space.is-canvas .tile--s.is-placed .tile__play,
  .space.is-canvas .tile--s.is-placed .tile__meta { display: none; }
  .space.is-canvas .tile--s.is-placed .tile__title { font-size: 12.5px; }
  .space.is-canvas .tile--m.is-placed .tile__title { font-size: 14px; }
  /* A slow drift on the floating tiles (inner card, so it never fights the
     outer position). Paused while pointed at or focused. */
  .space.is-canvas.is-drifting .is-placed .tile__card {
    animation: tile-drift var(--drift, 12s) cubic-bezier(0.37, 0, 0.63, 1) infinite;
    animation-delay: var(--drift-delay, 0s);
  }
  .space.is-canvas .is-placed:hover .tile__card,
  .space.is-canvas .is-placed:focus-within .tile__card { animation-play-state: paused; }
  /* Before space.js has placed things, keep them hidden (no jump); revealed anyway after 2s. */
  .js .space:not(.is-ready) .space__tiles,
  .js .space:not(.is-ready) .tags { visibility: hidden; animation: tile-reveal 0s 2s forwards; }
  .js .space:not(.is-ready) { min-height: min(max(560px, calc(100svh - var(--topbar-h) - 90px)), 860px); }
}
@keyframes tile-drift {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(var(--dx, 0px), var(--dy, 0px), 0); }
}
@keyframes tile-reveal { to { visibility: visible; } }

/* ---------- Search: top bar field (desktop), round button (phones), panel ---------- */
.searchbar {
  display: none;
  align-items: center; gap: 10px;
  flex: 0 1 380px; height: 44px; margin: 0 auto; padding: 0 8px 0 16px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--bg-raised); color: var(--text-3); font-size: 14.5px; text-align: left;
  transition: border-color 160ms ease, color 160ms ease;
}
.searchbar span { flex: 1; }
.searchbar .icon { width: 18px; height: 18px; }
.searchbar kbd {
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  font: 500 12px var(--font-mono); color: var(--text-2);
}
@media (hover: hover) and (pointer: fine) { .searchbar:hover { border-color: var(--text-3); color: var(--text-2); } }
@media (min-width: 900px) {
  .searchbar { display: flex; }
  .has-search .topbar__end { margin-left: 0; }
}
.search-fab {
  position: fixed; z-index: var(--z-nav);
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(var(--safe-bottom) + 18px);
  display: grid; place-items: center; width: 56px; height: 56px; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg);
  transition: transform 160ms var(--ease-out);
}
.search-fab .icon { width: 24px; height: 24px; }
.search-fab:active { transform: scale(0.94); }
@media (min-width: 900px) { .search-fab { display: none; } }
/* Toasts sit above the search button on phones. */
@media (max-width: 899px) { .has-search .toaster:not(.sheet-toaster) { bottom: calc(var(--safe-bottom) + 88px); } }
/* The last tiles and the footer clear the search button. */
@media (max-width: 899px) { .has-search .footer { padding-bottom: calc(96px + var(--safe-bottom)); } }

.ssheet .sheet__body { gap: 14px; }
.ssheet__field {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 16px; margin-right: 48px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--bg);
}
.ssheet__field .icon { width: 20px; height: 20px; color: var(--text-3); }
.ssheet__field input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font-size: 16px; color: var(--text);
}
.ssheet__field input::-webkit-search-cancel-button { display: none; }
.ssheet__field:focus-within { border-color: var(--accent); }
.ssheet__hint, .ssheet__status { color: var(--text-2); }
.ssheet__h { color: var(--text-3); font: 500 12px var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 4px; }
.ssheet__list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sresult {
  display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: center;
  width: 100%; min-height: 56px; padding: 4px; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text); text-align: left; text-decoration: none;
}
.sresult img { width: 96px; aspect-ratio: 16 / 9; height: auto; border-radius: var(--r-sm); object-fit: cover; background: var(--surface); }
.sresult--poster { grid-template-columns: 40px minmax(0, 1fr); }
.sresult--poster img { width: 40px; aspect-ratio: 2 / 3; }
.sresult__text { display: grid; gap: 2px; min-width: 0; }
.sresult__title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sresult__meta { color: var(--text-3); font: 500 12px var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.sresult:active { background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .sresult:hover { background: var(--surface); } }
@media (min-width: 768px) {
  #search-sheet .sheet__panel { top: 12vh; transform: translate(-50%, 0) scale(0.97); width: min(640px, calc(100vw - 48px)); max-height: min(76dvh, 720px); }
  #search-sheet[data-open] .sheet__panel { transform: translate(-50%, 0); }
}

/* ---------- Motion and accessibility preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .tcard__media img { transition: none; }
  .sheet__panel, .sheet[data-open] .sheet__panel {
    transform: none; opacity: 0;
    transition: opacity 200ms ease;
  }
  @media (min-width: 768px) {
    .sheet__panel, .sheet[data-open] .sheet__panel { transform: translate(-50%, -50%); }
  }
  .sheet[data-open] .sheet__panel { opacity: 1; }
  .toast, .toast[data-state] { transform: none; }
  .menu[data-state="closed"] { transform: none; }
  .space .tile__card { animation: none !important; }
  .tile__card img { transition: none; }
  @media (min-width: 768px) {
    #search-sheet .sheet__panel, #search-sheet[data-open] .sheet__panel { transform: translate(-50%, 0); }
  }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
