/* Voice Studio — Broadband Solutions demo
   Palette: navy #0F172A, slate #334155, CTA #0369A1, bg #F8FAFC, text #020617
   Type: Plus Jakarta Sans */

:root {
  --navy: #0F172A;
  --navy-800: #1E293B;
  --slate: #334155;
  --slate-500: #64748B;
  --slate-600: #475569;
  --cta: #0369A1;
  --cta-hover: #075985;
  --accent: #38BDF8;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #020617;
  --error: #B91C1C;
  --success: #15803D;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 4px 16px rgb(15 23 42 / 0.06);
  --focus-ring: 0 0 0 3px rgb(56 189 248 / 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* beat any display rule on hidden elements */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

h1, h2 { margin: 0; line-height: 1.25; }
p { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

:is(a, button, input, select, textarea, audio):focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-text { font-weight: 800; letter-spacing: -0.01em; font-size: 1.05rem; }
.brand-lg .brand-text { font-size: 1.5rem; }

.brand-mark {
  display: inline-flex; align-items: flex-end; gap: 3px;
  height: 26px; padding: 5px 6px;
  background: var(--navy); border-radius: 7px;
}
.brand-mark span {
  width: 3px; border-radius: 2px; background: var(--accent);
  animation: bar-idle 2.4s ease-in-out infinite;
}
.brand-mark span:nth-child(1) { height: 7px;  animation-delay: 0s; }
.brand-mark span:nth-child(2) { height: 12px; animation-delay: .18s; }
.brand-mark span:nth-child(3) { height: 16px; animation-delay: .36s; }
.brand-mark span:nth-child(4) { height: 10px; animation-delay: .54s; }
.brand-mark span:nth-child(5) { height: 7px;  animation-delay: .72s; }
@keyframes bar-idle { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.55); } }
@media (prefers-reduced-motion: reduce) {
  .brand-mark span, .spinner { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

/* ---------- Gate ---------- */
.gate {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgb(3 105 161 / 0.35), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgb(56 189 248 / 0.12), transparent 55%),
    var(--navy);
}
.gate-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  padding: 40px 36px 28px; text-align: center;
}
.gate-card .brand { justify-content: center; width: 100%; }
.gate-sub { color: var(--slate-600); margin: 10px 0 28px; }
.gate-row { display: flex; gap: 8px; }
.gate-row input {
  flex: 1; min-width: 0; padding: 12px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg);
  transition: border-color 0.2s;
}
.gate-row input:focus { border-color: var(--cta); }
.gate-row .btn { padding: 12px 16px; }
.gate-error { color: var(--error); font-size: 0.875rem; margin-top: 10px; font-weight: 600; }
.gate-fine { color: var(--slate-500); font-size: 0.75rem; margin-top: 28px; }

.gate-card.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  50% { transform: translateX(8px); }
  75% { transform: translateX(-4px); }
}

/* ---------- Layout ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; }
.topbar .brand-text { color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-tag { color: rgb(255 255 255 / 0.65); font-size: 0.8rem; }

.main { max-width: 1200px; margin: 0 auto; padding: 40px 24px 64px; }
.intro { margin-bottom: 28px; max-width: 640px; }
.intro h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; letter-spacing: -0.02em; }
.intro p { color: var(--slate-600); margin-top: 8px; }

.grid {
  display: grid; gap: 20px;
  grid-template-columns: 1fr;
}
.grid > * { min-width: 0; }
@media (min-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .card-generate { grid-column: 1 / -1; }
}
@media (min-width: 1180px) {
  .grid { grid-template-columns: 5fr 7fr 4fr; }
  .card-generate { grid-column: auto; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.card-head h2 { font-size: 1.05rem; font-weight: 700; }
.step-num {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  background: var(--navy); color: var(--accent);
  border-radius: 8px; font-size: 0.8rem; font-weight: 700;
}

.field-label {
  display: block; font-size: 0.8rem; font-weight: 600; color: var(--slate-600);
  margin-bottom: 6px; text-align: left;
}

/* ---------- Script card ---------- */
#script {
  width: 100%; resize: vertical; min-height: 150px;
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); line-height: 1.6;
  transition: border-color 0.2s;
}
#script:focus { border-color: var(--cta); }
.script-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; font-size: 0.8rem; color: var(--slate-500);
}
.link-btn {
  background: none; border: none; padding: 4px; color: var(--cta);
  font-size: 0.8rem; font-weight: 600; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--cta-hover); }

