:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #f1ede5;
  --border: #e4ded3;
  --text: #1c1b22;
  --muted: #6b6676;
  --accent: #2b3fd1;
  --accent-soft: #e8ebff;
  --again: #c4362b;
  --hard: #b86e00;
  --good: #1e7a3c;
  --easy: #2b3fd1;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 16, 40, 0.05), 0 8px 24px rgba(20, 16, 40, 0.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161c;
    --surface: #211f27;
    --surface-2: #2a2831;
    --border: #3a3743;
    --text: #f1eff6;
    --muted: #a8a3b3;
    --accent: #7b8cff;
    --accent-soft: #2a2f55;
    --again: #ff7a6e;
    --hard: #f0a640;
    --good: #5fcf86;
    --easy: #8f9dff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); }
kbd {
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand img { border-radius: 7px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs button {
  all: unset; cursor: pointer; padding: 6px 16px; border-radius: 999px; font-weight: 550; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.stats { margin-left: auto; display: flex; gap: 16px; color: var(--muted); font-size: 14px; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }

main { max-width: 880px; margin: 0 auto; padding: 32px 24px 80px; }

/* Buttons */
.btn {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: 10px; font-weight: 600; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .rate:focus-visible, .tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.big { padding: 12px 24px; font-size: 16px; border-radius: 12px; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--again); }
.btn kbd { background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.3); color: inherit; }

/* Welcome */
.welcome {
  background: var(--accent-soft); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 28px;
}
.welcome h2 { margin: 0 0 6px; }
.welcome ol { padding-left: 20px; }
.welcome li { margin: 6px 0; }

/* Review home */
.due-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 40px 32px; text-align: center;
}
.due-num { font-size: 64px; font-weight: 750; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.due-label { color: var(--muted); margin-top: 6px; }
.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 28px 0 24px; }
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes span {
  display: inline-block; cursor: pointer; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  font-size: 14px; font-weight: 550; color: var(--muted);
}
.modes input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.modes input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.start-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* Session */
.session-top { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.25s ease; }
.flashcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 40px 36px; min-height: 300px; display: flex; flex-direction: column; align-items: center; text-align: center;
}
.card-kind { font-size: 13.5px; color: var(--muted); font-weight: 600; }
.card-front { margin-top: 18px; width: 100%; }
.prompt-term { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.prompt-cloze { font-size: 22px; line-height: 1.5; max-width: 620px; margin: 0 auto; }
.blank { display: inline-block; min-width: 4ch; border-bottom: 2px solid var(--accent); color: var(--accent); font-weight: 650; }
.hint-line { margin-top: 12px; color: var(--muted); }
.speak { all: unset; cursor: pointer; font-size: 20px; opacity: 0.55; margin-left: 8px; vertical-align: middle; }
.speak:hover { opacity: 1; }
.context { margin-top: 18px; color: var(--muted); font-size: 16px; max-width: 620px; margin-inline: auto; font-style: italic; }
.context mark { background: none; color: var(--text); font-weight: 650; font-style: normal; }
.answer-form { width: 100%; max-width: 420px; margin-top: 26px; }
.answer-form input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font: inherit; font-size: 17px; text-align: center;
}
.answer-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.card-back { margin-top: 24px; padding-top: 22px; border-top: 1px dashed var(--border); width: 100%; }
.answer-main { font-size: 28px; font-weight: 650; color: var(--accent); overflow-wrap: anywhere; }
.alts { margin-top: 8px; color: var(--muted); font-size: 14px; }
.verdict { margin-top: 10px; font-weight: 600; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--again); }
.source { margin-top: 12px; font-size: 13px; }
.card-actions { margin-top: 20px; display: flex; justify-content: center; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; }
.rate {
  all: unset; cursor: pointer; text-align: center; padding: 12px 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 650;
  display: flex; flex-direction: column; gap: 2px;
}
.rate small { font-weight: 500; color: var(--muted); font-size: 12px; }
.rate:hover { background: var(--surface-2); }
.rate.again span { color: var(--again); }
.rate.hard span { color: var(--hard); }
.rate.good span { color: var(--good); }
.rate.easy span { color: var(--easy); }
.hint { text-align: center; margin-top: 18px; font-size: 13px; }
.done { text-align: center; padding: 60px 16px; }

