:root {
  color-scheme: light;
  --ink: #1c1915;
  --muted: #6d645b;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e2d9cc;
  --navy: #1e3348;
  --rust: #b85c38;
  --live: #0f7a4a;
  --danger: #8f2d2d;
  --ok: #1f6b45;
  --shadow: 0 16px 40px rgba(28, 25, 21, 0.08);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.45;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--paper);
}
a { color: var(--navy); }
button, input, textarea, select { font: inherit; color: inherit; }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  background: var(--navy);
  color: #f7f3ea;
  text-decoration: none;
  cursor: pointer;
}
button.secondary, .button.secondary { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
button.danger, .button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: 0.6; cursor: wait; }
button.linkish, a.linkish {
  background: transparent;
  color: var(--navy);
  padding: 0.2rem 0;
  border-radius: 0;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}
button.linkish.danger, a.linkish.danger { color: var(--danger); }
.top button.linkish,
.top a.linkish {
  color: #f7f3ea;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}
textarea { min-height: 5.5rem; resize: vertical; }
#testo-domanda { min-height: 11rem; }
label { display: grid; gap: 0.35rem; font-size: 0.92rem; }
label.check { display: flex; align-items: center; gap: 0.55rem; }
label.check input { width: auto; }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: #fff;
  padding: 0.4rem 0.7rem;
}
.skip:focus { top: 0.5rem; z-index: 30; }
:focus-visible { outline: 3px solid #d08963; outline-offset: 2px; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  align-items: center;
  padding: 0.85rem 1.2rem;
  background: var(--navy);
  color: #f7f3ea;
}
.brand { display: flex; flex-direction: column; min-width: 7rem; }
.mark {
  font-family: Palatino, "Palatino Linotype", Georgia, serif;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}
