/* Lines and type: no shadows, structure from thin rules and whitespace. A few muted colours mark state
   (due counts, rating buttons, notes, import status); the answer half of a review card is shaded. */
:root {
    --text: #141618;
    --muted: #6b7076;
    --line: #e1e4e7;
    --line-strong: #141618;
    --bg: #ffffff;
    --shade: #f4f7f6;
    --accent: #0b6e66;
    --accent-soft: #e7f2f0;
    --danger: #b3261e;
    --danger-soft: #fbeceb;
    --again: #b4533a;
    --hard: #a3781c;
    --good: #3c7d52;
    --easy: #3f67a6;
    --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
    :root {
        --text: #e8eaec;
        --muted: #989ea5;
        --line: #2a2e32;
        --line-strong: #c9cdd1;
        --bg: #0f1112;
        --shade: #171b1c;
        --accent: #5cc8b8;
        --accent-soft: #15302d;
        --danger: #ff8a80;
        --danger-soft: #3a1b19;
        --again: #e08a72;
        --hard: #d4ad5a;
        --good: #7fc192;
        --easy: #8eaee0;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0 auto;
    max-width: 42rem;
    padding: 0 1rem 4rem;
    font: 1rem/1.6 var(--sans);
    color: var(--text);
    background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover, button.link:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 2.1rem; font-weight: 600; letter-spacing: -.025em; line-height: 1.15; margin: .5rem 0 1.25rem; text-wrap: balance; }
h2 {
    display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    font-size: 1rem; font-weight: 600;
    margin: 2.75rem 0 0; padding-bottom: .5rem;
    border-bottom: 1px solid var(--line-strong);
}
.count { font: .8rem var(--mono); color: var(--muted); font-weight: 400; }
.muted, small { color: var(--muted); }
.error { color: var(--danger); }
p { margin: .75rem 0; }
code { font: .85em var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
nav.site { display: flex; justify-content: space-between; align-items: center; padding: 1.25rem 0; margin-bottom: 1rem; }
nav.site form { margin: 0; }
nav.site button.link { color: var(--muted); }
.brand { font: 500 .85rem var(--mono); letter-spacing: .02em; color: var(--text); }
.crumbs { font: .8rem var(--mono); color: var(--muted); margin: 0; }
.crumbs a { color: var(--muted); }

/* Forms */
input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%;
    padding: .55rem .7rem;
    font: inherit;
    color: inherit;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { background: var(--bg); width: auto; }
textarea { min-height: 4.5rem; resize: vertical; }
label { display: block; }
label > span { display: block; font: .75rem var(--mono); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .3rem; }
label > small { display: block; margin: -.2rem 0 .3rem; font-size: .85rem; }
label.inline { display: inline; }
label.check { display: flex; gap: .5rem; align-items: center; }
form.inline { display: inline; margin: 0; }
.stack { display: grid; gap: 1rem; }
.stack > p { margin: 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row input[type=text] { flex: 1; width: auto; min-width: 10rem; }
.row + .row, .row + form, form + .row { margin-top: .75rem; }

/* Buttons: outlined by default, solid ink for the main action, plain text for small actions */
button, .btn {
    display: inline-block; vertical-align: middle;
    font: 500 .95rem/1.4 var(--sans);
    padding: .5rem 1.05rem;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
}
button:hover, .btn:hover { background: var(--accent-soft); text-decoration: none; }
button.primary, .btn.primary { color: var(--bg); background: var(--text); border-color: var(--text); }
button.primary:hover, .btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.disabled { color: var(--muted); border-color: var(--line); cursor: default; }
.btn.disabled:hover { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button kbd, .btn kbd, summary kbd { margin-left: .5rem; }
button.link { display: inline; vertical-align: baseline; border: 0; padding: 0; background: none; font: inherit; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
    button, .btn { transition: background-color .15s, border-color .15s; }
}

/* Collapsible sections */
details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: .75rem; }
details.settings { margin-top: 2.5rem; }
details.settings details { margin-top: 1rem; }

/* "New deck", "Add card": a button that opens a form in a panel below the row of buttons */
details.create > summary { list-style: none; color: var(--text); font-size: .95rem; }
details.create > summary::-webkit-details-marker { display: none; }
details.create[open] { order: 10; flex-basis: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem 1.25rem; }
details.create[open] > summary { border: 0; padding: 0; font-weight: 600; background: none; display: flex; justify-content: space-between; width: 100%; margin-bottom: 1rem; }
details.create[open] > summary::after { content: "×"; color: var(--muted); font-weight: 400; font-size: 1.25rem; line-height: 1; }
.page-head, .actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { flex: 1; margin: 0; }
.actions { margin: 1.5rem 0 0; }

/* Messages */
.notice { background: var(--accent-soft); border-radius: 6px; padding: .6rem .9rem; font-size: .95rem; }

/* Deck list */
ul.decks { list-style: none; padding: 0; margin: 0; }
ul.decks li { display: flex; align-items: baseline; gap: .75rem; padding: .75rem .5rem .75rem 0; border-bottom: 1px solid var(--line); }
ul.decks li:hover { background: linear-gradient(to right, transparent, var(--accent-soft) 15%, var(--accent-soft) 85%, transparent); }
.deck-name { flex: 1; min-width: 0; color: var(--text); font-weight: 500; }
ul.decks .meta, .due { font: .8rem var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
ul.decks .meta { color: var(--muted); min-width: 5.5rem; }
.due { min-width: 5.5rem; font-weight: 500; }
.due.none { color: var(--muted); font-weight: 400; }
.group > p { margin: .75rem 0 0; }
details.folder-settings { margin-top: .5rem; }
details.folder-settings > summary { font-size: .8rem; }

/* Deck page */
.deck-meta { color: var(--muted); font-size: .9rem; margin: 0; }

/* Card text is plain text; keep the line breaks people typed */
.text { white-space: pre-wrap; overflow-wrap: anywhere; }

table.cards { width: 100%; border-collapse: collapse; }
table.cards td { padding: .9rem 1rem .9rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
/* The front column (the only td.text) gets a floor: "anywhere" lets columns shrink until words split mid-word */
table.cards td.text { min-width: 7rem; font-weight: 500; }
table.cards td.row-actions { white-space: nowrap; text-align: right; padding-right: 0; font-size: .8rem; }
table.cards td.row-actions a, table.cards td.row-actions button.link { color: var(--muted); margin-left: .75rem; }
table.cards td.row-actions a:hover, table.cards td.row-actions button.link:hover { color: var(--accent); }
table.cards details.notes { margin-top: .25rem; }
table.cards details.notes > summary { font: .75rem var(--mono); }
table.cards details.notes .text { color: var(--muted); font-size: .9rem; border-left: 2px solid var(--accent); padding-left: .75rem; }
/* Learned cards are excluded from reviews */
table.cards tr.learned td { color: var(--muted); }
table.cards tr.learned td.text::after {
    content: "learned"; font: 400 .65rem var(--mono); color: var(--good);
    border: 1px solid currentColor; border-radius: 3px; padding: 0 .3rem; margin-left: .5rem; vertical-align: .15em;
}

/* Import preview */
.intro { font-size: .95rem; }
.preview-summary { font-size: .95rem; }
table.preview td.line-no { font: .75rem/1.9 var(--mono); color: var(--muted); padding-right: .75rem; min-width: 0; }
table.preview td.status { font: .75rem/1.9 var(--mono); }
table.preview tr.new td.status { color: var(--good); }
table.preview tr.duplicate td.status { color: var(--muted); }
table.preview tr.duplicate .text { color: var(--muted); text-decoration: line-through; }
table.preview tr.error td { background: var(--danger-soft); }

/* Review */
.review-top { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0 0 1.5rem; font-size: .9rem; }
.progress { font: .8rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.flashcard { border: 1.5px solid var(--line-strong); border-radius: 10px; overflow: hidden; text-align: center; }
.card-front { padding: 3rem 1.5rem; }
.review-front { font-size: 2.4rem; font-weight: 500; letter-spacing: -.02em; line-height: 1.25; }
/* Kept small and quiet so the word on the card gets the attention */
details.answer > summary.reveal {
    display: inline-block; list-style: none; margin: 0 0 1.5rem;
    padding: .3rem .9rem; border: 1px solid var(--line); border-radius: 6px;
    color: var(--muted); font-size: .85rem;
}
details.answer > summary.reveal::-webkit-details-marker { display: none; }
details.answer > summary.reveal:hover { color: var(--text); border-color: var(--muted); }
details.answer[open] > summary { display: none; }
.card-back { background: var(--shade); border-top: 1px solid var(--line); padding: 2rem 1.5rem 2.25rem; }
.review-back { font-size: 1.35rem; }
.card-back details.notes { margin-top: 1.25rem; }
.review-notes { display: inline-block; text-align: left; color: var(--muted); border-left: 2px solid var(--accent); padding-left: .9rem; }
/* No ratings until the answer is shown */
.flashcard:has(details.answer:not([open])) + #rating-form { display: none; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 1.25rem; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
/* The button holds "Again <small>10m</small> <kbd>1</kbd>": dot and label on top, interval and key below */
.ratings button {
    display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; gap: .1rem .45rem;
    border: 0; border-radius: 0; padding: .7rem .4rem;
}
.ratings button + button { border-left: 1px solid var(--line); }
.ratings button::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--dot); }
.ratings small { font: .95rem var(--mono); justify-self: end; }
.ratings kbd { margin-left: 0; justify-self: start; font-size: .6rem; padding: .1rem .3rem; }
.ratings .again { --dot: var(--again); }
.ratings .hard { --dot: var(--hard); }
.ratings .good { --dot: var(--good); }
.ratings .easy { --dot: var(--easy); }
.hints { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: center; margin-top: 1.75rem; font-size: .8rem; color: var(--muted); }
.hints button.link { color: var(--muted); }
.flashcard:has(details.answer[open]) ~ #learned-form .hint-reveal { display: none; }
.hints button.link:hover { color: var(--accent); }
kbd { font: 500 .7rem/1 var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: .15rem .35rem; }
.done { text-align: center; padding: 3rem 0; }

/* Login */
main.login { max-width: 22rem; margin: 4rem auto 0; }
main.login .brand { display: block; margin-bottom: 1.5rem; }

@media (max-width: 480px) {
    .ratings { grid-template-columns: repeat(2, 1fr); }
    .ratings button:nth-child(3) { border-left: 0; }
    .ratings button:nth-child(n+3) { border-top: 1px solid var(--line); }
    .review-front { font-size: 2rem; }
    /* No room for an actions column: put Learned / Edit on a line under the back */
    table.cards, table.cards tbody { display: block; }
    table.cards tr { display: grid; grid-template-columns: 2fr 3fr; column-gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); }
    table.cards td { padding: 0; border: 0; }
    table.cards td.text { min-width: 0; }
    table.cards td.row-actions { grid-column: 2; text-align: left; padding-top: .4rem; }
    table.cards td.row-actions a, table.cards td.row-actions button.link { margin: 0 1rem 0 0; }
}
