/* ============================================================
   IELTS Speaking Practice — adult / calm theme
   Contract: governance/VT-UX_IELTS_SPEAKING_DESIGN.md §1.
   Palette: surface #FAFAFB · card #FFFFFF · text #1F1F2E ·
            muted #6B6B7B · accent #4F46E5 · success #2E7D32 ·
            caution #B45309 · soft-ring #EEF2FF.
   Radius 10px · hairline borders · 150–300ms fades only.
   ============================================================ */

:root {
    --surface: #FAFAFB;
    --card: #FFFFFF;
    --text: #1F1F2E;
    --muted: #6B6B7B;
    --accent: #4F46E5;
    --accent-ink: #4338CA;
    --success: #2E7D32;
    --caution: #B45309;
    --soft-ring: #EEF2FF;
    --hairline: #E4E4EC;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(31, 31, 46, 0.05), 0 4px 14px rgba(31, 31, 46, 0.05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--surface);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── header ─────────────────────────────────────────────── */

.ielts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--hairline);
}

.ielts-brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
    color: var(--text);
}

.ielts-mode-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent-ink);
    background: var(--soft-ring);
    border: 1px solid #C7D2FE;
    border-radius: 999px;
    padding: 3px 10px;
}

/* ── layout ─────────────────────────────────────────────── */

.ielts-app {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    padding: 24px 16px 64px;
}

.avatar-stage {
    position: sticky;
    top: 20px;
    align-self: start;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#avatar-svg {
    width: 200px;
    height: 280px;
}

.avatar-name {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* ── screens ────────────────────────────────────────────── */

.screen { display: none; animation: fade-in 250ms ease; }

.screen.active { display: block; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.screen-title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.lead {
    margin: 0 0 22px;
    color: var(--muted);
    font-size: 16px;
}

.field-label {
    margin: 20px 0 10px;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--muted);
}

/* ── region + target selectors ──────────────────────────── */

.region-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.region-card {
    appearance: none;
    border: 1px solid var(--hairline);
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 12px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--text);
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.region-card:hover { border-color: #C7D2FE; }

.region-card.selected {
    border-color: var(--accent);
    background: var(--soft-ring);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.region-card-name { font-weight: 600; font-size: 14px; }

/* ── adaptation card ────────────────────────────────────── */

.adaptation-card {
    margin-top: 14px;
    border: 1px solid #C7D2FE;
    background: var(--soft-ring);
    border-radius: var(--radius);
    padding: 14px 16px;
    animation: fade-in 200ms ease;
}

.adaptation-intro { margin: 0 0 10px; font-size: 14px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    display: inline-block;
    font-size: 12.5px;
    color: var(--accent-ink);
    background: var(--card);
    border: 1px solid #C7D2FE;
    border-radius: 999px;
    padding: 4px 10px;
}

.target-selector { display: flex; gap: 10px; flex-wrap: wrap; }

.target-chip {
    appearance: none;
    border: 1px solid var(--hairline);
    background: var(--card);
    border-radius: 999px;
    padding: 10px 22px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    min-width: 72px;
    transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.target-chip:hover { border-color: #C7D2FE; }

.target-chip.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #FFFFFF;
}

/* ── buttons ────────────────────────────────────────────── */

.btn {
    appearance: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    min-height: 44px;
    transition: background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-ink); }

.btn-ghost {
    background: var(--card);
    color: var(--text);
    border-color: var(--hairline);
}

.btn-ghost:hover:not(:disabled) { border-color: #C7D2FE; background: var(--soft-ring); }

.btn-link {
    background: none;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 400;
    font-size: 14px;
    min-height: 32px;
    padding: 6px 8px;
}

.btn-link:hover { color: var(--text); }

.setup-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 26px;
    flex-wrap: wrap;
}

/* ── preflight ──────────────────────────────────────────── */

.preflight-note { margin: 0 0 16px; color: var(--muted); }

.preflight-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

.preflight-live {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    font-style: italic;
    color: var(--muted);
    min-height: 44px;
}

.preflight-wait { color: var(--muted); }

.preflight-ok { color: var(--success); font-weight: 600; }

.preflight-heard { color: var(--muted); font-weight: 400; font-style: italic; }

.preflight-fail { color: var(--caution); font-weight: 600; }

/* ── exam screen ────────────────────────────────────────── */

.part-banner {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--muted);
    margin-bottom: 10px;
}

.examiner-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.examiner-bubble {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 16px 18px;
    font-size: 17px;
    box-shadow: var(--shadow);
}

.btn-repeat { flex-shrink: 0; font-size: 14px; min-height: 40px; padding: 8px 12px; }

/* ── cue card + timer ───────────────────────────────────── */

.cue-card {
    margin-top: 16px;
    background: var(--card);
    border: 1px solid var(--hairline);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow);
}

.cue-card-title { margin: 0 0 12px; font-size: 18px; font-weight: 700; }

.cue-card-bullets { margin: 0; padding-left: 20px; color: var(--text); }

.cue-card-bullets li { margin: 6px 0; }

.timer {
    margin-top: 16px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    justify-content: center;
    padding: 12px 16px;
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
}

.timer-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); font-weight: 700; }

.timer-value {
    font-family: "Cascadia Code", "Consolas", monospace;
    font-size: 30px;
    font-weight: 700;
    color: var(--text);
}

.timer-prep .timer-value { color: var(--muted); }
.timer-speak .timer-value { color: var(--accent-ink); }

/* ── answer row (mic + text side by side) ──────────────── */

.answer-row {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: stretch;
}

