/* acestream-hls — console dark (riferimento: docs/design/ui-v2.html) */

/* ---------- fonts ---------- */

@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */

:root {
  color-scheme: dark;

  --bg: #07080a;
  --panel: #0d0f12;
  --panel-2: #111418;
  --line: #1c2027;
  --line-hot: #2a3038;
  --ink: #f2f4f7;
  --muted: #8b939e;
  --dim: #79818b;
  --signal: #ff4d2e;
  --signal-soft: #ff4d2e14;
  --ok: #3ddc97;
  --warn: #ffc857;
  --r: 14px;

  /* alias di compatibilità (riferiti da vecchio codice) */
  --success: var(--ok);
  --danger: var(--signal);
  --warning: var(--warn);
  --primary: var(--signal);
  --field: var(--panel-2);

  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

::selection { background: #ff4d2e55; color: var(--ink); }

:focus-visible {
  outline: 2px solid color-mix(in oklab, var(--signal) 70%, transparent);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb {
  background: var(--line-hot);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-track { background: transparent; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

button:disabled { opacity: 0.45; cursor: default; }

/* componenti generati dal JS */

.glass { background: var(--panel); }

.ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
}

.path-spinner {
  width: 15px;
  height: 15px;
  flex: none;
  color: inherit;
  transform-box: fill-box;
  transform-origin: center;
}

.path-spinner-track { stroke: color-mix(in oklab, currentColor 26%, transparent); stroke-width: 2.6; }
.path-spinner-arc { stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

.path-spinner.css-spin { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.word { display: inline-block; margin-right: 0.28em; }

/* ---------- app shell ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- top bar ---------- */

.bar {
  height: 58px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(7, 8, 10, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  white-space: nowrap;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 14px;
}

.wordmark .glyph {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--signal);
}

.wordmark small {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  border: 1px solid var(--line);
  padding: 2px 6px;
  border-radius: 4px;
}

.bar-sep { width: 1px; height: 20px; background: var(--line); }
.bar-spacer { flex: 1; min-width: 0; }

.live-count {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.live-count b {
  color: var(--ink);
  font-weight: 600;
  display: inline-flex;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  background: var(--signal);
  animation: dot-pulse 2.4s infinite;
}

@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 #ff4d2e66; }
  70% { box-shadow: 0 0 0 7px #ff4d2e00; }
  100% { box-shadow: 0 0 0 0 #ff4d2e00; }
}

.trend { display: inline-flex; align-items: center; }
.trend svg { width: 11px; height: 11px; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--signal); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.chip .led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--dim);
}

.chip.ok .led { background: var(--ok); box-shadow: 0 0 8px #3ddc9788; }
.chip.err .led { background: var(--signal); box-shadow: 0 0 8px #ff4d2e88; }
.chip b { color: var(--ink); font-weight: 600; }

.avatar-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}

.avatar-btn svg { width: 14px; height: 14px; }
.avatar-btn:hover { border-color: var(--line-hot); background: var(--panel-2); color: var(--ink); }

/* ---------- grid ---------- */

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 312px;
  min-height: 0;
}

/* ---------- rail ---------- */

.rail, .inspector {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rail { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); }

.rail-head, .insp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 10px;
  flex: none;
}

.rail-title, .insp-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
}

.rail-title b, .sect b { color: var(--ink); font-weight: 600; }

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  background: var(--panel);
  flex: none;
  overflow: hidden;
}

.add-btn:hover { border-color: var(--line-hot); background: var(--panel-2); }

.rail-list {
  flex: 1;
  overflow: auto;
  padding: 0 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  counter-reset: channel;
  min-height: 60px;
}

.rail-list .stream { counter-increment: channel; }

.stream.chan {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}

.stream.chan:hover { background: var(--panel); }

.stream.chan.active {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: inset 2px 0 0 var(--signal);
}

.stream.chan:focus-visible {
  outline: none;
  box-shadow: inset 2px 0 0 var(--signal), 0 0 0 2px color-mix(in oklab, var(--signal) 60%, transparent);
}

.chan-num {
  width: 40px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0a0c0f;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
}

.chan-num::before { content: counter(channel, decimal-leading-zero); }

.stream.chan.active .chan-num { color: var(--ink); border-color: var(--line-hot); }

.chan-info { min-width: 0; display: flex; flex-direction: column; gap: 3px; }

.chan-name {
  font-size: 13px;
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.ticker-text {
  display: block;
  white-space: nowrap;
  will-change: transform;
}

.chan-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chan-state {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
  align-self: center;
}

.chan-state.RUNNING {
  color: var(--signal);
  border-color: #ff4d2e44;
  background: var(--signal-soft);
}

.chan-state.STARTING,
.chan-state.RECONNECTING,
.chan-state.DEGRADED {
  color: var(--warn);
  border-color: #ffc85733;
  background: #ffc85710;
}

.chan-state.FAILED {
  color: var(--signal);
  border-color: #ff4d2e44;
  background: var(--signal-soft);
}

.stream-error {
  margin: 0;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--signal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* sparkline: nascosto nella rail, mostrato nello stage */

.rail-list .stream-spark { display: none; }

.spark-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  pointer-events: none;
}

.sparkline { display: block; width: 100%; height: 100%; }
.spark-line { fill: none; stroke: var(--signal); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.spark-area { fill: var(--signal-soft); stroke: none; }

.rail-empty {
  margin: 6px 16px 10px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.7;
  flex: none;
}

.rail-foot {
  flex: none;
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
}

/* ---------- recordings ---------- */

.recordings-view {
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.recordings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.recordings-head h1 {
  font-size: 28px;
  line-height: 1.08;
  margin: 6px 0 5px;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.recordings-head .muted {
  margin: 0;
  font-size: 13px;
}

.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recordings-empty {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px;
  border: 1px dashed var(--line-hot);
  border-radius: var(--r);
  color: var(--muted);
  font-size: 13px;
}

.recordings-empty strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
}

.event-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel);
}

.event-card.live {
  border-color: #ff4d2e44;
  background: linear-gradient(90deg, var(--signal-soft), var(--panel) 58%);
}

.event-main { min-width: 0; flex: 1; }

.event-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.event-title-row h3 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 560;
  letter-spacing: -0.02em;
}

.event-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--dim);
}

.event-dot.live { background: var(--signal); box-shadow: 0 0 0 4px var(--signal-soft); }
.event-dot.waiting { background: var(--warn); }
.event-dot.scheduled { background: var(--muted); }
.event-dot.ready { background: var(--ok); }
.event-dot.partial { background: var(--warn); }
.event-dot.failed { background: var(--signal); }

.event-status {
  flex: none;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.event-status.live { color: var(--signal); border-color: #ff4d2e44; background: var(--signal-soft); }
.event-status.ready { color: var(--ok); border-color: #3ddc9733; background: #3ddc970d; }
.event-status.partial, .event-status.waiting { color: var(--warn); border-color: #ffc85733; background: #ffc8570d; }
.event-status.failed { color: var(--signal); border-color: #ff4d2e44; }

.event-meta {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.event-error {
  margin: 5px 0 0;
  color: #ff8a75;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  flex: none;
}

@media (max-width: 860px) {
  .recordings-head h1 { font-size: 24px; }
  .event-card { align-items: flex-start; flex-direction: column; gap: 11px; }
  .event-actions { width: 100%; justify-content: flex-start; }
  .event-title-row { flex-wrap: wrap; }
}

/* ---------- stage ---------- */

.stage {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px 26px 28px;
}

.stage-error { margin: 0 0 12px; }

.stage-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-transform: uppercase;
}

.stage h1 {
  font-size: 32px;
  line-height: 1.08;
  margin: 7px 0 0;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.tags {
  display: flex;
  gap: 6px;
  margin-top: 13px;
  flex-wrap: wrap;
  align-items: center;
}

.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.07em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 4px 7px;
  border-radius: 4px;
}

.tag.hot { color: var(--ink); border-color: var(--line-hot); background: var(--panel-2); }
.tag.live { color: var(--signal); border-color: #ff4d2e44; background: var(--signal-soft); }

/* player di preview nello stage */

.player {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 58vh;
  margin: 0 auto;
  width: 100%;
  border-radius: var(--r);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
}

.frame {
  width: 100%;
  height: 100%;
  position: relative;
  background:
    radial-gradient(80% 70% at 30% 20%, #1b2a3a 0%, transparent 60%),
    radial-gradient(60% 60% at 82% 92%, #3a1b1b 0%, transparent 60%),
    linear-gradient(160deg, #0a0d12, #05070a);
}

.frame-tag {
  position: absolute;
  left: 10px;
  top: 10px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #cfd6de;
  background: #000000a8;
  border: 1px solid #ffffff1f;
  padding: 2px 5px;
  border-radius: 3px;
}

.frame-tag.on { color: var(--signal); border-color: #ff4d2e44; }

.fplay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: 999px;
  background: #ffffff14;
  border: 1px solid #ffffff26;
  color: #fff;
  font-size: 13px;
  font-weight: 550;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
  transition: background 0.2s ease, transform 0.2s var(--ease);
}

.fplay:hover { background: #ffffff22; }
.fplay svg { flex: none; }

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* bottoni */

.btn {
  position: relative;
  height: 38px;
  padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  font-weight: 520;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: hidden;
  white-space: nowrap;
  flex: none;
}

.btn:hover { background: var(--panel-2); border-color: var(--line-hot); }

.btn.primary {
  background: var(--signal);
  border-color: var(--signal);
  color: #0b0b0b;
  font-weight: 650;
}

.btn.primary:hover { background: #ff5c3f; border-color: #ff5c3f; }

.btn.secondary { color: var(--ink); }

.btn.danger {
  color: #ff8a75;
  border-color: #3a1f1b;
}

.btn.danger:hover { background: #1a0f0d; border-color: #ff4d2e55; }

.btn.ghost {
  background: none;
  border-color: transparent;
  color: var(--muted);
}

.btn.ghost:hover { color: var(--ink); background: var(--panel); border-color: var(--line); }

.btn.sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 7px; }

.btn.wide { width: 100%; justify-content: center; }

.btn .btn-morph {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
}

.btn-morph-icon { width: 12px; height: 12px; display: block; }

/* etichette con effetto roll (dentro i bottoni) */

.btn .roll {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  height: 1.1em;
}

.btn .roll-in,
.btn .roll-out {
  display: inline-flex;
  align-items: center;
  height: 1.1em;
  transform: translateY(0);
  transition: transform 0.28s var(--ease), opacity 0.28s ease;
}

.btn .roll-out {
  position: absolute;
  left: 0;
  top: 100%;
  opacity: 0;
}

.btn:hover:not(:disabled) .roll-in { transform: translateY(-100%); }
.btn:hover:not(:disabled) .roll-out { transform: translateY(-100%); opacity: 1; }

.btn svg { width: 15px; height: 15px; }

/* selettore qualità */

.select {
  height: 38px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  max-width: 220px;
}

/* strip di metadati */

.meta-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--line);
}

.meta { background: var(--panel); padding: 13px 14px; min-width: 0; }

.meta .k {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-transform: uppercase;
}

.meta .v {
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta .v b { color: var(--ok); font-weight: 600; }
.meta .v b.bad { color: var(--signal); }

/* sezioni "più" nello stage */

.more { margin-top: 26px; }

.more-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.more-head h2 {
  font-size: 14px;
  margin: 0;
  font-weight: 560;
  letter-spacing: -0.01em;
}

.mono-note {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.stage-spark {
  position: relative;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ff4d2e12, transparent 70%);
  overflow: hidden;
}

.stage-spark .stream-spark { display: block; width: 100%; height: 100%; position: relative; }

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.pcard {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--panel);
  cursor: pointer;
  display: block;
  text-align: left;
  padding: 0;
  font: inherit;
  color: inherit;
}

.pcard:hover { border-color: var(--line-hot); }

.pcard .art {
  aspect-ratio: 16 / 9;
  background:
    radial-gradient(70% 80% at 20% 10%, #22303f, transparent 65%),
    linear-gradient(160deg, #0d1116, #07090c);
  position: relative;
}

.pcard .art .q {
  position: absolute;
  left: 8px;
  top: 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: #cfd6de;
  background: #000000a8;
  border: 1px solid #ffffff1f;
  padding: 2px 5px;
  border-radius: 3px;
}

.pcard .cap { padding: 9px 10px; }

.pcard .cap .n {
  font-size: 12px;
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcard .cap .m {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--dim);
  margin-top: 3px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pcard.add {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--dim);
  font-size: 12px;
  min-height: 120px;
}

.pcard.add:hover { color: var(--muted); border-color: var(--line-hot); }

/* ---------- composer (ricerca + aggiunta) ---------- */

.composer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  margin-bottom: 26px;
}

.composer .more-head { margin-bottom: 2px; }
.composer .more-head.composer-sep { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }

.search-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-field {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--dim);
  pointer-events: none;
}

.search-field input { padding-left: 38px; }

.composer input,
.composer select,
.login-card input {
  width: 100%;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0a0c0f;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
}

.composer select { padding: 0 10px; }

.composer input:focus-visible,
.composer select:focus-visible,
.login-card input:focus-visible {
  outline: none;
  border-color: var(--line-hot);
  box-shadow: 0 0 0 3px var(--signal-soft);
}

.composer input::placeholder,
.search-field input::placeholder { color: var(--dim); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field-label,
.field label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.field-control { position: relative; }

.field-control input { padding-right: 64px; }

.char-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  pointer-events: none;
}

.char-count.ok { color: var(--ok); }
.char-count.warn { color: var(--warn); }

.field-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--signal);
}

.create-form { display: flex; flex-direction: column; gap: 12px; }
.create-form .btn { align-self: flex-start; margin-top: 4px; }

.search-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-height: 18px;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0a0c0f;
}

.search-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.search-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  min-width: 0;
}

.search-title strong {
  font-weight: 560;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.search-meta { display: flex; align-items: center; min-width: 0; }

.search-meta .chip {
  height: 22px;
  padding: 0 8px;
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}

.badge .badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}

.badge.ok { color: var(--ok); border-color: #3ddc9733; background: #3ddc9710; }

/* ---------- inspector ---------- */

.insp-chip {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--dim);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 4px;
  height: 24px;
  display: inline-flex;
  align-items: center;
}

.insp-body {
  padding: 6px 16px 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.sect {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--dim);
  text-transform: uppercase;
  margin: 0 0 10px;
}

.sect b { display: inline-flex; }

.spark {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #ff4d2e12, transparent 70%);
  overflow: hidden;
}

.spark svg { display: block; width: 100%; height: 100%; }

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  font-size: 12px;
  margin: 0;
}

.kv dt { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-self: end;
  text-align: right;
}

.dotline {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
  background: var(--dim);
}

.dotline.ok { background: var(--ok); }
.dotline.warn { background: var(--warn); }
.dotline.err { background: var(--signal); }

.log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.log .row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: start;
}

.log .t { color: var(--dim); }

.log .row span:last-child { display: flex; align-items: center; gap: 7px; min-width: 0; line-height: 1.4; }

/* ---------- odometer ---------- */

.odo {
  display: inline-flex;
  overflow: hidden;
  height: 1em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.odo-digit {
  position: relative;
  width: 0.6em;
  height: 1em;
  overflow: hidden;
}

.odo-strip {
  display: flex;
  flex-direction: column;
  will-change: transform;
}

.odo-n {
  height: 1em;
  display: grid;
  place-items: center;
}

/* ---------- skeleton ---------- */

.skeleton {
  position: relative;
  overflow: hidden;
  height: 54px;
  border-radius: 10px;
  background: var(--panel);
  pointer-events: none;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 6px;
  background: linear-gradient(100deg, var(--panel-2) 30%, #1a1e24 50%, var(--panel-2) 70%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s linear infinite;
}

.skeleton-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, #ffffff09 50%, transparent 70%);
  pointer-events: none;
}

.motion-shimmer { will-change: transform; }

@keyframes skeleton-sweep {
  to { background-position: -200% 0; }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101318;
  font-size: 13px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 16px 44px #000000a8;
}

.toast .toast-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--panel-2);
  flex: none;
  color: var(--muted);
}

.toast .toast-icon svg { width: 13px; height: 13px; }

.toast.success .toast-icon { background: #3ddc9722; color: var(--ok); }
.toast.error .toast-icon { background: #ff4d2e22; color: var(--signal); }

.toast .toast-msg {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- login ---------- */

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
  overflow: auto;
}

.login-card {
  width: min(400px, 92vw);
  padding: 30px 30px 26px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-glyph {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--signal);
  margin-bottom: 10px;
  background: #0a0c0f;
}

.login-glyph svg { color: currentColor; }

.login-card h2 {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-card > .muted {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-card .btn.wide { margin-top: 8px; height: 42px; font-weight: 650; }

.muted { color: var(--muted); }

.error {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--signal);
  margin: 8px 0 0;
}

/* ---------- player modale ---------- */

.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 40px);
}

.player-backdrop {
  position: absolute;
  inset: 0;
  background: #000000f0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.player-panel {
  position: relative;
  width: min(1180px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  min-height: 34px;
}

.player-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  position: relative;
  overflow: hidden;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid #ffffff26;
  background: #ffffff12;
  color: #fff;
}

.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: #ffffff22; }

.player-error { margin: 0 4px; }

/* video shell + controlli */

.video-shell {
  position: relative;
  width: 100%;
  max-width: calc((100vh - 150px) * 1.7777);
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--r);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--line);
  user-select: none;
}

.video-shell video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  cursor: pointer;
}

.video-shell:fullscreen,
.video-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  border: 0;
}