.product { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.75; }
.nav { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; flex: 1; }
.nav a { color: #f7f3ea; text-decoration: none; padding: 0.2rem 0; }
.nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--rust); }
.alerts { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.top .check { color: #f7f3ea; font-size: 0.88rem; }
.staff-alert {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #f8e6dc;
  border: 1px solid #e4b39a;
}
.staff-alert p { margin: 0.3rem 0 0; white-space: pre-wrap; }
.who { display: flex; gap: 0.8rem; align-items: center; margin-left: auto; }
.who form { margin: 0; }

.schedule-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  background: #d9efe3;
  color: #14523a;
  border-bottom: 1px solid #b5d8c6;
  z-index: 25;
}
.schedule-banner-main { flex: 1 1 16rem; text-align: center; }
.schedule-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}
.schedule-banner-actions .button,
.schedule-banner-actions button {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.schedule-banner.is-bottom {
  position: sticky;
  bottom: 0;
  order: 99;
  border-bottom: 0;
  border-top: 1px solid #b5d8c6;
}
body.has-banner-bottom {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body.has-banner-bottom main { flex: 1 0 auto; }
body.has-banner-bottom #schedule-banner {
  position: sticky;
  bottom: 0;
  margin-top: auto;
}
.schedule-banner.is-wait {
  background: #e7eef5;
  color: #1e3348;
  border-color: #c5d0dc;
}
.schedule-banner.is-closing {
  background: #f3e0d2;
  color: #6a3218;
  border-color: #e0b89a;
}
.schedule-banner.is-urgent {
  background: #f0d0d0;
  color: #6b1f1f;
  border-color: #d9a0a0;
  font-weight: 600;
}
.schedule-banner.is-done {
  background: #ece7e0;
  color: #5c534a;
  border-color: #d5cdc2;
}
.preview-alert { background: #e7eef5; border-color: #c5d0dc; }

main {
  width: min(1120px, calc(100% - 2rem));
  margin: 1.25rem auto 2rem;
  flex: 1 0 auto;
}
.site-footer {
  width: min(1120px, calc(100% - 2rem));
  margin: auto auto 2rem;
  flex: 0 0 auto;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 0.9rem;
}
.site-footer p { margin: 0; }
.site-footer .credit { text-align: left; }
.site-footer a { color: var(--navy); }
.site-footer .copy {
  margin-left: auto;
  text-align: right;
  font-size: 0.82rem;
}
h1, h2 { font-family: Palatino, "Palatino Linotype", Georgia, serif; font-weight: 600; line-height: 1.15; }
h1 { margin: 0 0 0.6rem; font-size: 2rem; }
h2 { margin: 0 0 0.45rem; font-size: 1.35rem; }
.lead, .hint, .meta { color: var(--muted); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; color: var(--rust); }

.panel, .login, .video-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.panel { padding: 1.1rem 1.15rem 1.25rem; }
.panel + .panel, .qa .panel + .panel { margin-top: 0.9rem; }
.narrow { width: min(720px, 100%); }
.login { width: min(440px, 100%); margin: 8vh auto; padding: 1.4rem; }
.stack { display: grid; gap: 0.8rem; }
.inline, .split, .row-actions, .picker { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: end; }
.split { justify-content: space-between; align-items: start; }
.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.admin-grid { display: grid; gap: 1rem; }
.staff-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.55rem 1rem;
}
.staff-menu-form { margin-top: 0.4rem; }
.slot-edit-list li {
  align-items: end;
  gap: 0.7rem;
}
.slot-edit-list .slot-edit { flex: 1 1 18rem; }
.encoder-row {
  display: grid;
  gap: 0.35rem 0.7rem;
  align-items: start;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}
@media (min-width: 720px) {
  .encoder-row {
    grid-template-columns: 8.5rem minmax(0, 1fr) auto;
    align-items: center;
  }
}
.encoder-label { font-size: 0.92rem; color: var(--muted); }
.encoder-value {
  display: block;
  overflow-wrap: anywhere;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88rem;
  padding: 0.45rem 0.55rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}
@media (min-width: 900px) {
  .admin-grid { grid-template-columns: 1.3fr 0.8fr; align-items: start; }
}

.stage { display: grid; gap: 1rem; }
@media (min-width: 960px) {
  .stage { grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.8fr); align-items: start; }
  .video-card { position: sticky; top: 1rem; }
  .stage.is-cinema {
    grid-template-columns: minmax(0, 1fr);
  }
  .stage.is-cinema .video-card { position: static; }
}
.video-card { padding: 0.7rem; }
.video-frame { position: relative; }
.video-frame video:not(.is-playing) {
  opacity: 0;
}
.video-frame video.is-playing {
  opacity: 1;
}
/* Flusso live: niente scrubber orizzontale nei controlli nativi. */
.video-frame video::-webkit-media-controls-timeline,
.video-frame video::-webkit-media-controls-current-time-display,
.video-frame video::-webkit-media-controls-time-remaining-display {
  display: none !important;
}
.player-hold {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.2rem;
  background: #14181c;
  color: #f3efe6;
  border-radius: 12px;
}
.player-hold p { margin: 0.35rem 0; }
.player-hold .waiting-title { color: #f3efe6; }
.player-hold button {
  margin-top: 0.9rem;
  background: #f3efe6;
  color: var(--navy);
}
.player-spinner {
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  border: 3px solid rgba(243, 239, 230, 0.18);
  border-top-color: #f3efe6;
  border-right-color: rgba(243, 239, 230, 0.55);
  animation: player-spin 0.8s linear infinite;
}
.player-hold.is-connecting .player-spinner {
  display: block;
}
.player-hold:not(.is-connecting) .player-spinner {
  display: none;
}
.player-hold.is-connecting {
  background:
    radial-gradient(ellipse at center, rgba(30, 51, 72, 0.55) 0%, #14181c 68%),
    #14181c;
}
@keyframes player-spin {
  to { transform: rotate(360deg); }
}
.video-card video, .video-card.waiting {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #14181c;
  border-radius: 12px;
  display: block;
}
.video-card.waiting {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.4rem;
  color: #f3efe6;
}
.waiting-title { margin: 0 0 0.4rem; font-size: 1.35rem; }
.video-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.7rem;
  align-items: center;
  min-height: 2.4rem;
  padding: 0.45rem 0.2rem 0.1rem;
}
.video-tools .secondary { padding: 0.45rem 0.85rem; font-size: 0.9rem; }
.player-status { margin: 0; color: var(--muted); }
.program { margin-top: 0.9rem; }
.program-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.8rem; }
.program-head h2 { margin: 0; }
label.check { display: flex; gap: 0.5rem; align-items: center; }
.pw { font-family: ui-monospace, Consolas, monospace; }

