/* «Туман» — spec section 6. Tokens first, then layout, then components. */

@font-face {
  font-family: "Geologica";
  font-style: normal;
  font-weight: 200 600;
  font-display: swap;
  src: url("/static/fonts/geologica-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Geologica";
  font-style: normal;
  font-weight: 200 600;
  font-display: swap;
  src: url("/static/fonts/geologica-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #eef1ec;
  --surface: #ffffff;
  --sunk: #e3e8e0;
  --ink: #1c2620;
  --muted: #6f7a72;
  --line: #dbe1d7;
  --m: #ff7a5c;
  --m-soft: #ffe4dc;
  --a: #6f7fff;
  --a-soft: #e2e5ff;
  --danger: #c4452a;

  --tier-S: #ffe4dc; --tier-S-ink: #c4452a;
  --tier-A: #fff0d6; --tier-A-ink: #a86a12;
  --tier-B: #e3f3e0; --tier-B-ink: #3c7a34;
  --tier-C: #e2e5ff; --tier-C-ink: #3f4fd6;
  --tier-D: #ece6f3; --tier-D-ink: #6a4f8f;

  --r-xl: 22px; --r-lg: 18px; --r-md: 14px; --r-sm: 10px; --r-xs: 7px;
  --gutter: 20px;
  --tap: 44px;
  --poster-shadow: 0 6px 14px -8px rgb(var(--shade) / .5);
  --ease: cubic-bezier(.2, .8, .2, 1);

  --shade: 28 38 32;          /* shadows and the sheet backdrop, as rgb(var(--shade) / a) */
  --glass: rgba(255, 255, 255, .82);
  --tint: #ffffff;            /* person colours are mixed into this for chips… */
  --tint-ink: #000000;        /* …and into this for their text */
  --hero: #1c2620; --hero-ink: #eef1ec;
  --raised: var(--surface);   /* the chosen option in a segmented control */
  --glow: .5;                 /* how strongly a poster lights up its hero */
  color-scheme: light;
}

/* «Туман» at night: the same greens, lights off. Chosen in the profile sheet,
   or follows the system when nothing is chosen. The two blocks must match. */
:root[data-theme="dark"] {
  --bg: #121714; --surface: #1b211d; --sunk: #252c27;
  --ink: #e6ebe4; --muted: #8f9a91; --line: #2b332e;
  --a: #8b98ff; --m-soft: #3d2620; --a-soft: #262a4d; --danger: #ff8a6e;
  --tier-S: #3d2620; --tier-S-ink: #ff9b82;
  --tier-A: #3a2f17; --tier-A-ink: #f2bd62;
  --tier-B: #1f3521; --tier-B-ink: #93d48c;
  --tier-C: #262a4d; --tier-C-ink: #aab3ff;
  --tier-D: #2f2739; --tier-D-ink: #c9aee9;
  --poster-shadow: 0 6px 14px -8px rgba(0, 0, 0, .8);
  --shade: 0 0 0; --glass: rgba(27, 33, 29, .82);
  --tint: #1b211d; --tint-ink: #ffffff;
  --hero: #252e28; --hero-ink: #e6ebe4;
  --raised: #343d37;
  --glow: .36;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121714; --surface: #1b211d; --sunk: #252c27;
    --ink: #e6ebe4; --muted: #8f9a91; --line: #2b332e;
    --a: #8b98ff; --m-soft: #3d2620; --a-soft: #262a4d; --danger: #ff8a6e;
    --tier-S: #3d2620; --tier-S-ink: #ff9b82;
    --tier-A: #3a2f17; --tier-A-ink: #f2bd62;
    --tier-B: #1f3521; --tier-B-ink: #93d48c;
    --tier-C: #262a4d; --tier-C-ink: #aab3ff;
    --tier-D: #2f2739; --tier-D-ink: #c9aee9;
    --poster-shadow: 0 6px 14px -8px rgba(0, 0, 0, .8);
    --shade: 0 0 0; --glass: rgba(27, 33, 29, .82);
    --tint: #1b211d; --tint-ink: #ffffff;
    --hero: #252e28; --hero-ink: #e6ebe4;
    --raised: #343d37;
    --glow: .36;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 "Geologica", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Shell ---------- */

.shell { min-height: 100dvh; }
.main {
  padding: calc(18px + env(safe-area-inset-top, 0px)) var(--gutter) calc(120px + env(safe-area-inset-bottom, 0px));
  max-width: 720px;
  margin: 0 auto;
}
.side { display: none; }

.tabbar {
  position: fixed; z-index: 20;
  left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  max-width: 520px; margin: 0 auto;
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 6px;
  border-radius: 26px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px -14px rgb(var(--shade) / .35), 0 0 0 1px rgb(var(--shade) / .04);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 56px; min-height: var(--tap);
  font-size: 10.5px; color: var(--muted); text-decoration: none;
}
.tabbar a[aria-current="page"] { color: var(--ink); font-weight: 500; }
.plus {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--bg);
  transition: transform .15s var(--ease);
}
.plus:active { transform: scale(.94); }

/* Phones: brand on the left, the two of us on the right (opens theme and logout). */
.topbar { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 16px; }
.topbar .logo { font-weight: 300; font-size: 19px; letter-spacing: -.03em; text-decoration: none; }
.topbar .logo b { font-weight: 600; }
.pair { display: flex; }
.pair .who + .who { margin-left: -8px; }
.pair .who { box-shadow: 0 0 0 3px var(--bg); }
.topbar .pair { min-height: var(--tap); align-items: center; padding: 0 2px; }

@media (min-width: 768px) {
  .topbar { display: none; }
  .shell { display: grid; grid-template-columns: 76px 1fr; }
  .tabbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh;
    padding: 22px 12px; border-right: 1px solid var(--line);
  }
  .side .logo { font-weight: 300; font-size: 20px; letter-spacing: -.03em; padding: 0 8px 18px; white-space: nowrap; }
  .side .logo b { font-weight: 600; }
  .side a.nav {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: 12px;
    font-size: 14px; color: var(--muted); text-decoration: none;
  }
  .side a.nav span { display: none; }
  .side a.nav[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 500; }
  .side a.nav:hover { color: var(--ink); }
  .side .add-btn { margin: 10px 0 6px; justify-content: center; }
  .side .add-btn span { display: none; }
  .side .us {
    margin-top: auto; display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: 12px; font-size: 13px; color: var(--muted); text-align: left;
  }
  .side .us:hover { color: var(--ink); background: var(--sunk); }
  .side .us > span:last-child { display: none; }
  .side .us .who { width: 28px; height: 28px; }
  /* Content sits in the middle of what the sidebar leaves. */
  .main { padding: 28px 32px 60px; max-width: 1100px; width: 100%; margin: 0 auto; }
  .main.narrow { max-width: 800px; }
}
@media (min-width: 1200px) {
  /* On wide screens the whole app is one centred column: sidebar + content. */
  .shell { grid-template-columns: 220px minmax(0, 1fr); max-width: 1400px; margin: 0 auto; }
  .side { padding: 26px 18px; }
  .side .logo { font-size: 22px; padding-left: 10px; }
  .side a.nav span, .side .add-btn span, .side .us > span:last-child { display: inline; }
  .side .add-btn { justify-content: flex-start; }
}

/* ---------- Type ---------- */

.eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
h1.screen {
  font-weight: 200; font-size: 38px; line-height: 1; letter-spacing: -.035em;
  margin-bottom: 18px;
}
@media (min-width: 768px) { h1.screen { font-size: 44px; } }
h2.section { font-size: 13px; font-weight: 500; color: var(--muted); margin: 26px 0 10px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 20px; }
.page-head h1.screen { margin-bottom: 0; }
.page-head + * { margin-top: 18px; }

/* ---------- Primitives ---------- */

.who {
  --c: var(--ink);
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  font-size: 11px; font-weight: 600; line-height: 1;
  background: color-mix(in srgb, var(--c) 20%, var(--tint));
  color: color-mix(in srgb, var(--c) 72%, var(--tint-ink));
}
.who.sm { width: 20px; height: 20px; font-size: 10px; }
.who.lg { width: 36px; height: 36px; font-size: 14px; }

.pill {
  --c: var(--ink);
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px;
  background: color-mix(in srgb, var(--c) 18%, var(--tint));
  color: color-mix(in srgb, var(--c) 72%, var(--tint-ink));
  white-space: nowrap;
}
.pill.plain { --c: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-md);
  background: var(--ink); color: var(--bg);
  font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: transform .12s var(--ease), opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn.soft { background: var(--sunk); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--ink); padding: 0 10px; }
