:root {
  --bg: #000;
  --panel: #0b0c0f;
  --panel-2: #15171c;
  --line: #24272e;
  --text: #eef0f3;
  --muted: #8b919c;
  --accent: #00e5ff;
  --rec: #ff2d55;
  --warn: #ffb020;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body { overflow: hidden; }

#app { display: flex; height: 100vh; height: 100dvh; }

/* ---------- stage ---------- */
#stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#view {
  display: block;
  background: #000;
  border-radius: 10px;
  box-shadow: 0 0 0 1px #1b1d22;
}

.hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 22, 27, 0.85);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  pointer-events: none;
}
.hint b { color: var(--text); }

.badge {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #4a1220;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}
.badge .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

/* ---------- ad overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.92);
}
.ad-card { width: min(360px, 100%); text-align: center; }
.ad-label { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.ad-slot {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #3a3f48;
  border-radius: 14px;
  background: #0e1014;
  color: #6b7280;
  font-size: 22px;
  font-weight: 700;
}
.ad-bar { height: 4px; margin: 14px 0 10px; background: #1c1f25; border-radius: 4px; overflow: hidden; }
.ad-bar span { display: block; height: 100%; width: 0; background: var(--accent); }
@keyframes ad-fill { to { width: 100%; } }
.ad-count { color: var(--muted); }
.ad-count b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- panel ---------- */
#panel {
  width: 340px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 0;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.logo {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  background: radial-gradient(circle at 38% 40%, #ff2d55 0 22%, transparent 24%),
              radial-gradient(circle at 64% 62%, #00e5ff 0 20%, transparent 22%);
}

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 16px; }

button, .btn {
  font: inherit;
  font-weight: 650;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover:not(:disabled), .btn:hover { border-color: #3a3f48; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, .btn:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.primary { background: var(--accent); color: #001317; border-color: transparent; }
.primary:hover:not(:disabled) { border-color: transparent; filter: brightness(1.08); }
.rec { background: #250a11; border-color: #561424; color: #ffd6de; }
.rec.on { background: var(--rec); color: #fff; border-color: transparent; }
.ghost { background: transparent; }
.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.wide { width: 100%; }

#settings {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 24px;
  overscroll-behavior: contain;
}

.field { display: block; margin: 14px 0; }
.label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #c6cad1;
}
.label output { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }
.label .num { display: inline-flex; align-items: baseline; color: var(--accent); font-weight: 700; }
.label .num input {
  font: inherit; font-size: 16px; /* stops iOS zooming on focus */
  color: inherit; font-variant-numeric: tabular-nums; text-align: right;
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 1px 4px; margin: -2px 0; max-width: calc(10ch + 12px);
  cursor: text;
}
.label .num input:hover { border-color: var(--line); }
.label .num input:focus { outline: none; border-color: var(--accent); background: var(--panel-2); }
.hint-text { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }

select, textarea, input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 16px; /* stops iOS zooming on focus */
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
textarea { resize: vertical; min-height: 66px; }
input[type="range"] { width: 100%; margin: 0; height: 28px; accent-color: var(--accent); }

.check { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.group { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; margin: 18px 0 0; }
.group legend { padding: 0 6px; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
.note.accent { color: var(--accent); }
.note.warn { color: var(--warn); }
.legal-links { margin-top: 14px; text-align: center; }
.legal-links a { color: inherit; }

.upgrade { margin-top: 18px; background: transparent; border: 1px dashed #3a3f48; color: #d7dbe1; }

/* ---------- modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.8);
}
.modal-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.modal-card.narrow { width: min(380px, 100%); }
.modal-card h2 { margin: 0 0 12px; font-size: 18px; }
.modal-card video { display: block; width: 100%; max-height: 55dvh; background: #000; border-radius: 10px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.modal-actions > * { flex: 1 1 auto; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 30;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1b1e24;
  border: 1px solid #30343c;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { position: fixed; inset: auto 0 0 0; padding: 16px; text-align: center; background: #300; }

/* ---------- phones / narrow windows ---------- */
@media (max-width: 899px) {
  #app { flex-direction: column; }
  #panel {
    width: auto;
    max-height: 60dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel-head { padding: 8px 16px 0; }
  .actions { padding: 8px 16px 10px; }
  #panel.collapsed #settings { display: none; }
  #view { border-radius: 6px; }
  .hint { bottom: 8px; font-size: 12px; padding: 6px 12px; }
  .hint .long { display: none; }
}

@media (min-width: 900px) {
  #toggle-settings { display: none; }
}
