/* =====================================================================
   Flare Panel — stesso linguaggio visivo di portfolio.valentinlungu.art
   Font ospitati qui (licenza OFL): nessuna richiesta a server esterni.
   ===================================================================== */
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage.woff") format("woff"); font-weight: 500 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("/fonts/instrument-sans.woff") format("woff"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono.woff") format("woff"); font-weight: 400 700; font-display: swap; }

:root,
:root[data-theme="dark"] {
  --bg: #101219;
  --surface: #171a23;
  --surface-2: #1f2330;
  --ink: #e9ecf3;
  --ink-2: #c3c8d6;
  --ink-3: #9aa1b4;
  --line: #262b38;
  --line-2: #323848;
  --accent: #7b96ff;
  --accent-ink: #0c1020;
  --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
  --flare: #ff6a12;
  --flare-2: #ff8f24;
  --flare-ink: #ffa463;
  --flare-soft: color-mix(in srgb, var(--flare) 15%, transparent);
  --ok: #3ddc84;
  --ok-soft: color-mix(in srgb, var(--ok) 14%, transparent);
  --danger: #ff5c72;
  --danger-soft: color-mix(in srgb, var(--danger) 14%, transparent);
  --warn: #f0b640;
  --warn-soft: color-mix(in srgb, var(--warn) 15%, transparent);
  --term-bg: #11131c;
  --dot: rgba(233, 236, 243, 0.09);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, 0.7);
  --discord-bg: #313338;
  --discord-embed: #2b2d31;
  --discord-text: #dbdee1;
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "Instrument Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 14px;
  --r-ctl: 10px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #edeff3;
  --surface: #ffffff;
  --surface-2: #e2e6ee;
  --ink: #151821;
  --ink-2: #3b4152;
  --ink-3: #5b6172;
  --line: #d5d9e2;
  --line-2: #c4c9d5;
  --accent: #2f55e6;
  --accent-ink: #ffffff;
  --flare: #e8590c;
  --flare-ink: #b2470a;
  --ok: #18915a;
  --danger: #d2364b;
  --warn: #b87a0c;
  --term-bg: #151824;
  --dot: rgba(21, 24, 33, 0.1);
  --shadow: 0 18px 40px -22px rgba(21, 24, 33, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--ink);
  font: 15px/1.55 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--f-display); line-height: 1.12; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: clamp(1.9rem, 3.2vw, 2.6rem); font-weight: 800; letter-spacing: -0.025em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.nowrap { white-space: nowrap; }

/* Cursore lampeggiante dopo i titoli */
.caret {
  display: inline-block;
  width: 0.09em;
  height: 0.82em;
  margin-left: 0.12em;
  vertical-align: -0.04em;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Effetti di sfondo ---------- */
#fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -2; pointer-events: none; }
#cursor-glow {
  position: fixed; left: 0; top: 0; width: 560px; height: 560px; margin: -280px 0 0 -280px;
  border-radius: 50%; pointer-events: none; z-index: -1; opacity: 0; transition: opacity 0.4s;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 62%);
}
.scanline {
  position: fixed; left: 0; right: 0; top: -20vh; height: 20vh; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 6%, transparent) 85%, color-mix(in srgb, var(--accent) 14%, transparent) 99%, transparent);
  animation: scan 9s linear infinite;
}
@keyframes scan { to { transform: translateY(140vh); } }
html.no-fx #fx-canvas, html.no-fx #cursor-glow, html.no-fx .scanline { display: none; }
@media (hover: none) { #cursor-glow { display: none; } }

/* Spotlight che segue il puntatore su pannelli e statistiche */
.panel, .stat, .server { --mx: 50%; --my: 50%; position: relative; isolation: isolate; }
.panel::before, .stat::before, .server::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: -1;
  opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(320px circle at var(--mx) var(--my), color-mix(in srgb, var(--accent) 10%, transparent), transparent 65%);
}
.panel:hover::before, .stat:hover::before, .server:hover::before { opacity: 1; }
html.no-fx .panel::before, html.no-fx .stat::before, html.no-fx .server::before { display: none; }