.btn.danger { background: var(--m-soft); color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.htmx-request { opacity: .55; pointer-events: none; }

.icon-btn { width: var(--tap); height: var(--tap); border-radius: 12px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: var(--sunk); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px; border-radius: var(--r-md);
  border: 1.5px solid transparent; background: var(--surface);
  font-size: 16px; /* no zoom on iOS */
  transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--ink); }
textarea.input { min-height: 120px; resize: vertical; line-height: 1.4; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border-radius: var(--r-md); padding: 0 14px;
}
.search .input { padding-left: 0; background: transparent; border: 0; }
.search .input:focus { border: 0; }

.seg { display: flex; background: var(--sunk); border-radius: var(--r-md); padding: 4px; gap: 2px; }
.seg a, .seg button {
  flex: 1; text-align: center; padding: 8px 10px; border-radius: 10px;
  font-size: 13px; color: var(--muted); text-decoration: none; min-height: 36px;
  display: flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
}
.seg [aria-current="page"], .seg [aria-pressed="true"] {
  background: var(--raised); color: var(--ink); font-weight: 500;
  box-shadow: 0 1px 2px rgb(var(--shade) / .08);
}
@media (min-width: 768px) { .seg.fit { width: max-content; } .seg.fit a { flex: none; padding: 8px 22px; } }

