/* The looks are GDR Archive's: Emerald here, the default, and Grafite below.
   Every colour is a token; the rules name roles, never palette colours. */
:root {
  /* I menu che restano al browser (tendine delle select, scrollbar, input data)
     non si possono disegnare con il CSS: questo li fa nascere scuri invece che
     bianchi su una pagina scura. */
  color-scheme: dark;
  --bg: #131917;             /* page ground */
  --surface: #1a221f;        /* panels, header, buttons */
  --surface-2: #232d29;      /* inputs, elevated rows, tracks */
  --line: #33403a;
  --ink: #e7ece9;
  --muted: #97a49d;
  --primary: #1fb98a;        /* the accent: primary actions, brand, rules */
  --primary-hover: #2fcb9b;
  --on-primary: #08150f;
  --acc2: #e6b35a;           /* secondary: focus rings, hover */
  --amber: #f5a623;          /* un passo fatto ma da rifare */
  --danger: #ff2540;         /* errors */
  --radius: 6px;
  /* What differs between the looks by role rather than by palette. */
  --brand-rule: 2px;               /* the rule under the brand */
  --step-done: var(--ink);         /* a done step's dot */
  --done-fill: var(--primary);     /* .tag-done, .stepper li.done, the ok banner's rule */
  --on-done-fill: var(--on-primary);
  --active: var(--primary);        /* the selected filter pill */
  --notice-rule: var(--amber);     /* the banner asking for an archive token */
  --preview-ink: var(--ink);       /* text in .preview */
  --maxw: 980px;
  --sidebar-w: 220px;
  --font: "Barlow", system-ui, sans-serif;
  --display: "Barlow Condensed", "Barlow", sans-serif;
}
/* Grafite: the look cronista had before Emerald, for an archive account that
   chose it. Only what differs; the tokens that read another token resolve
   here, on <html>, so each look gets its own. */
:root[data-theme="grafite"] {
  --bg: #171b21;
  --surface: #1f242d;
  --surface-2: #28303b;
  --line: #343d49;
  --ink: #e8edf3;
  --muted: #96a1ae;
  --primary: #ff2540;
  --primary-hover: #ff3a52;
  --on-primary: #ffffff;
  --acc2: #4bd0c4;
  --radius: 4px;
  --brand-rule: 3px;
  --step-done: var(--acc2);
  --done-fill: var(--acc2);
  --on-done-fill: #06231f;
  --active: var(--acc2);
  --notice-rule: var(--danger);
  --preview-ink: #cfd7e0;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header: signed-out pages only (login, setup), the brand and nothing else. */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: var(--brand-rule) solid var(--primary);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--primary); font-size: 1.4rem; line-height: 1; }
.brand-name {
  font-family: var(--display); font-weight: 700; font-size: 1.5rem;
  letter-spacing: .02em; text-transform: uppercase;
}

/* Shell: the sidebar beside the page, with GDR Archive's geometry and type
   (AppLayout.tsx and the .sidebar rules of its index.css). The document
   scrolls as a whole; the sidebar is sticky, so it stays in view. */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main > .container { width: 100%; flex: 1; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar-brand { padding: 20px 16px 14px; border-bottom: var(--brand-rule) solid var(--primary); }
.sidebar-brand .brand-name { font-size: 1.25rem; }
.sidebar-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius); border-left: 3px solid transparent;
  color: var(--muted); text-decoration: none;
  font-family: var(--display); font-weight: 600; font-size: 15px;
  letter-spacing: .03em; text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}
