/* =====================================================================
   Infinite Happiness: stile ispirato a TV Time
   Nero pieno, giallo per le tue azioni, carattere arrotondato e pesante.
   ===================================================================== */
:root {
  --bg: #000000;
  --surface: #141414;
  --surface-2: #1f1f1f;
  --surface-3: #2a2a2a;
  --line: #262626;
  --text: #ffffff;
  --muted: #9a9a9a;
  --accent: #ffd21f;        /* giallo TV Time: solo per azioni e cose tue */
  --accent-ink: #000000;
  --good: #7fd6a4;
  --danger: #ff7a6b;
  --radius-lg: 18px;
  --radius: 12px;
  --gutter: 16px;
  --tabbar-h: 62px;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 15px/1.5 var(--font);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -0.015em; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding-left: var(--gutter); padding-right: var(--gutter); }
.top-gap { margin-top: 24px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- Barre di navigazione ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(16px); -webkit-backdrop-filter: saturate(1.4) blur(16px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 18px; letter-spacing: -0.02em; }
.brand img { border-radius: 8px; }
.nav-top { display: none; gap: 2px; }
.nav-top a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 800; }
.nav-top a:hover { color: var(--text); }
.nav-top a.active { background: var(--accent); color: var(--accent-ink); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, #0d0d0d 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10.5px; font-weight: 800; color: #7d7d7d; }
.tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linejoin: round; stroke-linecap: round; }
.tabbar a.active { color: var(--accent); }

