:root {
  --bg: #f3ead8;
  --bg-2: #e9dcc4;
  --ink: #241c14;
  --muted: #6b5c4c;
  --card: #fffaf1;
  --line: rgba(36, 28, 20, 0.12);
  --gold: #8a5a28;
  --gold-2: #c9a15b;
  --again: #9c3b2e;
  --hard: #b5812a;
  --good: #2f6f4e;
  --easy: #2a5f8a;
  --shadow: 0 18px 50px rgba(36, 28, 20, 0.08);
  --serif: "Source Serif 4", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --he: "Frank Ruhl Libre", "Times New Roman", serif;
  --radius: 18px;
}

[data-theme="ink"] {
  --bg: #161310;
  --bg-2: #221c16;
  --ink: #f3ead8;
  --muted: #b3a18c;
  --card: #221c16;
  --line: rgba(243, 234, 216, 0.12);
  --gold: #c9a15b;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 500px at 10% -10%, var(--bg-2), transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; font-size: 16px; }
.dock { display: none; }
a { color: inherit; text-decoration: none; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 22px 80px; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-bottom: 28px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px;
  overflow: hidden; background: #241c14;
}
.mark img { width: 52px; height: 52px; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 20px; }
.brand-text em { font-style: normal; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a {
  padding: 8px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px;
}
.nav a.on, .nav a:hover { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.kicker, .tile-kicker, .card-kicker {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--gold); font-weight: 700; margin: 0 0 8px;
}
h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(28px, 4vw, 44px); line-height: 1.15; margin: 0 0 10px; }
h2 { font-family: var(--serif); font-size: 20px; margin: 22px 0 10px; }
.lede { font-size: 18px; color: var(--muted); max-width: 46ch; }
.hint { color: var(--muted); font-size: 13px; }
.foot { margin-top: 48px; color: var(--muted); font-size: 12px; }

.hero { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 28px; align-items: start; }
.session-card, .card, .tile, .panel, .choice, .stat, .word-detail, .dx {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.session-card { padding: 22px; }
.session-head { display: flex; justify-content: space-between; font-weight: 700; }
.pips { display: flex; gap: 8px; margin: 14px 0; }
.pip { height: 8px; flex: 1; border-radius: 99px; background: var(--line); }
.pip.done { background: var(--good); }
.pip.next { background: var(--gold-2); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 16px; }
.mini-stats dt { color: var(--muted); font-size: 12px; }
.mini-stats dd { margin: 0; font-size: 22px; font-family: var(--serif); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 28px; }
.tile { padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.tile:hover { transform: translateY(-2px); }
.he { font-family: var(--he); direction: rtl; text-align: right; }
.he-xl { font-size: clamp(42px, 8vw, 72px); line-height: 1.3; margin: 8px 0; }
.he-lg { font-size: 42px; }
.he-md { font-size: 28px; }
.he-sm { font-size: 22px; }
.he-verse { font-size: clamp(26px, 4vw, 40px); line-height: 1.55; }

.btn {
  border: 0; background: var(--bg-2); padding: 12px 16px; border-radius: 12px;
  font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.row-actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 22px; }
.center-row { justify-content: center; }

.study { max-width: 720px; margin: 0 auto; padding-bottom: 8px; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; background: var(--gold); }
.study-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.pill { background: var(--bg-2); padding: 2px 8px; border-radius: 99px; font-weight: 700; }
.card { padding: 28px; cursor: pointer; }
.card.open { cursor: default; }
.card.parse-card, .card.verse-card { cursor: default; }
.gloss, .gloss-front { font-family: var(--serif); font-size: 28px; margin: 8px 0; }
.gloss-front small { display: block; font-size: 16px; color: var(--muted); }
.extra, .notes-text { color: var(--muted); }
.tap { color: var(--muted); margin-top: 24px; }
.notes { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 15px; line-height: 1.6; }
.notes [dir="rtl"] { font-family: var(--he); }
.mulligan-banner {
  background: var(--card);
  border: 1px solid var(--gold-2);
  color: var(--gold);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
.grades {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 18px;
  position: sticky;
  bottom: 0;
  padding: 12px 0 8px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  z-index: 2;
}
.grade {
  border: 0; border-radius: 14px; padding: 12px 8px; cursor: pointer; color: #fff; display: flex;
  flex-direction: column; gap: 2px;
}
.grade small { opacity: 0.85; font-size: 12px; }
.grade.again { background: var(--again); }
.grade.hard { background: var(--hard); }
.grade.good { background: var(--good); }
.grade.easy { background: var(--easy); }

.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.choice { padding: 16px; text-align: left; cursor: pointer; border: 1px solid var(--line); }
.choice.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-2); }
.choice span, .choice em { display: block; color: var(--muted); font-style: normal; margin-top: 4px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 600;
}
.chip.selected { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.slider { display: grid; gap: 6px; margin: 16px 0; }
.slider input { width: 100%; }
.steps { display: flex; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 18px; }
.steps .on { color: var(--ink); }
.steps .done { color: var(--good); }
.setup-body { max-width: 760px; }
.plain { color: var(--muted); padding-left: 18px; }
.check { display: flex; gap: 8px; align-items: center; margin: 16px 0; }
.danger { margin-top: 28px; display: flex; gap: 12px; align-items: center; }

.parse-head, .daily-nav { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 16px; }
.filters { display: flex; gap: 8px; align-items: center; }
select { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.dx, .word-detail { padding: 20px; margin-top: 16px; }
.dx.ok { border-color: var(--good); }
.dx-banner { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.dx-steps { padding-left: 18px; }
.dx-steps li { margin: 10px 0; }
.dx-steps p { margin: 4px 0 0; color: var(--muted); }
.why-not { padding-left: 18px; color: var(--muted); }
.why-not b { color: var(--ink); }
.words { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.word {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px; cursor: pointer; min-width: 110px;
}
.word span { font-family: var(--he); font-size: 20px; direction: rtl; }
.word.on { border-color: var(--gold); }
.word.hit { border-color: var(--good); }
.why-not [lang="he"] b { color: var(--gold); }
.crossed { text-decoration: line-through; opacity: 0.62; }
.quiz-input {
  width: 100%;
  margin-top: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px 16px;
  font-size: 18px;
}
.board-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.tile-card {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  font-weight: 700;
  cursor: pointer;
  padding: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 14px;
}
.tile-card.he { font-family: var(--he); font-size: 18px; }
.tile-card.up, .tile-card.matched { background: var(--card); }
.tile-card.matched { border-color: var(--good); opacity: 0.85; }
.tile-card.empty { visibility: hidden; }
.read-bar { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.read-v { margin: 18px 0; }
.read-v.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.he-word {
  font: inherit;
  background: transparent;
  border: 0;
  padding: 2px 1px;
  border-radius: 4px;
  color: inherit;
  min-height: 44px;
}
.he-word.lit, .en-line.lit { background: rgba(196, 163, 90, 0.35); }
.en-line { color: var(--muted); line-height: 1.55; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 88px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 40;
  box-shadow: var(--shadow);
}
.vocab-list { display: grid; gap: 12px; margin-top: 16px; }
.vocab-row { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; }
.vocab-he { text-align: right; }
.filter-bar { margin: 12px 0; }
.filter-bar select { max-width: 100%; }
a.chip { display: inline-block; }

.tour-scrim {
  position: fixed;
  inset: 0;
  background: rgba(36, 28, 20, 0.55);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}
.tour-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 34rem;
  width: 100%;
  padding: 22px 22px 18px;
  max-height: min(88vh, 640px);
  overflow: auto;
}
.tour-top { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.tour-card .lede { max-width: none; }

@media (max-width: 860px) {
  .vocab-row { grid-template-columns: 1fr; }
  .vocab-he { text-align: right; }
}

@media (max-width: 860px) {
  .nav { display: none; }
  .dock {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    justify-content: space-around;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    z-index: 20;
  }
  .dock a { padding: 10px 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
  .dock a.on { color: var(--ink); }
  .wrap { padding: 16px 14px 96px; }
  .hero, .tiles, .preset-grid, .read-v.split { grid-template-columns: 1fr; }
  .tile { min-height: 120px; }
  .he-xl { font-size: 36px; }
  .board-5 { gap: 6px; }
  .tile-card { min-height: 56px; font-size: 12px; padding: 4px; }
}
textarea {
  width: 100%; min-height: 90px; margin-top: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; padding: 12px; resize: vertical;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 16px; }
.stat b { display: block; font-family: var(--serif); font-size: 32px; }
.bars { display: flex; gap: 6px; height: 120px; align-items: end; }
.bar { flex: 1; background: var(--line); border-radius: 8px 8px 2px 2px; display: flex; align-items: end; overflow: hidden; }
.bar i { display: block; width: 100%; background: var(--gold); min-height: 4px; }
.center { text-align: center; padding: 48px 24px; }
.panel { padding: 28px; }

@media (max-width: 860px) {
  .hero, .tiles, .preset-grid, .grades, .stat-grid { grid-template-columns: 1fr; }
  .grades { grid-template-columns: 1fr 1fr; }
  .nav { width: 100%; }
}