/* Words */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }
input, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d5868' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
input:focus-visible, select:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); }
.add-form { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: 8px; margin-top: 12px; }
@media (max-width: 720px) { .add-form { grid-template-columns: 1fr; } }
.count { margin: 16px 0 8px; font-size: 13px; }
.word-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.word {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; display: grid; grid-template-columns: 1fr auto; gap: 4px 16px;
}
.word-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.word-term { font-weight: 700; font-size: 17px; }
.word-tr { color: var(--accent); font-weight: 550; }
.word-ctx { grid-column: 1 / -1; color: var(--muted); font-size: 14px; font-style: italic; }
.word-ctx mark { background: none; color: var(--text); font-weight: 650; font-style: normal; }
.word-meta { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.word-meta a { color: var(--muted); }
.pill { padding: 1px 8px; border-radius: 99px; background: var(--surface-2); font-weight: 600; }
.pill.new { background: var(--accent-soft); color: var(--accent); }
.pill.due { background: color-mix(in srgb, var(--hard) 18%, transparent); color: var(--hard); }
.pill.known { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.word-actions { display: flex; gap: 2px; align-items: start; }
.icon-btn { all: unset; cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.word.editing .word-tr, .word.editing .word-ctx { display: none; }
.edit-row { grid-column: 1 / -1; display: grid; gap: 6px; margin-top: 6px; }
.edit-row .row { display: flex; gap: 8px; justify-content: flex-end; }

/* Settings */
.settings { display: grid; gap: 18px; }
fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  padding: 16px 20px 18px; margin: 0; display: grid; gap: 12px;
}
legend { font-weight: 700; padding: 0 6px; }
.settings label { display: grid; gap: 6px; font-weight: 550; }
.settings label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.settings label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.settings p { margin: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.file { position: relative; }
.site-list { list-style: none; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.site-list li { display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 99px; background: var(--surface-2); }
.saved-note { color: var(--good); font-weight: 600; min-height: 1.5em; margin: 0; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; gap: 12px; }
  .stats { margin-left: 0; width: 100%; }
  main { padding: 20px 16px 60px; }
  .flashcard { padding: 28px 18px; }
  .prompt-term { font-size: 32px; }
  .ratings { grid-template-columns: repeat(2, 1fr); }
}
progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* ---------- Website version additions ---------- */
.brand { text-decoration: none; color: var(--text); }
.brand span { font-family: 'Fraunces', Georgia, serif; font-weight: 650; }
.banner { display: flex; justify-content: center; gap: 8px; padding: 10px 24px; background: var(--accent-soft); color: var(--text); font-size: 14px; }
.banner a { font-weight: 600; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); padding: 32px 28px; display: grid; gap: 14px; }
.auth-card .brand { display: flex; align-items: center; gap: 10px; font-size: 20px; margin-bottom: 6px; }
.auth-card .brand img { border-radius: 8px; }
.auth-card h1 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 28px; letter-spacing: -0.02em; margin: 0; }
.auth-card p { margin: 0; }
.auth-card form { display: grid; gap: 12px; }
.auth-card label { display: grid; gap: 5px; font-weight: 550; font-size: 14px; }
.auth-card label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.auth-card input[type=email], .auth-card input[type=password] { padding: 11px 12px; }
.btn.google { justify-content: center; padding: 11px 16px; font-size: 15px; }
.btn.big { justify-content: center; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.switch { font-size: 14px; color: var(--muted); }
button.link { all: unset; cursor: pointer; color: var(--accent); font-weight: 600; }
button.link.small { font-size: 13px; font-weight: 500; color: var(--muted); }
button.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.auth-msg { min-height: 1.4em; font-size: 14px; color: var(--muted); }
.auth-msg.err { color: var(--again); }
.google-gis { display: flex; justify-content: center; min-height: 44px; }
.google-gis:empty { display: none; }
.plan-status strong { font-weight: 700; }
#plan-msg:empty { display: none; }

/* Learning several languages */
.deck-switch {
  appearance: none; -webkit-appearance: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
  padding: 7px 30px 7px 12px; border-radius: 10px; border: 1px solid transparent; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d5868' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}
.deck-switch:hover { background-color: var(--surface-2); }
.deck-switch:focus { outline: none; }
.deck-switch:focus-visible { border-color: var(--border); box-shadow: 0 0 0 3px var(--accent-soft); }
.lang-field { display: grid; gap: 6px; font-weight: 550; }
.lang-tiles { display: flex; flex-wrap: wrap; gap: 8px; }
.lang-tiles .tile { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg); font-weight: 500; cursor: pointer; }
.lang-tiles .tile.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang-tiles .tile input { width: 14px; height: 14px; accent-color: #fff; margin: 0; }

/* Grammar from the on-device model */
.word-grammar { margin: 4px 0 2px; font-size: 13.5px; color: var(--muted); }
.word-grammar b { color: var(--accent); font-weight: 650; }
.grammar-note { display: block; margin-top: 2px; font-style: italic; }
.flashcard .word-grammar { text-align: center; margin: 8px 0; font-size: 14px; }
