/* extra-downloads — "Blu notte" ---------------------------------------------
   Design system mobile-first: fondo blu notte profondo, superfici scure a due
   livelli, accento blu elettrico, stati ok/attesa. Font di sistema (offline).
   Le variabili storiche (--panel, --ink, --amber, ...) restano come alias
   verso la nuova palette per non rompere i frammenti non ancora restilizzati. */

:root {
  /* palette Blu notte */
  --bg:  #0b0f1a;
  --sf:  #141b2b;
  --sf2: #1b2438;
  --ac:  #2f74f0;
  --ok:  #22c55e;
  --wait:#e0b64b;
  --tx:  #eaf0fb;
  --dim: #9fb0cc;
  --bd:  #22304a;
  --err: #ef4444;

  --mono: ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 10px;

  /* alias retro-compatibili (usati dai frammenti in attesa di restyling) */
  --panel:     var(--sf);
  --panel-2:   var(--sf2);
  --line:      var(--bd);
  --line-soft: var(--bd);
  --ink:       var(--tx);
  --ink-dim:   var(--dim);
  --ink-faint: var(--dim);
  --amber:     var(--ac);
  --amber-dim: rgba(47, 116, 240, .14);
  --red:       var(--err);
  --red-dim:   rgba(239, 68, 68, .12);
  --green:     var(--ok);
  --cyan:      #38bdf8;
  --accent:    var(--ac);
}

/* tema chiaro — stessa identità, superfici chiare */
:root[data-theme="light"] {
  --bg:  #f4f6fb;
  --sf:  #ffffff;
  --sf2: #e9edf7;
  --ac:  #2f74f0;
  --ok:  #16a34a;
  --wait:#a8790f;
  --tx:  #101827;
  --dim: #5b6883;
  --bd:  #d9e0ee;
  --err: #dc2626;

  --amber-dim: rgba(47, 116, 240, .10);
  --red-dim:   rgba(220, 38, 38, .10);
  --cyan:      #0284c7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

/* ---- guscio applicativo ----------------------------------------------------
   .app è mobile-first: colonna singola con la nav come bottom bar fissa.
   Da 1024px in su .app diventa una riga con la nav come sidebar sinistra.
   Nessun JS di layout: solo media query, stesso markup. */
.app { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding-bottom: 76px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--bd);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand h1 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: .3px; }
.brand h1 .rec { color: var(--err); }
.theme-toggle {
  font-size: 16px; line-height: 1; width: 44px; height: 44px; border-radius: 50%;
  background: var(--sf); color: var(--dim); border: 1px solid var(--bd);
  cursor: pointer; transition: color .12s, border-color .12s; flex: none;
}
.theme-toggle:hover { color: var(--ac); border-color: var(--ac); }

.view { flex: 1; padding: 14px 16px 28px; }
.libroot { padding: 0 16px 16px; margin: 0; }
.libroot span { color: var(--dim); }

/* ---- nav: bottom bar (mobile) / sidebar (desktop) -------------------------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; gap: 2px;
  background: var(--sf); border-top: 1px solid var(--bd);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.navitem {
  flex: 1; min-height: 44px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 6px 2px; border-radius: 10px;
  background: none; border: none; color: var(--dim); font-family: var(--sans);
  font-size: 10px; letter-spacing: .1px; cursor: pointer; transition: background .12s, color .12s;
}
.navitem .i { font-size: 18px; line-height: 1; }
.navitem .lbl { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem:hover { color: var(--tx); }
.navitem.on { background: var(--ac); color: #fff; }
.navitem.on .lbl { color: #fff; }

@media (min-width: 1024px) {
  .app { flex-direction: row; }
  .main { padding-bottom: 0; }
  .nav {
    position: sticky; top: 0; left: auto; right: auto; bottom: auto; height: 100vh;
    width: 92px; flex: none; flex-direction: column; justify-content: flex-start;
    gap: 6px; padding: 18px 8px; border-top: none; border-right: 1px solid var(--bd);
  }
  .navitem { flex: none; width: 100%; font-size: 10.5px; padding: 10px 4px; }
  .navitem .i { font-size: 20px; }
}

/* micro-label maiuscola spaziata */
.label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--dim);
}

