:root {
    --bg: #070b16;
    --panel: rgba(17, 24, 43, 0.82);
    --panel-strong: #11192c;
    --line: rgba(255, 255, 255, 0.1);
    --text: #f7f9ff;
    --muted: #9aa7bf;
    --accent: #f9cb28;
    --accent-soft: rgba(249, 203, 40, 0.14);
    --green: #48d597;
    --red: #ff6e79;
    --blue: #79a8ff;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 8% 0%, rgba(71, 104, 255, 0.2), transparent 34rem),
        radial-gradient(circle at 95% 15%, rgba(249, 203, 40, 0.12), transparent 30rem),
        var(--bg);
    min-height: 100vh;
}
button, textarea, select, input { font: inherit; }
button { cursor: pointer; }
.page-shell { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 28px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 26px; }
.eyebrow { color: var(--accent); font-weight: 800; letter-spacing: .18em; font-size: 12px; }
h1 { margin: 7px 0 8px; font-size: clamp(28px, 4vw, 48px); line-height: 1.03; }
.topbar p, .api-panel p { color: var(--muted); margin: 0; line-height: 1.55; }
.runtime-card { min-width: 310px; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(12, 18, 34, .76); }
.runtime-card strong, .runtime-card small { display: block; }
.runtime-card small { color: var(--muted); margin-top: 3px; }
.status-dot { width: 12px; height: 12px; border-radius: 999px; background: #6f7890; box-shadow: 0 0 0 5px rgba(111,120,144,.12); flex: 0 0 auto; }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 5px rgba(72,213,151,.13); }
.status-dot.offline { background: var(--red); }
.grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(310px, .75fr); gap: 20px; }
.side-column { display: grid; gap: 20px; align-content: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.25); backdrop-filter: blur(18px); }
.main-panel { padding: 26px; }
.metrics-panel, .api-panel { padding: 22px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 16px; }
.section-heading > div { display: flex; align-items: center; gap: 11px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading.spaced { margin-top: 26px; }
.step { display: grid; place-items: center; min-width: 38px; height: 30px; padding: 0 8px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 900; letter-spacing: .08em; }
.small-note { color: var(--muted); font-size: 13px; }
.engine-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.engine-card { border: 1px solid var(--line); color: var(--text); background: rgba(7, 12, 25, .7); border-radius: 17px; padding: 15px; display: flex; text-align: left; align-items: center; gap: 12px; transition: .2s ease; }
.engine-card:hover { transform: translateY(-1px); border-color: rgba(249,203,40,.35); }
.engine-card.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(249,203,40,.15); }
.engine-card strong, .engine-card small { display: block; }
.engine-card small { color: var(--muted); margin-top: 3px; }
.engine-icon { width: 42px; height: 42px; border-radius: 13px; background: rgba(255,255,255,.08); display: grid; place-items: center; font-weight: 900; color: var(--accent); }
textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    color: var(--text);
    background: rgba(5, 10, 21, .82);
    border-radius: 15px;
    outline: none;
}
textarea { resize: vertical; padding: 17px; line-height: 1.55; min-height: 164px; }
textarea:focus, select:focus { border-color: rgba(249,203,40,.65); box-shadow: 0 0 0 4px rgba(249,203,40,.08); }
.controls-row { display: grid; grid-template-columns: 1.1fr .8fr .8fr; gap: 14px; margin-top: 16px; }
.field { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.field b { color: var(--text); float: right; }
.field select { min-height: 45px; padding: 0 12px; }
.field input[type="range"] { width: 100%; accent-color: var(--accent); }
.actions { display: flex; gap: 11px; margin-top: 22px; }
.primary-btn, .secondary-btn { border-radius: 13px; min-height: 47px; padding: 0 20px; font-weight: 800; }
.primary-btn { flex: 1; border: 0; background: linear-gradient(135deg, #f9cb28, #ffdf69); color: #171300; box-shadow: 0 12px 30px rgba(249,203,40,.18); }
.primary-btn:disabled { opacity: .55; cursor: progress; }
.secondary-btn { border: 1px solid var(--line); color: var(--text); background: rgba(255,255,255,.055); }
.secondary-btn.full { width: 100%; }
.notice { margin-top: 16px; color: var(--muted); padding: 12px 14px; border-left: 3px solid var(--blue); background: rgba(121,168,255,.07); border-radius: 7px 12px 12px 7px; line-height: 1.45; font-size: 13px; }
.notice.error { border-color: var(--red); background: rgba(255,110,121,.08); color: #ffc5ca; }
.notice.warning { border-color: var(--accent); color: #ffe9a1; }
.metric { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { text-align: right; font-size: 14px; }
.text-btn { border: 0; background: none; color: var(--accent); padding: 14px 0 0; font-weight: 800; }
.api-panel p { font-size: 13px; margin-bottom: 14px; }
pre { margin: 0 0 13px; padding: 14px; overflow: auto; border-radius: 13px; color: #dce6ff; background: #060a13; border: 1px solid var(--line); font-size: 11px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.api-warning { color: var(--muted); font-size: 12px; margin-top: 12px; line-height: 1.45; }
footer { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 12px; padding: 20px 4px 0; }
@media (max-width: 900px) {
    .topbar { flex-direction: column; }
    .runtime-card { width: 100%; min-width: 0; }
    .grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
    .page-shell { width: min(100% - 20px, 1240px); padding-top: 20px; }
    .main-panel, .metrics-panel, .api-panel { padding: 18px; border-radius: 20px; }
    .engine-grid, .controls-row { grid-template-columns: 1fr; }
    .actions { flex-direction: column; }
    .secondary-btn { width: 100%; }
    footer { flex-direction: column; }
}


.download-panel {
    margin-top: 16px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(5, 10, 21, .64);
}
.download-heading,
.download-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}
.download-heading strong,
.download-heading span {
    display: block;
}
.download-heading strong {
    font-size: 14px;
}
.download-heading span,
.download-meta {
    color: var(--muted);
    font-size: 12px;
}
.download-heading span {
    margin-top: 4px;
}
.download-heading b {
    color: var(--accent);
    font-size: 13px;
    white-space: nowrap;
}
.progress-track {
    width: 100%;
    height: 11px;
    margin: 13px 0 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
}
.progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f9cb28, #fff0a6);
    transition: width .16s ease;
}
.progress-bar.indeterminate {
    width: 38%;
    animation: model-progress 1.1s ease-in-out infinite;
}
.progress-bar.complete {
    width: 100%;
    background: linear-gradient(90deg, #48d597, #a7f3d0);
}
.progress-bar.failed {
    background: linear-gradient(90deg, #ff6e79, #ffb0b7);
}
@keyframes model-progress {
    from { transform: translateX(-120%); }
    to { transform: translateX(320%); }
}
.audio-result-panel {
    margin-top: 16px;
    padding: 15px;
    border: 1px solid rgba(72, 213, 151, .28);
    border-radius: 16px;
    background: rgba(72, 213, 151, .075);
}
.audio-result-panel > div {
    margin-bottom: 10px;
}
.audio-result-panel strong,
.audio-result-panel span {
    display: block;
}
.audio-result-panel span {
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}
.audio-result-panel audio {
    width: 100%;
}
.download-audio {
    display: inline-block;
    margin-top: 10px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}
.hidden {
    display: none !important;
}
.diagnostics-panel {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(5, 10, 21, .45);
}
.diagnostics-panel summary {
    cursor: pointer;
    color: var(--muted);
    padding: 11px 13px;
    font-size: 12px;
}
.diagnostics-panel pre {
    margin: 0 11px 11px;
    max-height: 220px;
}
