:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1f2633;
  --muted: #6b7486;
  --line: #e4e8f0;
  --accent: #2563eb;
  --accent-ink: #1d4ed8;
  --accent-soft: #e8efff;
  --hl: #fff1a8;
  --hl-strong: #ffd84d;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(31, 38, 51, .06), 0 1px 3px rgba(31, 38, 51, .05);
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------ header */
.topbar { position: sticky; top: 0; z-index: 20; padding: 12px 16px 0; }
.topbar-inner { max-width: 1280px; margin: 0 auto; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px; padding: 10px 20px; min-height: 72px; }
.brand { display: flex; align-items: center; gap: 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 52px; width: auto; display: block; }
.brand-text strong { display: block; font-size: 17px; line-height: 1.2; }
.brand-text span { font-size: 13px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: transparent; color: var(--accent); cursor: pointer; }
.icon-btn:hover { background: var(--accent-soft); text-decoration: none; }
.icon-btn svg { width: 22px; height: 22px; }
.back-btn { background: var(--accent-soft); }

main { max-width: 1280px; margin: 24px auto 48px; padding: 0 16px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }

/* ------------------------------------------------ filtri */
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; margin-bottom: 24px; }
.field { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; min-height: 44px; }
.field input, .field select { border: 0; outline: 0; background: transparent; min-width: 0; height: 42px; }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.field.grow { flex: 1 1 220px; }
.field.grow input { width: 100%; }
.field label { font-size: 13px; color: var(--muted); white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 0 18px; min-height: 44px; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn.secondary { background: var(--accent-soft); color: var(--accent-ink); }
.btn.secondary:hover { background: #dbe6ff; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: #fdecec; color: var(--err); }
.btn.danger:hover { background: #fbdada; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.adv { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; padding: 14px; border-radius: 14px; background: var(--bg); }
.adv .field { flex: 1 1 220px; }
.adv .field select { width: 100%; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ------------------------------------------------ griglia sedute */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }
.card { background: var(--surface); border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); display: flex;
  flex-direction: column; color: var(--text); transition: transform .15s ease, box-shadow .15s ease; }
.card:hover { text-decoration: none; transform: translateY(-3px); box-shadow: 0 16px 36px rgba(31, 38, 51, .12); }
.card .thumb { aspect-ratio: 16 / 10; background: #dfe5ef center / cover no-repeat; position: relative; }
.card .thumb .dur { position: absolute; right: 10px; bottom: 10px; background: rgba(0, 0, 0, .7); color: #fff;
  font-size: 12px; padding: 2px 8px; border-radius: 8px; }
.card .body { padding: 16px 18px 18px; text-align: center; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 17px; font-weight: 600; color: var(--accent); line-height: 1.3; }
.card .desc { font-size: 13px; color: var(--muted); }
.card .date { margin-top: auto; padding-top: 8px; font-weight: 700; font-size: 14px; }
.card .snippet { font-size: 12.5px; text-align: left; background: var(--bg); padding: 8px 10px; border-radius: 10px; }
mark { background: var(--hl); color: inherit; padding: 0 1px; border-radius: 3px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.more { display: flex; justify-content: center; margin-top: 28px; }
.result-count { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }

.field.check { cursor: pointer; font-size: 14px; white-space: nowrap; }
.results { display: flex; flex-direction: column; gap: 18px; }
.result { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; }
.r-thumb { aspect-ratio: 16 / 10; border-radius: 12px; background: #dfe5ef center / cover no-repeat; }
.r-title { font-size: 18px; font-weight: 600; }
.r-meta { font-size: 13px; color: var(--muted); margin: 2px 0 10px; }
.hits { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hits a { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 7px 10px;
  border-radius: 10px; color: var(--text); font-size: 14px; }
.hits a:hover { background: var(--accent-soft); text-decoration: none; }
.h-time { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.h-spk { font-weight: 600; font-size: 13px; white-space: nowrap; }
.h-ctx { color: var(--muted); }
.h-ctx mark { color: var(--text); font-weight: 600; }
@media (max-width: 640px) {
  .result { grid-template-columns: 1fr; }
  .r-thumb { display: none; }
  .hits a { grid-template-columns: auto minmax(0, 1fr); }
  .h-ctx { grid-column: 1 / -1; }
}

/* ------------------------------------------------ pagina seduta */
.session-title { margin: 0 0 4px; font-size: 28px; font-weight: 500; }
.session-sub { margin: 0 0 20px; color: var(--muted); }
.player-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.player-col video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; display: block; }
.player-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.chip.warn { background: #fff4e5; color: var(--warn); }
.now-speaking { margin-top: 14px; padding: 12px 14px; background: var(--bg); border-radius: 12px; font-size: 14px; }
.now-speaking strong { color: var(--accent-ink); }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 12px 8px; cursor: pointer; color: var(--muted); font-size: 15px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-tools { display: flex; gap: 8px; align-items: center; padding: 10px 0; flex-wrap: wrap; }
.tab-tools .field { min-height: 36px; flex: 1 1 160px; }
.tab-tools .field input { height: 34px; width: 100%; }
.tab-tools .btn.small { white-space: nowrap; }
.scroller { height: 520px; overflow: auto; scroll-behavior: smooth; padding-right: 6px; }

table.index { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.index th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 700; padding: 10px 8px;
  border-bottom: 1px solid var(--line); z-index: 1; }
table.index td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.index tr.current td { background: var(--accent-soft); }
table.index tr.ev-other td { background: #fafbfd; }
table.index tr.ev-other td.desc { font-style: italic; }
table.index td.n { font-weight: 700; width: 36px; }
table.index td.lnk { width: 64px; white-space: nowrap; }
table.index td.tm { width: 76px; }
table.index td.ev { width: 110px; color: var(--muted); }
.tbtn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 2px 4px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.tbtn:hover { background: var(--accent-soft); }
.tbtn svg { width: 16px; height: 16px; vertical-align: -3px; }

.transcript { font-size: 15px; line-height: 1.75; }
.transcript .spk { display: block; margin: 18px 0 2px; font-weight: 700; cursor: pointer; }
.transcript .spk:first-child { margin-top: 0; }
.transcript .spk .t { font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 6px; }
.transcript .evt { display: block; margin: 14px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 8px 8px 0; font-size: 14px; cursor: pointer; }
.transcript .evt b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-ink); }
.transcript p { margin: 0 0 8px; }
.transcript .w { cursor: pointer; border-radius: 3px; }
.transcript .w:hover { background: var(--accent-soft); }
.transcript .w.cur { background: var(--hl-strong); box-shadow: 0 0 0 2px var(--hl-strong); }
.transcript .w.hit { background: var(--hl); }
.transcript .w.hit.focus { outline: 2px solid var(--accent); }
.provisional-note { font-size: 13px; padding: 8px 12px; background: #fff4e5; color: var(--warn); border-radius: 10px; margin-bottom: 10px; }

.share { display: flex; justify-content: center; gap: 10px; margin-top: 28px; flex-wrap: wrap; }
.share a, .share button { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 0; cursor: pointer; }
.share svg { width: 18px; height: 18px; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2633; color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }

/* ------------------------------------------------ admin */
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.admin-head h1 { margin: 0; font-size: 24px; font-weight: 600; flex: 1; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.list tr:hover td { background: #fafbfd; }
.status { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.dot { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef1f6; color: var(--muted); white-space: nowrap; }
.dot.ok { background: #e7f6ec; color: var(--ok); }
.dot.run { background: #fff4e5; color: var(--warn); }
.dot.err { background: #fdecec; color: var(--err); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.lbl { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.lbl input, .lbl textarea, .lbl select { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); background: #fff; }
.lbl input:focus, .lbl textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-top: 22px; }
.drop { border: 2px dashed var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop h4 { margin: 0; font-size: 15px; }
.drop .cur { font-size: 13px; color: var(--muted); word-break: break-all; }
.drop .cur.ok { color: var(--ok); }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.stats { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px 14px; min-width: 120px; }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--muted); }
.msg { margin-top: 14px; padding: 10px 14px; border-radius: 10px; background: var(--bg); font-size: 14px; }
.msg.err { background: #fdecec; color: var(--err); }
.login { max-width: 380px; margin: 60px auto; }
.login h1 { margin: 0 0 18px; font-size: 22px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }

@media (max-width: 960px) {
  .player-layout { grid-template-columns: 1fr; }
  .scroller { height: 60vh; }
}
@media (max-width: 640px) {
  .panel { padding: 18px; }
  .brand img { height: 40px; }
  .brand-text span { display: none; }
  .session-title { font-size: 22px; }
  table.index td.ev, table.index th.ev { display: none; }
  table.list .hide-sm { display: none; }
  .filters .field.date { flex: 1 1 140px; }
}

/* ------------------------------------------------ area riservata */
.small { font-size: 12.5px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 12px; color: var(--text); background: var(--bg); }
.user-chip:hover { text-decoration: none; background: var(--accent-soft); }
.user-chip svg { width: 26px; height: 26px; color: var(--accent); }
.user-chip span { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 11.5px; }
.reserved-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; margin: -8px 0 18px;
  background: var(--accent-soft); border-radius: 12px; font-size: 13px; }
.reserved-bar svg { width: 15px; height: 15px; vertical-align: -2px; }
.reserved-bar .muted { flex: 1; color: var(--accent-ink); }
.area-card h3 a { color: inherit; }
.area-card .thumb { display: block; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; padding: 0 14px 16px; }
.card-actions .btn { flex: 1 1 auto; }
.dialog { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .35); }
.dialog h3 { margin: 0 0 14px; }
.dialog form { display: flex; flex-direction: column; gap: 12px; }
.box { border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-top: 18px; }
.box h2 { margin: 0 0 12px; font-size: 17px; }
.box-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.box-head h2 { margin: 0; flex: 1; }
.box-head .field { min-height: 36px; }
.box-head .field input { height: 34px; }
.inline-form { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.actions .spacer { flex: 1; }

/* ------------------------------------------------ editing */
main.wide { max-width: 1500px; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 22px; align-items: start; }
.edit-left { position: sticky; top: 104px; }
.edit-left video { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; display: block; }
.timebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; }
.timebar b { font-variant-numeric: tabular-nums; font-size: 16px; }
.timebar .spacer { flex: 1; }
.inline { display: flex; gap: 6px; align-items: center; }
.inline input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.frag-form, .add-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.frag-form .full, .add-form .full { grid-column: 1 / -1; }
.frag-form > *, .add-form > *, .edit-layout > *, .lbl { min-width: 0; }
.inline .btn.small { padding: 0 10px; flex: none; }
.frag-foot { display: flex; justify-content: space-between; align-items: center; }
.frag-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.frag { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg); border-radius: 12px; flex-wrap: wrap; }
.frag-main { flex: 1 1 200px; display: flex; flex-direction: column; min-width: 0; }
.ev-scroller { height: 560px; }
.ev-table td { padding: 6px; vertical-align: top; }
.ev-table input, .ev-table select { width: 100%; border: 1px solid transparent; border-radius: 8px; padding: 6px 8px; background: transparent; }
.ev-table input:hover, .ev-table select:hover { border-color: var(--line); background: #fff; }
.ev-table input:focus, .ev-table select:focus { outline: 0; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-soft); }
.ev-table .tcell { width: 168px; }
.tline { display: flex; align-items: center; gap: 0; }
.tline .t-in { flex: 1; min-width: 0; }
.ev-table .t-in { font-variant-numeric: tabular-nums; }
.ev-table td:nth-child(3) { width: 128px; }
.ev-table td.n { width: 30px; }
.ev-table .acts { white-space: nowrap; width: 92px; text-align: right; }
.ev-table .acts .save { display: block; margin: 0 0 4px auto; }
.ev-table .acts .save.hidden { display: none; }
.row-tools { display: flex; gap: 0; flex: none; }
.ev-table .x-in { font-weight: 600; }
.ev-table tr.ev-other .x-in { font-weight: 400; font-style: italic; }
.ev-table tr.dirty td { background: #fffbea; }
.ev-table tr.flash td { animation: flash 1.6s ease; }
@keyframes flash { from { background: var(--hl-strong); } to { background: transparent; } }
.tbtn.del { color: var(--err); }
@media (max-width: 1100px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-left { position: static; }
}
@media (max-width: 640px) {
  .frag-form, .add-form { grid-template-columns: 1fr; }
  .ev-table td:nth-child(3) { width: auto; }
}
.result .card-actions .btn { flex: none; }

.ev-table .ti-in { font-weight: 700; margin-bottom: 2px; }
.ev-table .ti-in.hidden { display: none; }
