@font-face {
  font-family: "Bebas Neue"; font-style: normal; font-weight: 400;
  font-display: swap; src: url("/static/bebasneue.woff2") format("woff2");
}
:root {
  --bg: #0f1115; --panel: #181b22; --panel-2: #1f232c; --border: #2a2f3a;
  --text: #e7e9ee; --muted: #9aa3b2; --accent: #ee2168; --accent-2: #cc1f7a;
  --star: #f5c518; --danger: #f87171; --ok: #34d399;
  --grad: linear-gradient(135deg, #f4123f, #e0228c);
  --glow: rgba(240, 33, 100, .32);
  --maxw: 1200px;  /* shared page content width */
}
* { box-sizing: border-box; }
/* overflow-x: clip (not hidden) prevents horizontal scroll from full-bleed
   elements WITHOUT making the body a scroll container — hidden would break the
   sticky header (it forces overflow-y to auto). */
html { max-width: 100%; overflow-x: clip; height: 100%; background: var(--bg); }
body {
  /* No background here on purpose — html paints it. An opaque background on
     body covers the z-index:-1 layers (.page-backdrop, body::before), because
     block backgrounds paint *after* negative stack levels. */
  margin: 0; background: transparent; color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overflow-wrap: break-word; word-break: break-word;
  /* App shell: the page itself never scrolls — only #view does. This keeps the
     bottom tab bar out of the scroll entirely, so it can't be shoved/repainted
     on content swaps (the iOS "bar jumps" issue). The sticky header lives inside
     #view and sticks to it.
     Sized to the viewport; only #view scrolls. */
  height: 100vh; height: 100dvh; max-width: 100%; overflow: hidden;
  display: flex; flex-direction: column;
}
#view {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  /* Containing block for .page-backdrop so it anchors to the top of the scrolled
     content and scrolls away with it, rather than to the viewport. z-index stays
     auto: making this a stacking context would trap the backdrop behind it. */
  position: relative;
}
/* Ambient cinematic "spotlight" glow behind the page. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(244, 18, 63, .12), transparent 70%),
    radial-gradient(700px 420px at 85% 0%, rgba(224, 34, 140, .09), transparent 65%);
}
header {
  padding: 20px 16px; text-align: center; border-bottom: 1px solid var(--border);
  background: rgba(21, 25, 34, .55); backdrop-filter: blur(6px);
}
header h1 { margin: 0; font-size: 22px; letter-spacing: .5px; }
header h1 a { color: inherit; text-decoration: none; }
header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

nav {
  display: flex; justify-content: center; gap: 6px; margin-top: 14px; flex-wrap: wrap;
}
nav a {
  padding: 7px 14px; border-radius: 999px; text-decoration: none; font-size: 13px;
  font-weight: 600; color: var(--muted); border: 1px solid var(--border);
  background: var(--panel); transition: color .15s, border-color .15s, transform .15s;
}
nav a:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
nav a.active { background: var(--grad); border-color: transparent; color: #fff; }

/* Landing "app bar": brand left, underlined nav right, no divider line */
.appbar {
  position: sticky; top: 0; z-index: 50;
  /* Keep a 1px border always, transparent by default, so scrolling only fades
     its COLOR (no light flash from animating the default currentColor border). */
  /* Add the top safe-area inset so the bar clears the notch / Dynamic Island
     when installed as a standalone web app (env() is 0 in a normal browser). */
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; border-bottom: 1px solid transparent; text-align: left;
  transition: background .25s, box-shadow .25s, border-color .25s;
}
/* Solidify once scrolled (esp. the landing, which starts transparent over art). */
.appbar.scrolled {
  background: rgba(15, 17, 21, .82); border-bottom-color: var(--border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.appbar.over-hero.scrolled {  /* beat the transparent over-hero rule */
  background: rgba(15, 17, 21, .82); border-bottom-color: var(--border);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* Floating back-to-top button (all pages; shows after scrolling down). */
.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%; padding: 0;
  border: 1px solid var(--border); background: rgba(18, 21, 28, .85);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: var(--text); font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s, transform .2s, border-color .15s, background .15s;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); background: var(--panel-2); }
.appbar-inner {
  max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center;
  justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand .logo { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 3px 8px rgba(240, 33, 100, .32)); }
.brand .wordmark {
  font-family: "Bebas Neue", system-ui; font-size: 27px; line-height: 1;
  letter-spacing: 2px; text-transform: uppercase;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topnav { margin-top: 0; justify-content: flex-end; gap: 22px; }
.topnav a {
  position: relative; padding: 2px 1px 7px; border: 0; border-radius: 0; background: none;
  color: var(--muted); font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px; transition: color .15s;
}
/* Gradient underline that grows in from the left on hover, and stays put on the
   active page. transform: scaleX is GPU-cheap and doesn't reflow neighbours. */
.topnav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--grad); border-radius: 2px;
  transform: scaleX(0); transform-origin: left; transition: transform .22s ease;
}
.topnav a:hover { color: var(--text); transform: none; }
.topnav a:hover::after { transform: scaleX(1); }
.topnav a.active { color: var(--text); background: none; }
.topnav a.active::after { transform: scaleX(1); }
.topnav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
@media (prefers-reduced-motion: reduce) { .topnav a::after { transition: none; } }

