:root {
  --bg: #0e0f13;
  --panel: #16181e;
  --panel-2: #1d2028;
  --line: #2a2e38;
  --text: #e9eaee;
  --muted: #8d93a3;
  --accent: #e2001a;
  --accent-2: #ffcc00;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 8px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* Layout */
.app { display: grid; grid-template-rows: auto auto 1fr; height: 100vh; }
header.top {
  display: flex; align-items: center; gap: 14px; padding: 10px 16px;
  background: linear-gradient(90deg, #15060a, var(--panel)); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .04em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.brand small { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.spacer { flex: 1; }
nav.tabs { display: flex; gap: 2px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.tabs button {
  background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs button:hover { color: var(--text); }
main { overflow: auto; padding: 16px; }

/* Controls */
.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn, a.btn { color: var(--text); text-decoration: none; }
.btn:hover { border-color: #3d4250; background: #232733; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #c20016; }
.btn.danger { color: #ff8a8a; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn.icon { padding: 3px 7px; }
/* tasto ascolto delle liste: durante l'ascolto ■ dentro un anello che si riempie */
.btn.play-btn { position: relative; width: 28px; height: 26px; justify-content: center; padding: 0; }
.btn.play-btn.playing { color: #fff; border-color: var(--accent); background: #2a0d12; border-radius: 50%; width: 28px; height: 28px; font-size: 11px; }
.btn.play-btn.playing::before { content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p, 0%), #3d4250 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 3px)); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  background: #0b0c10; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
input[type=color] { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }
label.field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
label.field > * { color: var(--text); font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.muted { color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700; background: var(--panel-2); }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cat { display: inline-block; min-width: 24px; text-align: center; padding: 1px 5px; border-radius: 4px; font-weight: 800; font-size: 11px; color: #000; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel h3 { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.stats { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); }
.stats b { color: var(--text); }
.bad { color: var(--bad); } .ok { color: var(--ok); } .warn { color: var(--warn); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid #20232b; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; background: var(--panel); z-index: 1; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.grow { white-space: normal; width: 40%; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #1b1e26; }
tr.inactive td { opacity: .45; }

/* Scaletta */
.hour { margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.hour-head { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: var(--panel-2); cursor: pointer; user-select: none; }
.hour-head .h { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; width: 52px; }
.hour-head .fill { font-variant-numeric: tabular-nums; }
.hour.locked .hour-head { background: #2a2312; }
.hour.drop-target .hour-head { outline: 2px dashed var(--accent-2); outline-offset: -2px; }
.log-row td { padding: 4px 8px; }
.log-row .t { font-variant-numeric: tabular-nums; color: var(--muted); width: 70px; }
.log-row.nonsong td { color: var(--muted); font-style: italic; }
.log-row.violation td:first-child { box-shadow: inset 3px 0 var(--bad); }
.log-row.soft td:first-child { box-shadow: inset 3px 0 var(--warn); }
.vio.soft { color: var(--warn); }
.log-row.empty-slot td { color: var(--bad); }
.log-row.dragging { opacity: .35; }
.log-row.drop-before td { box-shadow: inset 0 2px var(--accent-2); }
.log-row .handle { cursor: grab; color: var(--muted); width: 18px; }
.log-row .actions { text-align: right; width: 1%; }
.log-row .actions .btn { visibility: hidden; }
.log-row:hover .actions .btn { visibility: visible; }
.vio { color: var(--bad); cursor: help; font-size: 12px; white-space: normal; }
.artist { font-weight: 600; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(900px, 100%); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 15px; flex: 1; }
.modal .body { padding: 14px 16px; overflow: auto; }
.modal footer { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

/* Clock */
.clock-layout { display: grid; grid-template-columns: 240px 1fr 300px; gap: 14px; align-items: start; }
.list-item { padding: 9px 12px; border-bottom: 1px solid #20232b; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.list-item:hover { background: #1b1e26; }
.list-item.active { background: #24151a; box-shadow: inset 3px 0 var(--accent); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.wheel { padding: 14px; text-align: center; }

/* Griglia */
.grid-table td.cell { width: 13%; height: 24px; cursor: crosshair; font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); border: 1px solid #0e0f13; user-select: none; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.grid-table td.hour-label { color: var(--muted); font-variant-numeric: tabular-nums; width: 50px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette .btn.sel { outline: 2px solid var(--accent-2); }

/* Toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: #22252e; border: 1px solid var(--line); border-left: 3px solid var(--ok); padding: 10px 14px; border-radius: 6px; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.error { border-left-color: var(--bad); }

@media (max-width: 1100px) {
  .clock-layout { grid-template-columns: 1fr; }
}

[hidden] { display: none !important; }

/* Copertine */
.thumb { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; display: block; background: var(--panel-2); }
.thumb.empty { display: inline-block; padding: 0; vertical-align: middle; }
.song-head { display: flex; gap: 16px; align-items: center; }
.cover-big { width: 160px; height: 160px; padding: 0; border-radius: 8px; object-fit: cover; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); font-size: 12px; flex: none; }

/* Editor marker */
.wave { width: 100%; height: 160px; background: #0b0c10; border-radius: 8px; cursor: crosshair; display: block; margin: 8px 0; }
.marker-info { font-variant-numeric: tabular-nums; gap: 16px; }

/* Artisti del brano */
.artists-box { background: #0b0c10; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.artist-row { display: grid; grid-template-columns: 70px 1fr 1.3fr; gap: 8px; align-items: center; margin-bottom: 6px; }

/* Scheda artista */
.news-row { display: grid; grid-template-columns: 140px 1fr 160px auto; gap: 6px; margin-bottom: 6px; }
.artist-photo { flex: none; }

.genre-row { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; align-items: center; margin-top: 6px; }
.genre-help { font-size: 12px; margin: 4px 0 4px 78px; white-space: normal; }

/* Libreria: i testi lunghi vanno a capo, cosi' le azioni restano visibili */
.lib-table td { white-space: normal; }
.lib-table td.num, .lib-table td.actions { white-space: nowrap; }
.lib-table td:nth-child(3) { min-width: 140px; }
.lib-table td:nth-child(4) { min-width: 180px; }

/* Player del pre-ascolto in testa alla pagina (stile iTunes) */
.listen-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; height: 64px; display: none; align-items: center; justify-content: center; gap: 16px;
  padding: 0 16px; background: linear-gradient(#262a34, #1b1e26); border-bottom: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.45); }
.listen-bar.on { display: flex; }
body.listening { padding-top: 64px; }
body.listening .app { height: calc(100vh - 64px); }
.listen-controls { display: flex; align-items: center; gap: 6px; }
.listen-btn { border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 20px; width: 40px; height: 40px; border-radius: 50%; }
.listen-btn:hover { background: rgba(255,255,255,.08); }
.listen-btn.small { font-size: 12px; width: 34px; color: var(--muted); }
.listen-btn.stop { font-size: 16px; color: var(--bad); }
.listen-lcd { display: flex; align-items: center; gap: 10px; flex: 0 1 560px; min-width: 0; height: 52px; padding: 0 12px 0 0;
  background: linear-gradient(#e9ecef, #d5d9de); color: #1f2329; border-radius: 6px; box-shadow: inset 0 1px 3px rgba(0,0,0,.35); overflow: hidden; }
.listen-lcd img, .listen-nocover { width: 52px; height: 52px; object-fit: cover; flex: none; }
.listen-nocover { display: grid; place-items: center; background: #b9bfc7; color: #555; font-size: 22px; }
.listen-info { flex: 1; min-width: 0; text-align: center; }
.listen-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listen-sub { font-size: 11px; color: #4b5260; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listen-progress { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.listen-time { font-size: 10px; color: #4b5260; font-variant-numeric: tabular-nums; width: 34px; }
.listen-time:last-child { text-align: right; }
.listen-seek { flex: 1; height: 4px; -webkit-appearance: none; appearance: none; border-radius: 2px; cursor: pointer;
  background: linear-gradient(to right, #6b7280 var(--p, 0%), #b9bfc7 var(--p, 0%)); }
.listen-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; background: #374151; }
.listen-seek::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: #374151; }
.listen-note { font-size: 11px; color: var(--muted); white-space: nowrap; }
@media (max-width: 900px) { .listen-note, .listen-btn.small { display: none; } }
@media (max-width: 520px) { .listen-bar { gap: 6px; padding: 0 8px; } }

/* Pagina Regole: formato a sinistra, regole a destra */
.rules-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; align-items: start; max-width: 1400px; }
.rules-grid td { vertical-align: middle; }
@media (max-width: 1000px) { .rules-grid { grid-template-columns: 1fr; } }
.rules-grid .panel { overflow-x: auto; }
.rules-grid table { width: 100%; }
.rules-grid th { white-space: normal; }
.rules-grid td:first-child { white-space: normal; min-width: 140px; }
.rules-grid input[type="text"], .rules-grid input[type="number"] { width: 64px !important; }
.rules-grid input[type="time"] { width: 96px; }

/* Editor marker: prova del passaggio */
.trial-box { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); margin-top: 6px; }
.test-results { display: flex; flex-wrap: wrap; gap: 6px; }

/* Proposte di brani */
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.req-panel { max-width: 1100px; margin-bottom: 14px; }
.req-panel h4 { margin: 18px 0 8px; }
.req-drop { border: 2px dashed var(--line); border-radius: 10px; padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; text-align: center; }
.req-drop.over, .req-drop:hover { border-color: var(--accent); background: rgba(226,0,26,.06); }
.req-list { display: grid; gap: 10px; }
.req-card { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); }
.req-cover { width: 120px; height: 120px; border-radius: 8px; overflow: hidden; background: #111; display: grid; place-items: center; font-size: 34px; color: #555; }
.req-cover img { width: 100%; height: 100%; object-fit: cover; }
.req-body { display: grid; gap: 8px; min-width: 0; }
.req-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.req-fields { display: grid; grid-template-columns: 1.3fr 1.3fr 1.2fr 90px 1fr; gap: 8px; }
.req-fields .field { margin: 0; }
.req-dup { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.4); border-radius: 6px; padding: 6px 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip.warn { background: rgba(245,158,11,.2); color: #fbbf24; }
.chip.ok { background: rgba(34,197,94,.2); color: #4ade80; }
.chip.bad { background: rgba(239,68,68,.2); color: #fca5a5; }
.warn-text { color: var(--warn); font-size: 12px; }
.news-list { display: grid; gap: 8px; }
.news-item { padding: 8px 10px; border-radius: 6px; background: var(--panel-2); }
.news-item.ok b { color: #4ade80; } .news-item.no b { color: #fca5a5; }
@media (max-width: 800px) { .req-card { grid-template-columns: 1fr; } .req-fields { grid-template-columns: 1fr 1fr; } }

/* Nuovo playout: radio o canale TV */
.media-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.media-choice .btn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; text-align: left; }
.media-choice small { color: var(--muted); font-size: 12px; }

/* BPM */
td.bpm { font-variant-numeric: tabular-nums; color: #a5b4fc; }
.bpm-edit { display: flex; gap: 6px; align-items: center; }
.bpm-edit input { width: 80px; }

/* Mix / DJ set */
.wide-modal { width: min(1100px, 96vw) !important; max-width: none !important; }
.mix-wave { cursor: pointer; }
.mix-status { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mix-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.mix-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.mix-list { display: grid; gap: 6px; max-height: 42vh; overflow: auto; }
.mix-row { display: grid; grid-template-columns: 26px 84px 40px 1fr auto; gap: 8px; align-items: start; padding: 6px; border-radius: 6px; background: var(--panel-2); }
.mix-row .thumb { width: 40px; height: 40px; }
.mix-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #000; }
.mix-time { width: 84px; font-variant-numeric: tabular-nums; }
.mix-fields { display: grid; grid-template-columns: 1fr 1.3fr; gap: 6px; }
.mix-sub { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mix-find { width: 150px; }
.mix-results { display: flex; gap: 4px; flex-wrap: wrap; }
.mix-actions { display: flex; gap: 4px; }
.mix-chip { cursor: pointer; border: 0; background: rgba(167,139,250,.2); color: #c4b5fd; }

/* scheda brano in sola lettura (utenti delle radio) */
.ro-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.ro-fieldset input, .ro-fieldset select { opacity: .85; cursor: default; }

/* autori e compositori (SIAE) nella scheda del brano */
.credits-grid { display: grid; grid-template-columns: 22px 1fr 210px; gap: 6px 8px; align-items: center; }