.sidebar-link:hover, .sidebar-link.active { background: var(--surface-2); color: var(--ink); }
.sidebar-link.active { border-left-color: var(--primary); }
.sidebar-link:focus-visible { outline: 2px solid var(--acc2); outline-offset: -2px; }
.sidebar-ext { margin-left: auto; color: var(--muted); font-size: .9em; }
.sidebar-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
/* Pushed to the bottom, away from the sections. */
.sidebar-user { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
/* Il nome è il comando, come il menu utente di GDR Archive: un bottone
   discreto, le voci dietro. */
.sidebar-user-chip {
  display: block; max-width: 100%;
  font-family: var(--font); font-size: .85rem; font-weight: 600; text-align: left;
  color: var(--ink); background: none;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .3rem .55rem; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user-chip:hover { background: var(--surface-2); border-color: var(--acc2); }
.sidebar-user-chip:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }
.sidebar-user-items { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.sidebar-user-item {
  font-family: var(--font); font-size: .85rem; text-align: left;
  color: var(--muted); background: none; border: none; border-radius: 3px;
  padding: .35rem .4rem .35rem 6px; cursor: pointer; text-decoration: none;
}
.sidebar-user-item:hover { background: var(--surface-2); color: var(--acc2); }
.sidebar-user-item:focus-visible { outline: 2px solid var(--acc2); outline-offset: -2px; }
/* L'ultima riga: la release che gira, come in GDR Archive. */
.sidebar-version { padding: 0 12px 12px; font-size: 11px; color: var(--muted); letter-spacing: .02em; }

/* The top bar and the drawer exist for a phone's width only. */
.shell-bar { display: none; }
.shell-drawer-layer { display: none; }
.shell-menu-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; font-size: 18px; line-height: 1;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.shell-menu-button:hover { background: var(--surface-2); }
.shell-menu-button:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }

/* The archive's breakpoint: at 390px a 220px sidebar would leave the page
   nothing, so a top bar takes its place and opens the same list as a drawer
   over the page. initShell (app.js) keeps a copy of this number. */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .shell-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    padding: 10px 16px; background: var(--surface); border-bottom: var(--brand-rule) solid var(--primary);
  }
  .shell-bar-brand .brand-name { font-size: 1.15rem; }
  .shell-drawer-layer:not([hidden]) { display: flex; position: fixed; inset: 0; z-index: 60; }
  .shell-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
  .shell-drawer {
    position: relative; display: flex; flex-direction: column;
    width: min(280px, 82vw); height: 100%; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
    animation: shell-drawer-in 160ms ease-out;
  }
}
@keyframes shell-drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
/* Asked for no motion: the drawer is there, it just does not travel. */
@media (prefers-reduced-motion: reduce) {
  .shell-drawer { animation: none; }
  .sidebar-link { transition: none; }
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 2rem 1.5rem 4rem; }

/* Hero */
.hero { margin-bottom: 2rem; }
.display {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: clamp(2.2rem, 6vw, 3.6rem); line-height: .98; letter-spacing: .01em;
  margin: 0 0 .5rem; text-wrap: balance;
}
.accent { color: var(--primary); }
.lede { color: var(--muted); font-size: 1.1rem; max-width: 60ch; margin: 0; }

/* Panels */
.panel {
  border: 1px solid var(--line); border-top: 3px solid var(--primary);
  background: var(--surface); padding: 1.5rem; margin-bottom: 1.5rem;
  border-radius: var(--radius);
}
.panel-title {
  font-family: var(--display); text-transform: uppercase; font-weight: 700;
  letter-spacing: .03em; font-size: 1.25rem; margin: 0 0 1rem;
}

/* Pannelli che si piegano (pagina account), con la geometria delle sezioni di
   GDR Archive. Il titolo è il comando: un bottone che riempie l'intestazione,
   con il segno che gira quando la sezione si apre. */
.panel-collapsible.is-collapsed { padding-bottom: 1.1rem; }
.panel-collapsible.is-collapsed .panel-title { margin-bottom: 0; }
.panel-toggle {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: 0; border: none; background: none; color: inherit;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  cursor: pointer;
}
.panel-toggle:hover { color: var(--acc2); }
.panel-toggle:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }
.panel-chevron {
  width: 8px; height: 8px; flex-shrink: 0;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
}
.panel-toggle[aria-expanded="true"] .panel-chevron { transform: rotate(45deg); }
@media (prefers-reduced-motion: no-preference) {
  .panel-chevron { transition: transform .15s; }
}
/* Al posto del corpo: una riga di quello che la sezione contiene. */
.panel-summary {
  margin: .6rem 0 0; color: var(--muted); font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.panel-description { margin: 0 0 1rem; }
.panel-collapsible.is-collapsed .panel-description { display: none; }
.panels-toolbar { display: flex; justify-content: flex-end; gap: 1rem; margin-bottom: .75rem; }
.link-button {
  padding: 0; border: none; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .9rem; text-decoration: underline;
}
.link-button:hover { color: var(--acc2); }
.link-button:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }

