:root {
    --bg: #14161a;
    --fg: #e8e8ea;
    --muted: #8a8f98;
    --accent: #7dd3fc;
    --good: #4ade80;
    --border: #2a2e35;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    max-width: 40rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    flex: 1;
}

footer {
    text-align: center;
    padding: 1rem;
    color: var(--muted);
}

input, button {
    font: inherit;
    color: inherit;
}

input[type=text] {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
}

button {
    padding: 0.75rem 1rem;
    background: var(--border);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    min-height: 44px;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--muted);
}

form > * + * {
    margin-top: 0.75rem;
}

.muted { color: var(--muted); }

.card { padding: 1rem 0; }
.replay-row { display: flex; gap: 0.75rem; justify-content: center; margin: 1.5rem 0; }
.replay {
    width: 4.5rem; height: 4.5rem; border-radius: 50%;
    font-size: 1.5rem; background: var(--border);
}
.replay.slow { font-size: 1.3rem; }
.reveal { font-size: 1.25rem; line-height: 1.8; }
.reveal .tok { color: var(--muted); }
.reveal .tok.good { color: var(--good); }
.reveal .tok.target {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 4px;
    text-decoration-thickness: 2px;
}
.reveal .tok.flag {
    cursor: pointer;
    border-bottom: 1px dashed var(--border);
}
.reveal .tok.flag.missed {
    color: #f87171;
    text-decoration: line-through;
    border-bottom-color: #f87171;
}
.translit { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.95rem; }
.gloss { color: var(--muted); font-style: italic; }
.typed { color: var(--muted); font-size: 0.95rem; margin-top: 0.75rem; }

.spinner {
    display: none;
    text-align: center; color: var(--muted); margin-top: 1rem;
}
.spinner.htmx-request { display: block; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-top: 1rem; }
.grades button { padding: 1rem 0.5rem; font-weight: 600; color: #fff; }
.g-again { background: #7f1d1d; }
.g-hard  { background: #92400e; }
.g-good  { background: #15803d; }
.g-easy  { background: #155e75; }

table.words { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.words th, table.words td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
table.words th { color: var(--muted); font-weight: 500; font-size: 0.9rem; }
table.words a { color: var(--fg); text-decoration: none; }
table.words a:hover { color: var(--accent); }

input[type=search] {
    width: 100%; padding: 0.5rem 0.75rem;
    background: transparent; border: 1px solid var(--border);
    border-radius: 6px; color: inherit; font: inherit;
    margin-top: 0.5rem;
}

.sentence-row { padding: 0.75rem 0; border-bottom: 1px solid var(--border); }
.sentence-row audio { width: 100%; margin-top: 0.5rem; }

.chart { display: block; width: 100%; height: auto; margin: 1rem 0; }

h1, h2 { font-weight: 500; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1rem; color: var(--muted); margin-top: 2rem; }
a { color: var(--accent); }

.nav-links { text-align: center; margin-top: 3rem; }

.mode-toggle { display: flex; gap: 0.25rem; margin-bottom: 1rem; }
.mode-toggle button {
    flex: 1; padding: 0.4rem; min-height: 0; font-size: 0.9rem;
    background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.mode-toggle button.active { background: var(--border); color: var(--fg); }
.prompt { font-size: 1.5rem; text-align: center; margin: 1rem 0; }
.reveal .tok.bad { color: #f87171; }