main { max-width: var(--maxw); margin: 0 auto; padding: 20px 24px 60px; }

/* --- Landing hero (search page only) --- */
/* Page-level backdrop: sits behind the transparent app bar AND the hero, tall
   enough to feel immersive, fading into the page + recommendations below. */
.page-backdrop {
  position: absolute; top: 0; left: 0; width: 100%;
  height: clamp(560px, 70vh, 820px);
  z-index: -1; overflow: hidden; pointer-events: none;
}
.page-backdrop .hero-slide {
  position: absolute; inset: 0; background-size: cover; background-position: center 24%;
  opacity: 0; transform: scale(1.05); transition: opacity 1.4s ease;
}
.page-backdrop .hero-slide.on { opacity: 1; }
/* Scrim (only with an image): dark at the top for nav legibility, lighter across
   the middle so the art shows, then dissolving into the page background + recs. */
.page-backdrop.has-img::after {
  content: ""; position: absolute; inset: 0;
  background:
    /* flat black wash so bright backdrops aren't jarring */
    linear-gradient(rgba(0, 0, 0, .42), rgba(0, 0, 0, .42)),
    /* dark at top (nav) + dissolve into the page/recs at the bottom */
    linear-gradient(to bottom,
      rgba(15, 17, 21, .55) 0%,
      rgba(15, 17, 21, .28) 24%,
      rgba(15, 17, 21, .42) 50%,
      rgba(15, 17, 21, .78) 80%,
      var(--bg) 100%),
    linear-gradient(to right, var(--bg), transparent 15%, transparent 85%, var(--bg));
}
/* Transparent app bar on the landing so the backdrop reads through it. */
.appbar.over-hero { background: transparent; backdrop-filter: none; border-bottom-color: transparent; }

.hero { position: relative; text-align: center; padding: 112px 0 84px; }
/* On phones the tall top padding pushes the search too far down — pull it up. */
@media (max-width: 600px) { .hero { padding: 44px 0 44px; } }
.hero-inner { position: relative; z-index: 1; }
.hero-caption {
  position: absolute; right: 4px; bottom: 6px; z-index: 1;
  font-size: 11.5px; color: var(--muted); letter-spacing: .3px;
  opacity: 0; transition: opacity .5s; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.hero-caption.show { opacity: .8; }
/* Solid white (not gradient) + shadow so it stays readable over any backdrop. */
/* Sentence case in the system sans (not the caps-only Bebas): this line is a
   friendly question to the user, so it reads warmer un-shouted. Heavier weight +
   tighter tracking keep it punchy. Caps stay on the labels (wordmark/nav/button). */
.hero-tag {
  margin: 0 0 22px; font-weight: 800; font-size: clamp(26px, 5vw, 44px);
  letter-spacing: -.4px; line-height: 1.1; color: #fff;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .65);
}
.hero .search { max-width: 660px; margin: 0 auto; }
/* Frosted-glass search: translucent + blur so it sits on the image, not over it. */
.hero .search input {
  background: rgba(22, 25, 32, .5);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-color: rgba(255, 255, 255, .14);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .4);
}

