/* ═══════════ BULKA PROMPTER · 2026 ═══════════ */
:root {
  --bg: #0a0a0f;
  --bg-card: rgba(255, 255, 255, 0.055);
  --bg-glass: rgba(20, 20, 30, 0.55);
  --stroke: rgba(255, 255, 255, 0.09);
  --text: #f5f5f7;
  --dim: rgba(245, 245, 247, 0.45);
  --accent: #7c5cff;
  --accent2: #00e0c6;
  --grad: #7c5cff;
  --radius: 22px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}
body { position: fixed; inset: 0; overflow: hidden; }

.hidden { display: none !important; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input[type="text"], textarea { font: inherit; color: inherit; background: none; border: none; outline: none; }

/* ─────────── БИБЛИОТЕКА ─────────── */
#screen-library {
  padding: calc(var(--sat) + 18px) 20px calc(var(--sab) + 20px);
  overflow-y: auto;
  background:
    radial-gradient(90% 45% at 15% -10%, rgba(124, 92, 255, 0.14), transparent 65%),
    var(--bg);
}
.lib-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 26px; }
.lib-header h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
.accent {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.lib-sub { color: var(--dim); font-size: 14px; font-weight: 500; margin-top: 2px; letter-spacing: 0.06em; text-transform: uppercase; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent);
  color: #fff; font-weight: 700; font-size: 16px;
  padding: 13px 20px; border-radius: 18px;
  box-shadow: 0 8px 28px rgba(124, 92, 255, 0.35);
  transition: transform 0.15s ease;
}
.btn-primary:active { transform: scale(0.94); }
.btn-round { padding: 13px; border-radius: 50%; }

.lib-actions { display: flex; align-items: center; gap: 10px; }
.btn-icon {
  position: relative;
  width: 46px; height: 46px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  color: var(--dim);
  transition: transform 0.15s ease;
}
.btn-icon:active { transform: scale(0.9); }
.account-dot {
  position: absolute; top: 9px; right: 9px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #30d158;
}

