/* Stessi colori e stili di Video Review */
:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --panel-2: #1f1f23;
  --border: #2c2c32;
  --text: #efeff1;
  --muted: #a1a1aa;
  --accent: #9147ff;
  --accent-2: #772ce8;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .14);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, .14);
  --amber: #f5b301;
  --amber-bg: rgba(245, 179, 1, .12);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: #bf94ff; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; color: var(--text); background: var(--panel-2);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-primary, .btn-twitch { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-twitch:hover { background: var(--accent-2); }
.btn-danger { background: var(--red-bg); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ---------- barra superiore ---------- */
.topbar {
  min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.view-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.view-switch > a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.view-switch > a:hover { color: var(--text); }
.view-switch > a.active { background: var(--panel-2); color: var(--text); }
.view-dropdown { display: none; position: relative; }
.view-dropdown .menu { left: 0; right: auto; white-space: nowrap; }
.view-btn { padding: 6px 10px; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

/* menu utente (avatar Twitch): uguale in Video Review e ModTools */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--panel-2); border-color: var(--border); }
.user-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-btn .avatar { width: 30px; height: 30px; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
.menu-item.current { background: var(--panel-2); cursor: default; }
.menu-item.current small { color: var(--muted); font-weight: 500; }
.menu-item.danger { color: #fca5a5; }
.menu-sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- pagine ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; }
.cols { margin-top: 20px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.card h2 { margin: 0; font-size: 15px; }
.fields { display: flex; flex-wrap: wrap; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field legend { font-size: 12px; color: var(--muted); font-weight: 600; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.timer-pick { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; min-height: 42px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.input-sm { font-size: 14px; min-height: 36px; padding: 7px 10px; }
.count, .hint { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results li { display: flex; gap: 10px; align-items: baseline; }
.ok { color: var(--green); font-weight: 700; }
.ko { color: #fca5a5; font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--panel-2);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #52525b; }
.pill.offline { background: var(--green-bg); border-color: rgba(34,197,94,.45); color: #86efac; }
.pill.offline .dot { background: var(--green); }
.pill.live { background: var(--red-bg); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.pill.live .dot { background: var(--red); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.error-box { padding: 10px 12px; border-radius: 8px; background: var(--red-bg); color: #fca5a5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); font-weight: 600;
}
.toast.error { border-color: var(--red); color: #fca5a5; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 440px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px 24px;
}
.login-card h1 { margin: 8px 0 4px; }
.login-error { background: var(--red-bg); color: #fca5a5; padding: 10px; border-radius: 8px; }
.login-card .btn-twitch { width: 100%; padding: 12px; font-size: 15px; margin-top: 16px; }

/* ---------- schermi stretti ---------- */
@media (max-width: 860px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 16px; }
  #username { display: none; }
  .view-switch > a { display: none; }
  .view-dropdown { display: block; }
  /* barra su una riga: se manca spazio si accorcia il nome della sezione, non va a capo */
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 6px 12px; }
  .brand, .user { flex: none; }
  .brand { gap: 8px; font-size: clamp(14px, 4vw, 16px); }
  .view-switch, .view-dropdown { min-width: 0; }
  .view-btn { max-width: 100%; gap: 6px; padding: 6px 8px; font-size: clamp(12px, 3.5vw, 14px); }
  .view-btn svg { flex: none; }
  #viewBtnLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.card p { margin: 0; }

/* ---------- SypherDance ---------- */
.steps { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.steps li { padding: 6px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; background: var(--panel-2); color: var(--muted); }
.steps li.done { background: var(--green-bg); color: #86efac; }
.steps li.now { background: var(--accent); color: #fff; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.songs { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.song { border-radius: 10px; overflow: hidden; background: var(--panel-2); outline: 1px solid var(--border); display: flex; flex-direction: column; }
.song.playing { outline: 2px solid var(--accent); }
.song.winner { outline: 2px solid var(--amber); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #000; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .num {
  position: absolute; top: 8px; left: 8px; width: 28px; height: 28px; border-radius: 7px;
  background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.thumb .dur { position: absolute; bottom: 8px; right: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.75); font-size: 12px; font-weight: 600; }
.song-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.who { font-weight: 700; color: #bf94ff; overflow-wrap: anywhere; }
.song-title { font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel); color: var(--muted); }
.chip.ok { background: var(--green-bg); color: #86efac; }
.chip.warn { background: var(--amber-bg); color: #fcd34d; }
.chip.bad { background: var(--red-bg); color: #fca5a5; }
.song-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
.song-actions .btn { flex: 1; min-height: 36px; }
.empty-slot { border: 2px dashed var(--border); border-radius: 10px; min-height: 180px; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 12px; }
.bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.vote-line { display: grid; grid-template-columns: 24px minmax(0, 1fr) 70px; gap: 8px; align-items: center; font-size: 13px; }
.vote-line .bar { grid-column: 2; }
.progress { display: flex; align-items: center; gap: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.progress .bar { flex: 1; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-actions .hint { margin-left: auto; }
.big-time { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.status-line { display: flex; align-items: center; gap: 8px; }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: #52525b; flex: none; }
.status-line.on .dot { background: var(--green); }
.switch { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }
.banner { padding: 14px 16px; border-radius: 10px; background: rgba(145,71,255,.12); border: 1px solid rgba(145,71,255,.45); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 20px; }
.mod-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 12px;
  border-radius: 10px; background: var(--panel); border: 1px solid var(--border);
}
.mod-row.flag { border-color: rgba(245,179,1,.45); }
.mod-row .thumb { width: 176px; flex: none; border-radius: 8px; overflow: hidden; }
.mod-row .info { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.mod-row .decide { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mod-list { display: flex; flex-direction: column; gap: 10px; }
.preview { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; min-width: 640px; border-collapse: collapse; }
table.list th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.list td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list td.who { white-space: nowrap; }
kbd { font: 12px ui-monospace, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-amber { background: var(--amber-bg); border-color: rgba(245,179,1,.45); color: #fcd34d; }
.btn-amber:hover { background: var(--amber); color: #1a1300; }
@media (max-width: 860px) {
  .mod-row .thumb { width: 100%; }
  .row-actions .hint { margin-left: 0; }
}
.spaced { margin-top: 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