.video-shell:fullscreen video,
.video-shell:-webkit-full-screen video { object-fit: contain; height: 100vh !important; }

.video-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #00000059 0%, transparent 22%, transparent 58%, #000000a6 100%);
  opacity: 1;
  transition: opacity 0.3s ease;
}

.video-shell.idle .video-scrim { opacity: 0; }

.video-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.vc-play-big {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: #ffffff14;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid #ffffff2b;
  color: #fff;
  cursor: pointer;
  transition: opacity 0.25s ease, transform 0.25s var(--ease), background 0.2s ease;
}

.vc-play-big svg { width: 26px; height: 26px; margin-left: 3px; }

.vc-play-big:hover { background: #ffffff24; }

.video-shell.playing:not(:hover) .vc-play-big { opacity: 0; transform: scale(0.9); pointer-events: none; }
.video-shell.idle .vc-play-big { opacity: 0; transform: scale(0.9); pointer-events: none; }

.video-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
  color: #fff;
  background: linear-gradient(transparent, #000000d9);
  transition: opacity 0.28s ease, transform 0.28s var(--ease);
}

.video-shell.idle .video-controls {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.vc-btn {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  transition: background 0.18s ease, transform 0.18s ease;
}

.vc-btn:hover { background: #ffffff16; }

.vc-btn svg { width: 15px; height: 15px; }

.vc-time {
  font-family: var(--mono);
  font-size: 11px;
  color: #dfe4ea;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
  flex: none;
}

.vc-track {
  position: relative;
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;
  min-width: 40px;
}

.vc-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 2px;
  background: #ffffff2b;
}

.vc-buffer,
.vc-progress {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  border-radius: 2px;
  width: 0;
}

.vc-buffer { background: #ffffff4d; }

.vc-progress {
  background: var(--signal);
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
  mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
}

.vc-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  margin-left: 0;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px #00000066;
  pointer-events: none;
  transition: transform 0.18s ease;
}

.vc-track:hover .vc-thumb,
.vc-track.dragging .vc-thumb { transform: translate(-50%, -50%) scale(1); }

.vc-live {
  display: none;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--signal);
  padding: 4px 9px;
  border-radius: 4px;
  border: 1px solid #ff4d2e44;
  background: var(--signal-soft);
  flex: none;
  white-space: nowrap;
}

.vc-live .dot {
  width: 6px;
  height: 6px;
  background: var(--signal);
  animation-duration: 1.6s;
}

.video-shell.live .vc-live { display: inline-flex; }

.vc-volume {
  display: flex;
  align-items: center;
  width: 0;
  overflow: hidden;
  transition: width 0.25s var(--ease), margin 0.25s var(--ease);
}

.vc-volume.open { width: 76px; }

.vc-volume input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 68px;
  height: 4px;
  border-radius: 999px;
  background: #ffffff33;
  outline: none;
}