main:has(.participants-panel) {
  width: min(1480px, calc(100% - 1.5rem));
}
.participants-panel > .grid-form {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.participants-panel > .grid-form .field-cred {
  max-width: 11rem;
}
.participants-table {
  font-size: 0.88rem;
}
.participants-table th,
.participants-table td {
  padding: 0.45rem 0.35rem;
  vertical-align: middle;
}
.participants-table .cred {
  white-space: nowrap;
  width: 1%;
  font-size: 0.8rem;
}
.participants-table .cred .pw {
  display: inline;
  margin-right: 0.35rem;
}
.participants-table .cred .linkish {
  font-size: 0.75rem;
}
.participants-table .cell-stato,
.participants-table .actions {
  white-space: nowrap;
  width: 1%;
}
.participants-table .cell-email {
  word-break: break-word;
}
.form-ok { margin: 0; color: var(--ok); font-weight: 650; }
.reply-alert {
  margin: 0 0 0.8rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #f8e6dc;
  border: 1px solid #e4b39a;
}
.reply-alert strong { color: var(--rust); }
.reply-alert p { margin: 0.35rem 0 0; white-space: pre-wrap; }

.reply-toast {
  position: fixed;
  left: 50%;
  top: 1rem;
  transform: translateX(-50%);
  z-index: 60;
  width: min(440px, calc(100% - 1.5rem));
  pointer-events: none;
}
.reply-toast[hidden] { display: none !important; }
.reply-toast-inner {
  pointer-events: auto;
  padding: 0.95rem 1rem;
  border-radius: 14px;
  background: #6a3218;
  color: #fff7f0;
  box-shadow: 0 18px 40px rgba(28, 25, 21, 0.28);
  animation: reply-toast-in 0.35s ease-out;
}
.reply-toast-inner strong { display: block; font-size: 1rem; }
.reply-toast-inner p {
  margin: 0.45rem 0 0;
  white-space: pre-wrap;
  line-height: 1.4;
}
.reply-toast-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}
.reply-toast-actions button {
  background: #fff7f0;
  color: #6a3218;
}
.reply-toast-actions button.secondary {
  background: transparent;
  color: #fff7f0;
  border: 1px solid rgba(255, 247, 240, 0.55);
}
.item.is-reply-flash,
.chat-thread.is-reply-flash {
  outline: 3px solid var(--rust);
  outline-offset: 2px;
  animation: reply-flash 1.4s ease-out 2;
}

.chat-board {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}
.chat-board:empty { display: none; }
.chat-board.is-older {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--line);
}
.chat-older-toggle { margin-top: 0.8rem; }
.chat-thread {
  display: grid;
  gap: 0.55rem;
}
.chat-turn {
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #f7f4ee;
  border: 1px solid var(--line);
}
.chat-turn.staff {
  background: #f8e6dc;
  border-color: #e4b39a;
}
.chat-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
}
.chat-turn.staff .chat-label { color: var(--rust); }
.chat-body {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
}
.chat-turn time {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
}
@keyframes reply-toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes reply-flash {
  0%, 100% { background: #fff; }
  50% { background: #f8e6dc; }
}

.item-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; }
.item-head form { margin: 0; }
.thread-list { display: grid; gap: 0.7rem; max-height: 70vh; overflow: auto; margin-top: 1rem; }
.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: #fff;
}
.item .kind { margin: 0; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--navy); }
.item.problem .kind { color: var(--rust); }
.item .body, .reply-line span { white-space: pre-wrap; }
.item time, .reply-line time { color: var(--muted); font-size: 0.82rem; }
.reply-line { margin: 0.55rem 0 0; padding-top: 0.55rem; border-top: 1px dashed var(--line); display: grid; gap: 0.15rem; }
form.reply { display: grid; gap: 0.45rem; margin-top: 0.7rem; }
.form-error, .flash.err { color: var(--danger); }
.flash.ok { color: var(--ok); }
.flash { margin: 0 0 0.8rem; }