/* L'attributo hidden deve vincere su qualunque display di una classe: .field è
   un flex, quindi senza questa regola un campo nascosto resta visibile. */
[hidden] { display: none !important; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label { font-weight: 600; font-size: .9rem; }
.field-check { flex-direction: row; gap: 1.5rem; align-items: center; }
/* Casella e testo sulla stessa riga: la casella disegnata è un grid, quindi la
   riga la tiene insieme l'etichetta. */
.field-check label { font-weight: 500; display: inline-flex; align-items: center; gap: .4rem; }
/* Un solo aspetto per ogni campo. La regola vale per qualunque input testuale,
   anche senza attributo type (un <input list=...> ne fa a meno), altrimenti il
   browser lo disegna bianco su una pagina scura. Caselle, radio e file hanno
   una forma loro e restano fuori. */
input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,
textarea {
  font-family: var(--font); font-size: 1rem; color: var(--ink);
  padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]):focus,
select:focus,
textarea:focus {
  outline: none; border-color: var(--primary); background: var(--bg);
}
select option { color: var(--ink); background: var(--surface); }
/* Caselle: disegnate come i campi, perché quelle di sistema sono bianche e su
   questa pagina si vedono da lontano. Il segno di spunta è un quadratino nel
   colore d'accento. */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 1.05rem; height: 1.05rem; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2);
  display: inline-grid; place-content: center; cursor: pointer;
}
input[type=checkbox]::before {
  content: ""; width: .55rem; height: .55rem; border-radius: 2px;
  background: var(--primary); transform: scale(0); transition: transform .12s ease;
}
input[type=checkbox]:checked { border-color: var(--primary); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:focus-visible { outline: none; border-color: var(--primary); }
input[type=radio] { accent-color: var(--primary); }
/* Rete di sicurezza: un controllo nuovo dentro un pannello, anche senza classi,
   nasce col tema invece che col default del browser. */
.panel input:not([type=checkbox]):not([type=radio]):not([type=file]),
.panel select,
.panel textarea {
  font-family: var(--font); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2);
}
/* Anche nelle finestre modali, che vivono fuori dai pannelli. */
.confirm-modal input:not([type=checkbox]):not([type=radio]):not([type=file]),
.confirm-modal select,
.confirm-modal textarea {
  font-family: var(--font); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2);
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.source-controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.source-controls input[type=text] { flex: 1 1 260px; }
.hint { color: var(--muted); font-size: .82rem; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: .5rem; }

/* Buttons */
.btn {
  font-family: var(--display); text-transform: uppercase; font-weight: 600;
  letter-spacing: .03em; font-size: .95rem; cursor: pointer;
  padding: .6rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--ink); text-decoration: none; display: inline-block;
}
.btn:hover { border-color: var(--acc2); color: var(--acc2); }
.btn:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-ghost { background: transparent; }
.btn-small { padding: .35rem .7rem; font-size: .82rem; }

/* File browser */
.browser {
  margin-top: .75rem; border: 1px solid var(--line); border-radius: var(--radius);
  max-height: 320px; overflow: auto; background: var(--surface-2);
}
.browser .crumb { padding: .5rem .75rem; border-bottom: 1px solid var(--line); font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.browser ul { list-style: none; margin: 0; padding: 0; }
.browser li { padding: .45rem .75rem; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; justify-content: space-between; }
.browser li:hover { background: var(--surface); }
.browser li.dir::before { content: "📁 "; }
.browser li.audio::before { content: "🎵 "; }
.browser li.file::before { content: "📄 "; }
.browser .size { color: var(--muted); font-size: .82rem; }

/* Dashboard delle sessioni: intestazione, barra dei filtri, gruppi e righe.
   Le righe sono una griglia di quattro colonne (data, testo, tacche, azioni):
   sotto i 1000px la griglia si scioglie e le colonne si impilano. */
.container.wide { max-width: 1180px; }

.sessions-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1.5rem; margin-bottom: 1.5rem;
}
.sessions-head .hero { margin: 0; }
.sessions-head .display { font-size: clamp(2rem, 4.5vw, 2.75rem); }
.sessions-head .btn { white-space: nowrap; }