.search { display: flex; gap: 8px; margin-bottom: 8px; }
.search .field { position: relative; flex: 1; display: flex; }
.search .search-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-size: 15px; color: var(--muted); pointer-events: none; opacity: .8;
}
.search input {
  flex: 1; padding: 13px 40px 13px 42px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 16px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); opacity: .45; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.search .clear {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0; border: none; border-radius: 50%;
  background: var(--panel-2); color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; display: none; align-items: center; justify-content: center;
}
.search .clear:hover { color: var(--text); }
.search .clear.show { display: flex; }
/* Scoped to .primary (the submit button) so it doesn't hit the clear ✕, whose
   own transform centers it — a shared :hover transform would knock it off-center. */
button.primary {
  padding: 13px 26px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--grad); color: #fff; font-weight: 700;
  font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px;
  transition: transform .15s, filter .15s, box-shadow .15s;
  box-shadow: 0 6px 22px var(--glow);
}
button.primary:hover { transform: translateY(-1px); filter: brightness(1.07); box-shadow: 0 8px 30px var(--glow); }
button { font-family: inherit; }

/* Category filter chips (Watchlist / Watched) */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.filter-chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--muted); font-size: 13px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.filter-chip:hover { color: var(--text); border-color: var(--accent); }
.filter-chip.active { background: var(--grad); border-color: transparent; color: #fff; }

/* Watched toolbar: search grows to fill; sort sits at the right edge. The count
   is a subtle summary line on its own row just above the grid. */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.search-input {
  flex: 1 1 240px; min-width: 0; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
/* Replace the browser's default type=search clear button with a themed × in our
   muted grey (brightening on hover). Webkit/Blink only — Firefox draws none. */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  height: 15px; width: 15px; margin-left: 8px; cursor: pointer; opacity: .85;
  background: no-repeat center / contain
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2.4' stroke-linecap='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E");
  transition: opacity .15s;
}
.search-input::-webkit-search-cancel-button:hover { opacity: 1; }

/* Sort: a themed pill matching the search box + filter chips. The native select
   chrome is stripped (appearance:none) and replaced with our own chevron so the
   closed control matches the dark theme (the OS-drawn option list can't be). */
.sort-field { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--muted); font-size: 13px; }
.sort-field select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding: 8px 34px 8px 15px; border-radius: 999px;
  border: 1px solid var(--border); background-color: var(--panel); color: var(--text);
  font: inherit; font-size: 13px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa3b2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px;
  transition: border-color .15s, box-shadow .15s;
}
.sort-field select:hover { border-color: var(--accent); }
.sort-field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.sort-field select option { background: var(--panel-2); color: var(--text); }

.count { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

/* Initial / empty state */
.results {
  margin: 6px 0 26px; display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr));
}

/* --- Loading skeletons --------------------------------------------------- */
.skel { position: relative; overflow: hidden; background: var(--panel-2); }
.skel::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
  animation: skel-shimmer 1.3s infinite;
}
@keyframes skel-shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel::after { animation: none; } }
/* Search result skeleton — mirrors the .result layout */
.sk-result {
  display: flex; align-items: flex-start; gap: 14px; padding: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.sk-result .sk-poster { width: 96px; height: 144px; flex: none; border-radius: 8px; }
.sk-body { flex: 1; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.sk-line { height: 11px; border-radius: 5px; }
.sk-line.t { height: 15px; width: 55%; }
.sk-line.w1 { width: 92%; }
.sk-line.w2 { width: 84%; }
.sk-line.w3 { width: 40%; }
.sk-result .sk-btn { width: 84px; height: 34px; border-radius: 8px; flex: none; }
/* Recommendation rail skeleton — mirrors the poster-forward .rec */
.sk-rec { aspect-ratio: 2 / 3; border-radius: 12px; }
.result {
  display: flex; align-items: flex-start; gap: 14px; padding: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.result:hover { border-color: #384056; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transform: translateY(-2px); }
.result .poster {
  width: 96px; height: 144px; flex: none; border-radius: 8px; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--border); transition: transform .25s;
}
.result:hover .poster { transform: scale(1.03); }
.result .poster.placeholder { font-size: 17px; }
.result .meta { flex: 1; min-width: 0; }
.result button.added { background: var(--panel-2); color: var(--ok); border-color: var(--ok); cursor: default; }
.result .title { font-weight: 600; }
.result .result-rate { margin-top: 3px; font-size: 12px; color: var(--star); font-variant-numeric: tabular-nums; }
.result .ov { color: var(--muted); font-size: 12.5px; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere; }
.result-actions { flex: none; display: flex; flex-direction: column; gap: 6px; }
.result button {
  padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; white-space: nowrap;
}
.result button:hover { border-color: var(--accent); }
.result button.ra-seen { color: var(--muted); }
.result button.ra-seen:hover { border-color: var(--ok); color: var(--ok); }
.result button.result-trailer { color: var(--accent); }
.result button.result-trailer:hover { border-color: var(--accent); }

h2 { font-size: 15px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin: 26px 0 12px; }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); }
.card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; gap: 14px; align-items: stretch;
}
.card .cposter {
  width: 72px; height: 108px; flex: none; border-radius: 8px; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--border);
}
.card .cposter.placeholder { font-size: 13px; }
.card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* padding-right keeps the title clear of the corner remove button. */
.card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-right: 22px; }
/* Pin the action row to the bottom so its position is consistent regardless of
   how long (or short) the overview is. */