/* ---- connessione ------------------------------------------------------------ */
.conn {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 13px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); display: inline-block; }
.dot.on  { background: var(--ok); box-shadow: 0 0 8px var(--ok); animation: pulse 2s infinite; }
.dot.warn { background: var(--wait); box-shadow: 0 0 8px var(--wait); }
.dot.off { background: var(--err); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }
.conn form { display: flex; gap: 8px; align-items: center; }

/* ---- selettore modalità watcher ---------------------------------------------- */
.watcher-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--bd); border-radius: var(--radius); background: var(--sf); }
.mode-seg { display: inline-flex; border: 1px solid var(--bd); border-radius: 8px; overflow: hidden; }
.mode-btn { font-family: var(--sans); font-size: 12px; background: var(--bg); color: var(--dim); border: none; border-right: 1px solid var(--bd); padding: 6px 14px; cursor: pointer; }
.mode-btn:last-child { border-right: none; }
.mode-btn:hover { color: var(--tx); }
.mode-btn.on { background: var(--sf2); color: var(--tx); }
.mode-btn.amber.on { background: var(--amber-dim); color: var(--ac); }

/* ---- inputs & buttons -------------------------------------------------------- */
input[type=text], select {
  font-family: var(--sans); font-size: 13px;
  background: var(--bg); color: var(--tx);
  border: 1px solid var(--bd); border-radius: 8px;
  padding: 8px 10px; outline: none; min-height: 38px;
}
input[type=text]:focus, select:focus { border-color: var(--ac); }

