:root {
    --bg: #f5f6fb;
    --surface: #ffffff;
    --text: #1b2030;
    --muted: #677086;
    --line: #dfe3ee;
    --accent: #4f46e5;
    --on-accent: #ffffff;
    --mine: #e3e7ff;
    --good: #15803d;
    --bad: #b91c1c;
    --nav: 60px;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1220;
        --surface: #1a1e32;
        --text: #e8eaf3;
        --muted: #9aa3ba;
        --line: #2c3350;
        --accent: #8b93ff;
        --on-accent: #10132a;
        --mine: #2b3163;
        --good: #4ade80;
        --bad: #f87171;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    -webkit-text-size-adjust: 100%;
}

main {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav) + 16px + env(safe-area-inset-bottom));
}

h1 { margin: 0; font-size: 2.2rem; }
h2 { margin: 20px 0 8px; font-size: 1.15rem; }
h3 { margin: 0; font-size: 1rem; }
p { margin: 8px 0; }

.hidden { display: none; }
.muted { color: var(--muted); }
.center { text-align: center; }
.error { color: var(--bad); min-height: 1px; margin: 4px 0; }
.error:empty { display: none; }
.done { font-size: 1.2rem; padding: 32px 0; }

input, select, button {
    font: inherit;
    color: inherit;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    padding: 10px 12px;
    min-width: 0;
}

input:not([type="checkbox"]) { width: 100%; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

button { cursor: pointer; white-space: nowrap; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.wide { width: 100%; margin-top: 12px; }
button.link { border: 0; background: none; color: var(--accent); padding: 6px; }
button.good { flex: 1; border-color: var(--good); color: var(--good); font-weight: 600; }
button.bad { flex: 1; border-color: var(--bad); color: var(--bad); font-weight: 600; }
button.say { border: 0; background: none; padding: 2px 6px; }

.row { display: flex; gap: 8px; margin-top: 12px; }
.row input { flex: 1; }
.stack { display: grid; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; }

/* login */
.login { max-width: 360px; padding-top: 12vh; text-align: center; }
.login form { display: grid; gap: 10px; margin: 24px 0 8px; }

/* bottom navigation */
nav {
    position: fixed;
    inset: auto 0 0 0;
    display: flex;
    justify-content: center;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
}
nav button {
    position: relative;
    flex: 1;
    max-width: 144px;
    height: var(--nav);
    border: 0;
    border-radius: 0;
    background: none;
    padding: 4px 0;
    color: var(--muted);
    font-size: 0.75rem;
    display: grid;
    place-items: center;
}
nav button.active { color: var(--accent); font-weight: 600; }
nav .icon { font-size: 1.3rem; line-height: 1.2; }
nav .badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 8px);
    background: var(--bad);
    color: #fff;
    border-radius: 999px;
    padding: 0 6px;
    font-size: 0.7rem;
    line-height: 1.5;
}

/* conversation: fills the screen above the navigation, with only the log scrolling */
.talk {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: calc(100dvh - var(--nav) - 32px - env(safe-area-inset-bottom));
}
.setup { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* the scene picker keeps a readable width, so on a phone the button and toggle wrap to a second row */
.setup select:first-child { flex: 1 1 180px; }
.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; background: var(--mine); border-bottom-right-radius: 4px; }
.coaching {
    align-self: flex-end;
    max-width: 85%;
    font-size: 0.9rem;
    border-left: 3px solid var(--accent);
    padding: 2px 0 2px 10px;
}
.coaching p { margin: 2px 0; }
.coaching b { color: var(--accent); margin-right: 6px; }
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; }
.mic.on { background: var(--bad); border-color: var(--bad); }

/* a suggested expression that can be saved as a card */
.chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    padding: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.chip div { flex: 1; display: grid; }
.chip small { color: var(--muted); }
.chip button { font-size: 0.85rem; padding: 6px 10px; }

/* review and test */
.card {
    position: relative;
    margin-top: 12px;
    padding: 28px 20px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
}
.card .front { font-size: 1.5rem; font-weight: 600; overflow-wrap: anywhere; }
.card .back { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 1.2rem; }
.card .say { position: absolute; top: 8px; right: 8px; font-size: 1.2rem; }
.choices { display: grid; gap: 8px; margin-top: 12px; }
.choice { text-align: left; white-space: normal; }
.choice:disabled { opacity: 1; }
.choice.right { border-color: var(--good); color: var(--good); font-weight: 600; }
.choice.wrong { border-color: var(--bad); color: var(--bad); }

/* deck list */
.cards { list-style: none; margin: 8px 0; padding: 0; }
.cards li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cards li div { flex: 1; display: grid; min-width: 0; }
.cards li span { color: var(--muted); font-size: 0.9rem; }
.cards .level { letter-spacing: -1px; font-size: 0.7rem; }
