:root {
  --bg: #faf7f0;
  --surface: #ffffff;
  --sidebar: #f2ede1;
  --ink: #1f2933;
  --muted: #5f6b76;
  --line: #e2dbcb;
  --accent: #1d4e89;
  --accent-soft: #dfe8f3;
  --warn: #8a3b12;
  --warn-soft: #fbe9dc;
  --serif: "Frank Ruhl Libre", "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --surface: #1c2229;
    --sidebar: #181d23;
    --ink: #e8e6e1;
    --muted: #9aa5b0;
    --line: #2e363f;
    --accent: #8db8ea;
    --accent-soft: #24344a;
    --warn: #f3b58f;
    --warn-soft: #3a2518;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

a {
  color: var(--accent);
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.2;
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
}

h2 {
  font-size: 1.45rem;
}

p {
  margin: 0 0 1em;
}

.he {
  font-family: var(--serif);
  font-size: 1.15em;
  line-height: 1;
}

.warning {
  background: var(--warn-soft);
  color: var(--warn);
  padding: 8px 16px;
  text-align: center;
  font-size: 0.9rem;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

main {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 44px 32px 80px;
  outline: none;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 8px 16px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--accent);
}

.brand-name {
  font-size: 0.85rem;
  color: var(--muted);
}

.nav-stage,
.nav-link {
  display: block;
  padding: 8px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.nav-stage {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 6px;
  font-size: 0.9rem;
}

.nav-stage:hover,
.nav-link:hover {
  background: var(--line);
}

.nav-stage[aria-current="true"],
.nav-link[aria-current="true"] {
  background: var(--accent-soft);
}

.nav-mark {
  font-family: var(--serif);
  font-size: 1.25rem;
  line-height: 1;
  text-align: center;
  color: var(--accent);
}

.nav-pct {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.nav-link {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  border-radius: 0;
  font-size: 0.9rem;
}

/* Page furniture */
.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.eyebrow a {
  color: inherit;
}

.lede {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 12px 0 0;
}

.page-head {
  margin-bottom: 32px;
}

.note {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 14px;
  margin: 0 0 24px;
  color: var(--muted);
}

.meter {
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s;
}

.meter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.page-head .meter-row {
  margin-top: 16px;
}

.button {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: var(--accent);
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
}

.button.danger {
  color: var(--warn);
}

/* Home */
.resume {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin: 28px 0 36px;
}

.resume h2 {
  margin-bottom: 14px;
}

.resume .meter-row {
  margin-bottom: 16px;
}

.stage-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 36px;
}

.stage-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  color: inherit;
  text-decoration: none;
}

.stage-card:hover,
.unit-card:hover {
  border-color: var(--accent);
}

.stage-mark {
  font-family: var(--serif);
  font-size: 2.2rem;
  line-height: 1;
  color: var(--accent);
  text-align: center;
}

.stage-card h3 {
  font-size: 1.15rem;
}

.stage-card p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 2px 0 10px;
}

.path {
  color: var(--muted);
  font-size: 0.9rem;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Stage and unit pages */
.unit-list {
  display: grid;
  gap: 10px;
  margin-bottom: 36px;
}

.unit-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
}

.unit-card strong {
  font-weight: 600;
}

.unit-card .meter-row {
  margin-top: 8px;
}

.block {
  margin-bottom: 32px;
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.count {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.checks li + li {
  border-top: 1px solid var(--line);
}

.checks label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 11px 14px;
  cursor: pointer;
}

.checks label:hover {
  background: var(--accent-soft);
}

.checks input {
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--accent);
}

.checks input:checked + span {
  color: var(--muted);
}

.notes textarea {
  width: 100%;
  min-height: 130px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 40px;
}

.pager a {
  max-width: 48%;
  text-decoration: none;
  font-size: 0.9rem;
}

.pager a:last-child:not(:first-child),
.pager .next {
  margin-left: auto;
  text-align: right;
}

/* Lessons */
.lesson {
  margin-bottom: 32px;
}

.lesson h2 {
  margin-bottom: 12px;
}

.lesson h3 {
  font-size: 1.15rem;
  margin: 1.5em 0 10px;
}

[data-clip-start] {
  cursor: pointer;
  border-radius: 4px;
}

.he[data-clip-start] {
  text-decoration: underline dotted var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

[data-clip-start]:hover {
  color: var(--accent);
}

[data-clip-start].playing {
  background: var(--accent-soft);
  color: var(--accent);
}

.lesson .passage[data-clip-start]:hover {
  border-color: var(--accent);
}

.lesson .passage {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 1.7;
}

.lesson blockquote {
  margin: 0 0 1em;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
}

.lesson .he {
  font-size: 1.3em;
}

/* Large enough to tell the vowel marks apart. */
.lesson li .he {
  font-size: 1.6em;
  line-height: 1.3;
}

.lesson-table td .he {
  font-size: 1.9em;
  line-height: 1.3;
}

.lesson .example {
  margin-left: 16px;
}

.lesson .example .he {
  font-size: 1.7em;
  line-height: 1.5;
}

.lesson ul,
.lesson ol {
  margin: 0 0 1em;
  padding-left: 22px;
}

.lesson li {
  margin-bottom: 4px;
}

.lesson-table {
  overflow-x: auto;
  margin-bottom: 1em;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.lesson-table table {
  width: 100%;
  border-collapse: collapse;
}

.lesson-table th,
.lesson-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.lesson-table tr:last-child td {
  border-bottom: 0;
}

.lesson-table th {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.answers {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.answers summary {
  font-weight: 600;
  cursor: pointer;
}

.answers[open] summary {
  margin-bottom: 12px;
}

.answers p:last-child {
  margin-bottom: 0;
}

.tag {
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Guide */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
}

.table th,
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table td:last-child {
  text-align: right;
  white-space: nowrap;
}

.guide-list {
  margin: 0 0 1em;
  padding-left: 22px;
}

.guide-list li {
  margin-bottom: 4px;
}

@media (max-width: 800px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px 16px;
  }

  .brand {
    padding: 0 0 8px;
  }

  #stage-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    margin: 0 -16px;
    padding: 0 16px;
  }

  .nav-stage {
    display: block;
    flex: none;
    min-width: 44px;
    text-align: center;
    padding: 6px;
  }

  .nav-title {
    display: none;
  }

  .nav-pct {
    display: block;
  }

  .nav-link {
    margin-top: 6px;
    padding: 8px 0 0;
  }

  main {
    padding: 28px 16px 60px;
  }

  .lesson-table td .he {
    font-size: 1.45em;
  }
}

/* Vocabulary review */
.review-prompt {
  font-size: 1.3rem;
  font-weight: 600;
}

.review-hebrew {
  margin-bottom: 0;
  font-size: 2rem;
}

.lesson-table select {
  max-width: 100%;
  font: inherit;
}

[data-vocab-pack] .lesson-table td:nth-child(4) .he {
  font-size: 1.1em;
}

.vocab-stage {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.vocab-stage summary {
  cursor: pointer;
  font-weight: 600;
}

.vocab-stage summary .count {
  margin-left: 8px;
  font-weight: 400;
}

.vocab-stage h3 {
  margin: 18px 0 8px;
}

/* AI tutor */
.tutor-line code {
  overflow-wrap: anywhere;
}

.agent-note {
  padding: 16px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.agent-note p {
  margin: 0 auto 8px;
  max-width: 640px;
}

.agent-note ul {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.tutor-line + .data-actions + p {
  margin-top: 12px;
}