.btn {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .2px;
  background: var(--sf2); color: var(--tx);
  border: 1px solid var(--bd); border-radius: 8px;
  padding: 8px 14px; min-height: 36px; cursor: pointer; transition: border-color .12s, color .12s, background .12s;
}
.btn:hover { border-color: var(--ac); color: var(--ac); }
.btn.primary { background: var(--ac); border-color: var(--ac); color: #fff; }
.btn.primary:hover { background: #2563eb; color: #fff; }
.btn.danger { color: var(--err); border-color: transparent; background: var(--red-dim); }
.btn.danger:hover { border-color: var(--err); }
.btn.ghost { background: none; border-color: transparent; color: var(--dim); padding: 6px 9px; }
.btn.ghost:hover { color: var(--ac); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; min-height: 30px; }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* ---- toggle vista griglia/lista (catalogo) ----------------------------------- */
.toggle { display: inline-flex; background: var(--sf); border-radius: 8px; padding: 2px; gap: 2px; }
.toggle span, .toggle button {
  font-family: var(--sans); font-size: 11px; padding: 5px 10px; border-radius: 6px;
  color: var(--dim); background: none; border: none; cursor: pointer;
}
.toggle span.on, .toggle button.on { background: var(--ac); color: #fff; }

/* ---- chip (filtri/generi) ----------------------------------------------------- */
.chip {
  font-family: var(--sans); font-size: 11px; letter-spacing: .2px;
  color: var(--dim); border: 1px solid var(--bd); border-radius: 999px; padding: 4px 11px;
  background: var(--sf); display: inline-block;
}
.chip.on { color: #fff; background: var(--ac); border-color: var(--ac); }
.chip.clk { cursor: pointer; text-decoration: none; }
.chip.clk:hover { border-color: var(--ac); color: var(--ac); }

/* ---- cards / rows -------------------------------------------------------- */
.rec-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.rec {
  border: 1px solid var(--bd); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--sf), var(--sf2));
  padding: 14px 16px;
}
.rec-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-id {
  font-family: var(--mono); font-size: 20px; font-weight: 600; color: var(--ac);
  min-width: 3ch;
}
.rec-id::before { content: "#"; color: var(--dim); font-size: 14px; }
.rec-meta { display: flex; gap: 20px; flex-wrap: wrap; flex: 1; }
.rec-meta .m { display: flex; flex-direction: column; gap: 2px; }
.rec-meta .m .v { font-family: var(--mono); font-size: 14px; color: var(--tx); }
.rec-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }

.badge {
  font-family: var(--sans); font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; border: 1px solid var(--ok);
  color: var(--ok); background: rgba(34,197,94,.10);
}

/* disclosure form download */
details.dl { margin-top: 12px; border-top: 1px solid var(--bd); padding-top: 12px; }
details.dl > summary { cursor: pointer; list-style: none; color: var(--dim); font-family: var(--sans); font-size: 12px; }
details.dl > summary::-webkit-details-marker { display: none; }
details.dl > summary:hover { color: var(--ac); }
.dl-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field input, .field select { min-width: 220px; }

/* job / progress */
.job { margin-top: 12px; }
.bar { height: 8px; background: var(--bg); border: 1px solid var(--bd); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ac), #6ea8ff); transition: width .4s; }
.job .row { display: flex; justify-content: space-between; font-family: var(--sans); font-size: 12px; color: var(--dim); margin-bottom: 6px; }
.job.done .bar > i { background: var(--ok); }
.job.error .bar > i { background: var(--err); }

/* ---- library -------------------------------------------------------------- */
.lib { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
.tree { border: 1px solid var(--bd); border-radius: var(--radius); background: var(--sf); padding: 8px; }
.tree a { display: block; padding: 5px 8px; color: var(--dim); text-decoration: none; font-family: var(--sans); font-size: 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree a:hover { color: var(--ac); background: var(--amber-dim); }
.tree a.cur { color: var(--ac); background: var(--amber-dim); }
.tree a .depth { color: var(--dim); }

.files { border: 1px solid var(--bd); border-radius: var(--radius); background: var(--sf); }
.crumb { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--bd); font-family: var(--sans); font-size: 12px; color: var(--dim); flex-wrap: wrap; }
.crumb .path { color: var(--ac); }
.filerow { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--bd); }
.filerow:last-child { border-bottom: none; }
.filerow .ico { width: 16px; color: var(--dim); font-family: var(--mono); }
.filerow .nm { font-family: var(--sans); font-size: 13px; flex: 1; color: var(--tx); overflow: hidden; text-overflow: ellipsis; }
.filerow.dir .nm { color: var(--cyan); cursor: pointer; }
.filerow .sz { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.filerow .acts { display: flex; gap: 4px; }

.toolbar { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--bd); flex-wrap: wrap; align-items: center; }

/* menu popup (⋯) */
.popmenu { position: absolute; margin-top: 6px; background: var(--sf2); border: 1px solid var(--bd); border-radius: 10px; padding: 10px; z-index: 5; min-width: 240px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* schede media (video con poster + info) */
.mediacard { display: grid; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--bd); }
.mediacard:last-child { border-bottom: none; }
.media-poster { width: 92px; height: 138px; object-fit: cover; border-radius: 6px; border: 1px solid var(--bd); background: var(--bg); }
.media-noposter { display: flex; align-items: center; justify-content: center; font-size: 34px; color: var(--dim); }
.media-info { min-width: 0; }
.media-title { font-family: var(--sans); font-size: 15px; color: var(--tx); }
.media-sub { margin-top: 2px; }
.media-genres { display: flex; gap: 5px; flex-wrap: wrap; margin: 7px 0; }
.media-plot { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.media-actions { display: flex; gap: 6px; align-items: center; position: relative; }

/* serie: testata (poster + info) + lista episodi */
.series { border-bottom: 1px solid var(--bd); padding: 16px 14px; }
.series:last-child { border-bottom: none; }
.series-head { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: start; }
.series-poster { width: 120px; height: 180px; object-fit: cover; border-radius: 8px; border: 1px solid var(--bd); background: var(--bg); }
.series-poster.media-noposter { display: flex; align-items: center; justify-content: center; font-size: 44px; }
.series-meta { min-width: 0; }
.series-title { font-family: var(--sans); font-size: 20px; color: var(--tx); margin-bottom: 8px; }
.series-cast { margin-top: 8px; }
.series-cast b { color: var(--dim); }
.series-plot { margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

.ep-list { margin-top: 16px; border-top: 1px solid var(--bd); }
.ep-row { display: flex; align-items: center; gap: 14px; padding: 9px 4px; border-bottom: 1px solid var(--bd); }
.ep-row:last-child { border-bottom: none; }
.ep-label { font-family: var(--sans); font-size: 14px; color: var(--ac); min-width: 6ch; }
.ep-sub { flex: 1; }
.ep-actions { display: flex; gap: 6px; align-items: center; position: relative; }

/* messaggi */
.msg { font-family: var(--sans); font-size: 12px; padding: 8px 12px; border-radius: 8px; margin: 12px 0; }
.msg.ok { color: var(--ok); background: rgba(34,197,94,.10); border: 1px solid rgba(34,197,94,.3); }
.msg.err { color: var(--err); background: var(--red-dim); border: 1px solid rgba(239,68,68,.35); }
.empty { color: var(--dim); font-family: var(--sans); font-size: 13px; padding: 24px 14px; text-align: center; }

.hint { color: var(--dim); font-family: var(--sans); font-size: 11px; }
a.link { color: var(--cyan); text-decoration: none; }
a.link:hover { text-decoration: underline; }

.htmx-request .spin { display: inline-block; }
.spin { display: none; color: var(--ac); }

/* ---- Tagging: coda "Da confermare" (proposta TMDB per download non-IPTV) -- */
.tags-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tagwrap { display: flex; flex-direction: column; gap: 12px; }
.tagrow {
  display: grid; grid-template-columns: 220px 1fr; gap: 16px;
  border: 1px solid var(--bd); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--sf), var(--sf2));
  padding: 14px;
}
.tag-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; border: 1px solid var(--bd); background: #000; }
.tag-body { min-width: 0; }
.tag-fields { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tag-fields .f { display: flex; flex-direction: column; gap: 4px; }
.tag-fields .f.grow { flex: 1; }
.tag-fields .f.grow input { width: 100%; }
.tag-actions { display: flex; gap: 8px; align-items: center; }
.tag-extra { margin-top: 10px; border-top: 1px solid var(--bd); padding-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.tag-extra b { color: var(--dim); }
.tag-plot { color: var(--dim); margin-top: 2px; }

.tmdb-results:not(:empty) { margin-top: 12px; border-top: 1px solid var(--bd); padding-top: 10px; }
.tmdb-list { display: flex; flex-direction: column; gap: 8px; }
.tmdb-item { display: flex; gap: 10px; align-items: center; }
.tmdb-poster { width: 46px; height: 69px; object-fit: cover; border-radius: 4px; border: 1px solid var(--bd); background: var(--bg); }
.tmdb-noposter { display: flex; align-items: center; justify-content: center; color: var(--dim); font-family: var(--sans); }
.tmdb-info { flex: 1; min-width: 0; }
.tmdb-title { font-family: var(--sans); font-size: 13px; color: var(--tx); }
.tmdb-ov { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

@media (max-width: 700px) {
  .tagrow { grid-template-columns: 1fr; }
  .tmdb-item { flex-wrap: wrap; }
}

/* ---- catalogo media / griglia locandine ------------------------------------ */
.cat-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.cat-search { min-width: 220px; }
.cat-actor { min-width: 180px; }
.genre-chips { display: flex; gap: 6px; flex-wrap: wrap; width: 100%; margin-top: 4px; }
.chip-toggle { cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle span { display: inline-block; font-family: var(--sans); font-size: 11px; letter-spacing: .2px;
  color: var(--dim); border: 1px solid var(--bd); border-radius: 999px; padding: 4px 11px; background: var(--sf); }
.chip-toggle:hover span { color: var(--tx); border-color: var(--dim); }
.chip-toggle:has(input:checked) span { color: #fff; border-color: var(--ac); background: var(--ac); }

/* griglia locandine — nome storico (desktop/tablet, colonne larghe) */
.poster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
/* .pgrid — griglia locandine mobile-first del design system Blu notte */
.pgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 600px)  { .pgrid { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
@media (min-width: 1024px) { .pgrid { grid-template-columns: repeat(5, 1fr); gap: 16px; } }
@media (min-width: 1280px) { .pgrid { grid-template-columns: repeat(6, 1fr); gap: 18px; } }

.poster-card { cursor: pointer; }
.pc-poster { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--bd); background: var(--bg); transition: border-color .12s, transform .12s; }
.pc-poster.pc-noposter { display: flex; align-items: center; justify-content: center; font-size: 44px; color: var(--dim); }
.poster-card:hover .pc-poster { border-color: var(--ac); transform: translateY(-3px); }
.pc-title { font-family: var(--sans); font-size: 13px; color: var(--tx); margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-sub { font-size: 11px; }
.pc-action { display: block; width: 100%; margin-top: 6px; text-align: center; }

/* .poster — card poster del design system Blu notte (badge/progress inclusi) */
.poster {
  position: relative; border-radius: var(--radius); aspect-ratio: 2/3; overflow: hidden;
  background: linear-gradient(140deg, var(--sf2), var(--sf)); box-shadow: 0 6px 16px rgba(0,0,0,.35);
  cursor: pointer; border: 1px solid var(--bd);
}
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster .title {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: 11px;
  color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.85));
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* badge di stato (✓ scaricato / ⏳ in download) — riusati su .poster e .pc-frame */
.badge-dl, .pc-badge, .poster .badge {
  font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .2px;
  padding: 3px 8px; border-radius: 7px; color: #fff; background: rgba(8,9,17,.75);
}
.badge-dl { display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; white-space: nowrap; }
.badge-dl.ok, .pc-badge.watched, .poster .badge.ok { background: var(--ok); color: #06210f; }
.badge-dl.wait, .pc-badge.wait, .poster .badge.wait { background: var(--wait); color: #231a06; }
.pc-badge { position: absolute; top: 6px; right: 6px; }
.poster .badge { position: absolute; top: 6px; right: 6px; }

/* barra di avanzamento visione sulle locandine */
.pc-progress, .poster .progress {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0,0,0,.5); overflow: hidden;
}
.pc-progress > i, .poster .progress > i { display: block; height: 100%; background: var(--ac); }
.pc-frame { position: relative; }
.pc-resume { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  font-family: var(--sans); font-size: 11px; background: rgba(8,9,17,.85); color: var(--ac);
  border: 1px solid var(--ac); border-radius: 999px; padding: 3px 10px; opacity: 0; transition: opacity .12s; }
.continue-card:hover .pc-resume { opacity: 1; }

/* continua a guardare */
.continue-row { margin-bottom: 22px; }
.continue-scroll { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.continue-card { flex: 0 0 130px; text-decoration: none; }
.continue-card .pc-poster { width: 130px; }

/* stato episodi nel dettaglio */
.ep-flag { font-family: var(--sans); font-size: 11px; margin-left: 6px; }
.ep-flag.watched { color: var(--ok); }
.ep-row.ep-done .ep-label { color: var(--dim); }

/* dettaglio */
.cat-detail { max-width: 900px; }
.detail-head { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; margin-top: 14px; }
.detail-poster { width: 200px; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--bd); background: var(--bg); }
.detail-poster.pc-noposter { display: flex; align-items: center; justify-content: center; font-size: 60px; }
.detail-title { font-family: var(--sans); font-size: 24px; color: var(--tx); }
.detail-cast { margin-top: 12px; }
.detail-plot { margin-top: 12px; line-height: 1.6; }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; }
.detail-eps { margin-top: 20px; border-top: 1px solid var(--bd); }

/* catalogo IPTV */
.iptv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.iptv-filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.iptv-filters .cat-search { flex: 1; min-width: 200px; }
.iptv-list { display: flex; flex-direction: column; }
.iptv-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--bd); }
.iptv-row:hover { background: var(--sf2); }
.iptv-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.iptv-name { color: var(--tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iptv-rec-msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px;
  background: var(--sf2); border-left: 3px solid var(--ok); }
.iptv-rec-msg.err { border-left-color: var(--err); color: var(--err); }

/* Live TV / EPG */
.live-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.live { display: flex; gap: 16px; align-items: flex-start; }
.live-chan { width: 240px; flex: none; display: flex; flex-direction: column; gap: 6px; }
.live-chrow {
  display: flex; align-items: center; gap: 10px; background: var(--sf);
  border: 1px solid transparent; border-radius: 8px; padding: 8px 10px;
  cursor: pointer; font-size: 13px; color: var(--tx);
}
.live-chrow:hover { background: var(--sf2); }
.live-chrow.on { border-color: var(--ac); background: var(--sf2); }
.live-logo { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; flex: none; background: var(--sf2); }
.live-noicon { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 14px; }
.live-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-epg { flex: 1; min-width: 0; }
.live-now { background: var(--sf); border-radius: var(--radius); padding: 14px 16px; }
.live-lab { font-family: var(--sans); font-size: 11px; letter-spacing: .5px; color: var(--ac); text-transform: uppercase; }
.live-title { font-size: 16px; margin: 6px 0 4px; }
.live-time { font-family: var(--sans); font-size: 12px; color: var(--dim); }
.live-desc { margin-top: 8px; line-height: 1.5; }
.live-next { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.live-nxt {
  display: flex; justify-content: space-between; gap: 12px; font-size: 12px;
  color: var(--tx); border-top: 1px solid var(--bd); padding-top: 8px;
}
@media (max-width: 700px) {
  .live { flex-direction: column; }
  .live-chan { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .live-chrow { flex: 1 1 45%; }
}

/* scheda attore */
.actor-section { margin-top: 22px; border-top: 1px solid var(--bd); padding-top: 16px; }
.filmo { display: flex; flex-direction: column; }
.filmo-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: baseline;
  padding: 7px 8px; border-radius: 6px; }
.filmo-row.in-lib { background: rgba(34,197,94,.09); cursor: pointer; }
.filmo-row.in-lib:hover { background: rgba(34,197,94,.18); }
.filmo-year { font-family: var(--sans); font-size: 12px; }
.filmo-title { color: var(--tx); }
.filmo-role { font-size: 12px; text-align: right; max-width: 40%; }

/* widget attività (download/lavori in corso) */
#activity { position: fixed; right: 18px; bottom: 92px; z-index: 1500; }
.act-widget { width: 300px; max-width: calc(100vw - 36px); background: var(--sf); border: 1px solid var(--ac); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.55); }
.act-head { font-family: var(--sans); font-size: 12px; color: var(--ac); margin-bottom: 8px; }
.act-job { margin-bottom: 10px; } .act-job:last-child { margin-bottom: 0; }
.act-row { display: flex; justify-content: space-between; font-family: var(--sans); font-size: 12px; }
.act-name { color: var(--tx); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.act-stage { font-size: 11px; }

@media (min-width: 1024px) {
  #activity { bottom: 18px; }
}

/* toast */
#toast-container { position: fixed; right: 18px; top: 18px; z-index: 1600; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { font-family: var(--sans); font-size: 12px; background: var(--sf2); color: var(--tx);
  border: 1px solid var(--ok); border-left-width: 3px; border-radius: 8px; padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); max-width: 340px; animation: toastin .3s ease; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: opacity .4s, transform .4s; }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 720px) {
  .lib { grid-template-columns: 1fr; }
  .rec-actions { margin-left: 0; width: 100%; }
  .tagcard { grid-template-columns: 1fr; }
  .detail-head { grid-template-columns: 1fr; }
  .poster-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* --- episodi serie (catalogo IPTV) --- */
.episodes-box {
  margin: 4px 0 12px 12px;
  padding: 10px 12px;
  border-left: 2px solid var(--ac);
  background: var(--sf2);
  border-radius: 0 8px 8px 0;
}
.season-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 10px; max-height: 108px; overflow-y: auto;
}
.episodes-box .iptv-row { padding: 6px 0; }

/* --- dettaglio serie/film (testata TMDB + episodi), fragments/detail.html --- */
.iptv-detail { max-width: 960px; }
.iptv-detail .detail-actions { flex-wrap: wrap; }
.iptv-detail .episodes-container { margin-top: 18px; }
.iptv-detail .episodes-box { margin: 0; padding: 0; border-left: none; background: none; border-radius: 0; }
@media (min-width: 1024px) {
  .iptv-detail-body { display: grid; grid-template-columns: 1fr 1.3fr; gap: 28px; align-items: start; }
}

/* --- modale di caricamento cattura episodi --- */
.capture-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4,6,12,.6); backdrop-filter: blur(2px);
}
.capture-overlay[hidden] { display: none; }
.capture-box {
  background: var(--sf); color: var(--tx);
  padding: 26px 30px; border-radius: 16px; max-width: 360px; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); border: 1px solid var(--bd);
}
.capture-title { font-weight: 600; margin: 12px 0 6px; }
.capture-box .spinner {
  width: 38px; height: 38px; margin: 0 auto; border-radius: 50%;
  border: 4px solid var(--bd); border-top-color: var(--ac);
  animation: cap-spin .8s linear infinite;
}
@keyframes cap-spin { to { transform: rotate(360deg); } }