.toolbar {
  display: grid; grid-template-columns: 260px minmax(0, 1fr) auto;
  gap: .75rem; align-items: center;
  padding: .9rem 1rem; margin-bottom: 1.5rem;
  background: var(--surface); border: 1px solid var(--line);
  border-top: 3px solid var(--primary); border-radius: var(--radius);
}
.toolbar select, .toolbar input {
  font-family: var(--font); font-size: .9rem; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .55rem .7rem; width: 100%;
}
.pills { display: flex; gap: .4rem; }
.pill {
  font-family: var(--font); font-size: .8rem; font-weight: 600; line-height: 1;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem .65rem; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.pill:hover { color: var(--acc2); }
.pill.is-active { color: var(--active); border-color: var(--active); }
.pill:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }

.campaign-group { margin-bottom: 1.5rem; }
.campaign-group:last-child { margin-bottom: 0; }
.group-head {
  display: flex; align-items: baseline; gap: .75rem;
  flex-wrap: wrap; padding: 0 .25rem .5rem;
}
.group-name {
  font-family: var(--display); text-transform: uppercase; font-weight: 700;
  letter-spacing: .04em; font-size: 1.05rem; color: var(--acc2); margin: 0;
}
.group-meta { margin: 0; color: var(--muted); font-size: .82rem; }
/* Il link alla campagna è un rimando, non l'azione della pagina: il colore
   secondario, non l'accento, così l'unico accento della riga resta il suo
   passo successivo. */
.group-meta a { color: var(--acc2); font-weight: 500; }

.session-list {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius);
}
.session-row {
  display: grid; grid-template-columns: 108px minmax(0, 1fr) auto auto;
  gap: 1.25rem; align-items: center; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.session-row:last-child { border-bottom: none; }
.session-row[hidden] { display: none !important; }

.row-date { display: flex; flex-direction: column; line-height: 1; }
.row-day {
  font-family: var(--display); font-weight: 700; text-transform: uppercase;
  font-size: 1.6rem; color: var(--ink);
}
.row-month {
  font-family: var(--display); font-weight: 600; text-transform: uppercase;
  letter-spacing: .03em; font-size: .78rem; color: var(--muted); margin-top: .25rem;
}
.row-stamp {
  /* Il font monospaziato è dichiarato qui e non con .mono, che porta con sé
     una dimensione pensata per il testo di una tabella. */
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .68rem; color: var(--muted); margin-top: .25rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.row-main { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.row-title {
  margin: 0; font-size: 1rem; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-note { margin: 0; font-size: .8rem; color: var(--muted); }
.row-stale { margin: .1rem 0 0; font-size: .8rem; color: var(--amber); }
.row-main .artifacts { margin: .15rem 0 0; }

/* Le quattro tacche: piena una fatta, cerchio nel colore d'accento il passo
   successivo (come il suo pulsante), cerchio ambra un passo da rifare,
   cerchio spento quello che manca. */
.row-steps { display: flex; align-items: center; gap: .5rem; }
.step { display: inline-flex; align-items: center; gap: .4rem; }
.step-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: transparent; border: 2px solid var(--line);
}
.step-label {
  font-family: var(--display); text-transform: uppercase; font-weight: 600;
  letter-spacing: .03em; font-size: .7rem; color: var(--muted);
}
.step-link { width: 18px; height: 1px; background: var(--line); }
.step.is-done .step-dot { background: var(--step-done); border-color: var(--step-done); }
.step.is-done .step-label { color: var(--ink); }
.step.is-next .step-dot { border-color: var(--primary); }
.step.is-next .step-label { color: var(--primary); }
.step.is-stale .step-dot { border-color: var(--amber); }
.step.is-stale .step-label { color: var(--amber); }

.session-row .row-actions { justify-content: flex-end; flex-wrap: nowrap; }

/* Menu "···": tutto quello che non è il passo successivo. */
.row-menu { position: relative; }
.menu-btn { padding: .35rem .55rem; color: var(--muted); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  display: flex; flex-direction: column; min-width: 12rem;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .3rem; box-shadow: 0 8px 24px rgba(4, 8, 12, .5);
}
.menu-panel[hidden] { display: none !important; }
.menu-item {
  font-family: var(--font); font-size: .85rem; text-align: left;
  color: var(--ink); background: none; border: none; border-radius: 3px;
  padding: .45rem .6rem; cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); color: var(--acc2); }
.menu-item:focus-visible { outline: 2px solid var(--acc2); outline-offset: -2px; }
/* Un gruppo per riassunto: l'intestazione nomina il modello, una riga separa. */
.menu-heading {
  font-family: var(--display); text-transform: uppercase; font-size: .72rem;
  font-weight: 600; letter-spacing: .04em; color: var(--muted);
  margin: 0; padding: .45rem .6rem .15rem;
}
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: .3rem .2rem; }

@media (max-width: 1000px) {
  .toolbar { grid-template-columns: 1fr; }
  .session-row { grid-template-columns: 72px minmax(0, 1fr); }
  .row-steps, .session-row .row-actions { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
}

.crumb-actions { display: flex; gap: .4rem; }

/* Tabelle (mappatura degli speaker) */
table { width: 100%; border-collapse: collapse; }
.mapping th, .mapping td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9rem; }
.row-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.link { color: var(--primary); text-decoration: none; font-weight: 600; }
.link:hover { text-decoration: underline; }
/* link-styled <button> for inline actions */
button.link { background: none; border: none; padding: 0; font: inherit; font-weight: 600; cursor: pointer; }

/* Artifact chips (testo / named / riassunto): quiet neutral pills, not the
   accent link style, so the action buttons stay the only strong call to action. */
.artifacts { display: inline-flex; gap: .35rem; flex-wrap: wrap; margin-right: .25rem; }
.chip {
  display: inline-flex; align-items: center;
  font-family: var(--font); font-size: .8rem; font-weight: 600; line-height: 1;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: .3rem .6rem; text-decoration: none; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  transition: color .12s ease, border-color .12s ease;
}
.chip:hover { color: var(--acc2); border-color: var(--acc2); }
.chip:focus-visible { outline: 2px solid var(--acc2); outline-offset: 2px; }
/* Il riassunto che è nell'archivio: un punto e il bordo nel colore d'accento. */
.chip-published { border-color: var(--primary); }
.chip-published::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); margin-right: .4rem; flex-shrink: 0;
}

