:root {
  --bg: #0b0c10;
  --panel: #12141a;
  --card: #171a21;
  --card-2: #1d2029;
  --line: #262a35;
  --line-2: #323745;
  --text: #e9ebf1;
  --muted: #9298a8;
  --faint: #636a7b;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, .14);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Naskh Arabic", Tahoma, sans-serif;
  --mono: "Cascadia Code", Consolas, "SFMono-Regular", ui-monospace, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f8; --panel: #ffffff; --card: #ffffff; --card-2: #f6f7fa; --line: #e4e6ec; --line-2: #d5d8e0;
    --text: #151821; --muted: #5d6475; --faint: #8b91a1; --accent-soft: rgba(124, 92, 255, .1);
    --shadow: 0 10px 30px rgba(20, 24, 40, .08); color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: var(--accent-2); text-decoration: none; }
code, kbd { font-family: var(--mono); font-size: 12.5px; background: var(--card-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
[hidden] { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.02em; padding: 4px 10px 22px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { display: flex; align-items: center; gap: 11px; color: var(--muted); padding: 9px 12px; border-radius: var(--radius-sm); font-weight: 500; transition: background .15s, color .15s; }
nav a:hover { background: var(--card-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--text); }
nav a.active svg { color: var(--accent); }
.badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }
.badge.new { background: var(--ok); color: #05281b; }
.side-foot { margin-top: auto; padding: 10px 12px; color: var(--faint); font-size: 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.side-foot .ver { width: 100%; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .15); }
.dot.bad { background: var(--err); }
main { padding: 28px 34px 120px; min-width: 0; max-width: 1500px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 4px 0 0; }
.head-actions { display: flex; gap: 8px; }

/* cards & controls */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.link { font-size: 13px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.mono { font-family: var(--mono); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; color: var(--text); background: var(--card-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 9px 15px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #6a4cf0); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card-2); }
.btn.danger { color: var(--err); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--card-2); color: var(--text); border-color: var(--line); }
.icon-btn.on { color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.filters { display: flex; gap: 10px; margin-bottom: 14px; max-width: 640px; }
.filters select { max-width: 180px; }

/* studio */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 18px; margin-bottom: 18px; }
.script-card { display: flex; flex-direction: column; gap: 12px; min-height: 520px; }
.title-input { font-size: 16px; font-weight: 600; background: transparent; border-color: transparent; padding-left: 4px; }
.title-input:focus { background: var(--card-2); }
#script { flex: 1; min-height: 380px; font-size: 15.5px; line-height: 1.75; background: transparent; border-color: var(--line); padding: 16px; }
.script-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; }
.stats span:empty { display: none; }
.stats span + span::before { content: "·"; margin-right: 14px; color: var(--faint); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.seg button.active[data-mode="quality"] { color: var(--accent); }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--faint); border: 1px solid var(--line-2); border-radius: 5px; padding: 0 5px; line-height: 16px; align-self: center; }
.tag.fast { color: var(--warn); border-color: rgba(251,191,36,.35); }
.voice-card { display: flex; flex-direction: column; gap: 12px; max-height: 640px; }
.voice-head { display: flex; justify-content: space-between; align-items: center; }
.voice-filters { display: grid; gap: 8px; }
.voice-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; margin: 0 -6px; padding: 0 6px; flex: 1; }
.voice { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 11px; border: 1px solid transparent; cursor: pointer; transition: background .12s, border-color .12s; }
.voice:hover { background: var(--card-2); }
.voice.sel { background: var(--accent-soft); border-color: rgba(124, 92, 255, .45); }
.orb { width: 36px; height: 36px; border-radius: 50%; flex: none; box-shadow: inset 0 0 12px rgba(0,0,0,.35); }
.voice-main { min-width: 0; flex: 1; }
.voice-name { font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.voice-meta { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.new { background: rgba(52, 211, 153, .12); color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.pill.fav { color: #f472b6; }
.empty { color: var(--muted); text-align: center; padding: 30px 12px; }
.empty b { color: var(--text); }

/* jobs */
.job-list { display: flex; flex-direction: column; }
.job-list.card { padding: 6px 18px; }
.job { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--card-2); color: var(--muted); }
.job-icon.done { color: var(--ok); }
.job-icon.failed { color: var(--err); }
.job-icon.running, .job-icon.queued { color: var(--accent); }
.job-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { color: var(--faint); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.job-msg { font-size: 12.5px; color: var(--err); margin-top: 3px; }
.job-actions { display: flex; gap: 2px; align-items: center; }
.bar { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 7px; max-width: 520px; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .3s ease; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* voices page */
.voice-group { margin-bottom: 26px; }
.voice-group h2 { margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.voice-tile { display: flex; gap: 12px; align-items: flex-start; }
.voice-tile .voice-main { display: flex; flex-direction: column; gap: 4px; }
.voice-desc { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.voice-tile .row { margin-top: 4px; gap: 6px; }

/* accounts */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; margin-bottom: 18px; }
.acct { display: flex; flex-direction: column; gap: 12px; }
.acct-top { display: flex; gap: 12px; align-items: center; }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); flex: none; }
.acct-name { font-weight: 650; font-size: 15px; }
.acct-email { color: var(--faint); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv div { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kv b { display: block; font-size: 15px; }
.kv span { color: var(--faint); font-size: 11.5px; }
.status-line { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.status-line.err { color: var(--err); }
.acct-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.add-account { max-width: 860px; }
.add-account > h2 { margin-bottom: 12px; }
.tabs { display: flex; gap: 4px; background: var(--card-2); border: 1px solid var(--line); border-radius: 11px; padding: 4px; width: fit-content; margin-bottom: 14px; }
.tab { font: inherit; font-weight: 600; color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.tab-body p { color: var(--muted); margin: 0 0 12px; }
.tab-body > input { margin-bottom: 10px; }
#import-login { min-height: 90px; }
.steps { color: var(--muted); padding-left: 20px; margin: 0 0 14px; display: grid; gap: 8px; }
.steps b { color: var(--text); }
.snippet { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.snippet code { flex: 1; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 7px 10px; }
.notice { margin-top: 12px; padding: 11px 14px; border-radius: 10px; background: var(--accent-soft); border: 1px solid rgba(124,92,255,.35); display: flex; gap: 10px; align-items: center; }
.notice.ok { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.35); }
.notice.err { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.35); }

/* settings */
.settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.settings .card h2 { margin-bottom: 14px; }
.field { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; }
.field label { font-weight: 600; font-size: 13px; }
.field .help { grid-column: 1 / -1; color: var(--faint); font-size: 12px; margin-top: -2px; }
.field input[type=checkbox] { width: 18px; height: 18px; justify-self: start; accent-color: var(--accent); }

/* player, toasts, modal */
.player { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow); padding: 10px 12px 10px 18px; display: flex; align-items: center; gap: 14px; z-index: 20; }
.player-info { min-width: 0; width: 220px; }
.player-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player audio { flex: 1; height: 38px; min-width: 0; }
.toasts { position: fixed; top: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s ease; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 60; }
.modal-box { background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; width: min(520px, calc(100vw - 32px)); }
.modal-box p { color: var(--muted); }

@media (max-width: 1100px) { .studio { grid-template-columns: 1fr; } .voice-card { max-height: 460px; } }

/* playing state */
.icon-btn.play.on, .btn.play.on { color: var(--accent); }
.btn.play.on { border-color: rgba(124, 92, 255, .5); background: var(--accent-soft); }
.job.playing .job-title, .voice.playing .voice-name, .voice-tile.playing .voice-name { color: var(--accent); }
.voice-tile.playing { border-color: rgba(124, 92, 255, .45); }

/* dialogs */
.modal-box h2 { font-size: 17px; margin-bottom: 8px; }
.modal-box p { margin: 0 0 6px; line-height: 1.55; }
.modal-box .row.end { margin-top: 18px; flex-wrap: wrap; }
#dlg-input { margin-top: 8px; }
.modal-box .btn.danger { border-color: rgba(248, 113, 113, .45); }

/* voices: favourites, hidden, rename */
.icon-btn.fav-on, .btn.fav-on { color: #f472b6; }
.btn.fav-on { border-color: rgba(244, 114, 182, .45); }
.icon-btn.on#btn-fav-only { color: #f472b6; background: rgba(244, 114, 182, .12); }
.voice-tile.is-hidden { opacity: .6; }
.row.wrap { flex-wrap: wrap; }
.hint { margin: -6px 0 16px; font-size: 12.5px; }
label.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); white-space: nowrap; cursor: pointer; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }
#script.drop { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--accent-soft); }

/* server page */
.server-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.server-grid .card { display: flex; flex-direction: column; gap: 10px; }
.server-grid .card .row.end { margin-top: auto; }
.server-grid .card-head { margin-bottom: 0; }
.kv.kv-4 { grid-template-columns: repeat(4, 1fr); }
.kv b.ok { color: var(--ok); } .kv b.err { color: var(--err); } .kv b.warn { color: var(--warn); }
.status-line.ok { color: var(--ok); }
.status-line svg, .rm-log svg { width: 15px; height: 15px; flex: none; }
.pill.ok { color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.pill.err { color: var(--err); border-color: rgba(248, 113, 113, .3); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, .3); }
.checks { display: grid; gap: 6px; }
.checks label { display: flex; gap: 9px; align-items: center; padding: 7px 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.checks input { width: 16px; height: 16px; accent-color: var(--accent); }
.checks small { color: var(--faint); margin-left: auto; }
.rm-files { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.rm-files div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rm-log { display: grid; gap: 4px; font-size: 12.5px; max-height: 320px; overflow: auto; }
.rm-log div { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); }
.rm-log div.ok { color: var(--text); } .rm-log div.ok svg { color: var(--ok); }
.rm-log div.err { color: var(--err); }
.rm-log time { color: var(--faint); font-family: var(--mono); font-size: 11.5px; flex: none; padding-top: 1px; }
.side-foot .machine { width: 100%; color: var(--faint); }
@media (max-width: 720px) { .server-grid { grid-template-columns: 1fr; } .kv.kv-4 { grid-template-columns: repeat(2, 1fr); } }
nav a .dot { margin-left: auto; }
.pill:empty { display: none; }

/* sign-in page (public side) */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: min(380px, 100%); display: grid; gap: 10px; padding: 26px; }
.login-box .brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.login-box form { display: grid; gap: 8px; margin-top: 8px; }
.login-box label { font-weight: 600; font-size: 13px; margin-top: 6px; }
.login-box .btn { margin-top: 10px; justify-content: center; }
.login-box .notice { margin-top: 6px; }

/* access page */
.secret { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.secret code { flex: 1; overflow-wrap: anywhere; padding: 8px 10px; font-size: 12.5px; }
.list-rows { display: grid; gap: 6px; margin: 8px 0 12px; }
.list-rows > div { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; }
.list-rows .grow { flex: 1; min-width: 0; }
.list-rows small { color: var(--faint); display: block; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row input { flex: 1; min-width: 140px; }
.form-row input.num { flex: 0 0 120px; min-width: 0; }
#btn-signout[hidden] { display: none; }
nav a[hidden] { display: none; }

/* API guide */
.guide { display: grid; gap: 14px; }
.guide h2 { margin-bottom: 10px; }
.guide h3 { font-size: 13.5px; margin: 16px 0 8px; }
.guide-list { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 7px; color: var(--muted); }
.guide-list b { color: var(--text); }
.kv.kv-guide { grid-template-columns: 2fr 2fr 1fr; }
.kv.kv-guide b { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.guide-tabs { margin: 14px 0 10px; display: inline-flex; flex-wrap: wrap; }
.code-block { position: relative; }
.code-block pre { margin: 0; background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; overflow: auto; max-height: 520px; }
.code-block code { background: none; border: 0; padding: 0; font-size: 12.5px; line-height: 1.55; white-space: pre; display: block; }
.code-block > .btn { position: absolute; top: 8px; right: 8px; z-index: 1; }
.table-wrap { overflow-x: auto; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.guide-table th { text-align: left; color: var(--faint); font-weight: 600; font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.guide-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--muted); }
.guide-table td:first-child { white-space: nowrap; color: var(--text); }
.guide-table tr:last-child td { border-bottom: 0; }
@media (max-width: 720px) { .kv.kv-guide { grid-template-columns: 1fr; } .guide-table td:first-child { white-space: normal; } }

/* forms with labels (Access page): one consistent pattern */
.stack { display: grid; gap: 14px; max-width: 1100px; }
.facts { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; margin: 4px 0 0; font-size: 13.5px; }
.facts dt { color: var(--faint); font-weight: 600; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.facts dd.err { color: var(--err); }
.form-box { margin-top: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card-2); }
.form-box h3 { margin: 0 0 12px; font-size: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-key { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
.form-field { display: grid; gap: 6px; align-content: start; }
.form-field label { font-weight: 600; font-size: 13px; }
.form-field input { width: 100%; }
.form-field input[readonly] { opacity: .7; }
.form-field small { color: var(--faint); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.list-rows .empty-row { color: var(--faint); justify-content: center; }
.secret-box { display: grid; gap: 8px; width: 100%; }
.secret-box small { color: var(--muted); }
.secret-box .form-actions { margin-top: 4px; }
#btn-ac-user-cancel[hidden] { display: none; }
@media (max-width: 760px) {
  .form-grid.cols-3, .form-grid.cols-key { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 8px; }
  .list-rows > div { flex-wrap: wrap; }
}

/* new voice (voice design) */
.design { margin-bottom: 16px; }
.design textarea { min-height: 70px; }
.design .form-field.narrow { max-width: 200px; }
.ds-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.ds-preview { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.ds-preview.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.ds-preview input { accent-color: var(--accent); }
.ds-preview .grow { flex: 1; min-width: 0; }
.ds-preview small { display: block; color: var(--faint); }
.ds-preview .orb { width: 34px; height: 34px; }
#design[hidden], #ds-pick[hidden], #ds-slots[hidden], #ds-account-field[hidden] { display: none; }
#ds-done[hidden] { display: none; }
.ds-note { margin: -4px 0 12px; font-size: 12.5px; }
.notice.ds-slots { margin: 4px 0 12px; font-size: 13px; }
#ds-slots[hidden] { display: none; }
#ds-save-as { margin: 0 0 4px; }

/* search boxes: detect browser autofill (cleared by app.js) and hide the browser's own clear icon */
@keyframes svAutofill { from { opacity: 1; } to { opacity: 1; } }
input[data-filter]:-webkit-autofill { animation: svAutofill 1ms; }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.empty .btn { margin-left: 8px; }

/* =====================================================================
   Responsive layout (phones and tablets). Kept last so it wins.
   Rule of thumb: nothing may make the page wider than the screen —
   long code scrolls inside its own box, grids never ask for more than 100%.
   ===================================================================== */
.menu-btn { display: none; }
.view > *, .guide, .stack, .studio > *, .steps > li, .card { min-width: 0; }
.guide, .stack { grid-template-columns: minmax(0, 1fr); }
.voice-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.accounts { grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.settings { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.server-grid { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.ds-previews { grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
/* one-line snippets: scroll inside the box instead of widening the page */
.snippet { min-width: 0; }
.snippet code { flex: 1 1 0; min-width: 0; overflow-x: auto; text-overflow: clip; scrollbar-width: thin; }
.snippet .btn { flex: none; }
.filters { flex-wrap: wrap; }
.filters input { flex: 1 1 220px; min-width: 0; }
.head > div:first-child { min-width: 0; }
.head-actions { flex-wrap: wrap; }

/* tablets */
@media (max-width: 1100px) {
  main { padding: 24px 22px 120px; }
}

/* phones */
@media (max-width: 760px) {
  .app { display: block; }
  /* top bar with a menu button; the menu drops down under it */
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: column; align-items: stretch; padding: 8px 14px; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .brand { padding: 0; justify-content: flex-start; gap: 10px; min-height: 40px; }
  .menu-btn { display: inline-grid; margin-left: auto; width: 40px; height: 40px; }
  .menu-btn svg { width: 20px; height: 20px; }
  .sidebar nav, .sidebar .side-foot { display: none; }
  .sidebar.open nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 0 4px; }
  .sidebar.open nav a { padding: 12px 12px; font-size: 15px; }
  .sidebar.open .side-foot { display: flex; padding: 8px 12px 10px; border-top: 1px solid var(--line); margin-top: 4px; }
  .sidebar.open .side-foot .machine { width: auto; }

  main { padding: 16px 14px 150px; }
  .head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .head h1 { font-size: 24px; }
  .head-actions { justify-content: flex-start; }
  .card { padding: 14px; }

  /* Studio */
  .studio { grid-template-columns: 1fr; gap: 14px; }
  .script-card { min-height: 0; }
  .script-card textarea { min-height: 240px; }
  .script-foot { flex-direction: column; align-items: stretch; }
  .actions { justify-content: space-between; }
  .actions .seg { flex: 1 1 100%; }
  .actions .seg button { flex: 1; }
  .actions #btn-generate { flex: 1 1 auto; justify-content: center; }
  .voice-card { max-height: 520px; }

  /* History and Recent: actions go under the title */
  .job { grid-template-columns: 34px minmax(0, 1fr); gap: 6px 12px; }
  .job-actions { grid-column: 2; flex-wrap: wrap; gap: 4px; }
  .job-actions .icon-btn { width: 36px; height: 36px; }
  .job-list.card { padding: 4px 14px; }

  /* Settings: label above the input */
  .field { grid-template-columns: 1fr; gap: 6px; }
  .settings { grid-template-columns: 1fr; }

  /* Accounts, Access, Server */
  .accounts, .server-grid { grid-template-columns: 1fr; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 6px; }
  .acct-actions .btn, .list-rows .btn { flex: 1 1 auto; justify-content: center; }
  .facts { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; }
  .notice { align-items: flex-start; }

  /* API guide */
  .guide-tabs { display: flex; width: 100%; }
  .guide-tabs button { flex: 1 1 auto; }
  .code-block pre { padding: 12px; max-height: 420px; }
  .code-block code { font-size: 12px; }

  /* player: title on top, controls full width */
  .player { bottom: 8px; width: calc(100vw - 16px); flex-wrap: wrap; gap: 6px 10px; padding: 10px 10px 8px 14px; border-radius: 14px; }
  .player-info { width: auto; flex: 1 1 0; }
  .player audio { order: 3; flex: 1 1 100%; height: 36px; }

  .toasts { left: 10px; right: 10px; top: 64px; }
  .toast { max-width: none; }
  .modal-box { padding: 18px; }
  .modal-box .row.end .btn { flex: 1 1 auto; justify-content: center; }

  /* 16px text in fields stops phones from zooming in when typing */
  input, select, textarea { font-size: 16px; }
}

/* long words (paths, URLs, errors) wrap instead of widening the page */
.toast, .sub code, .head code, .notice, .status-line, .job-msg, .help, .form-field small { overflow-wrap: anywhere; }
.sub code, .head code { word-break: break-all; }
/* safety net: the page itself never scrolls sideways (boxes that need it scroll inside) */
html, body { overflow-x: clip; }

/* code examples: the Copy button sits above the code, never on top of it */
.code-block { display: flex; flex-direction: column; gap: 6px; }
.code-block > .btn { position: static; align-self: flex-end; }
.settings-foot { margin-top: 14px; max-width: 100%; }