.card { background: var(--surface); border-radius: var(--r-xl); padding: 14px; }
.list { background: var(--surface); border-radius: var(--r-xl); padding: 2px 14px; }
.list > * + * { border-top: 1px solid var(--line); }

.empty {
  text-align: center; padding: 38px 20px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--r-xl);
}
.empty b { display: block; color: var(--ink); font-weight: 500; margin-bottom: 4px; }
.notice { background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; font-size: 14px; color: var(--muted); }
.error-text { color: var(--danger); font-size: 14px; }

/* ---------- Posters ---------- */

.poster {
  display: block; position: relative; flex: none; overflow: hidden;
  border-radius: var(--r-sm);
  background: linear-gradient(160deg, hsl(var(--h, 140) 30% 72%), hsl(var(--h, 140) 32% 28%));
  box-shadow: var(--poster-shadow);
  aspect-ratio: 2 / 3;
}
.poster img { width: 100%; height: 100%; object-fit: cover; }
.poster::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.16), transparent 40%); pointer-events: none; }
.poster .ph {
  position: absolute; inset: 0; display: grid; place-items: end start; padding: 6px;
  font-size: 10px; line-height: 1.15; color: rgba(255,255,255,.92); font-weight: 500;
}
.poster.xs { width: 38px; border-radius: var(--r-xs); }
.poster.sm { width: 42px; }
.poster.md { width: 58px; }
.poster.lg { width: 100%; border-radius: var(--r-md); }

/* ---------- Title rows & grid ---------- */

.row {
  display: flex; gap: 12px; align-items: center; padding: 11px 0;
  text-decoration: none; color: inherit;
}
.row .meta { flex: 1; min-width: 0; }
.row .t { font-weight: 500; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .y { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row .end { display: flex; align-items: center; gap: 6px; }
.prog { height: 4px; border-radius: 4px; background: var(--sunk); margin-top: 7px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--ink); border-radius: 4px; }

.grid { display: none; }
@media (min-width: 768px) {
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 22px 18px; }
  .grid + .list.mobile-only { display: none; }
  .tile { text-decoration: none; color: inherit; display: block; }
  .tile .poster { width: 100%; border-radius: var(--r-md); }
  .tile .t { font-size: 14px; font-weight: 500; margin-top: 9px; letter-spacing: -.01em; }
  .tile .y { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
}
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(5, 1fr); } }

/* ---------- «Сегодня» ---------- */