@media (min-width: 820px) {
  :root { --gutter: 32px; }
  .nav-top { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  main { max-width: 1180px; margin: 0 auto; }
}

/* ---------- Titoli di pagina e blocchi ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px var(--gutter) 16px; }
.page-head h1 { font-size: 34px; line-height: 1.05; letter-spacing: -0.03em; }
@media (min-width: 820px) { .page-head { padding-top: 28px; } .page-head h1 { font-size: 42px; } }
.block { margin-bottom: 30px; }
.block-title { font-size: 20px; margin-bottom: 12px; }
.sub-h { font-size: 16px; font-weight: 900; margin: 18px 0 10px; }
.field-label { margin: 0 0 8px; color: var(--muted); font-weight: 700; font-size: 14px; }
.field-label b { color: var(--accent); }

/* ---------- Pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 14px; padding: 10px 18px; border-radius: 999px; cursor: pointer; transition: background .15s, transform .1s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #ffdd52; }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--surface-3); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--muted); background: transparent; }
.btn.danger { color: var(--danger); }
.btn.seen { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn.big { font-size: 16px; padding: 14px 22px; }
.btn.wide { width: 100%; }
.btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled, .busy { opacity: .55; pointer-events: none; }
.link { background: none; border: 0; color: var(--accent); font-weight: 800; padding: 0; cursor: pointer; }

/* Spunta tonda (come TV Time) */
.check { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); color: #8a8a8a; cursor: pointer; transition: background .15s, color .15s, transform .12s; box-shadow: inset 0 0 0 1.5px var(--surface-3); }
.check svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.check:hover { color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.check:active { transform: scale(.88); }
.check.on { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.check.sm { width: 36px; height: 36px; }
.check.sm svg { width: 18px; height: 18px; }
.check.placeholder { background: none; box-shadow: none; cursor: default; }

/* ---------- Voto IMDb: pastiglia neutra ---------- */
.imdb { display: inline-flex; align-items: baseline; gap: 4px; background: var(--surface-2); color: var(--text); font-weight: 900; font-size: 13px; line-height: 1; padding: 5px 7px; border-radius: 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.imdb b { font-weight: 800; font-size: 9.5px; color: var(--muted); letter-spacing: .02em; }
.imdb.sm { font-size: 12px; padding: 4px 6px; }
.imdb.xs { font-size: 11px; padding: 2px 5px; background: none; margin-left: auto; }
.imdb.lg { font-size: 17px; padding: 7px 10px; border-radius: 9px; background: rgba(255,255,255,.1); }
.imdb.lg b { font-size: 11px; }

/* ---------- Avvisi ---------- */
#status:empty { display: none; }
#status { padding: 0 var(--gutter) 14px; display: grid; gap: 8px; }
.notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin: 0 0 12px; }
#status .notice { margin: 0; }
.notice.error { box-shadow: inset 3px 0 0 var(--danger); }
.spin { display: inline-block; width: 15px; height: 15px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); max-width: 420px; margin: 0 auto; grid-column: 1 / -1; }
.empty-title { color: var(--text); font-size: 20px; font-weight: 900; margin: 0 0 6px; }
.empty p { margin: 0 0 18px; }

/* ---------- Home: episodio in primo piano ---------- */
.hero-next { margin: 0 var(--gutter) 30px; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); transition: opacity .2s, transform .2s; }
.hn-media { display: block; aspect-ratio: 16 / 9; background: var(--surface-2); position: relative; }
.hn-media img { width: 100%; height: 100%; object-fit: cover; }
.hn-media::after { content: ""; position: absolute; inset: 40% 0 0; background: linear-gradient(to bottom, transparent, var(--surface)); }
.hn-body { padding: 0 18px 18px; margin-top: -34px; position: relative; display: grid; gap: 10px; }
.hn-title { font-size: 28px; font-weight: 900; letter-spacing: -0.025em; line-height: 1.1; }
.hn-ep { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.hn-ep-name { font-weight: 700; color: #dcdcdc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hn-progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
.hn-progress span { flex: none; }
.hero-next .btn.big { justify-self: start; }
@media (min-width: 820px) {
  .hero-next { display: grid; grid-template-columns: 1.35fr 1fr; align-items: stretch; }
  .hn-media { aspect-ratio: auto; min-height: 280px; }
  .hn-media::after { inset: 0 0 0 55%; background: linear-gradient(to right, transparent, var(--surface)); }
  .hn-body { margin: 0; padding: 28px 28px 28px 8px; align-content: center; }
  .hn-title { font-size: 34px; }
}
.ep-code { color: var(--accent); font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Righe ---------- */
.rows { display: grid; }
@media (min-width: 820px) { .rows { grid-template-columns: repeat(2, 1fr); column-gap: 28px; } }
.ep-row, .wait-row, .cal-row, .result-row, .mini-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-width: 0; transition: opacity .2s, transform .2s; }
.ep-row + .ep-row, .wait-row + .wait-row, .cal-row + .cal-row, .result-row + .result-row { border-top: 1px solid var(--line); }
@media (min-width: 820px) {
  .ep-row:nth-child(2), .wait-row:nth-child(2), .cal-row:nth-child(2), .result-row:nth-child(2) { border-top: 0; }
}
.leaving { opacity: 0 !important; transform: translateX(24px) !important; }
.ep-thumb { flex: none; width: 112px; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.ep-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ep-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.ep-row-series { font-weight: 900; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-row-ep { font-size: 14px; color: #d0d0d0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-row-foot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 4px; }
.ep-row-foot > span { flex: none; }
.thumb { flex: none; width: 48px; aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-ov { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.date-chip { flex: none; background: var(--surface-2); color: var(--accent); font-weight: 900; font-size: 12.5px; padding: 6px 10px; border-radius: 999px; }
.cal-row.watched .row-title { color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.badge { font-size: 11px; font-weight: 900; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); border-radius: 6px; padding: 2px 7px; }
.badge.hot { color: var(--accent-ink); background: var(--accent); }

/* ---------- Barre di avanzamento ---------- */
.bar { position: relative; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: 1; min-width: 40px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: inherit; transition: width .35s ease; }

/* ---------- Caroselli orizzontali ---------- */
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: 118px; gap: 12px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; padding: 0 var(--gutter) 6px; scroll-padding: 0 var(--gutter); scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail > * { scroll-snap-align: start; }
@media (min-width: 820px) { .rail { grid-auto-columns: 150px; gap: 18px; scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; } }
.tile-poster { min-width: 0; transition: opacity .2s, transform .2s; }
.tile-meta { display: flex; align-items: flex-start; gap: 6px; margin-top: 8px; }
.tile-title { flex: 1; min-width: 0; font-weight: 800; font-size: 13.5px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.type-flag { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.72); color: #fff; font-size: 10.5px; font-weight: 900; padding: 2px 7px; border-radius: 6px; }

/* ---------- Locandine ---------- */
.poster { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.poster img { width: 100%; height: 100%; object-fit: cover; }
.noposter { display: grid; place-items: center; height: 100%; padding: 10px; text-align: center; color: var(--muted); font-weight: 800; font-size: 13px; }

/* ---------- Libreria ---------- */
.seg { display: inline-flex; background: var(--surface); border-radius: 999px; padding: 4px; }
.seg button { border: 0; background: none; color: var(--muted); font-weight: 800; padding: 7px 18px; border-radius: 999px; cursor: pointer; }
.seg button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 7px; border: 0; background: var(--surface); color: #d0d0d0; font-weight: 800; font-size: 13.5px; padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.chip span { color: var(--muted); font-weight: 700; }
.chip.on { background: var(--text); color: #000; }
.chip.on span { color: #555; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 20px 12px; padding-bottom: 30px; }
@media (min-width: 820px) { .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 18px; } }
.card { min-width: 0; display: block; }
.card .poster img { transition: transform .3s ease; }
.card:hover .poster img { transform: scale(1.04); }
.card-title { display: block; margin-top: 8px; font-weight: 800; font-size: 14px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 2px; }
.poster-bar { position: absolute; left: 0; right: 0; bottom: 0; }
.poster-bar .bar { height: 5px; border-radius: 0; background: rgba(0,0,0,.6); }
.poster-bar .bar > span { border-radius: 0; }
.seen-badge, .my-badge { position: absolute; top: 6px; display: grid; place-items: center; height: 26px; min-width: 26px; border-radius: 999px; box-shadow: 0 2px 10px rgba(0,0,0,.5); }
.seen-badge { right: 6px; background: var(--accent); color: var(--accent-ink); }
.seen-badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.my-badge { left: 6px; padding: 0 8px; background: #000; color: var(--accent); font-weight: 900; font-size: 13px; }

/* ---------- Scheda titolo ---------- */
.title-hero { position: relative; isolation: isolate; margin-bottom: 18px; }
.th-backdrop { position: absolute; inset: 0 0 auto; height: 300px; z-index: -1; overflow: hidden; }
.th-backdrop img { width: 100%; height: 100%; object-fit: cover; opacity: .55; }
.th-backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,.25), var(--bg) 96%); }
.th-inner { display: flex; align-items: flex-end; gap: 18px; padding: 140px var(--gutter) 0; }
.th-poster { flex: none; width: 112px; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); box-shadow: 0 14px 34px rgba(0,0,0,.6); }
.th-poster img { width: 100%; height: 100%; object-fit: cover; }
.th-info { min-width: 0; padding-bottom: 2px; }
.th-title { font-size: 30px; line-height: 1.05; letter-spacing: -0.03em; }
.th-tagline { margin: 6px 0 0; color: #d6d6d6; font-weight: 700; }
.th-facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; color: var(--muted); font-size: 13.5px; font-weight: 700; }
.th-ratings { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.votes { color: var(--muted); font-size: 13px; font-weight: 700; }
.my-score { color: var(--muted); font-size: 13px; font-weight: 700; }
.my-score b { color: var(--accent); font-size: 18px; font-weight: 900; }
@media (min-width: 820px) {
  .th-backdrop { height: 460px; -webkit-mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent); }
  .th-inner { padding-top: 220px; gap: 28px; }
  .th-poster { width: 190px; }
  .th-title { font-size: 46px; }
}
.th-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.th-actions:empty { display: none; }
.done-line { margin: 0; font-weight: 800; color: var(--good); }
.overview { max-width: 68ch; margin: 0 0 14px; color: #dedede; font-size: 16px; line-height: 1.6; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 12.5px; font-weight: 800; color: #cfcfcf; background: var(--surface); border-radius: 999px; padding: 4px 11px; }
.title-tools { display: flex; flex-wrap: wrap; gap: 10px; }

/* Il tuo voto */
.my-rating { margin-bottom: 18px; }
.my-rating-scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; max-width: 460px; }
.rate { aspect-ratio: 1; border-radius: 10px; border: 0; background: var(--surface); color: var(--muted); font-weight: 900; font-size: 14px; cursor: pointer; padding: 0; transition: background .12s, color .12s, transform .1s; }
.rate:hover { color: var(--text); background: var(--surface-2); }
.rate:active { transform: scale(.9); }
.rate.fill { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); color: var(--text); }
.rate.current { background: var(--accent); color: var(--accent-ink); }

.tracking { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-bottom: 26px; max-width: 560px; }
.track-line { display: flex; align-items: center; gap: 12px; flex: 1 1 220px; font-size: 14px; color: var(--muted); font-weight: 700; }
.track-line > span { flex: none; }
.track-line b { color: var(--text); }
.status-pick { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 700; }
.status-pick select { font: inherit; font-weight: 800; color: var(--text); background: var(--surface); border: 0; border-radius: 999px; padding: 7px 30px 7px 14px; -webkit-appearance: none; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

/* Stagioni ed episodi */
.season-list { list-style: none; margin: 0 0 10px; padding: 0; }
.season-list li { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.season { background: var(--surface); border-radius: var(--radius-lg); margin-bottom: 10px; overflow: hidden; }
.season summary { display: flex; align-items: center; gap: 10px; padding: 15px 16px; cursor: pointer; list-style: none; font-weight: 900; font-size: 16px; }
.season summary::-webkit-details-marker { display: none; }
.s-name { flex: 1; }
.s-count { color: var(--muted); font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.season.done .s-count { color: var(--accent); }
.s-ring { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); -webkit-mask: radial-gradient(circle, transparent 6px, #000 7px); mask: radial-gradient(circle, transparent 6px, #000 7px); }
.season-tools { padding: 0 16px 8px; }
.season-tools .link { font-size: 13.5px; }
.episodes { list-style: none; margin: 0; padding: 0 0 6px; }
.ep { display: flex; align-items: center; gap: 6px; padding: 2px 12px 2px 4px; }
.ep + .ep { border-top: 1px solid var(--line); }
.ep-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 10px 8px; text-align: left; cursor: pointer; border-radius: 10px; }
.ep-open:hover { background: var(--surface-2); }
.ep-num { flex: none; width: 26px; text-align: center; color: var(--muted); font-weight: 900; font-variant-numeric: tabular-nums; }
.ep-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ep-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-date { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.ep-react { font-size: 18px; line-height: 1; }
.ep.watched .ep-num { color: var(--accent); }
.ep.watched .ep-name { color: #bdbdbd; }
.ep.upcoming .ep-name { color: var(--muted); }
.ep.upcoming .ep-date { color: var(--accent); }

/* Persone (cast e preferiti) */
.person { margin: 0; min-width: 0; text-align: center; display: block; }
.rail:has(.person) { grid-auto-columns: 92px; }
.face { display: block; width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; overflow: hidden; background: var(--surface-2); }
.face img { width: 100%; height: 100%; object-fit: cover; }
.initials { display: grid; place-items: center; height: 100%; font-weight: 900; font-size: 22px; color: var(--muted); }
.person figcaption, .person-cap { display: flex; flex-direction: column; margin-top: 8px; font-size: 12.5px; line-height: 1.3; }
.person b { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person figcaption span, .person-cap span { color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Pannello episodio ---------- */
.sheet { width: min(560px, 100%); max-width: 100%; max-height: min(92dvh, 900px); margin: auto auto 0; padding: 0; border: 0; border-radius: 24px 24px 0 0; background: #111; color: var(--text); overflow-y: auto; overscroll-behavior: contain; }
.sheet::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet[open] { animation: sheet-in .28s cubic-bezier(.2,.9,.3,1); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 820px) { .sheet { margin: auto; border-radius: 24px; } }
.sheet-media { position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); }
.sheet-media img { width: 100%; height: 100%; object-fit: cover; }
.sheet-media::after { content: ""; position: absolute; inset: 50% 0 0; background: linear-gradient(to bottom, transparent, #111); }
.sheet-close { position: absolute; top: 12px; right: 12px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; display: grid; place-items: center; cursor: pointer; }
.sheet-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.sheet-body { padding: 4px 20px calc(22px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.sheet-series { margin: 0; font-weight: 900; color: var(--muted); }
.sheet-series a:hover { color: var(--text); }
.sheet-title { font-size: 24px; line-height: 1.15; letter-spacing: -0.02em; }
.sheet-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.sheet-overview { margin: 0; color: #d6d6d6; line-height: 1.6; }
.sheet-h { font-size: 17px; margin-top: 8px; }
.reactions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
@media (max-width: 380px) { .reactions { grid-template-columns: repeat(3, 1fr); } }
.reaction { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--surface); border: 0; border-radius: 14px; padding: 10px 2px 8px; cursor: pointer; transition: background .15s, transform .12s; }
.reaction:hover { background: var(--surface-2); }
.reaction:active { transform: scale(.92); }
.r-emoji { font-size: 28px; line-height: 1; filter: grayscale(.35); transition: filter .15s, transform .15s; }
.r-label { font-size: 11px; font-weight: 800; color: var(--muted); }
.reaction.on { background: var(--accent); }
.reaction.on .r-emoji { filter: none; transform: scale(1.12); }
.reaction.on .r-label { color: var(--accent-ink); }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 12px 8px; }
.fav { display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: 0; padding: 4px 0; cursor: pointer; min-width: 0; }
.fav .face { width: 64px; height: 64px; box-shadow: 0 0 0 3px transparent; transition: box-shadow .15s, transform .12s; }
.fav:hover .face { box-shadow: 0 0 0 3px var(--surface-3); }
.fav.on .face { box-shadow: 0 0 0 3px var(--accent); transform: scale(1.05); }
.fav-name { font-size: 12px; font-weight: 800; line-height: 1.25; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #cfcfcf; }
.fav.on .fav-name { color: var(--accent); }
.sheet-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }

/* ---------- Ricerca e Scopri ---------- */
.search-wrap { position: relative; margin-bottom: 20px; }
.search-wrap svg { position: absolute; left: calc(var(--gutter) + 14px); top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; pointer-events: none; }
.search { width: 100%; font: inherit; font-weight: 700; font-size: 16px; color: var(--text); background: var(--surface); border: 0; border-radius: 999px; padding: 13px 18px 13px 46px; outline: none; -webkit-appearance: none; appearance: none; }
.search:focus { box-shadow: 0 0 0 2px var(--accent); }
.search::placeholder { color: #777; }
#results .rows { margin-bottom: 24px; }

/* ---------- Calendario ---------- */
.day-head { display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter) 8px; }
.day-num { font-size: 34px; font-weight: 900; line-height: 1; letter-spacing: -0.04em; min-width: 44px; font-variant-numeric: tabular-nums; }
.day-txt { display: flex; flex-direction: column; line-height: 1.2; }
.day-txt b { font-weight: 900; font-size: 16px; }
.day-txt span { color: var(--muted); font-size: 13px; font-weight: 700; }
.day-head.today .day-num, .day-head.today b { color: var(--accent); }

/* ---------- Profilo ---------- */
.counters { display: grid; gap: 12px; margin-bottom: 18px; }
@media (min-width: 820px) { .counters { grid-template-columns: 1fr 1fr; } }
.time-counter { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-lg); padding: 18px 20px 20px; }
.time-counter + .time-counter { background: var(--surface); color: var(--text); }
.tc-label { margin: 0 0 6px; font-weight: 800; font-size: 14px; opacity: .8; }
.tc-value { display: flex; gap: 18px; margin: 0; flex-wrap: wrap; }
.tc-part { display: flex; flex-direction: column; font-weight: 800; font-size: 13px; }
.tc-part b { font-size: 46px; line-height: 1; font-weight: 900; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
@media (min-width: 820px) { .facts { grid-template-columns: repeat(4, 1fr); } .facts.two { grid-template-columns: repeat(2, 1fr); } }
.facts > div { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.panel .facts > div { background: var(--surface-2); }
.facts dt { color: var(--muted); font-size: 13px; font-weight: 700; }
.facts dd { margin: 2px 0 0; font-size: 26px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 18px; }
.panel .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.panel p { margin: 0 0 6px; }
.panel.list { padding: 6px 16px; }
.mini-row + .mini-row { border-top: 1px solid var(--line); }
.mini-row .thumb { width: 40px; }
.settings .block-title { margin-top: 6px; }

.react-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; }
.rs-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rs-bar { display: flex; align-items: flex-end; width: 100%; max-width: 40px; height: 90px; }
.rs-bar span { width: 100%; background: var(--accent); border-radius: 6px 6px 2px 2px; }
.rs-emoji { font-size: 24px; line-height: 1; }
.rs-num { font-weight: 900; font-size: 14px; font-variant-numeric: tabular-nums; }

.mchart, .rdist { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; height: 170px; align-items: end; }
.rdist { grid-template-columns: repeat(10, 1fr); height: 110px; margin-top: 16px; }
.mcol { position: relative; display: flex; flex-direction: column; height: 100%; outline: none; }
.mbar-wrap { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid var(--surface-3); }
.mbar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.mcol:hover .mbar, .mcol:focus .mbar { opacity: .75; }
.mlabel { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--muted); padding-top: 5px; }
[data-tip]:hover::after, [data-tip]:focus::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #fff; color: #000; border-radius: 8px; font-weight: 800;
  padding: 6px 9px; font-size: 12px; white-space: nowrap; z-index: 5; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
.mcol:nth-child(-n+3)[data-tip]:hover::after, .mcol:nth-child(-n+3)[data-tip]:focus::after { left: 0; transform: none; }
.mcol:nth-last-child(-n+3)[data-tip]:hover::after, .mcol:nth-last-child(-n+3)[data-tip]:focus::after { left: auto; right: 0; transform: none; }

.hbars { display: grid; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr 40px; align-items: center; gap: 10px; font-size: 14px; font-weight: 800; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbar { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.hbar-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------- Avviso in basso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px); z-index: 30;
  display: flex; align-items: center; gap: 4px; max-width: calc(100% - 24px);
  background: #fff; color: #000; font-weight: 800; font-size: 14px; border-radius: 999px; padding: 8px 8px 8px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast > span { padding-right: 6px; }
.toast-btn { flex: none; border: 0; background: none; color: #000; font-weight: 900; padding: 6px 10px; border-radius: 999px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.toast-btn:hover { background: rgba(0,0,0,.08); }
@media (min-width: 820px) { .toast { bottom: 24px; } }

.credits { color: #5f5f5f; font-size: 11px; line-height: 1.5; text-align: center; padding: 24px var(--gutter) 18px; }

/* ---------- Pagina di accesso ---------- */
.login-page { padding: 0; display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; }
.login-box { width: min(360px, calc(100% - 32px)); text-align: center; }
.login-logo { margin: 0 auto 16px; border-radius: 18px; }
.login-box h1 { font-size: 28px; }
.login-box p { margin: 6px 0 22px; }
.login-box .search { padding-left: 18px; margin: 0 0 12px; text-align: center; }
.login-box .btn { width: 100%; padding: 13px; font-size: 16px; }
.login-err { color: var(--danger); min-height: 1.5em; font-size: 14px; font-weight: 700; margin: 12px 0 0 !important; }

/* =====================================================================
   Home 2.0, voto con decimali, accesso
   ===================================================================== */
.home-head { padding: 14px var(--gutter) 18px; }
.home-hello { font-size: 38px; line-height: 1.02; letter-spacing: -0.035em; }
.home-week { margin: 6px 0 0; color: var(--muted); font-weight: 700; font-size: 15px; max-width: 60ch; }
@media (min-width: 820px) { .home-head { padding-top: 30px; } .home-hello { font-size: 52px; } }

.caught-up { position: relative; margin: 0 var(--gutter) 32px; border-radius: var(--radius-lg); overflow: hidden; background: var(--accent); color: var(--accent-ink); isolation: isolate; }
.caught-up.has-art { background: var(--surface); color: var(--text); min-height: 260px; display: flex; align-items: flex-end; }
.cu-art { position: absolute; inset: 0; z-index: -1; }
.cu-art img { width: 100%; height: 100%; object-fit: cover; opacity: .5; }
.cu-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, #000 8%, rgba(0,0,0,.2)); }
.cu-body { padding: 26px 22px 24px; display: grid; gap: 10px; justify-items: start; max-width: 560px; }
.cu-body h2 { font-size: 30px; line-height: 1.05; letter-spacing: -0.03em; }
.cu-body p { margin: 0 0 6px; font-weight: 700; opacity: .85; }
.caught-up:not(.has-art) .btn.primary { background: #000; color: var(--accent); }
@media (min-width: 820px) { .caught-up.has-art { min-height: 340px; } .cu-body { padding: 36px; } .cu-body h2 { font-size: 40px; } }

.tile-sub { display: block; color: var(--muted); font-size: 12.5px; font-weight: 700; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-poster > .tile-title { display: -webkit-box; margin-top: 8px; }
.soon .poster { margin-bottom: 0; }
.soon-date { position: absolute; left: 6px; right: 6px; bottom: 6px; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 12.5px; text-align: center; padding: 4px 6px; border-radius: 8px; }
.rail:has(.tile-wide) { grid-auto-columns: 220px; }
@media (min-width: 820px) { .rail:has(.tile-wide) { grid-auto-columns: 280px; } }
.tile-wide { display: block; min-width: 0; }
.wide-img { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.wide-img img { width: 100%; height: 100%; object-fit: cover; }
.wide-when { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-weight: 800; font-size: 11.5px; padding: 3px 8px; border-radius: 999px; }
.tile-wide .tile-title { display: block; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Voto con cursore e decimali */
.my-rating { max-width: 460px; }
.rate-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rate-value { min-width: 92px; text-align: center; font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.my-rating.empty .rate-value { color: var(--surface-3); }
.rate-step { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 22px; font-weight: 900; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.rate-step:hover { background: var(--surface-3); }
.rate-step:active { transform: scale(.9); }
.rate-clear { margin-left: auto; font-size: 13.5px; }
#rate-range { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; background: transparent; cursor: pointer; margin: 0; }
#rate-range::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
#rate-range::-moz-range-track { height: 8px; border-radius: 4px; background: linear-gradient(to right, var(--accent) var(--fill), var(--surface-3) var(--fill)); }
#rate-range::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.5); }
#rate-range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent); }
.my-rating.empty #rate-range::-webkit-slider-runnable-track { background: var(--surface-3); }
.my-rating.empty #rate-range::-moz-range-track { background: var(--surface-3); }
.my-rating.empty #rate-range::-webkit-slider-thumb { border-color: var(--muted); }
.rate-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11.5px; font-weight: 800; padding: 0 4px; }

.facts-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }

/* Accesso: muro di copertine dietro al modulo */
.login-page { position: relative; overflow: hidden; }
.poster-wall { position: fixed; inset: -40px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; transform: rotate(-8deg) scale(1.15); opacity: 0; transition: opacity 1.2s ease; z-index: -2; }
.poster-wall.ready { opacity: .28; }
.poster-wall img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 10px; }
@media (max-width: 600px) { .poster-wall { grid-template-columns: repeat(4, 1fr); } }
.login-page::before { content: ""; position: fixed; inset: 0; z-index: -1; background: radial-gradient(ellipse at center, rgba(0,0,0,.55) 0%, #000 72%); }
.login-sub { color: #cfcfcf; font-weight: 700; }
.pw-field { position: relative; margin-bottom: 12px; }
.pw-field .search { margin: 0; padding-right: 96px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 13px; padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.pw-toggle:hover { background: var(--surface-3); }
.pw-toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