.mic-btn {
    appearance: none;
    border: 1px solid var(--hairline);
    background: var(--card);
    border-radius: var(--radius);
    padding: 12px 16px;
    font: inherit;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    min-height: 48px;
    color: var(--text);
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.mic-btn:hover { border-color: #C7D2FE; }

.mic-btn.listening {
    border-color: var(--accent);
    color: var(--accent-ink);
    animation: mic-pulse 1.6s ease-out infinite;
}

.mic-btn.processing { border-color: var(--success); color: var(--success); }

.mic-btn.error { border-color: var(--caution); color: var(--caution); }

@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.35); }
    70% { box-shadow: 0 0 0 14px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.text-answer-wrap { display: flex; flex-direction: column; gap: 8px; }

#text-answer {
    flex: 1;
    resize: vertical;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    padding: 12px 14px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--card);
    min-height: 48px;
}

#text-answer:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }

.exam-controls { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ── live transcript ────────────────────────────────────── */

.live-transcript {
    margin-top: 16px;
    min-height: 76px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px dashed var(--hairline);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
}

.live-transcript.has-content { border-style: solid; }

.live-transcript .interim { color: var(--muted); font-style: italic; }

.live-transcript .final-seg { color: var(--text); }

.stt-status {
    margin-top: 8px;
    font-size: 12px;
    color: var(--muted);
}

/* ── feedback ───────────────────────────────────────────── */

.feedback-header {
    text-align: center;
    margin-bottom: 22px;
}

.feedback-heading {
    font-size: 15px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--muted);
    margin-bottom: 10px;
}

.overall-band {
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    letter-spacing: -1px;
}

/* Equal visual weight to the number, per UX §2.5 — never fine print. */
.estimated-label {
    margin-top: 8px;
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-ink);
}

.feedback-provenance {
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--muted);
}

.criterion-list { display: flex; flex-direction: column; gap: 12px; }

.criterion-row {
    display: flex;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
    background: var(--card);
}

.criterion-band {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--soft-ring);
    color: var(--accent-ink);
    font-size: 28px;
    font-weight: 800;
}

.criterion-band-null {
    background: #FDF1E3;
    color: var(--caution);
    font-size: 20px;
    font-weight: 700;
}

.criterion-body { flex: 1; min-width: 0; }

.criterion-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }

.criterion-basis { font-size: 13px; color: var(--muted); margin-bottom: 8px; }

.criterion-metrics { display: flex; flex-wrap: wrap; gap: 8px; }

.metric {
    font-size: 12.5px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 3px 10px;
}

.flag-list, .watchlist { margin: 10px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--text); }

.flag-list li, .watchlist li { margin: 4px 0; }

/* ── badges ─────────────────────────────────────────────── */

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    border-radius: 999px;
    padding: 2px 9px;
    vertical-align: middle;
    margin-left: 6px;
}

.badge-ielts { color: var(--accent-ink); border: 1px solid #C7D2FE; background: var(--soft-ring); }

.badge-region { color: var(--caution); border: 1px solid #F3D8A6; background: #FDF1E3; }

/* ── region recap + actions ─────────────────────────────── */

.region-recap {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #C7D2FE;
    background: var(--soft-ring);
    border-radius: var(--radius);
}

.region-recap h3 { margin: 0 0 8px; font-size: 15px; }

.region-recap p { margin: 0 0 10px; font-size: 14px; }

.region-observed { margin-top: 10px !important; font-size: 13px !important; color: var(--text); }

.feedback-actions {
    margin-top: 22px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── modal ──────────────────────────────────────────────── */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(31, 31, 46, 0.45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px 12px;
    z-index: 50;
    overflow-y: auto;
}

.modal-card {
    width: 100%;
    max-width: 620px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(31, 31, 46, 0.25);
    overflow: hidden;
    animation: fade-in 200ms ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hairline);
}

.modal-header h2 { margin: 0; font-size: 18px; }

.modal-close {
    appearance: none;
    border: none;
    background: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    padding: 4px 8px;
}

.modal-close:hover { color: var(--text); }

.modal-body { padding: 16px 20px; max-height: 62vh; overflow-y: auto; }

.modal-region { color: var(--muted); font-size: 14px; margin: 0 0 6px; }

.modal-body h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--muted);
    margin: 18px 0 6px;
}

.sample-line {
    margin: 8px 0;
    font-size: 14.5px;
    padding-left: 12px;
    border-left: 2px solid var(--hairline);
}

.sample-feedback {
    margin-top: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--hairline);
    border-radius: var(--radius);
}

.sample-bands { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.sample-band {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--hairline);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
}

.sample-band b { color: var(--accent-ink); font-size: 16px; }

.sample-band-overall { grid-column: 1 / -1; border-color: #C7D2FE; background: var(--soft-ring); }

.sample-disclaimer { font-size: 13px; color: var(--accent-ink); font-weight: 700; margin: 10px 0 0; }

.modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--hairline);
}

/* ── responsive ─────────────────────────────────────────── */

@media (max-width: 640px) {
    .ielts-app { grid-template-columns: 1fr; gap: 16px; padding-top: 16px; }

    .avatar-stage {
        position: fixed;
        top: 8px;
        right: 8px;
        width: 64px;
        z-index: 20;
        gap: 0;
    }

    #avatar-svg { width: 64px; height: 90px; }

    .avatar-name { display: none; }

    .screen-title { font-size: 21px; }
}

@media (max-width: 480px) {
    .answer-row { grid-template-columns: 1fr; }

    .examiner-row { flex-direction: column; }

    .btn-repeat { width: 100%; }

    .overall-band { font-size: 44px; }

    .estimated-label { font-size: 22px; }

    .criterion-band { width: 48px; height: 48px; font-size: 22px; }
}
