.app { grid-template-rows: auto auto 1fr; }
.clock { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 800; letter-spacing: .04em; }
:root { --msg-size: 17px; }

/* Stato dei canali in testata */
.ch-status { display: flex; gap: 6px; flex-wrap: wrap; }
.ch-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); cursor: default; }
.ch-dot i { width: 8px; height: 8px; border-radius: 50%; background: #4b5060; }
.ch-dot.ok i { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.ch-dot.attesa i, .ch-dot.avvio i { background: var(--warn); }
.ch-dot.errore i { background: var(--bad); }
.ch-dot.spento { opacity: .5; }

/* Barra filtri */
.msg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.msg-toolbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.filter { background: var(--panel-2); border: 1px solid var(--line); border-radius: 16px; padding: 4px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.filter.on { border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--panel-2)); }
.filter .n { background: var(--accent); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.filter .n:empty { display: none; }
.msg-toolbar input[type=search] { width: 200px; }
.toggle.on { border-color: var(--accent-2); color: var(--accent-2); }

/* Layout */
.msg-main { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 14px; padding: 14px; overflow: hidden; min-height: 0; }
.feed-col { position: relative; min-height: 0; display: flex; flex-direction: column; }
.feed { overflow: auto; flex: 1; display: grid; align-content: start; gap: 8px; padding-right: 4px; }
.new-pill { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 5; background: var(--accent); color: #fff; border: 0; border-radius: 16px; padding: 6px 16px; font-weight: 700; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.5); }

/* Messaggio */
.msg { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 10px 14px; cursor: pointer; display: grid; gap: 6px; }
.msg:hover { border-color: #3d4250; border-left-color: var(--c); }
.msg.sel { outline: 2px solid var(--accent-2); outline-offset: -1px; }
.msg.nuovo { background: #1b1d25; }
.msg.nuovo .who::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; margin-right: 6px; vertical-align: middle; }
.msg.letto:not(.sel) { opacity: .62; }
.msg.onair .who::after { content: '  🎙'; }
.msg.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--c) 30%, var(--panel)); } }
.msg .head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.msg .who { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg .time { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; white-space: nowrap; }
.msg .text { font-size: var(--msg-size); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.msg .meta .star { color: var(--accent-2); }
.badge-ch { font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 2px 7px; border-radius: 10px; text-transform: uppercase; background: var(--c); color: #000; white-space: nowrap; }
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; background: var(--panel-2); }
.kind { font-size: 11px; color: var(--muted); }

/* Dettaglio */
.detail-col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: auto; display: flex; flex-direction: column; }
.detail-col .empty { margin: auto; }
.detail { padding: 16px 18px; display: grid; gap: 14px; border-top: 4px solid var(--c); }
.detail .who { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail .avatar { width: 44px; height: 44px; }
.detail .sub { color: var(--muted); }
.detail .big { font-size: calc(var(--msg-size) * 1.45); line-height: 1.35; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.detail .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail .actions .btn { padding: 8px 12px; font-size: 13px; }
.detail .actions .btn.on { border-color: var(--accent-2); color: var(--accent-2); }
.detail img.media { max-width: 100%; max-height: 360px; border-radius: 8px; }
.detail audio, .detail video { width: 100%; }
.reply-box { display: grid; gap: 8px; }
.reply-box textarea { min-height: 80px; resize: vertical; }
.reply-done { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.reply-done small { color: var(--muted); display: block; margin-bottom: 4px; }
.history { display: grid; gap: 6px; }
.history h4 { margin: 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.history .row { font-size: 13px; background: var(--panel-2); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.history .row span { color: var(--muted); font-size: 11px; margin-right: 6px; }
.keys { color: var(--muted); font-size: 11px; }
.keys kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font: inherit; }

/* Impostazioni canali */
.ch-cfg { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; display: grid; gap: 10px; }
.ch-cfg .title { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 14px; }
.ch-cfg .help { color: var(--muted); font-size: 12px; line-height: 1.45; }
.ch-cfg code { background: #0b0c10; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; font-size: 12px; user-select: all; overflow-wrap: anywhere; }
.ch-cfg .st { font-size: 12px; }

@media (max-width: 900px) {
  .msg-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; overflow: auto; }
  .detail-col { max-height: 50vh; }
  .ch-status { display: none; }
  header.top { flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  header.top .clock, header.top #who { display: none; }
  .msg-toolbar { padding: 8px 16px; }
  .msg-toolbar input[type=search] { flex: 1 1 100%; width: auto; order: 10; }
  .msg-main { padding: 10px 16px; }
}
/* spunta "In TV" su ogni messaggio */
.tv-tick { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--muted); cursor: pointer; flex: none; white-space: nowrap; }
.tv-tick input { margin: 0; cursor: pointer; }
.tv-tick.on { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.msg .meta .tv { color: #60a5fa; }
