:root {
  --bg: #f6f7f5;
  --paper: #ffffff;
  --ink: #1e2a24;
  --ink-2: #5b6a64;
  --ink-3: #9aa7a1;
  --line: #dfe4e0;
  --gold: #c8871a;
  --gold-ink: #7a4f08;
  --gold-soft: #fbf1dc;
  --good: #2f7d4f;
  --good-soft: #e3f2e8;
  --bad: #b5402d;
  --bad-soft: #fbe7e2;
  --shadow: 0 1px 2px rgba(30, 42, 36, .06), 0 8px 24px -12px rgba(30, 42, 36, .18);
  --serif: "Fraunces", "Iowan Old Style", "Palatino", Georgia, serif;
  --sans: "Figtree", -apple-system, "Helvetica Neue", "Segoe UI", sans-serif;
  --tabs-h: calc(58px + env(safe-area-inset-bottom));
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121a18;
    --paper: #1a2421;
    --ink: #eef1ee;
    --ink-2: #a8b5ae;
    --ink-3: #6c7a73;
    --line: #2b3834;
    --gold: #d9a13a;
    --gold-ink: #f0c773;
    --gold-soft: #2e2711;
    --good: #6fc792;
    --good-soft: #17301f;
    --bad: #ef8a74;
    --bad-soft: #3a1c16;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; min-height: 100dvh; overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.rm { font-family: var(--serif); }

#app { max-width: 560px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(var(--tabs-h) + 24px); }
.view { display: none; }
.view.active { display: block; animation: rise .25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .view.active { animation: none; } }

/* header */
.head { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 0 14px; }
.head h1 { font: 600 22px/1.1 var(--serif); margin: 0; letter-spacing: -.01em; }
.head .meta { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.eyebrow .rm { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink-2); }

/* tabs */
.tabs {
  position: fixed; inset: auto 0 0 0; height: var(--tabs-h); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--paper); border-top: 1px solid var(--line); z-index: 5;
}
.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--ink-3); padding: 6px 0; }
.tabs .rm { font-size: 17px; line-height: 1.1; }
.tabs .de { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; }
.tabs button.active { color: var(--ink); }
.tabs button.active .rm { color: var(--gold-ink); }

/* cards */
.card {
  background: var(--paper); border-radius: 18px; padding: 22px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--gold), transparent 70%); }
.card + .card { margin-top: 14px; }
.word { font: 600 40px/1.05 var(--serif); letter-spacing: -.015em; margin: 6px 0 4px; overflow-wrap: anywhere; }
.word small { font: italic 400 22px/1 var(--serif); color: var(--ink-2); margin-left: 6px; }
.gloss { font-size: 19px; line-height: 1.35; }
.gloss .alt, .de-word .alt { color: var(--ink-2); font-weight: 400; }
.de-word { font: 500 26px/1.25 var(--sans); letter-spacing: -.01em; margin: 6px 0 4px; }
.meta-line { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; line-height: 1.6; }
.sent { font: 400 21px/1.4 var(--serif); margin: 16px 0 4px; }
.sent .blank { display: inline-block; min-width: 5ch; border-bottom: 2px solid var(--gold); color: var(--gold-ink); text-align: center; }
.sent .w { border-radius: 4px; cursor: pointer; }
.sent .w:active { background: var(--gold-soft); }
.sent-de { color: var(--ink-2); font-size: 15px; margin: 0 0 6px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.tag.mt { color: var(--gold-ink); border-color: var(--gold); }
.hint { font-size: 14px; color: var(--ink-2); margin: 10px 0 0; }
.reveal { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 14px; }

/* inputs + buttons */
.answer { display: flex; gap: 8px; margin-top: 16px; }
.answer input {
  flex: 1; min-width: 0; font: 500 20px/1.2 var(--serif); padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg);
}
.answer input.ok { border-color: var(--good); background: var(--good-soft); }
.answer input.ko { border-color: var(--bad); background: var(--bad-soft); }
.btn {
  border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 600; font-size: 16px; background: var(--ink); color: var(--bg);
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn.gold { background: var(--gold); color: #1e1607; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.row { display: flex; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1; }
.grade { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.grade .btn { padding: 14px 8px; }
.grade .btn small { display: block; font-weight: 400; font-size: 12px; opacity: .7; }
.result { margin-top: 12px; font-size: 15px; }
.result.ok { color: var(--good); } .result.ko { color: var(--bad); }
.result .rm { font-size: 19px; }

/* chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.chip { border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--ink-2); }
.chip.on { border-color: var(--gold); color: var(--gold-ink); background: var(--gold-soft); }

/* lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--paper); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.item .l { font: 600 22px/1.15 var(--serif); }
.item .g { color: var(--ink-2); font-size: 15px; }
.item .ex { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.item .ex .sent { font-size: 17px; margin: 4px 0 0; }
.item .ex .sent-de { font-size: 13px; }

/* paradigm table */
.paradigm { width: 100%; border-collapse: collapse; font-size: 15px; margin-top: 12px; }
.paradigm th, .paradigm td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.paradigm th { font-weight: 500; color: var(--ink-2); width: 5.5em; }
.paradigm td { font-family: var(--serif); font-size: 17px; }
.paradigm .now td { background: var(--gold-soft); }
.scroll { overflow-x: auto; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--paper); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font: 600 28px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--ink-2); }
.ridge { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 14px 0 4px; padding: 0 2px; }
.ridge i { flex: 1; background: var(--ink-3); border-radius: 3px 3px 0 0; min-height: 2px; }
.ridge i.today { background: var(--gold); }
.ridge-l { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }
textarea { width: 100%; min-height: 90px; font: 12px/1.4 ui-monospace, Menlo, monospace; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; background: var(--bg); color: var(--ink); }
label.set { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
select { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); }
h2 { font: 600 17px/1.2 var(--serif); margin: 22px 0 10px; }
p { margin: 8px 0; }
.muted { color: var(--ink-2); font-size: 14px; }

/* word sheet */
.sheet { position: fixed; inset: 0; background: rgba(20, 28, 24, .35); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet > div {
  width: 100%; max-width: 560px; background: var(--paper); border-radius: 18px 18px 0 0; padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  max-height: 70dvh; overflow-y: auto; animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet .entry + .entry { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.empty { text-align: center; padding: 40px 10px; color: var(--ink-2); }
.empty .rm { font-size: 28px; color: var(--ink); display: block; margin-bottom: 6px; }