/* The one loud move: a poster lights up what is around it, like a screen
   in a dark room. Everything else on the page stays quiet. */
.glow { position: absolute; z-index: -1; pointer-events: none; overflow: hidden; }
.glow img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.3); filter: blur(var(--glow-blur, 70px)) saturate(1.6); opacity: var(--glow-a, var(--glow)); }

.tonight {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--hero); color: var(--hero-ink);
  border-radius: var(--r-xl); padding: 16px;
  display: flex; gap: 16px; align-items: center;
  margin-bottom: 22px;
}
.tonight .glow { inset: 0; --glow-blur: 36px; --glow-a: .6; }
.tonight .glow::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(0 0 0 / .1), rgb(0 0 0 / .45)); }
.tonight .poster { width: 64px; box-shadow: 0 10px 24px -10px rgb(0 0 0 / .7); }
.tonight .when { font-size: 12px; opacity: .7; margin-bottom: 4px; }
.tonight .ttl { font-size: 20px; font-weight: 500; letter-spacing: -.015em; line-height: 1.15; margin-bottom: 12px; }
.tonight .btn { background: rgb(255 255 255 / .16); color: #fff; min-height: 36px; font-size: 12px; padding: 0 14px; border-radius: 99px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
@media (min-width: 768px) {
  .tonight { padding: 20px 22px; gap: 22px; }
  .tonight .poster { width: 84px; }
  .tonight .ttl { font-size: 26px; font-weight: 300; letter-spacing: -.025em; }
}

/* ---------- Title page ---------- */

.title-head { position: relative; isolation: isolate; padding-bottom: 8px; }
.title-head .glow {
  top: -140px; left: calc(-1 * var(--gutter)); right: calc(-1 * var(--gutter)); height: 680px;
  /* An ellipse that fades out before any edge, so the light has no visible border. */
  -webkit-mask-image: radial-gradient(ellipse 46% 60% at 42% 38%, #000 25%, transparent 100%);
  mask-image: radial-gradient(ellipse 46% 60% at 42% 38%, #000 25%, transparent 100%);
}
.title-head .back { margin: -6px 0 10px -10px; }
.title-hero { display: grid; gap: 18px; grid-template-columns: 120px 1fr; align-items: start; }
.title-hero .poster.lg { box-shadow: 0 24px 40px -22px rgb(var(--shade) / .65), 0 0 0 1px rgb(var(--shade) / .06); }
.title-hero h1 { font-weight: 300; font-size: 30px; line-height: 1.04; letter-spacing: -.035em; text-wrap: balance; }
.title-hero .orig { color: var(--muted); font-size: 14px; margin-top: 6px; }
.title-hero .facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.title-hero .facts .pill { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--ink); font-weight: 500; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.overview { line-height: 1.6; max-width: 64ch; font-size: 15.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.title-body { display: grid; gap: 22px; margin-top: 22px; }
.title-main { display: grid; gap: 22px; align-content: start; min-width: 0; }
.title-aside { display: grid; gap: 18px; align-content: start; }
.title-main > .card { margin-top: 0; }
@media (min-width: 768px) {
  .title-hero { grid-template-columns: 230px 1fr; gap: 32px; }
  .title-head .glow { left: -32px; right: -32px; } /* exactly .main's padding, so .main's clip never shows */
  .title-hero h1 { font-size: 52px; }
  .title-hero > div { padding-top: 14px; }
}
@media (min-width: 1000px) {
  .title-body { grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; margin-top: 30px; }
}

/* ---------- Ratings ---------- */

.scores { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
@media (min-width: 560px) { .scores { grid-template-columns: repeat(10, 1fr); } }
.scores button {
  min-height: var(--tap); border-radius: 12px; background: var(--sunk);
  font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background .12s, transform .12s var(--ease);
}
.scores button:active { transform: scale(.94); }
.scores button[aria-pressed="true"] { background: var(--me, var(--ink)); color: #fff; }
.rate-pair { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Our two scores side by side, each in its owner's colour. */
.rate { padding: 16px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-card {
  display: flex; flex-direction: column; min-height: 132px; min-width: 0;
  padding: 12px 14px 14px; border-radius: var(--r-lg);
  background: color-mix(in srgb, var(--c) 11%, var(--surface));
}
.score-card .who-line { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.score-card .big {
  font-size: 60px; font-weight: 200; line-height: 1; letter-spacing: -.05em; margin-top: 12px;
  color: color-mix(in srgb, var(--c) 82%, var(--tint-ink)); font-variant-numeric: tabular-nums;
}
.score-card .big.none { color: var(--line); }
.score-card .big.lock { color: color-mix(in srgb, var(--c) 45%, var(--surface)); }
.score-card .quote, .score-card .hint { font-size: 12.5px; line-height: 1.35; margin-top: 8px; color: var(--muted); }
.score-card .quote { color: var(--ink); }
.verdict { margin: 12px 0 0; text-align: center; font-size: 14px; font-weight: 500; }
.rate .sheet-label { margin: 16px 0 8px; }
.input.sunk { background: var(--bg); }
.reveal { animation: reveal .45s var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px) scale(.96); } }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 8px; }
table.data th a { text-decoration: none; }
table.data td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
table.data td.n { text-align: center; font-variant-numeric: tabular-nums; width: 56px; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--r-xl); padding: 4px 8px; }

/* ---------- Tiers ---------- */

.tiers { display: grid; gap: 8px; }
.tier { display: flex; gap: 8px; background: var(--surface); border-radius: var(--r-lg); padding: 8px; align-items: stretch; min-height: 74px; }
.tier .l {
  width: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px; font-weight: 300;
}
.tier .drop { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; align-content: center; min-height: 56px; }
.tier .poster { width: 40px; border-radius: var(--r-xs); cursor: grab; touch-action: none; }
.tier-S .l { background: var(--tier-S); color: var(--tier-S-ink); }
.tier-A .l { background: var(--tier-A); color: var(--tier-A-ink); }
.tier-B .l { background: var(--tier-B); color: var(--tier-B-ink); }
.tier-C .l { background: var(--tier-C); color: var(--tier-C-ink); }
.tier-D .l { background: var(--tier-D); color: var(--tier-D-ink); }
/* Each row carries a breath of its tier colour, so the board reads as a ladder. */
.tiers > .tier-S { background: color-mix(in srgb, var(--tier-S) 30%, var(--surface)); }
.tiers > .tier-A { background: color-mix(in srgb, var(--tier-A) 30%, var(--surface)); }
.tiers > .tier-B { background: color-mix(in srgb, var(--tier-B) 30%, var(--surface)); }
.tiers > .tier-C { background: color-mix(in srgb, var(--tier-C) 30%, var(--surface)); }
.tiers > .tier-D { background: color-mix(in srgb, var(--tier-D) 30%, var(--surface)); }
@media (min-width: 768px) {
  .tiers { gap: 10px; }
  .tier { min-height: 108px; padding: 10px; gap: 14px; }
  .tier .l { width: 64px; font-size: 32px; font-weight: 200; border-radius: 14px; }
  .tier .drop { gap: 10px; }
  .tier .poster { width: 60px; border-radius: var(--r-sm); }
  .unranked .poster { width: 60px; }
}
.unranked { margin-top: 14px; }
.unranked .drop { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px 12px; min-height: 76px; }
.sortable-ghost { opacity: .35; }
.sortable-chosen.poster, .poster.dragging {
  transform: rotate(-6deg) translateY(-6px);
  box-shadow: 0 14px 22px -8px rgb(var(--shade) / .55);
  outline: 2px solid var(--me, var(--ink)); outline-offset: 2px;
}
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare .tier { min-height: 60px; }
.compare .tier .poster { width: 32px; }
.poster.split { outline: 2px solid var(--danger); outline-offset: 2px; }
.match { display: flex; align-items: baseline; gap: 10px; }
.match b { font-weight: 200; font-size: 44px; letter-spacing: -.03em; }

/* ---------- Episodes ---------- */

.eps { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.ep {
  aspect-ratio: 1; border-radius: 50%; min-height: var(--tap);
  display: grid; place-items: center; background: var(--sunk);
  font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums;
  transition: background .12s, transform .12s var(--ease);
}
.ep[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.ep.future { opacity: .45; }
.ep:active { transform: scale(.92); }
.next-ep { font-size: 15px; margin: 12px 0; }
.next-ep b { font-weight: 500; }

/* ---------- Plans ---------- */

.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 16px; scrollbar-width: none; }
.daystrip a {
  flex: none; width: 46px; padding: 8px 0; border-radius: 14px; text-align: center; text-decoration: none;
  background: var(--surface); font-size: 11px; color: var(--muted);
}
.daystrip a b { display: block; font-size: 17px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.daystrip a.today { background: var(--ink); color: var(--bg); }
.daystrip a.today b { color: var(--bg); }
.daystrip .dots { display: flex; gap: 2px; justify-content: center; height: 6px; margin-top: 3px; }
.daystrip .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--muted)); }
.day { background: var(--surface); border-radius: var(--r-lg); padding: 14px; margin-bottom: 10px; }
.day .d { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; margin-bottom: 6px; }
.day .d b { font-weight: 500; font-size: 15px; }
.item { display: flex; gap: 10px; align-items: center; padding: 6px 0; min-height: var(--tap); font-size: 14px; }
.item .tm { color: var(--muted); width: 42px; flex: none; font-variant-numeric: tabular-nums; }
.item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink)); flex: none; }
.item .tx { flex: 1; min-width: 0; }
.item.done .tx { color: var(--muted); text-decoration: line-through; }
.item .poster { width: 26px; border-radius: 5px; box-shadow: none; }
.chk {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line); flex: none;
  display: grid; place-items: center; background: var(--surface);
}
.chk[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chk svg { width: 14px; height: 14px; stroke-width: 2.4; }
.quick { display: flex; gap: 8px; margin-top: 6px; }
.quick .input { min-height: 40px; padding: 8px 12px; background: var(--bg); font-size: 15px; }
.overdue { border: 1.5px dashed var(--line); background: transparent; }
.menu-inline { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 4px 52px; }

/* ---------- Wishlist ---------- */

.wish { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.wish .meta { flex: 1; min-width: 0; }
.wish .tx { font-weight: 500; }
.wish .sub { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.wish .sub a { color: var(--a); }
.wish.done .tx { color: var(--muted); text-decoration: line-through; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* ---------- Sheet (quick add, menus) ---------- */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgb(var(--shade) / .32);
  animation: fade .2s ease both;
}
.sheet {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: 88dvh; overflow: auto;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 10px var(--gutter) calc(24px + env(safe-area-inset-bottom, 0px));
  animation: rise .28s var(--ease) both;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-weight: 300; font-size: 26px; letter-spacing: -.03em; margin-bottom: 14px; }
.sheet form { display: grid; gap: 12px; }
@media (min-width: 768px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 12vh; width: 560px; transform: translateX(-50%); border-radius: 26px; animation: pop .22s var(--ease) both; }
  .sheet .grab { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: translateX(-50%) scale(.97); opacity: 0; } }

.results { display: grid; gap: 4px; margin-top: 8px; }
.result { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: var(--r-md); width: 100%; text-align: left; }
.result:hover, .result:focus-visible { background: var(--surface); }
.result .meta { flex: 1; min-width: 0; }
.result .t { font-weight: 500; }
.result .y { font-size: 12px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: var(--tap); }
.toggle input { width: 20px; height: 20px; accent-color: var(--ink); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 14px;
  animation: rise .25s var(--ease) both;
}
@media (min-width: 768px) { .toast { bottom: 28px; } }

/* ---------- Right rail (desktop) ---------- */

.with-rail { display: grid; gap: 26px; }
@media (min-width: 1200px) {
  .with-rail { grid-template-columns: minmax(0, 1fr) 300px; gap: 30px; }
  .rail { border-left: 1px solid var(--line); padding-left: 24px; }
}
.rail h2.section:first-child { margin-top: 0; }

/* ---------- Login ---------- */

/* No sidebar here: the desktop shell grid would squeeze the form into the sidebar's column. */
.bare .shell { display: block; }
.bare .main { max-width: 420px; min-height: 100dvh; margin: 0 auto; display: grid; align-content: center; padding-bottom: 40px; }
.login-logo { font-weight: 200; font-size: 72px; letter-spacing: -.05em; line-height: 1; margin-bottom: 28px; }
.login-logo b { font-weight: 600; }
.pick-user { display: flex; gap: 10px; }
.pick-user label {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-height: 56px; border-radius: var(--r-md); background: var(--sunk); cursor: pointer;
}
.pick-user input { position: absolute; opacity: 0; pointer-events: none; }
.pick-user label:has(input:checked) { background: var(--raised); box-shadow: 0 1px 2px rgb(var(--shade) / .1); font-weight: 500; }
.pick-user label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.login-form { display: grid; gap: 14px; }

/* ---------- Motion preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.row-link { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-decoration: none; color: inherit; }

.kind-opt { flex: 1; display: grid; place-items: center; padding: 8px 10px; border-radius: 10px; font-size: 13px; color: var(--muted); min-height: 36px; cursor: pointer; }
.kind-opt input { position: absolute; opacity: 0; pointer-events: none; }
.kind-opt:has(input:checked) { background: var(--raised); color: var(--ink); font-weight: 500; box-shadow: 0 1px 2px rgb(var(--shade) / .08); }
.kind-opt:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.filters .who { pointer-events: none; }

/* The rail repeats the Plans tab; on phones the tab bar is enough. */
.rail { display: none; }
@media (min-width: 768px) { .rail { display: block; } }

.chk svg { opacity: 0; transition: opacity .12s; }
.chk[aria-pressed="true"] svg { opacity: 1; }
.poster.xs .ph, .poster.sm .ph { display: none; }

/* ---------- Profile sheet ---------- */

.me-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.me-head h2 { margin: 0; }
.me-head .who { width: 36px; height: 36px; font-size: 14px; }
.sheet-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.me-logout { margin-top: 22px; }

/* ---------- Atmosphere ---------- */

/* Glows bleed past the content edges; they must never make the page scroll sideways.
   Clipped on .main: on body the rule would move to the viewport and stop working. */
.main { overflow-x: clip; }

/* «м+а» in our two colours. */
.logo b, .login-logo b { color: color-mix(in srgb, var(--c, var(--ink)) 88%, var(--tint-ink)); }

.match-card {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px;
  padding: 14px 16px; border-radius: var(--r-lg); text-decoration: none;
  background: linear-gradient(115deg, color-mix(in srgb, var(--m) 20%, var(--surface)), color-mix(in srgb, var(--a) 20%, var(--surface)));
}
.match-card b { font-size: 44px; font-weight: 200; letter-spacing: -.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.match-card span { font-size: 12.5px; line-height: 1.3; color: var(--muted); }
.match-card:hover b { letter-spacing: -.03em; }

/* Ratings table: scores in their owners' colours, big gaps called out. */
table.data .tt { display: flex; gap: 12px; align-items: center; text-decoration: none; }
table.data .tt b { display: block; font-weight: 500; }
table.data .tt small { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
table.data td.n { width: 68px; }
.sc {
  display: inline-grid; place-items: center; min-width: 38px; height: 32px; padding: 0 8px; border-radius: 10px;
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--c) 15%, var(--tint)); color: color-mix(in srgb, var(--c) 78%, var(--tint-ink));
}
.gap { font-variant-numeric: tabular-nums; color: var(--muted); }
.gap.far { color: var(--danger); font-weight: 600; }

/* The side-by-side compare keeps its compact letters. */
.compare .tier .l { width: 40px; font-size: 22px; }

/* Grid tiles answer the pointer with a little lift. */
@media (hover: hover) {
  .tile .poster { transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
  .tile:hover .poster { transform: translateY(-4px); box-shadow: 0 18px 28px -16px rgb(var(--shade) / .6); }
}

/* In the narrow side column ten score buttons would be cramped: two rows of five. */
.title-aside .scores { grid-template-columns: repeat(5, 1fr); }

/* Long descriptions fold to a few lines until asked for (app.js adds the button when needed). */
.overview.folded { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden; }
.more-btn { margin-top: 6px; padding: 6px 0; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 1000px) { .overview.folded { -webkit-line-clamp: 12; } }