/* ─────────── АККАУНТ ─────────── */
.auth-box {
  display: flex; flex-direction: column; gap: 12px;
  padding: 28px 24px;
  max-width: 420px; width: 100%;
  margin: 0 auto;
}
.auth-lead { color: var(--dim); font-size: 15px; line-height: 1.45; margin-bottom: 8px; }
.auth-input {
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  border-radius: 15px;
  padding: 15px 16px;
  font-size: 17px;
  color: var(--text);
}
.auth-input::placeholder { color: var(--dim); }
.auth-input:focus { border-color: var(--accent); }
.auth-error {
  color: #ff375f; font-size: 14px; font-weight: 500;
  padding: 2px 4px;
}
.auth-btn { justify-content: center; text-align: center; margin-top: 6px; }
.auth-btn-secondary {
  padding: 13px 20px; border-radius: 18px;
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  font-weight: 600; font-size: 16px;
  color: var(--text);
  transition: transform 0.15s ease;
}
.auth-btn-secondary:active { transform: scale(0.96); }
.account-screen-title { flex: 1; }
.profile-avatar {
  width: 74px; height: 74px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  color: var(--dim);
  margin: 12px auto 2px;
}
.profile-email { text-align: center; font-size: 18px; font-weight: 700; }
.sync-status { text-align: center; color: var(--dim); font-size: 14px; margin-bottom: 10px; }
.sync-status.ok { color: #30d158; }
.sync-status.err { color: #ff375f; }

.script-list { display: flex; flex-direction: column; gap: 14px; }
.script-card {
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  transition: transform 0.15s ease;
}
.script-card:active { transform: scale(0.98); }
.script-card-body { flex: 1; min-width: 0; }
.script-card-title { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.script-card-meta { color: var(--dim); font-size: 13px; margin-top: 4px; }
.script-card-actions { display: flex; gap: 8px; }
.card-btn {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  transition: transform 0.15s ease;
}
.card-btn:active { transform: scale(0.9); }
.card-btn-play { background: var(--accent); border: none; color: #fff; box-shadow: 0 6px 18px rgba(124, 92, 255, 0.32); }
.card-btn-del { color: #ff375f; }

.lib-empty { text-align: center; margin-top: 16vh; font-size: 18px; }
.lib-empty-icon { font-size: 56px; margin-bottom: 16px; }
.lib-empty .dim { color: var(--dim); font-size: 15px; margin-top: 6px; }

/* ─────────── РЕДАКТОР ─────────── */
#screen-editor { background: var(--bg); }
.editor-header {
  display: flex; align-items: center; gap: 12px;
  padding: calc(var(--sat) + 12px) 16px 12px;
  border-bottom: 1px solid var(--stroke);
}
.btn-ghost { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--dim); }
.btn-ghost:active { background: rgba(255, 255, 255, 0.08); }
.editor-title { flex: 1; font-size: 19px; font-weight: 700; min-width: 0; }
.editor-title::placeholder { color: var(--dim); font-weight: 500; }
.editor-text {
  flex: 1; width: 100%; resize: none;
  padding: 20px 20px calc(var(--sab) + 12px);
  font-size: 18px; line-height: 1.6;
  caret-color: var(--accent);
}
.editor-text::placeholder { color: var(--dim); }
.editor-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px calc(var(--sab) + 12px);
  border-top: 1px solid var(--stroke);
  font-size: 13px; color: var(--dim);
}
.editor-saved { opacity: 0; transition: opacity 0.4s; color: var(--accent2); font-weight: 600; }
.editor-saved.show { opacity: 1; }

/* ─────────── СУФЛЁР ─────────── */
#screen-prompter { background: #000; }
.prompter-viewport { position: absolute; inset: 0; overflow: hidden; }
.prompter-mirror { position: absolute; inset: 0; }
.prompter-mirror.mirror-h { transform: scaleX(-1); }
.prompter-mirror.mirror-v { transform: scaleY(-1); }
.prompter-mirror.mirror-h.mirror-v { transform: scale(-1, -1); }

.prompter-content {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 45vh 6% 60vh;
  font-size: 48px; line-height: 1.4; font-weight: 600;
  letter-spacing: -0.01em;
  color: #f5f5f7;
  white-space: pre-wrap; word-wrap: break-word;
  will-change: transform;
  text-align: left;
}

.focus-fade { position: absolute; left: 0; right: 0; height: 22vh; pointer-events: none; z-index: 2; }
.focus-fade-top { top: 0; background: linear-gradient(#000 12%, transparent); }
.focus-fade-bottom { bottom: 0; background: linear-gradient(transparent, #000 88%); }
.focus-fade.off { display: none; }

.guide-line {
  position: absolute; left: 0; right: 0; top: 38vh; z-index: 3;
  height: 2px;
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.9), rgba(124, 92, 255, 0.4) 40%, transparent 75%);
  pointer-events: none;
}
.guide-arrow {
  position: absolute; left: 6px; top: -7px;
  width: 0; height: 0;
  border: 8px solid transparent; border-left: 12px solid var(--accent);
  filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.8));
}
.guide-line.off { display: none; }

.progress-track {
  position: absolute; top: 0; left: 0; right: 0; height: calc(var(--sat) + 3px);
  z-index: 6; background: rgba(255, 255, 255, 0.06);
}
.progress-bar {
  height: 100%; width: 0%;
  background: var(--grad);
  border-radius: 0 3px 3px 0;
  transition: width 0.2s linear;
}

/* панели суфлёра */
.prompter-ui { transition: opacity 0.35s ease, transform 0.35s ease; z-index: 5; }
.ui-hidden .prompter-ui { opacity: 0; pointer-events: none; }
.ui-hidden .prompter-topbar { transform: translateY(-12px); }
.ui-hidden .prompter-bottombar { transform: translateY(12px); }

.prompter-topbar {
  position: absolute; top: calc(var(--sat) + 12px); left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.glass-btn {
  width: 46px; height: 46px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--bg-glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  transition: transform 0.15s ease;
}
.glass-btn:active { transform: scale(0.9); }
.glass-btn-sm { width: 42px; height: 42px; font-size: 22px; font-weight: 700; }

.time-pill {
  display: flex; gap: 6px; align-items: baseline;
  background: var(--bg-glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  padding: 9px 16px; border-radius: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 700; font-size: 15px;
}
.time-sep { color: var(--dim); }
#time-remaining { color: var(--dim); font-weight: 500; }

.prompter-bottombar {
  position: absolute; bottom: calc(var(--sab) + 16px); left: 16px; right: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.speed-cluster {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  padding: 7px 12px; border-radius: 26px;
}
.play-btn {
  width: 62px; height: 62px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 32px rgba(124, 92, 255, 0.45);
  transition: transform 0.15s ease;
}
.play-btn:active { transform: scale(0.9); }
.speed-readout {
  min-width: 52px; text-align: center;
  background: var(--bg-glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  padding: 12px 10px; border-radius: 16px;
  font-weight: 800; font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.speed-readout.boost { color: var(--accent2); }

/* ─────────── ДЖОЙСТИК ─────────── */
.joystick {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%);
  touch-action: none;
}
.joystick.off { display: none; }
.joystick-track {
  width: 58px; height: 200px; border-radius: 29px;
  background: var(--bg-glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.joystick-knob {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.5), inset 0 1px 0 rgba(255,255,255,0.35);
  transition: transform 0.25s cubic-bezier(0.2, 1.6, 0.4, 1);
  will-change: transform;
}
.joystick.active .joystick-knob { transition: none; }
.joystick-hint {
  position: absolute; left: 0; right: 0; text-align: center;
  font-size: 11px; color: var(--dim); pointer-events: none;
}
.joystick-hint-up { top: 10px; }
.joystick-hint-down { bottom: 10px; }

/* ─────────── ОТСЧЁТ ─────────── */
.countdown {
  position: absolute; inset: 0; z-index: 8;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#countdown-num {
  font-size: 32vw; font-weight: 900;
  color: var(--accent);
  animation: cd-pop 1s ease infinite;
}
@keyframes cd-pop {
  0% { transform: scale(0.55); opacity: 0; }
  25% { transform: scale(1.05); opacity: 1; }
  80% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.1); opacity: 0; }
}

/* ─────────── ШТОРКА НАСТРОЕК ─────────── */
.settings-backdrop {
  position: absolute; inset: 0; z-index: 9;
  background: rgba(0, 0, 0, 0.45);
  opacity: 1; transition: opacity 0.3s;
}
.settings-backdrop.hidden { display: block !important; opacity: 0; pointer-events: none; }
.settings-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 10;
  background: rgba(18, 18, 26, 0.92);
  backdrop-filter: blur(36px); -webkit-backdrop-filter: blur(36px);
  border-radius: 28px 28px 0 0;
  border-top: 1px solid var(--stroke);
  padding: 10px 22px calc(var(--sab) + 24px);
  max-height: 78vh; overflow-y: auto;
  transform: translateY(105%);
  transition: transform 0.38s cubic-bezier(0.32, 0.72, 0, 1);
}
.settings-sheet.open { transform: translateY(0); }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,0.22); margin: 6px auto 16px; }
.sheet-title { font-size: 22px; font-weight: 800; margin-bottom: 18px; letter-spacing: -0.02em; }

.set-group { margin-bottom: 22px; }
.set-label {
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--dim); margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.set-val { color: var(--accent2); font-size: 14px; }

.seg-row { display: flex; gap: 10px; }
.seg-btn {
  flex: 1; padding: 13px; border-radius: 15px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  font-weight: 600; font-size: 15px;
  transition: all 0.2s ease;
}
.seg-btn.on {
  background: rgba(124, 92, 255, 0.22);
  border-color: var(--accent);
  color: #cfc2ff;
}

input[type="range"] {
  width: 100%; height: 34px;
  -webkit-appearance: none; appearance: none; background: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent);
  margin-top: -11px;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.45);
}

.color-row { display: flex; gap: 14px; }
.color-dot {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--c);
  border: 3px solid transparent;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.color-dot.on { border-color: #fff; transform: scale(1.12); }

.toggle-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; font-size: 16px; font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.toggle-row input { display: none; }
.toggle {
  width: 51px; height: 31px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  position: relative; transition: background 0.25s; flex-shrink: 0;
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.25s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.toggle-row input:checked + .toggle { background: var(--accent); }
.toggle-row input:checked + .toggle::after { transform: translateX(20px); }

/* пейзажная ориентация — компактнее */
@media (orientation: landscape) {
  .prompter-content { padding-top: 42vh; }
  .joystick-track { height: 150px; }
}

/* ═══════════ ТЕМА APPLE ═══════════
   Светлая: канва parchment #f5f5f7, чернила #1d1d1f,
   один акцент Action Blue #0066cc, pill-кнопки,
   волосяные рамки вместо теней, без градиентов. */
body.theme-apple {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-glass: rgba(210, 210, 215, 0.64);
  --stroke: #e0e0e0;
  --text: #1d1d1f;
  --dim: #7a7a7a;
  --accent: #0066cc;
  --accent2: #0071e3;
  --grad: #0066cc;
  background: var(--bg);
  color: var(--text);
}

/* библиотека: чистая канва, без свечений */
body.theme-apple #screen-library { background: var(--bg); }
body.theme-apple .accent {
  background: none;
  -webkit-text-fill-color: var(--accent);
}
body.theme-apple .btn-primary {
  background: var(--accent);
  color: #fff;
  border-radius: 9999px;
  box-shadow: none;
}
body.theme-apple .script-card {
  background: var(--bg-card);
  border: 1px solid var(--stroke);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
body.theme-apple .card-btn {
  background: #fafafc;
  border: 1px solid var(--stroke);
}
body.theme-apple .card-btn-play { color: var(--accent); }
body.theme-apple .card-btn-del { color: #a1a1a6; }

/* редактор */
body.theme-apple #screen-editor { background: #fff; }
body.theme-apple .btn-ghost:active { background: rgba(0, 0, 0, 0.06); }

/* аккаунт */
body.theme-apple #screen-account { background: var(--bg); }
body.theme-apple .btn-icon,
body.theme-apple .auth-input,
body.theme-apple .auth-btn-secondary,
body.theme-apple .profile-avatar { background: #fff; border-color: var(--stroke); }
body.theme-apple .auth-btn-secondary { color: var(--accent); }
body.theme-apple .sync-status.ok { color: #248a3d; }

/* суфлёр: полотно остаётся чёрным, хром — светлые прозрачные чипы */
body.theme-apple .glass-btn,
body.theme-apple .time-pill,
body.theme-apple .speed-cluster,
body.theme-apple .speed-readout,
body.theme-apple .joystick-track {
  background: rgba(210, 210, 215, 0.64);
  border-color: transparent;
  color: #1d1d1f;
}
body.theme-apple #time-remaining,
body.theme-apple .time-sep,
body.theme-apple .joystick-hint { color: rgba(29, 29, 31, 0.55); }
body.theme-apple .play-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}
body.theme-apple .joystick-knob {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
body.theme-apple .progress-track { background: rgba(255, 255, 255, 0.14); }
body.theme-apple .progress-bar { background: #2997ff; }
body.theme-apple .guide-line {
  background: linear-gradient(90deg, rgba(41, 151, 255, 0.9), rgba(41, 151, 255, 0.35) 40%, transparent 75%);
}
body.theme-apple .guide-arrow {
  border-left-color: #2997ff;
  filter: none;
}
body.theme-apple .speed-readout.boost { color: var(--accent); }

/* шторка настроек: светлое матовое стекло */
body.theme-apple .settings-sheet {
  background: rgba(245, 245, 247, 0.94);
  border-top-color: var(--stroke);
  color: var(--text);
}
body.theme-apple .sheet-grab { background: rgba(0, 0, 0, 0.2); }
body.theme-apple .settings-backdrop { background: rgba(0, 0, 0, 0.25); }
body.theme-apple .seg-btn {
  background: #fff;
  border-color: var(--stroke);
}
body.theme-apple .seg-btn.on {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
body.theme-apple input[type="range"]::-webkit-slider-runnable-track { background: rgba(0, 0, 0, 0.12); }
body.theme-apple input[type="range"]::-webkit-slider-thumb {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
body.theme-apple .color-dot.on { border-color: var(--text); }
body.theme-apple .color-dot[data-color="#f5f5f7"] { box-shadow: 0 0 0 1px var(--stroke) inset; }
body.theme-apple .toggle { background: rgba(0, 0, 0, 0.16); }
body.theme-apple .toggle-row { border-bottom-color: rgba(0, 0, 0, 0.06); }
body.theme-apple .toggle-row input:checked + .toggle { background: var(--accent); }
