:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #eef5f2;
    color: #17191c;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background: #eef5f2;
}

button, select { font: inherit; }

.page-shell {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.speak-card {
    width: min(540px, 100%);
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: clamp(18px, 4vw, 28px);
    background: #fff;
    border: 1px solid #dde1e6;
    border-radius: 20px;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.06);
}

.header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.brand-mark {
    width: 39px;
    height: auto;
    flex: 0 0 auto;
}

.brand-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex: 0 0 auto;
}

.brand-k2 {
    font-size: 1.35rem;
    font-weight: 850;
    letter-spacing: 0.03em;
    color: #20242a;
}

.brand-speak {
    margin-top: 2px;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #5d6570;
}

h1 {
    margin: 0 0 0 20px;
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill {
    flex: 0 0 auto;
    min-width: 72px;
    padding: 7px 10px;
    text-align: center;
    border-radius: 999px;
    background: #eceff2;
    color: #414852;
    font-size: 0.88rem;
    font-weight: 650;
}

.status-pill[data-state="listening"] {
    background: #e5f4e8;
    color: #1c6b31;
}

.status-pill[data-state="error"] {
    background: #fbe9e9;
    color: #9d2525;
}

.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    border-radius: 12px;
    background: #f0f2f4;
}

.mode-tab {
    min-height: 40px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #59616b;
    font-weight: 700;
    cursor: pointer;
}

.mode-tab.active {
    background: #fff;
    color: #20242a;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.mode-tab:disabled { opacity: 0.5; cursor: default; }

.mode-view { display: grid; gap: 12px; }

.target-card,
.result-card,
.transcript-panel {
    border: 1px solid #dfe3e8;
    border-radius: 15px;
    background: #fbfcfd;
}

.target-card { padding: 18px; }
.result-card { padding: 16px 18px; min-height: 116px; }

.section-label {
    color: #626b75;
    font-size: 0.8rem;
    font-weight: 750;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.target-sentence {
    margin: 12px 0 16px;
    font-size: clamp(1.35rem, 5vw, 1.85rem);
    line-height: 1.35;
    font-weight: 650;
}

.sentence-nav {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    color: #69717b;
    font-size: 0.86rem;
    text-align: center;
}

.small-button {
    min-height: 36px;
    padding: 0 12px;
}

.result-heading,
.free-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.accuracy-label {
    color: #606872;
    font-size: 0.88rem;
}

.accuracy-label strong {
    color: #20242a;
    font-size: 1.05rem;
}

.heard-text {
    margin-top: 11px;
    color: #343a42;
    font-size: clamp(1.15rem, 4vw, 1.45rem);
    line-height: 1.45;
}

.free-note {
    margin-top: 4px;
    color: #69717b;
    font-size: 0.9rem;
}

.countdown {
    min-width: 58px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 1.2rem;
    font-weight: 750;
}

.transcript-panel {
    min-height: 210px;
    max-height: 300px;
    overflow-y: auto;
    padding: 18px;
    font-size: clamp(1.1rem, 4vw, 1.38rem);
    line-height: 1.5;
}

.final-transcript { white-space: pre-wrap; }
.final-line + .final-line { margin-top: 0.55em; }
.partial-transcript { margin-top: 0.55em; color: #7b838d; }

.controls {
    display: grid;
    gap: 12px;
}

.field {
    display: grid;
    gap: 6px;
    color: #4b535d;
    font-size: 0.85rem;
    font-weight: 650;
}

select,
button {
    min-height: 44px;
    border: 1px solid #cfd5dc;
    border-radius: 10px;
    background: #fff;
    color: #20242a;
}

select { width: 100%; padding: 0 11px; }

.button-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 8px;
}

button {
    padding: 0 14px;
    cursor: pointer;
    font-weight: 650;
}

button.start-stop {
    color: #fff;
    font-weight: 750;
}

button.start-stop.start-state {
    border-color: #21863a;
    background: #21863a;
}

button.start-stop.stop-state {
    border-color: #b52b2b;
    background: #b52b2b;
}

button.start-stop:disabled {
    opacity: 0.72;
}


button:disabled { opacity: 0.45; cursor: default; }

.public-footer {
    padding-top: 4px;
    border-top: 1px solid #eceef1;
    color: #7a828c;
    font-size: 0.72rem;
    line-height: 1.45;
}

.public-footer p { margin: 7px 0 0; }

@media (max-width: 420px) {
    .page-shell { padding: 8px; }
    .speak-card { padding: 16px; border-radius: 16px; gap: 14px; }
    .header { align-items: center; }
    .status-pill { min-width: 66px; }
    .sentence-nav { gap: 6px; }
    .small-button { padding: 0 9px; }
}