.card .row { margin-top: auto; }

/* Watched page: horizontal cards — poster on the left, rating + notes on the right */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 12px; }
/* Breathing room between the controls (pills / search / sort) and the card grid,
   so the top of the Watchlist / Watched lists doesn't feel packed. This top margin
   collapses with the controls' bottom margin (14–18px) and wins as the max, so both
   pages settle on an equal 26px gap. */
#towatch, #watched { margin-top: 26px; }
.gcard {
  position: relative; display: flex; gap: 14px; align-items: flex-start; padding: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
/* Small remove affordance, tucked in the top-right corner (Watchlist + Watched). */
.corner-x {
  position: absolute; top: 6px; right: 7px; width: 24px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center; line-height: 1;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.corner-x:hover { color: var(--danger); background: var(--panel-2); border-color: var(--danger); }
.gcard:hover { border-color: #384056; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transform: translateY(-2px); }
.gcard .gposter {
  width: 96px; aspect-ratio: 2 / 3; flex: none; border-radius: 8px; object-fit: cover;
  background: var(--panel-2); border: 1px solid var(--border);
}
.gcard .gposter.placeholder { font-size: 15.5px; }
.gcard .gbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
/* padding-right keeps the title clear of the corner remove button. */
.gcard .title { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; padding-right: 22px; }
.gcard .year { color: var(--muted); font-weight: 400; }
.gcard .stars { font-size: 18px; }
/* Comment as an italic quote to the right of the poster; click to edit. */
.gcard .note {
  font-size: 12.5px; font-style: italic; color: var(--muted); line-height: 1.45;
  padding-left: 9px; border-left: 2px solid var(--border); cursor: text; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.gcard .note:hover { border-left-color: var(--accent); color: var(--text); }
.gcard .note.empty { font-style: normal; opacity: .8; }
.gcard .note-edit { display: none; margin-top: 0; min-height: 58px; font-size: 12.5px; }
.gcard.editing .note { display: none; }
.gcard.editing .note-edit { display: block; }
.card .title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card .year { color: var(--muted); font-weight: 400; }
/* Fixed to 4 lines for every card: long overviews clamp, short/empty ones still
   reserve the space, so all Watchlist cards are the same height. */
.card .ov {
  color: var(--muted); font-size: 13px; line-height: 1.45; margin: 6px 0 10px;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  min-height: calc(1.45em * 4);
}
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.stars { font-size: 22px; letter-spacing: 2px; user-select: none; }
.stars span { cursor: pointer; color: #3a4150; }
.stars span.on { color: var(--star); }
textarea {
  width: 100%; margin-top: 8px; padding: 9px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  resize: vertical; min-height: 44px; font: inherit;
}
.btn {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
/* Compact play-icon button (trailer) — accent triangle, same height as siblings. */
.trailer-btn { padding: 7px 11px; color: var(--accent); font-size: 12px; }
.trailer-btn:hover { color: var(--accent); border-color: var(--accent); }
.btn.ok:hover { border-color: var(--ok); color: var(--ok); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.empty { color: var(--muted); font-size: 13px; font-style: italic; grid-column: 1 / -1; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* --- Recommendations ---------------------------------------------------- */
.recs { margin: 8px 0 34px; }
/* Title/subtitle on the left, filter pills on the right (wraps on narrow screens). */
.recs-head {
  margin: 0 0 14px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 12px 16px; flex-wrap: wrap;
}
.recs-title {
  font-size: 15px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin: 0; display: inline-block;
  padding-bottom: 4px; border-bottom: 2px solid transparent; border-image: var(--grad) 1;
}
.recs-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.recs-head .filters { margin: 0; }
.rec-empty { color: var(--muted); font-size: 13px; font-style: italic; padding: 8px 2px; }
/* Horizontal poster rail; scrolls within itself so the page never scrolls sideways. */
/* The rail scrolls; soft edge fades hint at more content instead of a scrollbar. */
.recs-rail { position: relative; }
.recs-rail::before, .recs-rail::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 46px; z-index: 1;
  pointer-events: none; opacity: 0; transition: opacity .2s;
}
.recs-rail::before { left: 0; background: linear-gradient(to right, var(--bg), transparent); }
.recs-rail::after { right: 0; background: linear-gradient(to left, var(--bg), transparent); }
.recs-rail.more-left::before { opacity: 1; }
.recs-rail.more-right::after { opacity: 1; }
.recs-row {
  display: grid; grid-auto-flow: column; grid-auto-columns: 158px; gap: 14px;
  overflow-x: auto; overflow-y: hidden; padding: 18px 4px 26px;  /* room for the lift + glow */
  scroll-snap-type: x proximity;
  scrollbar-width: none;  /* hidden — the edge fades are the affordance */
}
.recs-row::-webkit-scrollbar { display: none; }

/* Poster-forward "cinematic reveal" card: art + title at rest; hover lifts the
   card, zooms the art, and expands a panel with rating, synopsis + actions. */
.rec {
  position: relative; scroll-snap-align: start; aspect-ratio: 2 / 3; border-radius: 12px;
  transition: transform .28s cubic-bezier(.2, .7, .2, 1), box-shadow .28s;
  will-change: transform;
}
/* The clip lives on an inner wrapper that is NOT transformed, so the zooming
   poster keeps its rounded corners (Safari won't clip a scaled child when the
   clip element itself carries the transform). */
.rec-clip {
  position: absolute; inset: 0; border-radius: 12px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border);
}
.rec .rposter {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s cubic-bezier(.2, .7, .2, 1);
}
.rec .rposter.placeholder { font-size: 26px; }
.rec .rposter.placeholder .ph-title { -webkit-line-clamp: 6; }

/* Shared text-placeholder styling (Search/Watchlist/Watched/Recs). This combined
   selector is specific enough (and ordered after the per-tile base rules) to beat
   their panel-2 background / display. The per-tile rules above set font-size,
   which the title inherits; the year is sized relative to it. */
.poster.placeholder, .cposter.placeholder, .gposter.placeholder, .rposter.placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 8px; text-align: center; overflow: hidden;
  background: linear-gradient(155deg, #2a3042 0%, #1b1f29 55%, #14171f 100%);
}
.ph-title {
  font-family: "Bebas Neue", system-ui, sans-serif; letter-spacing: .6px;
  line-height: 1.04; color: #cfd4e0;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.ph-year {
  font-family: "Bebas Neue", system-ui, sans-serif; letter-spacing: .5px;
  font-size: .62em; color: var(--muted); line-height: 1;
}
.rec-info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 10px 11px 11px;
  background: linear-gradient(to top,
    rgba(7, 9, 12, .97) 0%, rgba(7, 9, 12, .93) 62%, rgba(7, 9, 12, .58) 84%, transparent 100%);
}
.rec-title {
  font-weight: 700; font-size: 13px; line-height: 1.18; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Extra detail expands (grid 0fr → 1fr) only on hover / focus. */
.rec-extra {
  display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows .3s ease, opacity .25s ease;
}
.rec-extra > div { overflow: hidden; min-height: 0; }
.rec-sub { font-size: 11px; color: var(--muted); margin-top: 6px; }
.rec-rate { color: var(--star); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-desc {
  font-size: 11.5px; color: #d0d5de; margin: 6px 0 0; line-height: 1.4; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.rec-actions { display: flex; gap: 6px; margin-top: 10px; }
/* Add + Trailer share the same outline style (consistent with search/watchlist). */
.rec-add {
  flex: 1; padding: 7px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(31, 35, 44, .8); color: var(--text); font-size: 12px; cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.rec-add:hover { border-color: var(--accent); }
.rec-add.added { color: var(--ok); border-color: var(--ok); background: rgba(31, 35, 44, .8); cursor: default; }
.rec-trailer {
  flex: 0 0 auto; width: 34px; padding: 7px 0; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(31, 35, 44, .8); color: var(--accent);
  font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color .15s, background .15s;
}
.rec-trailer:hover { border-color: var(--accent); background: var(--panel-2); }
.rec-add:focus-visible, .rec-trailer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rec:hover, .rec:focus-within {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .5), 0 0 0 1px var(--glow);
}
.rec:hover .rposter, .rec:focus-within .rposter { transform: scale(1.07); }
.rec:hover .rec-extra, .rec:focus-within .rec-extra { grid-template-rows: 1fr; opacity: 1; }
/* Touch devices have no hover — show the detail panel by default. */
@media (hover: none) { .rec-extra { grid-template-rows: 1fr; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .rec { will-change: auto; }
  .rec, .rec .rposter { transition: box-shadow .2s, opacity .2s; }
  .rec:hover, .rec:focus-within { transform: none; }
  .rec:hover .rposter, .rec:focus-within .rposter { transform: none; }
}

/* --- Trailer modal ------------------------------------------------------ */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0, 0, 0, .8);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-body { position: relative; z-index: 1; width: min(920px, 100%); }
.modal-video {
  position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px;
  overflow: hidden; border: 1px solid var(--border); box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.modal-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.modal-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px; text-align: center; padding: 0 16px;
}
.modal-loading a { color: var(--accent); }
.modal-close {
  position: absolute; top: -42px; right: 0; z-index: 2; width: 34px; height: 34px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { border-color: var(--accent); }
body.modal-open { overflow: hidden; }

/* Styled confirm dialog */
.confirm-card {
  position: relative; z-index: 1; width: min(380px, 100%); text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px 22px 18px; box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.confirm-msg { font-size: 15px; line-height: 1.45; margin-bottom: 20px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions .btn { min-width: 96px; padding: 9px 14px; }
.confirm-ok { border-color: var(--danger); color: var(--danger); }
.confirm-ok:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ===== Mobile app shell: bottom tab bar + touch polish ==================== */
/* Hidden on desktop; the top nav handles wide screens. */
.tabbar { display: none; }

@media (max-width: 600px) {
  /* Swap the wrapped top nav for a native-style bottom tab bar. */
  .topnav { display: none; }
  /* Small breathing room so the last card doesn't butt against the tab bar.
     The bar's own height is reserved by the flex layout, not by padding. */
  #view { padding-bottom: 8px; }

  .tabbar {
    /* NOT position:fixed. body is a 100dvh flex column (#view flexes, this
       doesn't), so being the last in-flow item pins the bar to the bottom
       through layout alone. iOS standalone mis-anchors fixed elements on the
       first paint and only corrects them once the user scrolls — which is what
       left a gap under the bar at launch. In-flow layout has no such failure
       mode, and it also drops the whole "fixed bar gets animated/repainted on
       tab swap" class of jump the surrounding comments were fighting. */
    flex: 0 0 auto;
    display: flex; justify-content: space-around; align-items: stretch;
    /* Solid, not translucent + backdrop-blur (that re-samples the content behind
       it on every swap, which iOS standalone renders as a jump). */
    background: #14161d;
    border-top: 1px solid var(--border);
    /* Clears the home indicator. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar a {
    position: relative; flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px; min-height: 54px; padding: 8px 0;
    background: none; border: 0; border-radius: 0;   /* reset the generic nav a pill */
    color: var(--muted); text-decoration: none;
    font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; font-weight: 600;
    transition: color .15s;
  }
  .tabbar a svg { width: 23px; height: 23px; }
  .tabbar a.active { color: var(--accent); background: none; }
  .tabbar a.active::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 2.5px; border-radius: 2px; background: var(--grad);
  }
  .tabbar a:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

  /* These stay position:fixed (viewport-anchored), so lift them clear of the
     tab bar: 54px link + 1px border-top + the home-indicator inset. */
  .to-top, .toast { bottom: calc(71px + env(safe-area-inset-bottom, 0px)); }

  /* Watched toolbar: search on its own row, Rating + Sort share the next row
     (instead of stacking awkwardly to the right). */
  .toolbar { gap: 10px; }
  /* font-size:16px on form controls stops iOS from auto-zooming on focus. */
  .search-input { flex-basis: 100%; padding: 11px 16px; font-size: 16px; }
  .sort-field { margin-left: 0; flex: 1 1 0; min-width: 0; gap: 6px; }
  .sort-field select { flex: 1; min-width: 0; padding: 10px 32px 10px 14px; font-size: 16px; }

  /* Bigger touch targets. */
  .filter-chip { padding: 9px 16px; font-size: 13px; }
  .corner-x { width: 30px; height: 30px; }
}

/* ===== Native-feel touch polish (all screens; effects are touch-relevant) === */
/* No grey tap-highlight flash; no accidental text selection on the chrome; no
   browser pull-to-refresh / overscroll glow; no legacy ~300ms tap delay. */
* { -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior-y: contain; }
.appbar, .tabbar, .topnav, .filters, .filter-chip, button, .sort-field,
.brand, .stars, .count { -webkit-user-select: none; user-select: none; }
a, button, select, input, .filter-chip, .gcard, .card, .rec { touch-action: manipulation; }

/* Touch has no hover, so give taps an immediate pressed state instead. */
.filter-chip:active { transform: scale(.95); }
.tabbar a:active { opacity: .5; }
button.primary:active, .btn:active, .result button:active,
.rec-add:active, .rec-trailer:active { transform: scale(.97); }
.gcard:active, .card:active { transform: scale(.992); }

/* On touch devices (no real hover), don't let hover lifts "stick" after a tap. */
@media (hover: none) {
  .gcard:hover, .card:hover { transform: none; }
  .result:hover .poster, .rec:hover .rposter { transform: none; }
}

/* Cross-document view transitions are disabled on purpose. Tab navigation is
   handled in JS (an instant #view swap — see common.js), so pages never do a
   full-navigation crossfade. A crossfade would animate the tab bar, making it
   appear to slide/reload when the scroll resets — the very jump we're
   eliminating. */
@view-transition { navigation: none; }

/* ===== Sign-in screen ==================================================== */
.login-body { min-height: 100dvh; }
.login-wrap {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 20px
           calc(24px + env(safe-area-inset-bottom, 0px));
}
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px;
  padding: 30px 26px 26px; border: 1px solid var(--border); border-radius: 18px;
  background: rgba(24, 27, 34, .72);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .5);
}
.login-brand { display: flex; align-items: center; gap: 11px; justify-content: center; }
.login-brand .logo { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 3px 8px var(--glow)); }
.login-brand .wordmark { font-family: "Bebas Neue", system-ui; font-size: 30px; letter-spacing: .5px; line-height: 1; }
.login-sub { margin: 0 0 4px; text-align: center; color: var(--muted); font-size: 13.5px; }
.login-input {
  width: 100%; padding: 12px 16px; font-size: 16px;   /* 16px stops iOS focus-zoom */
  color: var(--text); background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; transition: border-color .15s, box-shadow .15s;
}
.login-input::placeholder { color: var(--muted); opacity: .5; }
.login-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--glow); }
.login-btn { width: 100%; padding: 12px 16px; font-size: 15px; }
.login-btn:disabled { opacity: .6; cursor: default; transform: none; filter: none; }
.login-err { margin: 2px 0 0; text-align: center; color: var(--danger); font-size: 13px; }