/* Preview modal */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 8, 12, .7);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem; z-index: 50;
}
/* the [hidden] attribute must beat the display:flex above */
.overlay[hidden] { display: none; }
.preview-modal {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--primary);
  border-radius: var(--radius); width: min(820px, 100%); max-height: 85vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.preview-head .panel-title { margin: 0; }
.preview-head-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.preview-modal .preview { margin: 0; border: none; border-radius: 0; max-height: none; flex: 1; }
.confirm-modal {
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--primary);
  border-radius: var(--radius); width: min(440px, 100%); overflow: hidden;
}
.confirm-body { margin: 0; padding: 1.25rem; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: 0 1.25rem 1.25rem; }
/* Spunta dei presenti prima della pubblicazione: una riga per personaggio. */
.attendance-list { padding: 0 1.25rem; max-height: 40vh; overflow-y: auto; }
.attendance-row { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; }
.attendance-row .hint { margin-left: auto; }
#attendance-hint, #attendance-error { margin: 0; padding: .5rem 1.25rem 0; }
.tag { font-size: .75rem; text-transform: uppercase; font-weight: 600; padding: .15rem .5rem; border: 1px solid var(--muted); border-radius: 999px; color: var(--muted); }
.tag-done { background: var(--done-fill); color: var(--on-done-fill); border-color: var(--done-fill); }
.tag-muted { border-color: var(--line); color: var(--muted); }
.empty { color: var(--muted); }
.error-text { color: var(--danger); font-weight: 600; }

