/* ===== Що? Де? Коли? — графітова тема, акцент: золото; вторинний — крижаний блакитний ===== */
:root {
  --bg: #0c0d0f;
  --bg-2: #121316;
  --surface: #17191c;
  --surface-2: #1e2024;
  --surface-3: #262930;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --text: #eceae6;
  --text-2: #b7b5b0;
  --muted: #7d7f86;
  --accent: #e8b04a;
  --accent-2: #f6d28b;
  --accent-ink: #1a1305;
  --accent-soft: rgba(232, 176, 74, 0.12);
  --ice: #7cc7e8;
  --ice-soft: rgba(124, 199, 232, 0.12);
  --ok: #45d49a;
  --ok-soft: rgba(69, 212, 154, 0.12);
  --bad: #ff6464;
  --bad-soft: rgba(255, 100, 100, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(232, 176, 74, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(124, 199, 232, 0.05), transparent 60%);
  background-attachment: fixed;
}
body::before {
  /* легка «зернистість» для преміального графіту */
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app, main, header { position: relative; z-index: 1; }

h1, h2, h3, .display { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(26px, 4vw, 40px); }
h2 { font-size: 20px; }
h3 { font-size: 15px; font-weight: 500; }
p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.dim { color: var(--text-2); }
.small { font-size: 13px; }
.xs { font-size: 11.5px; letter-spacing: 0.02em; }
.upper { text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; font-weight: 700; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.gap-lg { gap: 18px; }
.center { text-align: center; }
.pre { white-space: pre-wrap; }

/* ---------- Логотип ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, #2a2c31, #141518);
  box-shadow: 0 0 0 1px var(--line-2) inset, 0 8px 24px -8px rgba(232, 176, 74, 0.35);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-title { font-family: var(--display); font-weight: 600; font-size: 16px; line-height: 1.1; }
.brand-sub { color: var(--muted); font-size: 12px; }

/* ---------- Картки ---------- */
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0) 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* ---------- Кнопки ---------- */
.btn {
  --b: var(--surface-3);
  appearance: none; border: 1px solid var(--line-2); background: var(--b); color: var(--text);
  font: 600 14px/1 var(--font); padding: 11px 16px; border-radius: 11px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s;
  user-select: none;
}
.btn:hover { background: #2e3138; border-color: rgba(255, 255, 255, 0.18); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); color: var(--accent-ink); border-color: transparent;
  box-shadow: 0 8px 24px -10px rgba(232, 176, 74, 0.7), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }
.btn.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(69, 212, 154, 0.3); }
.btn.ok.on, .btn.ok:hover { background: var(--ok); color: #05130d; }
.btn.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 100, 100, 0.3); }
.btn.bad.on, .btn.bad:hover { background: var(--bad); color: #1a0505; }
.btn.ice { background: var(--ice-soft); color: var(--ice); border-color: rgba(124, 199, 232, 0.3); }
.btn.sm { padding: 7px 10px; font-size: 12.5px; border-radius: 9px; }
.btn.lg { padding: 16px 22px; font-size: 16px; border-radius: 14px; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn kbd { font: 600 10px var(--font); opacity: 0.6; border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px; }

/* ---------- Поля ---------- */
.input, textarea.input, select.input {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  font: 500 15px/1.4 var(--font); padding: 12px 14px; border-radius: 11px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: rgba(232, 176, 74, 0.6); box-shadow: 0 0 0 4px rgba(232, 176, 74, 0.12); }
.input::placeholder { color: #5d6067; }
textarea.input { resize: vertical; min-height: 80px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); position: relative; cursor: pointer; transition: background 0.2s; border: 1px solid var(--line-2); flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #9a9ca3; transition: transform 0.2s, background 0.2s; }
.switch input:checked { background: var(--accent-soft); border-color: rgba(232, 176, 74, 0.5); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent); }

/* ---------- Бейджі ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(232, 176, 74, 0.25); }
.badge.ice { background: var(--ice-soft); color: var(--ice); border-color: rgba(124, 199, 232, 0.25); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: rgba(69, 212, 154, 0.25); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 100, 100, 0.25); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex-shrink: 0; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(69, 212, 154, 0.18); }
.dot.off { background: #50535a; }
.dot.warn { background: var(--accent); box-shadow: 0 0 0 3px rgba(232, 176, 74, 0.18); }

/* ---------- Таймер ---------- */
.timer { position: relative; display: grid; place-items: center; aspect-ratio: 1; width: var(--size, 180px); }
.timer svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.timer .track { stroke: rgba(255, 255, 255, 0.06); }
.timer .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke 0.3s; filter: drop-shadow(0 0 10px rgba(232, 176, 74, 0.45)); }
.timer .ticks line { stroke: rgba(255, 255, 255, 0.12); }
.timer-inner { text-align: center; position: relative; }
.timer-num { font-family: var(--display); font-weight: 500; font-size: calc(var(--size, 180px) * 0.3); line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.timer-label { font-size: calc(var(--size, 180px) * 0.065); text-transform: uppercase; letter-spacing: 0.16em; color: var(--muted); font-weight: 700; margin-top: calc(var(--size, 180px) * 0.04); }
.timer.write .prog { stroke: var(--ice); filter: drop-shadow(0 0 10px rgba(124, 199, 232, 0.5)); }
.timer.write .timer-label { color: var(--ice); }
.timer.danger .prog { stroke: var(--bad); filter: drop-shadow(0 0 12px rgba(255, 100, 100, 0.6)); }
.timer.danger .timer-num { color: #ffd1d1; animation: pulse 1s ease-in-out infinite; }
.timer.paused .timer-num { opacity: 0.55; }
.timer.idle .prog { stroke: rgba(232, 176, 74, 0.35); filter: none; }
.timer.closed .prog { stroke: #4a4d54; filter: none; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- Медіа ---------- */
.media { border-radius: 14px; overflow: hidden; background: #000; border: 1px solid var(--line); position: relative; }
.media img, .media video { display: block; width: 100%; max-height: 100%; object-fit: contain; background: #000; }
.media iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; display: block; }
.audio-card { display: flex; align-items: center; gap: 16px; padding: 18px; background: linear-gradient(135deg, #1f2125, #15171a); border-radius: 14px; border: 1px solid var(--line); }
.audio-card audio { width: 100%; }
.eq { display: flex; gap: 3px; align-items: flex-end; height: 28px; }
.eq span { width: 4px; background: var(--accent); border-radius: 2px; animation: eq 1s ease-in-out infinite; }
.eq span:nth-child(2) { animation-delay: 0.2s; } .eq span:nth-child(3) { animation-delay: 0.4s; } .eq span:nth-child(4) { animation-delay: 0.1s; }
.eq.stop span { animation: none; height: 6px; }
@keyframes eq { 0%, 100% { height: 6px; } 50% { height: 28px; } }
.handout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; white-space: pre-wrap; }

/* ---------- Тости ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; width: min(92vw, 420px); }
.toast { background: #25282e; border: 1px solid var(--line-2); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; animation: toastIn 0.25s ease; pointer-events: auto; }
.toast.ok { border-color: rgba(69, 212, 154, 0.4); color: var(--ok); }
.toast.bad { border-color: rgba(255, 100, 100, 0.4); color: var(--bad); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.conn-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 90; background: var(--bad); color: #1a0505; font-weight: 700; font-size: 13px; text-align: center; padding: 6px; }

/* ---------- Анімації появи ---------- */
.fade-in { animation: fadeIn 0.45s cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Модальні вікна ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(5, 6, 7, 0.72); backdrop-filter: blur(6px); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fadeIn 0.2s; }
.modal { width: min(820px, 100%); max-height: calc(100vh - 32px); overflow: auto; }

/* ---------- Таблиці ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b2e34; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