/* ---- Impostazioni ---------------------------------------------------------- */
.settings { max-width: 720px; display: flex; flex-direction: column; gap: 22px; }
.settings-group { display: flex; flex-direction: column; gap: 10px; }
.settings-group .label { display: block; margin-bottom: 2px; }
.settings-group .hint { display: block; margin-top: 4px; }
@media (min-width: 1024px) {
  .settings { max-width: none; display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; }
  .settings-group.settings-sync { grid-column: 1 / -1; }
}

/* --- pagina di pairing dispositivo (/pair) --- */
.pair-page { max-width: 560px; margin: 0 auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 18px; }
.pair-page h1 { font-size: 20px; margin: 0 0 4px; }
.pair-page .card { background: #141b2b; border: 1px solid #22304a; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.pair-page .mono { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; background: #0b0f1a; color: #eaf0fb; border: 1px solid #22304a; border-radius: 8px; padding: 8px; resize: vertical; }
.pair-page .qr { display: flex; justify-content: center; }
.pair-page .qr svg { width: 180px; height: 180px; background: #fff; padding: 6px; border-radius: 8px; }
.pair-page .fp { font-size: 32px; font-weight: 700; letter-spacing: 4px; text-align: center; color: #2f74f0; }
.pair-page .ok { color: #22c55e; text-align: center; font-weight: 600; }
.pair-page .err { color: #ef5350; }


/* ── Live TV: accordion categorie + ricerca ─────────────────────────── */
.live-search { padding: 8px 10px; }
.live-search input { width: 100%; box-sizing: border-box; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  color: var(--ink); font: inherit; }
.live-cat { border-bottom: 1px solid var(--line); }
.live-cat > summary { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px; cursor: pointer; list-style: none; font-weight: 600; }
.live-cat > summary::-webkit-details-marker { display: none; }
.live-cat > summary::before { content: "▸"; color: var(--muted, #8a8a8a);
  transition: transform .12s ease; }
.live-cat[open] > summary::before { transform: rotate(90deg); }
.live-catname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-catn { font-variant-numeric: tabular-nums; }
.live-catbody { padding-left: 6px; }
.live-loading { padding: 10px 14px; }