.files, .event-list, .online { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.55rem; }
.files li, .event-list li, .online li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}
.badge {
  display: inline-block;
  margin-left: 0.4rem;
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  background: var(--line);
}
.badge.active { background: #d9efe3; color: var(--live); }
.badge.closed { background: #f0e4dc; color: var(--rust); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
details { min-width: 14rem; }
summary { cursor: pointer; }
pre {
  overflow: auto;
  padding: 0.7rem 0.8rem;
  background: #1c1915;
  color: #f3efe6;
  border-radius: 10px;
}
.empty { color: var(--muted); }
.materials-empty {
  min-height: 12rem;
  display: grid;
  align-content: start;
}

.kick[hidden] { display: none !important; }
.kick {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.2rem;
  background: rgba(20, 24, 28, 0.72);
}
.kick div {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 1.3rem;
}

.login-help-trigger { margin: 1rem 0 0; text-align: center; }
button.text-link {
  background: transparent;
  color: var(--navy);
  border: 0;
  border-radius: 0;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  font-size: 0.95rem;
  cursor: pointer;
}
.login-help[hidden] { display: none !important; }
.login-help {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.login-help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.72);
}
.login-help-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 1.2rem 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}
.login-help-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}
.login-help-head h2 { margin: 0; font-size: 1.35rem; }
.login-help-close {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 8px;
  padding: 0.1rem 0.45rem;
  font-size: 1.5rem;
  line-height: 1;
}
.login-help-body {
  white-space: normal;
  line-height: 1.55;
  word-break: break-word;
}
.login-help-body a { color: var(--navy); }

.login-confirm[hidden] { display: none !important; }
.login-confirm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}
.login-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 28, 0.72);
}
.login-confirm-dialog {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 18px;
  padding: 1.25rem 1.3rem 1.35rem;
  box-shadow: var(--shadow);
}
.login-confirm-dialog h2 {
  margin: 0 0 0.65rem;
  font-size: 1.3rem;
}
.login-confirm-dialog p {
  margin: 0 0 1.15rem;
  line-height: 1.55;
  color: var(--text);
}
.login-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  flex-wrap: wrap;
}

@media (max-width: 720px) {
  h1 { font-size: 1.6rem; }
  .who { width: 100%; margin-left: 0; justify-content: space-between; }
  .thread-list { max-height: none; }
}

@media print {
  header, .skip, .flash, .no-print, .picker { display: none !important; }
  body { background: #fff; color: #111; }
  main { padding: 0; }
  .panel { box-shadow: none; border: 0; padding: 0; background: #fff; }
  h1 { font-size: 14pt; margin: 0 0 3mm; }
  .print-sheet {
    columns: 2;
    column-gap: 7mm;
    max-height: none;
    overflow: visible;
    margin: 0;
    gap: 0;
  }
  .print-sheet .item {
    break-inside: avoid;
    box-shadow: none;
    border: 0;
    border-bottom: 1px solid #bbb;
    border-radius: 0;
    padding: 1.2mm 0 1.8mm;
    margin: 0 0 1.2mm;
    background: #fff;
  }
  .print-sheet .kind, .print-sheet .item-head { display: none; }
  .print-sheet .meta, .print-sheet time { margin: 0; font-size: 9pt; color: #333; }
  .print-sheet .body { margin: 0.6mm 0 0; font-size: 11pt; }
  @page { size: A4; margin: 10mm 12mm; }
}