/* Entrata della pagina: un solo momento orchestrato */
.page.enter > * { animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.page.enter > *:nth-child(2) { animation-delay: 0.05s; }
.page.enter > *:nth-child(3) { animation-delay: 0.1s; }
.page.enter > *:nth-child(4) { animation-delay: 0.15s; }
.page.enter > *:nth-child(n + 5) { animation-delay: 0.2s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.rail {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; flex: none; display: block; filter: drop-shadow(0 4px 14px rgba(255, 106, 18, 0.35)); }
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; line-height: 1.1; }
.brand-sub { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); line-height: 1.3; }
.nav-group { margin-top: 16px; padding: 0 10px 6px; font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); }
.nav-group::before { content: "// "; color: var(--accent); opacity: 0.8; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-ctl);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav a:hover { background: var(--surface); color: var(--ink); }
.nav a[aria-current="page"] {
  background: var(--accent-soft); color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.nav a[aria-current="page"] svg { color: var(--accent); opacity: 1; }
.nav a .count {
  margin-left: auto; font: 600 11px/1.6 var(--f-mono);
  background: var(--flare); color: #fff; border-radius: 999px; padding: 0 7px; min-width: 22px; text-align: center;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 106, 18, 0.55); } 50% { box-shadow: 0 0 0 6px rgba(255, 106, 18, 0); } }
.rail-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.rail-tools { display: flex; gap: 6px; padding: 0 4px; }
.me { display: flex; align-items: center; gap: 10px; padding: 6px 6px; }
.me-name { font-weight: 600; }
.me-role { font-family: var(--f-mono); font-size: 11px; color: var(--ink-3); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-2); transform: translateY(-1px); }
.icon-btn[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.icon-btn svg { width: 17px; height: 17px; }

.main { padding: 30px 40px 72px; min-width: 0; }
.page { max-width: 1140px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { color: var(--ink-3); margin-top: 6px; max-width: 70ch; }
.crumb { font-family: var(--f-mono); font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.crumb b { color: var(--accent); font-weight: 400; }

.mobile-bar { display: none; }

/* ---------- Pannelli ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
  transition: border-color 0.25s;
}
.panel:hover { border-color: color-mix(in srgb, var(--accent) 22%, var(--line)); }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head p { color: var(--ink-3); font-size: 14px; margin-top: 3px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .panel + .panel { margin-top: 0; }

/* Server (intestazione panoramica) */
.server {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; margin-bottom: 18px; flex-wrap: wrap;
  background: linear-gradient(135deg, color-mix(in srgb, var(--flare) 8%, var(--surface)), var(--surface) 55%);
  border: 1px solid color-mix(in srgb, var(--flare) 28%, var(--line));
  border-radius: var(--r);
}
.server-icon {
  width: 58px; height: 58px; border-radius: 16px; flex: none; object-fit: cover;
  background: linear-gradient(135deg, var(--flare-2), var(--flare)); color: #fff;
  display: grid; place-items: center; font: 800 24px var(--f-display);
  box-shadow: 0 10px 30px -10px rgba(255, 106, 18, 0.6);
}
.server h2 { font-size: 1.4rem; font-weight: 800; }
.server-meta { display: flex; gap: 8px 18px; color: var(--ink-3); font-size: 14px; flex-wrap: wrap; margin-top: 4px; }
.server-meta .mono { font-size: 12px; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--ok); font-weight: 600; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.live.off { color: var(--danger); }

/* Terminale */
.term {
  display: inline-flex; flex-wrap: wrap; gap: 0 7px; align-items: center;
  padding: 9px 13px; border-radius: 9px; background: var(--term-bg); border: 1px solid #262b38;
  font-family: var(--f-mono); font-size: 12.5px; color: #d7dceb; max-width: 100%;
}
.term .p { color: #7ee787; }
.term .c { color: #7f8ab0; }
.term .cmd::after { content: ""; display: inline-block; width: 7px; height: 1em; background: #d7dceb; margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
.term .cmd.done::after { display: none; }
.term .out { color: #9fb2ff; flex-basis: 100%; }
.term .out:not(:empty)::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; margin-right: 7px; vertical-align: 1px; box-shadow: 0 0 8px #3ddc84; }

/* Statistiche */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 18px; overflow: hidden; }
.stat { padding: 18px 20px; border-left: 1px solid var(--line); text-decoration: none; color: inherit; transition: background 0.2s; }
.stat:first-child { border-left: 0; }
a.stat:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.stat-value { font: 800 30px/1.05 var(--f-display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-label { font-size: 13px; color: var(--ink-3); margin-top: 6px; }
.stat.hot .stat-value { color: var(--flare-ink); }

/* ---------- Tabelle ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font: 500 11.5px var(--f-mono); color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 22px; }
th:last-child, td:last-child { padding-right: 22px; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; transition: background 0.15s; }
tr.clickable:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--line);
  display: grid; place-items: center; font: 700 11px var(--f-mono); color: var(--ink-2);
}
.avatar.lg { width: 52px; height: 52px; font-size: 16px; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-id { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font: 500 11.5px/1.7 var(--f-mono); background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.chip.flare { background: var(--flare-soft); color: var(--flare-ink); border-color: color-mix(in srgb, var(--flare) 30%, transparent); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.chip.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }

.empty { padding: 32px 8px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; font-family: var(--f-display); font-size: 1.05rem; }

/* ---------- Controlli ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: var(--r-ctl); padding: 9px 15px; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--line-2); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary {
  position: relative; overflow: hidden; border: 0; color: #fff;
  background: linear-gradient(135deg, #5b7bff 0%, #8a5bff 55%, #c44bff 100%);
  box-shadow: 0 8px 22px -10px rgba(110, 90, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover { box-shadow: 0 14px 28px -10px rgba(110, 90, 255, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn.primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-18deg); transition: left 0.6s;
}
.btn.primary:hover::after { left: 120%; }
.btn.flare { border: 0; color: #fff; background: linear-gradient(135deg, var(--flare-2), var(--flare) 55%, #f2481c); box-shadow: 0 8px 22px -10px rgba(255, 106, 18, 0.8); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--surface-2); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field > label, .field-label { font-weight: 600; font-size: 14px; }
.hint { font-size: 12.5px; color: var(--ink-3); }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: var(--r-ctl);
  padding: 9px 12px; min-height: 40px; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:hover { border-color: var(--line-2); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input:disabled { opacity: 0.6; }
textarea.input { resize: vertical; min-height: 100px; line-height: 1.5; }
textarea.mono { font-family: var(--f-mono); font-size: 13px; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 14px; }
.input-color { display: flex; gap: 8px; align-items: center; }
.input-color input[type="color"] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--bg); cursor: pointer; }

.switch { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; margin-bottom: 13px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); position: relative; flex: none; cursor: pointer; margin: 1px 0 0; transition: background 0.2s, border-color 0.2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: transform 0.2s, background 0.2s; }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: #fff; }
.switch-text strong { display: block; font-weight: 600; }
.switch-text span { font-size: 13px; color: var(--ink-3); }

.picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.pick { display: inline-flex; align-items: center; gap: 5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 13px; font-weight: 600; }
.pick-dot { width: 9px; height: 9px; border-radius: 50%; }
.pick button { border: 0; background: none; cursor: pointer; color: var(--ink-3); width: 20px; height: 20px; border-radius: 50%; line-height: 1; }
.pick button:hover { background: var(--line); color: var(--ink); }

.tabs { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { border: 0; background: none; padding: 7px 14px; font-weight: 600; color: var(--ink-3); cursor: pointer; border-radius: 8px; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Configurazione */
.cfg { display: grid; grid-template-columns: 190px 1fr; gap: 28px; align-items: start; }
.cfg-nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.cfg-nav a { padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--ink-3); font-family: var(--f-mono); font-size: 12.5px; }
.cfg-nav a::before { content: "# "; color: var(--accent); }
.cfg-nav a:hover { background: var(--surface); color: var(--ink); }
.cfg-section { scroll-margin-top: 20px; }
.savebar {
  position: sticky; bottom: 16px; margin-top: 18px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); border-radius: var(--r);
  padding: 10px 12px 10px 18px; box-shadow: var(--shadow);
  animation: rise 0.25s ease-out;
}
.savebar span { font-family: var(--f-mono); font-size: 13px; }
.savebar span::before { content: "● "; color: var(--warn); }

.types-table input { min-height: 34px; padding: 6px 8px; }
.types-table td { padding: 6px; }
.types-table .emoji-in { width: 64px; text-align: center; }
.types-table .id-in { width: 110px; }

/* ---------- Annunci: anteprima Discord ---------- */
.composer { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.preview-wrap { position: sticky; top: 24px; }
.preview-label { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); margin-bottom: 8px; }
.preview-label::before { content: "// "; color: var(--accent); }
.discord {
  background: var(--discord-bg); border-radius: var(--r); padding: 18px 16px 20px;
  color: var(--discord-text); font: 15px/1.375 "gg sans", "Noto Sans", var(--f-body);
  border: 1px solid #3f4147; box-shadow: var(--shadow);
}
.dc-head { display: flex; gap: 14px; }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; background: #1e1f22; flex: none; display: grid; place-items: center; overflow: hidden; }
.dc-avatar img { width: 30px; height: 30px; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-bot { background: #5865f2; color: #fff; font-size: 10px; font-weight: 700; border-radius: 3px; padding: 1px 4px; margin-left: 4px; vertical-align: 2px; }
.dc-time { font-size: 12px; color: #949ba4; margin-left: 6px; }
.dc-mention { background: rgba(88, 101, 242, 0.3); color: #c9cdfb; border-radius: 3px; padding: 0 2px; font-weight: 500; }
.dc-embed { margin-top: 6px; background: var(--discord-embed); border-left: 4px solid var(--flare); border-radius: 4px; padding: 10px 16px 14px 12px; max-width: 520px; display: grid; grid-template-columns: 1fr auto; gap: 0 14px; }
.dc-title { font-weight: 600; color: #f2f3f5; font-size: 16px; margin-top: 2px; grid-column: 1; }
.dc-desc { font-size: 14px; white-space: pre-wrap; word-wrap: break-word; margin-top: 6px; grid-column: 1; }
.dc-desc:empty::before { content: "Il testo dell'annuncio apparirà qui."; color: #6d6f78; }
.dc-thumb { grid-column: 2; grid-row: 1 / span 2; width: 80px; height: 80px; border-radius: 4px; object-fit: cover; margin-top: 4px; }
.dc-image { grid-column: 1 / -1; margin-top: 14px; max-width: 100%; border-radius: 4px; max-height: 300px; object-fit: cover; }
.dc-foot { grid-column: 1 / -1; font-size: 12px; color: #b5bac1; margin-top: 10px; }
.dc-strong { font-weight: 700; }
.dc-code { background: #1e1f22; border-radius: 3px; padding: 0 3px; font-family: var(--f-mono); font-size: 0.85em; }

/* Trascrizioni */
.transcript {
  background: var(--term-bg); color: #d7dceb; border: 1px solid #262b38; border-radius: var(--r-ctl);
  padding: 14px 16px; font: 12.5px/1.65 var(--f-mono); white-space: pre-wrap; word-break: break-word;
  max-height: 60vh; overflow: auto;
}

/* Registro a catena */
.integrity { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-mono); font-size: 12.5px; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); }
.integrity.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.integrity.bad { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, 500px); }
.auth-side {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 44px 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
  border-right: 1px solid var(--line);
}
.auth-side canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.auth-side .brand { padding: 0; }
.auth-hero h1 { font-size: clamp(2.4rem, 5vw, 4rem); line-height: 1.04; letter-spacing: -0.03em; max-width: 13ch; }
.auth-hero h1 em { font-style: normal; color: var(--accent); }
.auth-hero .roles { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 22px; }
.auth-hero .roles span { font-family: var(--f-mono); font-size: 12px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-3); background: color-mix(in srgb, var(--bg) 70%, transparent); }
.auth-hero p.lead { color: var(--ink-3); font-size: 1.05rem; max-width: 46ch; margin-bottom: 24px; }
.auth-foot { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); }
.auth-foot b { color: var(--accent); font-weight: 400; }
.auth-main { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; padding: 40px 36px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card .crumb { margin-bottom: 14px; }
.auth-card h2 { font-size: 1.7rem; font-weight: 800; margin-bottom: 6px; letter-spacing: -0.02em; }
.auth-card h2 + p { color: var(--ink-3); margin-bottom: 24px; }
.auth-card .btn.primary { width: 100%; padding: 11px; font-size: 15px; }
.code-input { font: 600 26px var(--f-mono); letter-spacing: 0.4em; text-align: center; padding: 10px; }
.qr { display: block; width: 196px; height: 196px; border-radius: 12px; border: 1px solid var(--line); margin: 6px auto 12px; background: #fff; padding: 6px; }
.secret { font: 600 14px var(--f-mono); text-align: center; background: var(--bg); border: 1px dashed var(--line-2); border-radius: var(--r-ctl); padding: 9px; word-spacing: 3px; user-select: all; }
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--ink-2); }
.steps li + li { margin-top: 6px; }
.steps li::marker { color: var(--accent); font-family: var(--f-mono); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font: 600 14px var(--f-mono); background: var(--term-bg); color: #d7dceb; border: 1px solid #262b38; border-radius: var(--r-ctl); padding: 14px 18px; margin: 14px 0; user-select: all; }

.alert { padding: 10px 14px; border-radius: var(--r-ctl); font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.info { background: var(--accent-soft); color: var(--ink-2); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.linklike { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 13.5px; }

/* ---------- Modale e toast ---------- */
dialog {
  border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--ink);
  padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.7);
}
dialog[open] { animation: pop 0.2s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(6px); } }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(8, 9, 14, 0.6); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 8px; font-size: 1.35rem; }
dialog > div > p, dialog > form > p { color: var(--ink-3); margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: var(--r-ctl); font-size: 14px; max-width: 400px; box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.loading { padding: 48px; text-align: center; color: var(--ink-3); font-family: var(--f-mono); font-size: 13px; }
.loading::after { content: "_"; animation: blink 1s steps(1) infinite; }

/* Avviso di inattività */
.idle-bar {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--warn) 50%, var(--line)); border-radius: var(--r);
  box-shadow: var(--shadow); font-size: 14px; animation: rise 0.25s ease-out;
}

/* ---------- Correzioni layout ---------- */
.grid-2 > *, .composer > *, .cfg > *, .stack > *, .panel { min-width: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4) { border-left: 0; }
  .stat:nth-child(n + 4) { border-top: 1px solid var(--line); }
  .composer, .grid-2 { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
  .cfg { grid-template-columns: 1fr; }
  .cfg-nav { position: static; flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform 0.22s; background: var(--bg); }
  .rail.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, 0.5); }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
  .main { padding: 22px 16px 56px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-hero h1 { font-size: 2.3rem; }
  .auth-hero p.lead, .auth-foot { display: none; }
  .auth-main { padding: 28px 20px 40px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { border-left: 0 !important; border-top: 1px solid var(--line); }
  .stat:nth-child(-n + 2) { border-top: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .table-wrap { margin: 0 -22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  #fx-canvas, .scanline, #cursor-glow { display: none; }
}

/* ---------- Sezione Ticket ---------- */
.acc { padding: 0; }
.acc > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 18px; font-weight: 700; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::before { content: "▸"; color: var(--ink-3); transition: transform 0.15s; }
.acc[open] > summary::before { transform: rotate(90deg); }
.acc-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--f-display); font-size: 17px; }
.acc-body { padding: 4px 18px 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.acc-body h3 { font-size: 15px; }
.q-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) minmax(120px, 1.6fr) auto auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; }
.days { display: grid; gap: 6px; margin-top: 6px; max-width: 460px; }
.day-row { display: grid; grid-template-columns: 130px 1fr auto 1fr; gap: 8px; align-items: center; }
.day-row .input { min-height: 34px; padding: 5px 8px; }
.field-label { font-weight: 600; font-size: 13.5px; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 8px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.bar { width: 100%; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--flare), color-mix(in srgb, var(--flare) 40%, var(--surface))); transition: filter 0.15s; }
.bar-col:hover .bar { filter: brightness(1.25); }
.hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: 34px 1fr 34px; gap: 10px; align-items: center; }
.hbar { height: 10px; border-radius: 6px; background: var(--bg-2, var(--line)); overflow: hidden; }
.hbar > div { height: 100%; background: var(--accent); border-radius: 6px; }
.embed-preview { display: flex; max-width: 520px; background: var(--bg-2, var(--surface)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.ep-bar { width: 4px; flex: none; }
.ep-body { padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.ep-body p { margin: 0; font-size: 13.5px; color: var(--ink-2, var(--ink)); white-space: pre-wrap; overflow-wrap: anywhere; }
.ep-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ep-btn { padding: 5px 12px; border-radius: 4px; font-size: 13px; font-weight: 600; color: #fff; background: #5865f2; }
.ep-btn.secondary { background: #4e5058; } .ep-btn.success { background: #248046; } .ep-btn.danger { background: #da373c; }
.ep-select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 13.5px; color: var(--ink-3); }
@media (max-width: 760px) {
  .q-row { grid-template-columns: 1fr 1fr; }
  .day-row { grid-template-columns: 110px 1fr auto 1fr; }
}
