:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #10151d;
  --panel-soft: #151c26;
  --line: #273140;
  --text: #f4f6f8;
  --muted: #91a0b3;
  --accent: #55e6a5;
  --accent-blue: #66b6ff;
  --danger: #ff7b72;
  --warning: #ffc857;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% 0%, rgba(102, 182, 255, .12), transparent 34rem),
    radial-gradient(circle at 5% 25%, rgba(85, 230, 165, .08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell { width: min(1060px, calc(100% - 32px)); margin: 0 auto; padding: 72px 0 96px; }
.hero { max-width: 760px; margin-bottom: 36px; }
.eyebrow, .step { color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .16em; }
.hero h1 { margin: 12px 0 10px; font-size: clamp(2.7rem, 8vw, 5.8rem); line-height: .92; letter-spacing: -.065em; }
.hero > p { max-width: 650px; color: var(--muted); font-size: 1.1rem; line-height: 1.6; }
.runtime-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .83rem; }
.runtime-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 12px currentColor; }
.runtime-status.ready::before { background: var(--accent); }
.runtime-status.error::before { background: var(--danger); }

.panel { background: linear-gradient(145deg, rgba(21, 28, 38, .98), rgba(14, 19, 27, .98)); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.input-panel { padding: clamp(20px, 4vw, 36px); }
form { display: grid; gap: 22px; }
.phrase-library, .word-library { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.phrase-library label, .word-library label { display: grid; gap: 9px; }
.phrase-library label > span, .word-library label > span, .recording-panel > div > span { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 750; }
.phrase-library select, .word-library select { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 13px; background: #0b1017; color: var(--text); padding: 0 14px; font: inherit; outline: none; }
.phrase-library select:focus, .word-library select:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(102, 182, 255, .12); }
.word-library { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(102, 182, 255, .035); }
.score-card > span, .transcript-card > span { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 750; }
.model-field { display: grid; gap: 9px; }
.model-field > span { font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 750; }
.model-field select { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: 13px; background: #0b1017; color: var(--text); padding: 0 14px; font: inherit; outline: none; }
.model-field select:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px rgba(102, 182, 255, .12); }
.model-field small { color: var(--muted); }
audio { width: 100%; }
.recording-panel { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.02); }
.recording-panel > div:first-child { display: grid; gap: 7px; }
.recording-panel small { color: var(--muted); }
.recording-actions { display: flex; align-items: center; gap: 10px; }
.recording-actions button, .phrase-library button, .word-library button { width: auto; padding: 0 18px; white-space: nowrap; }
.recording-actions strong { min-width: 62px; color: var(--accent-blue); font-variant-numeric: tabular-nums; }
.record-button.recording { background: var(--danger); color: #250705; }
.outline-button { background: transparent; color: var(--accent-blue); border: 1px solid var(--accent-blue); }
button { height: 54px; border: 0; border-radius: 13px; background: var(--accent); color: #071a12; font-weight: 850; font-size: .95rem; cursor: pointer; transition: .2s ease; }
button:hover { filter: brightness(1.07); transform: translateY(-1px); }
button:disabled { opacity: .65; cursor: wait; transform: none; }
.spinner { display: none; width: 18px; height: 18px; border: 2px solid rgba(0,0,0,.25); border-top-color: #071a12; border-radius: 50%; animation: spin .7s linear infinite; }
button.loading .button-label { display: none; }
button.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-message { min-height: 1.2em; color: var(--danger); margin: -8px 0 0; font-size: .9rem; }

.results { display: grid; gap: 20px; margin-top: 26px; }
.summary-grid { display: grid; grid-template-columns: .75fr 1.25fr; gap: 20px; }
.score-card, .transcript-card { padding: 28px; }
.score { margin: 16px 0 10px; display: flex; align-items: baseline; gap: 4px; }
.score strong { font-size: 3.5rem; letter-spacing: -.07em; }
.score small { color: var(--muted); }
.score-bar { height: 6px; overflow: hidden; background: #080b10; border-radius: 99px; }
.score-bar i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent-blue), var(--accent)); transition: width .7s ease; }
.score-card p { color: var(--muted); font-size: .75rem; line-height: 1.5; margin: 16px 0 0; }
blockquote { margin: 18px 0; font-size: clamp(1.35rem, 3vw, 2.1rem); line-height: 1.25; letter-spacing: -.025em; }
.transcript-word { padding: 0 .08em; border-radius: 5px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.transcript-word.warning { color: #ffd166; background: rgba(255, 209, 102, .12); }
.transcript-word.severe { color: #ff8b83; background: rgba(255, 123, 114, .16); }
.transcript-word.text-error { text-decoration: underline; text-decoration-thickness: 2px; }
.transcript-word.text-error.sustitucion { color: #ffb86b; background: rgba(255, 184, 107, .16); }
.transcript-word.text-error.insercion { color: #71d7ff; background: rgba(113, 215, 255, .14); }
.transcript-omission { display: inline-block; margin: 0 .22em; padding: .08em .28em; border: 1px solid rgba(199, 160, 255, .55); border-radius: 5px; color: #c7a0ff; background: rgba(199, 160, 255, .12); font-size: .58em; vertical-align: middle; letter-spacing: 0; }
.transcript-undetected { display: inline-block; margin: 0 .22em; padding: .08em .28em; border: 1px solid rgba(255, 184, 107, .55); border-radius: 5px; color: #ffb86b; background: rgba(255, 184, 107, .12); font-size: .58em; vertical-align: middle; letter-spacing: 0; }
.transcript-card small { color: var(--muted); }
.transcript-card .asr-model { display: block; margin-top: 7px; color: var(--accent-blue); }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); }
.metric-grid article { padding: 20px; display: grid; gap: 8px; border-right: 1px solid var(--line); }
.metric-grid article:last-child { border: 0; }
.metric-grid span { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-grid strong { font-size: 1.4rem; }
.result-section { padding: clamp(22px, 4vw, 34px); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-heading > div { display: flex; align-items: baseline; gap: 13px; }
h2 { margin: 0; font-size: 1.3rem; }
.section-heading p { color: var(--muted); margin: 0; font-size: .85rem; }
.collapsible-section > summary { cursor: pointer; list-style: none; }
.collapsible-section > summary::-webkit-details-marker { display: none; }
.collapsible-section > summary::after { content: "⌄"; color: var(--accent-blue); font-size: 1.4rem; line-height: 1; transition: transform .2s ease; }
.collapsible-section[open] > summary::after { transform: rotate(180deg); }
.error-list, .pronunciation-list { display: grid; gap: 10px; padding-top: 18px; }
.error-row { display: grid; grid-template-columns: 120px 1fr auto 1fr; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; background: rgba(255,255,255,.025); }
.error-type { color: var(--warning); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.error-row .arrow { color: var(--muted); }
.empty-state { color: var(--accent); padding: 22px 0 4px; }
.pronunciation-item { padding: 18px; border-radius: 13px; background: rgba(255,255,255,.025); }
.pronunciation-top { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.pronunciation-word { font-size: 1.15rem; font-weight: 800; }
.confidence { color: var(--muted); font-size: .8rem; }
.ipa { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); }
.ipa code, .phone-chip { padding: 6px 9px; background: #090e14; border: 1px solid var(--line); border-radius: 8px; color: var(--text); font-size: .88rem; }
.phone-details { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.phone-chip.bad { border-color: rgba(255, 123, 114, .5); color: #ffc1bc; }
.processing-time { display: flex; justify-content: flex-end; align-items: baseline; gap: 10px; padding: 4px 3px; color: var(--muted); font-size: .8rem; }
.processing-time strong { color: var(--text); font-size: 1rem; }
.transcript-processing-time { justify-content: flex-start; margin-top: 12px; padding: 0; }
.raw-panel { padding: 4px 22px; }
.raw-panel summary { cursor: pointer; padding: 18px 0; color: var(--muted); }
pre { max-height: 420px; overflow: auto; white-space: pre-wrap; color: #b8c7d9; font-size: .76rem; line-height: 1.55; }

@media (max-width: 720px) {
  .shell { padding-top: 42px; }
  .summary-grid, .metric-grid { grid-template-columns: 1fr; }
  .metric-grid article { border-right: 0; border-bottom: 1px solid var(--line); }
  .section-heading { align-items: start; flex-direction: column; }
  .error-row { grid-template-columns: 95px 1fr; }
  .error-row .arrow { display: none; }
  .phrase-library, .word-library, .recording-panel { grid-template-columns: 1fr; }
  .phrase-library button, .word-library button { width: 100%; }
  .recording-actions { flex-wrap: wrap; }
}
