/* Base reset + layout.  Reads only design tokens from theme.css. */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    line-height: var(--line);
    font-size: 17px;
    -webkit-font-smoothing: antialiased;
}

@media (max-width: 640px) {
    html, body { font-size: 16px; }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: var(--font-head);
    color: var(--fg);
    line-height: 1.2;
    margin: 0 0 0.6em;
}
h1 { font-size: clamp(1.75rem, 3.5vw, 2.6rem); letter-spacing: -0.01em; }
h2 { font-size: clamp(1.4rem, 2.5vw, 1.9rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 1rem; max-width: var(--measure); }

/* ---- header ---- */

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.brand {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--fg);
    text-decoration: none;
    letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-sub {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--fg-muted);
    font-size: 0.9rem;
    margin-left: 6px;
}

.theme-switcher {
    display: flex;
    gap: 6px;
}
.theme-chip {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--fg-muted);
    font-size: 0.78rem;
    font-family: var(--font-body);
    text-decoration: none;
}
.theme-chip:hover { color: var(--fg); border-color: var(--accent); text-decoration: none; }

/* mark the current theme chip */
[data-theme="diia"]  .theme-chip[data-theme-chip="diia"],
[data-theme="paper"] .theme-chip[data-theme-chip="paper"],
[data-theme="punch"] .theme-chip[data-theme-chip="punch"] {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}

/* ---- container ---- */

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 48px 24px 80px;
}

/* ---- hero ---- */

.hero {
    margin: 0 0 56px;
}
.hero h1 { margin-top: 0; }
.hero .lead {
    font-size: 1.1rem;
    color: var(--fg-muted);
}
.hero .btn + .btn { margin-left: 8px; }

.btn {
    display: inline-block;
    padding: 12px 22px;
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.04s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
    background: transparent;
    color: var(--fg);
}
.btn-ghost:hover { background: var(--bg-soft); }

/* ---- cards ---- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin: 0 0 48px;
}
.card {
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-soft);
    box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card p { color: var(--fg-muted); margin-bottom: 0; }

.note {
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    background: var(--bg-soft);
    color: var(--fg-muted);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.note p { margin: 0; }
.note strong { color: var(--fg); }

/* ---- test items ---- */

.item {
    max-width: 760px;
    margin: 0 auto;
}

.item-meta {
    display: flex;
    justify-content: space-between;
    color: var(--fg-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg-muted);
}

.instruction {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--fg-muted);
    margin-bottom: 24px;
}

.stem {
    font-family: var(--font-head);
    font-size: 1.35rem;
    line-height: 1.8;
    margin: 24px 0;
    padding: 24px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stem > span { white-space: pre-wrap; }

.blank {
    display: inline-block;
    min-width: 90px;
    padding: 2px 12px;
    margin: 0 2px;
    border: none;
    border-bottom: 2px dashed var(--accent);
    background: transparent;
    font-family: var(--font-head);
    font-size: 1.1em;
    color: var(--accent);
    cursor: pointer;
    transition: background 0.1s ease;
}
.blank:hover { background: var(--bg); }
.blank.active {
    background: var(--accent);
    color: var(--accent-fg);
    border-bottom-color: var(--accent);
    border-radius: 4px;
}
.blank.filled {
    border-bottom-style: solid;
    color: var(--fg);
}
.blank.filled.active { color: var(--accent-fg); }

.hint {
    color: var(--fg-muted);
    font-size: 0.9rem;
    margin: 16px 0;
}

.bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 24px;
}

.chip {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.08s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.used {
    opacity: 0.35;
    pointer-events: none;
    text-decoration: line-through;
}

.item-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 28px;
}

.btn:disabled, .btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.incorrect {
    font-family: var(--font-head);
    font-size: 1.3rem;
    line-height: 1.6;
    margin: 24px 0;
    padding: 20px;
    background: var(--bg-soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--fg);
}

textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.5;
    resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0;
    margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}

/* ---- audio block ---- */

.audio-block {
    margin: 16px 0 28px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.audio-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-soft);
    color: var(--fg);
    font-family: var(--font-body);
    font-size: 1rem;
    cursor: pointer;
}
.audio-btn:hover { border-color: var(--accent); color: var(--accent); }
.audio-btn.playing { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.audio-played { color: var(--fg-muted); font-size: 0.9rem; }

/* ---- writing ---- */

.write-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.95rem;
    color: var(--fg-muted);
}
.word-count.ok   { color: #15803d; font-weight: 600; }
.word-count.warn { color: #b45309; }

/* ---- speaking ---- */

.read-aloud {
    font-family: var(--font-head);
    font-size: 1.3rem;
    line-height: 1.6;
    margin: 24px 0;
    padding: 24px;
    background: var(--bg-soft);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius) var(--radius) 0;
}
.record-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
}
.recorded-audio {
    display: block;
    width: 100%;
    margin: 16px 0;
}
.recording-tip { text-align: center; }

/* ---- score ---- */

.cefr-result {
    font-family: var(--font-head);
    margin: 4px 0;
}
.cefr-label {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}
.cefr-band {
    color: var(--fg-muted);
    font-size: 0.95rem;
    margin-left: 8px;
}
.cefr-pending {
    font-family: var(--font-head);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--border);
    letter-spacing: -0.02em;
}
.card-pending { opacity: 0.6; }
.muted {
    color: var(--fg-muted);
    font-size: 0.85rem;
    margin: 4px 0 0;
}

.response-detail {
    margin: 32px 0;
    padding: 16px 20px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.response-detail summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--fg-muted);
}
.response-detail ol {
    margin: 16px 0 0;
    padding-left: 20px;
    font-size: 0.95rem;
}
.response-detail li.ok { color: #15803d; }
.response-detail li.fail { color: #b91c1c; }

/* ---- footer ---- */

.site-footer {
    border-top: 1px solid var(--border);
    padding: 24px;
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.9rem;
}