.vc-volume input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.vc-volume input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.player-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #00000099;
  color: #dfe4ea;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-align: center;
  padding: 20px;
}

.spinner-lg {
  width: 26px;
  height: 26px;
  border: 3px solid #ffffff22;
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.video-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: none;
}

.video-spinner .path-spinner { width: 30px; height: 30px; color: #fff; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .grid { grid-template-columns: 262px minmax(0, 1fr); }
  .inspector { display: none; }
}

@media (max-width: 860px) {
  .bar { gap: 12px; padding: 0 14px; }
  .hide-sm { display: none; }
  .grid { grid-template-columns: 1fr; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 236px;
  }
  .rail-head { padding: 12px 12px 8px; }
  .rail-list { padding: 0 8px 10px; }
  .rail-foot { display: none; }
  .stage { padding: 16px; }
  .stage h1 { font-size: 23px; }
  .player { max-height: 50vh; }
  .meta-strip { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .login-card { padding: 24px 22px 20px; }
}

@media (max-width: 430px) {
  .wordmark small { display: none; }
  .wordmark { font-size: 13px; }
  .stage h1 { font-size: 21px; }
}

/* target di tocco generosi sui pointer touch */

@media (pointer: coarse) {
  .btn, .select, .add-btn, .avatar-btn { min-height: 44px; min-width: 44px; }
  .btn.sm { min-height: 44px; min-width: 44px; padding: 0 13px; }
  .stream.chan { min-height: 52px; }
  .vc-btn, .icon-btn { width: 44px; height: 44px; }
  .vc-live { min-height: 44px; }
  .fplay { min-height: 44px; }
  .search-result .btn { min-height: 44px; }
  .pcard { min-height: 44px; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .dot,
  .dot-pulse,
  .spinner-lg,
  .skeleton::after {
    animation: none !important;
  }
  .btn .roll-in,
  .btn .roll-out,
  .fplay,
  .video-controls,
  .vc-play-big {
    transition: none !important;
  }
  .btn .roll-out { display: none; }
  .btn:hover:not(:disabled) .roll-in { transform: none; }
}
/* ---------- idle stage + empty signal ---------- */
/* A stopped channel must not reserve a full 16:9 black hole. */
.player.is-idle {
  aspect-ratio: auto;
  height: 190px;
  border-style: dashed;
  background: var(--panel);
}
.player.is-idle .frame {
  background:
    radial-gradient(120% 140% at 50% 130%, #ff4d2e10, transparent 62%),
    var(--panel);
}
.player.is-idle .frame::before {
  content: "Stream fermato";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.spark svg { display: block; width: 100%; height: 100%; }
.spark.is-empty::after {
  content: "nessun dato";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}
.spark { position: relative; }

/* ---------- buffer / recordings (0.10.0) ---------- */
.player-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.record-minutes {
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}
.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.check-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--signal);
}
.player-recordings {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}
.recording-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}
.recording-row .recording-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.recording-row .recording-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--dim);
}
.btn.sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* ---------- recording dialog ---------- */
.record-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(8px);
}
.record-card {
  width: min(440px, 94vw);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}
.record-head h2 {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.record-card > .muted {
  font-size: 13px;
  margin: 0 0 16px;
}
.record-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.record-form input,
.record-form select {
  width: 100%;
  height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #0a0c0f;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-size: 13px;
  min-width: 0;
  color-scheme: dark;
}
.record-form input:focus-visible,
.record-form select:focus-visible {
  outline: none;
  border-color: var(--line-hot);
  box-shadow: 0 0 0 3px var(--signal-soft);
}
.record-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
