:root {
  --bg: #05060a;
  --fg: #e8ecff;
  --muted: rgba(232, 236, 255, 0.62);
  --line: rgba(255, 255, 255, 0.12);
  --glass: rgba(10, 13, 24, 0.82);
  --accent-a: #22d3ee;
  --accent-b: #7c5cff;
  --accent-c: #ff3d81;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.ui {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 20px;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.ui.hide { opacity: 0; visibility: hidden; }
.ui.hide * { pointer-events: none !important; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  padding-top: 4px;
  text-shadow: 0 0 24px rgba(120, 160, 255, 0.45);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 0 12px var(--accent-a), 0 0 26px rgba(124, 92, 255, 0.7);
}

.sub {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
  opacity: 0.38;
  text-transform: uppercase;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: var(--muted);
}

.chip.lang {
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--fg);
  -webkit-appearance: none;
  appearance: none;
}

.chip.lang:hover { border-color: rgba(255, 255, 255, 0.34); color: #fff; }

.chip.live-btn {
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  -webkit-appearance: none;
  appearance: none;
}

.chip.live-btn.on {
  color: #7fe3ff;
  border-color: rgba(127, 227, 255, 0.45);
  box-shadow: 0 0 12px rgba(127, 227, 255, 0.18);
}

.chip.ghost { opacity: 0.6; }

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7a7f96;
  transition: background 0.25s, box-shadow 0.25s;
}

.chip.live .live-dot {
  background: #3dffa8;
  box-shadow: 0 0 10px #3dffa8;
}

.chip.live { color: var(--fg); }

/* ---------- запись ---------- */

body.recording #fps::before {
  content: '●';
  color: #ff4d6d;
  margin-right: 6px;
  animation: recPulse 1.2s ease-in-out infinite;
}

body.recording::after {
  content: '';
  position: fixed;
  inset: 0;
  border: 2px solid rgba(255, 77, 109, 0.55);
  pointer-events: none;
  z-index: 60;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}


/* ---------- intro ---------- */

.intro {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 18px;
  border-radius: 24px;
  /* Затемнение под стартовым экраном: на ярких шаблонах текст иначе терялся */
  background: radial-gradient(120% 85% at 50% 45%,
    rgba(5, 7, 12, 0.80) 0%,
    rgba(5, 7, 12, 0.66) 45%,
    rgba(5, 7, 12, 0.28) 72%,
    rgba(5, 7, 12, 0) 88%);
  backdrop-filter: blur(3px) saturate(0.92);
  -webkit-backdrop-filter: blur(3px) saturate(0.92);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.intro.hidden,
.intro.hidden * {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
}

.intro > * { pointer-events: auto; }

.intro h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-shadow: 0 0 60px rgba(110, 150, 255, 0.35);
}

