:root {
  --bg: #08090d;
  --panel: #10131a;
  --panel-2: #161a23;
  --line: #232936;
  --text: #e8ecf4;
  --dim: #8b95a8;
  --accent: #6c5ce7;
  --accent-2: #00d2a8;
  --danger: #ff5c72;
  --warn: #ffb454;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(700px circle at 15% -10%, rgba(108, 92, 231, 0.16), transparent 60%),
    radial-gradient(600px circle at 85% 5%, rgba(0, 210, 168, 0.10), transparent 55%),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: auto, auto, 46px 46px, 46px 46px;
}

.topbar, main, footer { position: relative; z-index: 1; }

.topbar {
  max-width: 940px; margin: 0 auto; padding: 30px 22px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 30px; color: var(--accent-2);
  filter: drop-shadow(0 0 14px rgba(0,210,168,0.55));
}
.brand h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.brand p { color: var(--dim); font-size: 13px; }

.engine-tag {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  padding: 7px 13px; border-radius: 999px;
  font-size: 11.5px; color: var(--dim);
  font-family: 'JetBrains Mono', monospace;
}
.dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2);
  box-shadow: 0 0 9px var(--accent-2);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

main { max-width: 940px; margin: 0 auto; padding: 10px 22px 60px; display: grid; gap: 20px; }

.panel {
  background: linear-gradient(180deg, var(--panel) 0%, #0d1016 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.panel-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 20px; }
.panel-head h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head p { color: var(--dim); font-size: 13px; margin-top: 2px; }
.step {
  flex: none; width: 27px; height: 27px; border-radius: 8px;
  background: rgba(108,92,231,0.16); border: 1px solid rgba(108,92,231,0.45);
  color: #b3a8ff; display: grid; place-items: center;
  font-size: 13px; font-weight: 600;
}

.voice-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .voice-body { grid-template-columns: 1fr; } }

.script-box {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 15px;
}
.script-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--accent-2); font-weight: 600; margin-bottom: 9px;
}
#refScript { font-size: 14px; color: #cfd6e4; line-height: 1.65; }

.rec-panel { display: flex; flex-direction: column; gap: 12px; }
.rec-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
  border: none; border-radius: 10px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 11px 17px; transition: all 0.16s ease;
  display: inline-flex; align-items: center; gap: 9px;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-rec { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); }
.btn-rec:hover:not(:disabled) { border-color: var(--danger); }
.btn-rec.recording { background: rgba(255,92,114,0.14); border-color: var(--danger); color: #ffb3bd; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.btn-rec.recording .rec-dot { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.15; } }

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #8b6ef0 100%);
  color: #fff; font-weight: 600;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--dim); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

.timer { font-family: 'JetBrains Mono', monospace; font-size: 15px; color: var(--dim); }

.meter-wrap {
  height: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
}
.meter {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--warn), var(--danger));
  transition: width 0.07s linear;
}
.meter-hint { font-size: 11.5px; color: var(--dim); }
.meter-hint.bad { color: var(--danger); }
.meter-hint.good { color: var(--accent-2); }

.input, .textarea {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: 14px;
  width: 100%; outline: none; transition: border-color 0.16s;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.input { flex: 1; min-width: 150px; }
.input.wide { margin-bottom: 12px; }
.textarea { resize: vertical; line-height: 1.65; }

.hidden, .hidden-input { display: none; }
audio { width: 100%; height: 34px; }
audio.hidden { display: none; }

.msg { font-size: 13px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--accent-2); }

.voice-list { display: grid; gap: 10px; margin-top: 18px; }
.voice-card {
  display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 12px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 14px; cursor: pointer;
  transition: border-color 0.16s;
}
.voice-card:hover { border-color: #3a4356; }
.voice-card.selected { border-color: var(--accent); background: rgba(108,92,231,0.09); }
.voice-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.voice-main strong { font-size: 14px; }
.voice-meta { font-size: 11.5px; color: var(--dim); font-family: 'JetBrains Mono', monospace; }
.btn-del {
  background: none; border: none; color: var(--dim); cursor: pointer;
  font-size: 15px; padding: 5px 8px; border-radius: 7px;
}
.btn-del:hover { color: var(--danger); background: rgba(255,92,114,0.1); }
.empty { color: var(--dim); font-size: 13px; padding: 14px; text-align: center; }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.counter { font-size: 12px; color: var(--dim); font-family: 'JetBrains Mono', monospace; }

.job-list { display: grid; gap: 11px; }
.job {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 14px 16px;
}
.job-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 9px; }
.job-title { font-size: 14px; font-weight: 500; }
.badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.07em;
  padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.badge.queued  { background: rgba(139,149,168,0.16); color: var(--dim); }
.badge.running { background: rgba(255,180,84,0.16); color: var(--warn); }
.badge.done    { background: rgba(0,210,168,0.16); color: var(--accent-2); }
.badge.error   { background: rgba(255,92,114,0.16); color: var(--danger); }

.bar { height: 6px; background: #0b0e14; border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.4s ease;
}
.job-meta {
  font-size: 11.5px; color: var(--dim); margin-top: 7px;
  font-family: 'JetBrains Mono', monospace;
}
.job-err { font-size: 12.5px; color: var(--danger); margin-top: 7px; }
.job audio { margin-top: 11px; }

footer {
  text-align: center; padding: 26px; color: #5a6478; font-size: 12px;
  border-top: 1px solid var(--line);
}