/* Stepper + progress */
.stepper { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1rem; flex-wrap: wrap; }
.stepper li {
  font-family: var(--display); text-transform: uppercase; font-weight: 600; font-size: .9rem;
  padding: .4rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.stepper li.active { border-color: var(--primary); color: var(--primary); }
.stepper li.done { background: var(--done-fill); border-color: var(--done-fill); color: var(--on-done-fill); }
.progress { height: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }
.job-detail { color: var(--muted); margin: .75rem 0 0; }
.job-result { margin-top: 1rem; }

/* Relabel */
.relabel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
/* let the preview column shrink so its <pre> wraps instead of overflowing */
.relabel-grid > * { min-width: 0; }
@media (max-width: 760px) { .relabel-grid { grid-template-columns: 1fr; } }
/* Assegnazione: una select dei candidati e, per un nome che la campagna non ha,
   un campo di testo che compare accanto. */
.mapping .assign-cell { display: flex; flex-direction: column; gap: .35rem; }
.mapping select.assign, .mapping input.assign-other { width: 100%; min-width: 0; }
.label-cell { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.label-stripe { width: 4px; align-self: stretch; min-height: 1.4em; border-radius: 2px; }
.label-name { font-family: var(--display); text-transform: uppercase; font-weight: 700; letter-spacing: .02em; }
.mapping .label-cell .hint { width: 100%; margin-left: .9rem; }
.preview {
  background: var(--bg); color: var(--preview-ink); padding: 1rem; border-radius: var(--radius);
  border: 1px solid var(--line);
  max-height: 480px; overflow: auto; font-size: .85rem; white-space: pre-wrap;
  overflow-wrap: anywhere;
}
textarea { resize: vertical; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 1.5rem; text-align: center; }

/* Auth: login, setup, account, admin users */
.container.narrow { max-width: 520px; }
.auth-panel .auth-form { margin: 0; }
.auth-banner { margin: 0 0 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-left: 3px solid var(--danger); border-radius: var(--radius); background: var(--surface-2); }
.auth-banner.ok-text { border-left-color: var(--done-fill); color: var(--ink); font-weight: 500; }
.auth-divider { display: flex; align-items: center; gap: .75rem; margin: 1.25rem 0; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-provider { display: block; text-align: center; }
.auth-foot { margin: 1.25rem 0 0; }
.identities .identity { display: flex; align-items: center; gap: .75rem; padding: .4rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.identities .identity > * { min-width: 0; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.identities .identity:last-child { border-bottom: none; }
.users-table .tag { white-space: nowrap; }
.users-table .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.users-table td.mono { font-size: .85rem; }
.archive-token-status p { margin: 0 0 1rem; }
.archive-token-status .tag { margin-right: .35rem; }
.archive-banner { margin: 0 0 1rem; padding: .6rem .8rem; border: 1px solid var(--line); border-left: 3px solid var(--notice-rule); border-radius: var(--radius); background: var(--surface-2); color: var(--ink); }
.archive-banner .link { white-space: nowrap; }
.btn[disabled], .menu-item[disabled] { opacity: .45; cursor: not-allowed; }

/* Confronta: due riassunti affiancati. La colonna di destra ha la riga in
   alto nel colore secondario, così le due si distinguono a colpo d'occhio. */
.compare-back { display: inline-block; margin-bottom: 1rem; }
.compare-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.compare-head .hero { margin: 0; }
.compare-head .display { font-size: clamp(2rem, 4.5vw, 2.75rem); }
.compare-toggle { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink); font-size: .9rem; cursor: pointer; white-space: nowrap; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.compare-col { display: flex; flex-direction: column; margin-bottom: 0; }
.compare-col--alt { border-top-color: var(--acc2); }
.compare-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 0 .9rem; }
.compare-text {
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; color: var(--ink);
  flex: 1; margin-bottom: 1rem;
}
.compare-actions { border-top: 1px solid var(--line); padding-top: .9rem; }
.compare-hint { margin: 0 0 1rem; }
.compare-note { margin: 1.25rem 0 0; }
.tag-archive { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tag-unpublished { border-color: var(--acc2); color: var(--acc2); }
.diff {
  color: inherit;
  background: color-mix(in srgb, var(--acc2) 18%, transparent);
  border-bottom: 1px solid var(--acc2); border-radius: 2px;
}
@media (max-width: 720px) {
  .compare-grid { grid-template-columns: minmax(0, 1fr); }
}