/* ---------- Voice card ---------- */
.voice-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1 1 160px; min-width: 140px; }
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--slate-500); pointer-events: none;
}
#voiceSearch {
  width: 100%; padding: 9px 12px 9px 32px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  transition: border-color 0.2s;
}
#voiceSearch:focus { border-color: var(--cta); }
#langFilter {
  max-width: 100%;
  padding: 9px 30px 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.chip-group { display: flex; gap: 6px; }
.chip {
  padding: 8px 14px; border: 1.5px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--slate-600); font-size: 0.8rem; font-weight: 600;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { border-color: var(--cta); color: var(--cta); }
.chip.is-active { background: var(--navy); border-color: var(--navy); color: #fff; }

.voice-list {
  overflow-y: auto; max-height: 380px; min-height: 120px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
}
.voice-loading, .voice-empty {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 36px 16px; color: var(--slate-500); font-size: 0.9rem;
}

.voice-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface); cursor: pointer; text-align: left;
  border-left: 3px solid transparent; width: 100%;
  border-top: none; border-right: none;
  transition: background-color 0.15s, border-left-color 0.15s;
}
.voice-row:last-child { border-bottom: none; }
.voice-row:hover { background: var(--bg); }
.voice-row.is-selected { background: #EFF8FF; border-left-color: var(--cta); }

.voice-info { flex: 1; min-width: 0; }
.voice-name { font-weight: 700; font-size: 0.92rem; display: flex; align-items: center; gap: 8px; }
.voice-tags { color: var(--slate-500); font-size: 0.78rem; margin-top: 1px; }
.voice-check { color: var(--cta); flex: none; visibility: hidden; }
.voice-row.is-selected .voice-check { visibility: visible; }

.preview-btn {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--navy);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.preview-btn:hover { border-color: var(--cta); color: var(--cta); }
.preview-btn.is-playing { background: var(--cta); border-color: var(--cta); color: #fff; }
.preview-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Generate card ---------- */
.summary {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; margin-bottom: 18px; background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.summary-row { display: flex; gap: 12px; font-size: 0.85rem; }
.summary-label { flex: none; width: 52px; color: var(--slate-500); font-weight: 600; }
.summary-value {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 12px 20px; font-weight: 700; font-size: 0.92rem;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}
.btn-primary { background: var(--cta); color: #fff; }
.btn-primary:hover { background: var(--cta-hover); }
.btn-primary:disabled { background: var(--border); color: var(--slate-500); cursor: not-allowed; }
.btn-ghost { background: transparent; color: rgb(255 255 255 / 0.85); padding: 8px 14px; }
.btn-ghost:hover { background: rgb(255 255 255 / 0.1); color: #fff; }
.btn-generate { width: 100%; padding: 14px 20px; }

.form-error { color: var(--error); font-size: 0.85rem; font-weight: 600; margin-top: 12px; }

.spinner {
  width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--cta);
  animation: spin 0.7s linear infinite;
}
.spinner-light { border-color: rgb(255 255 255 / 0.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.result {
  margin-top: 18px; border: 1px solid #BBE5CB; background: #F0FDF4;
  border-radius: var(--radius-sm); padding: 16px;
}
.result-head {
  display: flex; align-items: center; gap: 8px;
  color: var(--success); font-weight: 700; font-size: 0.92rem; margin-bottom: 12px;
}
.badge {
  background: #DCFCE7; color: var(--success); border-radius: 999px;
  font-size: 0.72rem; padding: 2px 10px; font-weight: 700;
}
.result audio { width: 100%; }
.result-actions {
  display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap;
}
.result-meta { color: var(--slate-600); font-size: 0.78rem; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border); padding: 20px 24px 32px;
  text-align: center; color: var(--slate-500); font-size: 0.78rem;
}

/* ---------- Format + advanced settings (step 3) ---------- */
.format-select {
  width: 100%; padding: 10px 30px 10px 12px; margin-bottom: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.advanced { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.advanced summary {
  padding: 10px 14px; cursor: pointer; font-size: 0.85rem; font-weight: 700;
  color: var(--slate-600); user-select: none;
}
.advanced summary:hover { color: var(--cta); }
.advanced[open] summary { border-bottom: 1px solid var(--border); }
.advanced-hint { padding: 10px 14px 0; font-size: 0.78rem; color: var(--slate-500); }
.slider-row { display: block; padding: 10px 14px 2px; }
.slider-label {
  display: flex; justify-content: space-between; font-size: 0.8rem;
  font-weight: 600; color: var(--slate-600); margin-bottom: 4px;
}
.slider-label output { font-variant-numeric: tabular-nums; color: var(--text); }
.slider-row input[type="range"] { width: 100%; accent-color: var(--cta); cursor: pointer; }
.check-row {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-size: 0.85rem; font-weight: 600; color: var(--slate-600); cursor: pointer;
}
.check-row input { accent-color: var(--cta); width: 16px; height: 16px; cursor: pointer; }
.advanced .link-btn { margin: 0 14px 12px; }
.result-note { font-size: 0.8rem; color: var(--slate-600); margin-bottom: 10px; }

/* ---------- Developer section ---------- */
.dev-card { margin-top: 24px; }
.dev-card .step-num svg { display: block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 16px; background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 0.88rem; font-weight: 700; color: var(--slate-500);
  transition: color 0.2s, border-color 0.2s; margin-bottom: -1px;
}
.tab:hover { color: var(--cta); }
.tab.is-active { color: var(--navy); border-bottom-color: var(--cta); }
.tab-panel { font-size: 0.9rem; }
.tab-panel > p { margin-bottom: 14px; color: var(--slate-600); max-width: 75ch; }
.tab-panel h3 { font-size: 0.95rem; font-weight: 700; margin: 20px 0 10px; }
.tab-panel code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.82em;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
}
.code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.78rem; line-height: 1.6;
  background: var(--navy); color: #E2E8F0; border-radius: var(--radius-sm);
  padding: 14px 16px; overflow-x: auto; white-space: pre; margin: 0 0 6px;
}
.table-wrap { overflow-x: auto; }
.ref-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ref-table th, .ref-table td {
  text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top;
}
.ref-table th { color: var(--slate-500); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ref-table td:first-child { white-space: nowrap; }

.sandbox-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
#sandboxEndpoint {
  flex: 1 1 220px; max-width: 320px; padding: 10px 30px 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); cursor: pointer; appearance: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.85rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.code-input {
  width: 100%; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.8rem;
  line-height: 1.6; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg); resize: vertical;
}
.code-input:focus { border-color: var(--cta); }
.sandbox-status { font-weight: 700; font-size: 0.85rem; margin: 14px 0 8px; }
.sandbox-status.ok { color: var(--success); }
.sandbox-status.err { color: var(--error); }
#sandboxResponse { max-height: 420px; overflow: auto; }
.schema-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; }
.schema-note { font-size: 0.8rem; color: var(--slate-500); }

/* ---------- Setting hints ---------- */
.slider-hint {
  font-size: 0.75rem; line-height: 1.5; color: var(--slate-500);
  margin: 4px 0 2px;
}
.check-hint { padding: 0 14px 4px; margin-top: -6px; }
.slider-row .slider-label { cursor: default; }