.lead {
  margin: 0;
  max-width: 52ch;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

.lead b { color: var(--fg); font-weight: 600; }

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

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.primary,
.secondary {
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.primary {
  border: 0;
  color: #05060a;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b) 55%, var(--accent-c));
  box-shadow: 0 10px 34px rgba(90, 130, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 40px rgba(90, 130, 255, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.primary:active { transform: translateY(0); }

.secondary {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(12, 15, 26, 0.84);
}

.secondary:hover { border-color: rgba(255, 255, 255, 0.34); background: rgba(20, 24, 40, 0.6); }

.link {
  border: 0;
  background: none;
  padding: 10px 6px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.22);
  text-underline-offset: 5px;
}

.link:hover { color: var(--fg); }

.hint {
  margin: 4px 0 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  letter-spacing: 0.03em;
  color: rgba(232, 236, 255, 0.38);
}

/* ---------- bottom bar ---------- */

.bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.keys {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  color: rgba(232, 236, 255, 0.3);
  margin-right: 4px;
}

.pill {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  color: rgba(232, 236, 255, 0.72);
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.pill:hover { color: var(--fg); border-color: rgba(255, 255, 255, 0.3); }

#presets {
  gap: 6px;
}

#presets .pill {
  padding: 6px 10px;
  font-size: 10px;
}

.pill.active {
  color: #fff;
  background: rgba(110, 150, 255, 0.18);
  border-color: rgba(150, 185, 255, 0.55);
  box-shadow: 0 0 20px rgba(90, 140, 255, 0.22);
}

.sel {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(232, 236, 255, 0.42);
  padding-left: 6px;
}

select {
  font: inherit;
  color: var(--fg);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  outline: none;
  cursor: pointer;
}

select:hover { border-color: rgba(255, 255, 255, 0.3); }

select.wide { width: 100%; }

/* курсор прячется после 3 с простоя (класс ставит app.js) */
body.idle #gl { cursor: none; }

/* ---------- toast / fatal ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translate(-50%, 12px);
  max-width: min(560px, 88vw);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(14, 17, 30, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 20;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.fatal[hidden] { display: none; }

/* Полоска прогресса локального трека: тонкая, у самого низа, скрываемая кнопкой */
.trackbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  z-index: 45;
  display: flex;
  align-items: center;
  background: rgba(8, 10, 18, 0.55);
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.25s ease;
  font: 10.5px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.04em;
  color: rgba(232, 236, 255, 0.66);
}

.trackbar.show { opacity: 1; pointer-events: auto; }
.trackbar:hover { color: #fff; }

.trackbar-rail { position: absolute; inset: 0; overflow: hidden; }

.trackbar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, rgba(127, 227, 255, 0.32), rgba(255, 95, 162, 0.42));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.trackbar-name {
  position: relative;
  z-index: 3;
  padding: 0 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fatal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 40px;
  background: rgba(5, 6, 10, 0.94);
  color: #ff9aa8;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  text-align: center;
  z-index: 100;
}

@media (max-width: 720px) {
  .ui { padding: 14px; }
  .sub, .keys, .chip.ghost { display: none; }
  .bottom { justify-content: center; }
  .lead { font-size: 13px; }
  .primary, .secondary { padding: 12px 16px; font-size: 13px; }
}

/* ---------- settings panel ---------- */

.panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(342px, 94vw);
  height: 100%;
  padding: 20px 20px 28px;
  background: rgba(7, 9, 16, 0.88);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-left: 1px solid rgba(255, 255, 255, 0.10);
  transform: translateX(103%);
  visibility: hidden;
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.35s;
  overflow-y: auto;
  pointer-events: none;
  color: var(--fg);
}

.panel.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.panel-close {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  padding: 6px 9px;
  border-radius: 8px;
  transition: color 0.18s, background 0.18s;
}

.panel-close:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.field { margin-bottom: 20px; }

.field-label {
  margin-bottom: 10px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: rgba(232, 236, 255, 0.42);
}

.swatches { display: flex; flex-wrap: wrap; gap: 9px; }

.check.palette-auto { margin-top: 10px; font-size: 10.5px; }

.swatch {
  width: 42px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.swatch:hover { transform: translateY(-1px); border-color: rgba(255, 255, 255, 0.4); }

.swatch.active {
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(120, 160, 255, 0.35), 0 0 18px rgba(120, 160, 255, 0.25);
}

.range { display: block; margin-bottom: 15px; }

.range-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  font-size: 11.5px;
  color: var(--muted);
}

.range output {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 10px;
  color: rgba(232, 236, 255, 0.7);
}

.range input[type="range"] {
  width: 100%;
  height: 4px;
  cursor: pointer;
  accent-color: var(--accent-b);
}

.panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  cursor: pointer;
}

.check input { accent-color: var(--accent-b); }

.panel-hint {
  margin: 16px 0 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 9.5px;
  line-height: 1.65;
  color: rgba(232, 236, 255, 0.32);
}

@media (max-width: 720px) {
  .panel { width: 100%; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
