/*
  base.css — shared, theme-independent layout and reset.
  No colors or fonts are hardcoded here: every visual value comes from
  CSS custom properties defined per-theme in css/theme-*.css and applied
  via [data-theme]/[data-mode] on <html> (see js/theme.js). This file
  only exists once; theme files never redefine layout, only tokens.
*/

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html[data-theme] {
  background: var(--bg);
}

/* Installed-app behaviour (iPhone / iPad / Mac Add to Dock): no rubber-band bounce or
   pull-to-refresh, no double-tap zoom on controls, no long-press callouts, no tap flash. */
html, body {
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  -webkit-tap-highlight-color: transparent;
}

button, a, .w, .pv-num, .lesson-node, .nav-item, .option, .kbd button {
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

input, textarea, select, canvas {
  touch-action: manipulation;
}

canvas.scribe {
  touch-action: none; /* the pen canvas takes every gesture */
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  transition: background 0.15s ease, color 0.15s ease;
}

img, svg {
  display: block;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ---------- App shell ---------- */

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 900px;
  }
}

/* ---------- Top bar ---------- */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.app-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--primary);
}

.stat-group {
  display: flex;
  align-items: center;
  gap: 18px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.stat-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stat.gold .stat-icon { color: var(--gold); }
.stat.accent .stat-icon { color: var(--accent); }
.stat.primary .stat-icon { color: var(--primary); }

/* ---------- Theme switcher panel (demo control, not a real Settings screen) ---------- */

.theme-panel {
  flex-shrink: 0;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.theme-panel-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 4px;
}

.theme-option-group {
  display: flex;
  gap: 6px;
}

.theme-option {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  transition: all 0.12s ease;
}

.theme-option.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.mode-toggle {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Unit header ---------- */

.unit-header {
  padding: 22px 20px 6px;
}

.unit-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.unit-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.unit-nav {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 4px;
}

.unit-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg, 14px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.unit-kicker {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.unit-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  margin-top: 4px;
}

/* ---------- Lesson path ---------- */

.lesson-path {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 900px) {
  .lesson-path {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-content: start;
  }
}

.lesson-node {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg, 14px);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
}

@media (min-width: 900px) {
  .lesson-node {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
}

.lesson-node[data-state="locked"] {
  opacity: 0.55;
}

.node-dot {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.node-dot svg {
  width: 22px;
  height: 22px;
}

.lesson-node[data-state="complete"] .node-dot { background: var(--gold); }
.lesson-node[data-state="active"] .node-dot { background: var(--accent); }
.lesson-node[data-state="open"] .node-dot { background: var(--primary); }
.lesson-node[data-state="locked"] .node-dot { background: var(--muted); }

.node-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.node-label {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
}

.node-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.node-status {
  margin-left: auto;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}

@media (min-width: 900px) {
  .node-status { margin-left: 0; }
}

.lesson-node[data-state="complete"] .node-status { color: var(--gold-dark); }
.lesson-node[data-state="active"] .node-status { color: var(--accent-dark); }
.lesson-node[data-state="open"] .node-status { color: var(--primary); }

.lesson-node[data-state="locked"] {
  cursor: not-allowed;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.lesson-node.shake {
  animation: shake 0.25s ease;
}

/* ---------- Bottom nav ---------- */

.bottom-nav {
  flex-shrink: 0;
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--muted);
  background: none;
  border: none;
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 10.5px;
}

/* ---------- Due-review banner (lesson path) ---------- */

.install-banner + .due-banner {
  margin-top: 10px;
}

.due-banner {
  margin: 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius-lg, 14px);
  background: var(--primary-tint);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: var(--ink);
}

.due-banner[hidden] {
  display: none;
}

.due-banner strong {
  font-family: var(--font-display);
  color: var(--primary);
}

.btn {
  padding: 9px 16px;
  border-radius: var(--radius-lg, 14px);
  border: 1.5px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.btn.secondary {
  background: transparent;
  color: var(--primary);
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.lesson-node.linked {
  cursor: pointer;
}

/* ---------- Drill screen ---------- */

.drill-top {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.progress {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 5px;
  transition: width 0.25s ease;
}

.drill-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 20px 20px 120px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.drill-kicker {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  padding: 22px 20px;
}

.prompt {
  text-align: center;
}

.prompt-main {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 40px;
  line-height: 1.15;
  color: var(--ink);
  word-break: break-word;
}

.prompt-main.english {
  font-size: 26px;
}

.prompt-hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.intro-citation {
  font-family: var(--font-greek, var(--font-display));
  font-size: 18px;
  color: var(--muted);
  margin-top: 4px;
}

.intro-gloss {
  font-size: 22px;
  color: var(--ink);
  margin-top: 14px;
}

.intro-meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  text-align: left;
  padding: 14px 16px;
  border-radius: var(--radius-lg, 14px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 12px;
}

.option .key {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.option.greek {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 22px;
}

.option:not(:disabled):hover {
  border-color: var(--primary);
}

.option.correct {
  border-color: var(--ok);
  background: var(--ok-tint);
}

.option.wrong {
  border-color: var(--bad);
  background: var(--bad-tint);
}

.option:disabled {
  cursor: default;
}

.type-row {
  display: flex;
  gap: 10px;
}

.type-input {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: var(--radius-lg, 14px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 20px;
}

.type-input.greek {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 24px;
}

.type-input:focus {
  outline: none;
  border-color: var(--primary);
}

.kbd {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.kbd button {
  padding: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-greek, var(--font-display));
  font-size: 18px;
  font-weight: 600;
}

.kbd button.wide {
  grid-column: span 2;
  font-size: 14px;
}

.feedback {
  border-radius: var(--radius-lg, 14px);
  padding: 16px 18px;
  border: 1.5px solid var(--ok);
  background: var(--ok-tint);
  display: none;
}

.feedback.show {
  display: block;
}

.feedback.bad {
  border-color: var(--bad);
  background: var(--bad-tint);
}

.feedback-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--ok);
}

.feedback.bad .feedback-headline {
  color: var(--bad);
}

.feedback-answer {
  margin-top: 6px;
  font-size: 18px;
  color: var(--ink);
}

.feedback-reason {
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

.drill-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px calc(20px + env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
}

.drill-footer[hidden] {
  display: none;
}

.drill-footer .btn {
  width: 100%;
  max-width: 520px;
  padding: 14px 16px;
  font-size: 16px;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.summary-stat {
  text-align: center;
  padding: 12px 6px;
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--border);
}

.summary-stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--primary);
}

.summary-stat span {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.summary-list {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink);
  display: grid;
  gap: 6px;
}

.summary-list .greek {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
}

/* ---------- Shared session bits ---------- */

.session-note {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

.prompt-main.letter {
  font-size: 72px;
  line-height: 1;
}

.prompt-main .stress {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-underline-offset: 6px;
}

.letter-pair {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 24px;
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 84px;
  line-height: 1;
  color: var(--ink);
}

.letter-pair .lower {
  color: var(--primary);
}

.letter-name {
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--ink);
}

.letter-facts {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 15px;
  color: var(--ink);
}

.letter-facts .k {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 6px;
}

.rule-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  color: var(--ink);
}

.rule-body {
  margin-top: 8px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

.rule-examples {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.rule-example {
  padding: 10px 12px;
  border-radius: var(--radius-lg, 14px);
  background: var(--primary-tint);
  font-size: 14px;
}

.rule-example .gr {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  display: block;
}

.rule-example .en {
  color: var(--muted);
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 10px;
}

.ref-table td {
  padding: 8px 6px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

.ref-table td.gr {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 22px;
  color: var(--primary);
  white-space: nowrap;
  width: 1%;
}

.pill-group {
  display: inline-flex;
  gap: 6px;
}

.pill {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- Read & Translate ---------- */

.verse {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 600;
  font-size: 26px;
  line-height: 1.7;
  color: var(--ink);
}

.verse .w {
  cursor: pointer;
  border-radius: 6px;
  padding: 0 2px;
}

.verse .w.unknown {
  text-decoration: underline dotted;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.verse .w.active {
  background: var(--primary-tint);
  color: var(--primary);
}

.verse .punct {
  color: var(--muted);
}

.verse-meta {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}

.verse-meta .legend .w {
  font-family: var(--font-body);
  cursor: default;
}

.gloss-panel {
  border: 1.5px solid var(--primary);
  background: var(--primary-tint);
  border-radius: var(--radius-lg, 14px);
  padding: 14px 16px;
}

.gloss-panel[hidden] {
  display: none;
}

.gloss-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.gloss-form {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 24px;
  color: var(--ink);
}

.gloss-pos {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
}

.gloss-parse {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.gloss-lemma {
  margin-top: 10px;
  font-size: 15px;
  color: var(--ink);
}

.gloss-lemma .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.gloss-status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.tr-head {
  display: flex;
  justify-content: flex-end;
}

.tr-text {
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
}

.rate {
  margin-top: 4px;
}

.rate-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 10px;
}

.rate-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.rate-btn {
  padding: 14px 8px;
  border-radius: var(--radius-lg, 14px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
}

.rate-btn.miss { border-color: var(--bad); color: var(--bad); }
.rate-btn.close { border-color: var(--gold); color: var(--gold-dark); }
.rate-btn.nailed { border-color: var(--ok); color: var(--ok); }

/* ---------- Settings ---------- */

.settings-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 20px 110px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  padding: 16px 18px;
}

.settings-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.settings-row:first-of-type {
  border-top: 0;
}

.settings-label {
  font-size: 15px;
  color: var(--ink);
}

.settings-help {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.theme-option-group.wrap {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.about {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.about b {
  color: var(--ink);
}

.danger {
  border-color: var(--bad);
  color: var(--bad);
  background: transparent;
}

.install-banner {
  margin: 0 20px;
  padding: 12px 14px;
  border-radius: var(--radius-lg, 14px);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  color: var(--ink);
}

.install-banner[hidden] {
  display: none;
}

.hidden-input {
  display: none;
}

/* ---------- Paradigm tables (grammar screen) ---------- */

.paradigm-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.paradigm {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

.paradigm th {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: 6px 8px;
  white-space: nowrap;
}

.paradigm thead th {
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.paradigm td {
  padding: 7px 8px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.paradigm td.gr {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
  white-space: nowrap;
}

.paradigm.parts td.gr {
  text-align: left;
}

.paradigm tbody tr:first-child td {
  border-top: 0;
}

/* ---------- Reader (Read tab) ---------- */

.reader-shell {
  max-width: 1100px;
}

.reader-bar {
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 16px;
}

.reader-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  max-width: 180px;
}

.reader-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reader-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 120px;
}

.reader-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 4px 14px;
}

.reader-head .btn {
  text-decoration: none;
}

.pv-head {
  display: none;
}

.pv-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 4px 10px;
  padding: 12px 4px;
  border-top: 1px solid var(--border);
}

.pv-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  padding-top: 8px;
}

.pv-gr {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 600;
  font-size: 22px;
  line-height: 1.65;
  color: var(--ink);
}

.pv-gr .w {
  cursor: pointer;
  border-radius: 6px;
  padding: 0 1px;
}

.pv-gr .w.unknown {
  text-decoration: underline dotted;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.pv-gr .w.active {
  background: var(--primary-tint);
  color: var(--primary);
}

.pv-gr .punct {
  color: var(--muted);
}

.pv-en {
  grid-column: 2;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--muted);
}

@media (min-width: 900px) {
  .pv-head, .pv-row {
    display: grid;
    grid-template-columns: 36px 1fr 1fr;
    gap: 0 28px;
  }
  .pv-head {
    padding: 6px 4px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
  }
  .pv-en {
    grid-column: 3;
    color: var(--ink);
    font-size: 16px;
    padding-top: 6px;
  }
}

.reader-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 4px;
}

.gloss-sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom));
  width: min(560px, calc(100% - 24px));
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-lg, 14px);
  padding: 14px 44px 14px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  z-index: 5;
}

.gloss-sheet[hidden] {
  display: none;
}

.gloss-sheet a {
  color: var(--primary);
}

.sheet-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
}

.sheet-close svg {
  width: 14px;
  height: 14px;
}

/* ---------- Lexicon ---------- */

.lex-bar {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.lex-search .type-input {
  width: 100%;
  font-size: 16px;
  padding: 10px 14px;
}

.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.lex-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 0 120px;
}

.lex-count {
  padding: 10px 20px 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.lex-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 2px 14px;
  align-items: baseline;
  text-align: left;
  padding: 10px 20px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
}

.lex-row:hover {
  background: var(--surface);
}

.lex-lemma {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
}

.lex-gloss {
  font-size: 14.5px;
}

.lex-meta {
  grid-column: 2;
  font-size: 12px;
  color: var(--muted);
}

.status {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.status.strong { color: var(--ok); }
.status.learning { color: var(--primary); }
.status.due { color: var(--accent); }
.status.new, .status.gloss-only { color: var(--muted); }

.lex-forms {
  margin-top: 6px;
}

.lex-form {
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr auto;
  gap: 10px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--ink);
}

.lex-form .greek {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 16px;
}

.lex-form .n {
  color: var(--muted);
}

/* ---------- Progress ---------- */

.meter {
  margin-top: 10px;
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  margin-bottom: 6px;
  color: var(--ink);
}

.meter-label b {
  font-family: var(--font-display);
  color: var(--primary);
}

.progress-fill.gold {
  background: var(--gold);
}

.ach-group {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  margin: 14px 0 6px;
}

.ach-list {
  display: grid;
  gap: 8px;
}

.ach {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--border);
  opacity: 0.8;
}

.ach.unlocked {
  opacity: 1;
  border-color: var(--gold);
  background: var(--primary-tint);
}

.ach-badge {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--border);
  color: var(--muted);
}

.ach.unlocked .ach-badge {
  background: var(--gold);
  color: #fff;
}

.ach-badge svg {
  width: 18px;
  height: 18px;
}

.ach-text {
  flex: 1;
  min-width: 0;
}

.ach-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
}

.ach-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 1px;
}

.ach-bar {
  height: 6px;
  margin-top: 6px;
}

.ach-count {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------- Switch (Settings) ---------- */

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: var(--border);
  transition: background 0.15s;
  cursor: pointer;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}

/* ---------- Speaker buttons (pronunciation) ---------- */

.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  vertical-align: middle;
  margin-left: 8px;
  flex-shrink: 0;
}

.speak-btn.small {
  width: 28px;
  height: 28px;
  margin-left: 6px;
}

.speak-btn svg {
  width: 18px;
  height: 18px;
}

.speak-btn.small svg {
  width: 14px;
  height: 14px;
}

.speak-btn.speaking {
  background: var(--primary-tint);
  border-color: var(--primary);
}

.no-speech .speak-btn {
  display: none;
}

.prompt-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ---------- Range control (Settings) ---------- */

.rate-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rate-control input[type="range"] {
  width: 140px;
  accent-color: var(--primary);
}

/* ---------- Placement ---------- */

.placement-link {
  margin: 10px 20px 0;
  font-size: 13px;
  color: var(--muted);
}

.placement-link a {
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 600;
}

.book-result {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.book-result b {
  font-family: var(--font-display);
}

.book-result .pass { color: var(--ok); }
.book-result .fail { color: var(--bad); }

/* =====================================================================
   Desktop / landscape layout
   Mobile-first rules above stay untouched; at 900px and up, pages with the
   bottom nav get a left sidebar, the path gets a Books list, the Lexicon
   becomes two panes, and session screens get a framed, wider column.
   ===================================================================== */

.nav-brand {
  display: none;
}

.book-list {
  display: none;
}

.lex-placeholder {
  display: none;
}

@media (min-width: 900px) {
  /* --- sidebar navigation --- */
  .has-sidebar .bottom-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 232px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 22px 14px;
    border-top: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    overflow-y: auto;
    z-index: 4;
  }

  .has-sidebar .nav-brand {
    display: block;
    padding: 4px 12px 18px;
  }

  .nav-brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.5px;
    color: var(--primary);
  }

  .nav-brand-stats {
    display: flex;
    gap: 14px;
    margin-top: 6px;
  }

  .has-sidebar .nav-item {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 12px;
    text-align: left;
  }

  .has-sidebar .nav-item.active {
    background: var(--primary-tint);
  }

  .has-sidebar .nav-item svg {
    width: 20px;
    height: 20px;
  }

  .has-sidebar .nav-item-label {
    font-size: 14.5px;
  }

  /* --- page column beside the sidebar --- */
  .has-sidebar .app-shell {
    max-width: none;
    margin: 0 0 0 232px;
    padding: 0 40px 40px;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .has-sidebar .reader-shell {
    max-width: none;
  }

  .has-sidebar .topbar {
    padding-left: 0;
    padding-right: 0;
    background: transparent;
    border-bottom-color: var(--border);
  }

  .has-sidebar .topbar .app-name {
    display: none; /* the sidebar carries the brand */
  }

  .has-sidebar .install-banner,
  .has-sidebar .due-banner,
  .has-sidebar .placement-link {
    margin-left: 0;
    margin-right: 0;
  }

  .has-sidebar .unit-header {
    padding-left: 0;
    padding-right: 0;
  }

  .has-sidebar .lesson-path {
    padding: 20px 0 40px;
    overflow: visible;
    flex: none;
  }

  .has-sidebar .settings-body {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 40px;
    max-width: 760px;
    margin: 0;
  }

  .has-sidebar .reader-body {
    padding: 16px 0 40px;
    overflow: visible;
    flex: none;
  }

  .has-sidebar .reader-bar {
    padding-left: 0;
    padding-right: 0;
  }

  /* --- the path: Books list + lesson grid --- */
  .path-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
  }

  .book-list {
    display: block;
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 14px);
    background: var(--surface);
    padding: 6px;
  }

  .book-item {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0 8px;
    text-align: left;
    padding: 9px 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--ink);
  }

  .book-item:hover {
    background: var(--bg);
  }

  .book-item.active {
    background: var(--primary-tint);
  }

  .book-item-kicker {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
  }

  .book-item-title {
    grid-column: 1;
    font-size: 13.5px;
    line-height: 1.3;
  }

  .book-item-count {
    grid-row: 1 / span 2;
    grid-column: 2;
    align-self: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 11.5px;
    color: var(--muted);
  }

  .book-item.done .book-item-count {
    color: var(--ok);
  }

  /* --- Lexicon: list + detail pane --- */
  .has-sidebar .lex-bar {
    padding-left: 0;
    padding-right: 0;
  }

  .lex-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 24px;
    align-items: start;
  }

  .has-sidebar .lex-body {
    overflow: visible;
    padding-bottom: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg, 14px);
    background: var(--surface);
  }

  .has-sidebar .lex-row {
    padding-left: 16px;
    padding-right: 16px;
  }

  .lex-detail {
    position: sticky;
    top: 20px;
  }

  .lex-detail .gloss-sheet {
    position: static;
    transform: none;
    width: auto;
    box-shadow: none;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
  }

  .lex-detail .sheet-close {
    display: none;
  }

  .lex-detail .gloss-sheet[hidden] + .lex-placeholder {
    display: block;
    padding: 24px 18px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg, 14px);
    color: var(--muted);
    font-size: 14px;
  }

  /* --- Reader: gloss docked bottom-right --- */
  .reader-shell .gloss-sheet {
    left: auto;
    right: 32px;
    bottom: 32px;
    transform: none;
    width: 380px;
  }

  /* --- Session screens (no sidebar): a real desktop working column ---
     The phone layout pins the action button to the bottom of the viewport; on a
     wide window that leaves the button stranded far from the content. Here the
     footer flows directly under the content, the header is compact and sticky,
     and the column is wide enough to breathe. */
  html:not(.has-sidebar) .app-shell {
    max-width: 960px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 0 32px 64px;
  }

  html:not(.has-sidebar) .drill-top {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }

  html:not(.has-sidebar) .drill-body {
    flex: none;
    overflow: visible;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 36px 0 8px;
    gap: 18px;
  }

  html:not(.has-sidebar) .drill-footer {
    position: static;
    padding: 12px 0 0;
    background: transparent;
    border: 0;
    justify-content: flex-start;
  }

  html:not(.has-sidebar) .drill-footer .btn {
    width: auto;
    min-width: 240px;
    max-width: none;
    padding: 14px 28px;
  }

  html:not(.has-sidebar) .key-hint {
    display: inline-block;
  }

  html:not(.has-sidebar) .options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html:not(.has-sidebar) .options.long {
    grid-template-columns: 1fr;
  }

  html:not(.has-sidebar) .type-row {
    max-width: 560px;
  }

  html:not(.has-sidebar) .kbd {
    max-width: 640px;
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }

  html:not(.has-sidebar) .card.prompt {
    padding: 34px 28px;
  }

  /* Read & Translate: verse + translation on the left, the gloss panel sticky on the right */
  html:not(.has-sidebar)[data-screen="reading"] .drill-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px 28px;
    align-items: start;
  }

  html:not(.has-sidebar)[data-screen="reading"] .drill-body > * {
    grid-column: 1;
  }

  html:not(.has-sidebar)[data-screen="reading"] .drill-body > .gloss-panel {
    grid-column: 2;
    grid-row: 1 / span 6;
    position: sticky;
    top: 84px;
  }

  html:not(.has-sidebar)[data-screen="reading"] .drill-footer {
    max-width: none;
  }

  html:not(.has-sidebar)[data-screen="reading"] .rate-buttons {
    max-width: 560px;
  }

  /* Grammar: paradigm tables get the full column */
  html:not(.has-sidebar) .paradigm td.gr {
    font-size: 21px;
  }

  .prompt-main {
    font-size: 44px;
  }

  .verse {
    font-size: 28px;
  }
}

@media (min-width: 1200px) {
  .path-layout {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .has-sidebar .lesson-path {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* --- short landscape phones: keep the working area usable --- */
@media (max-height: 520px) and (orientation: landscape) {
  .drill-top, .topbar {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .drill-body {
    padding-top: 12px;
    padding-bottom: 84px;
    gap: 10px;
  }

  .card {
    padding: 14px 16px;
  }

  .prompt-main {
    font-size: 30px;
  }

  .prompt-main.letter {
    font-size: 52px;
  }

  .drill-footer {
    padding-top: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .drill-footer .btn {
    padding: 10px 16px;
  }

  .options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bottom-nav {
    padding-top: 4px;
  }

  .nav-item {
    padding: 4px 0;
  }
}

/* ---------- Beta badge + disabled settings rows ---------- */

.beta {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--gold);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  vertical-align: middle;
}

.settings-row.disabled {
  opacity: 0.45;
  pointer-events: none;
}

/* ---------- Study drawer (reader), jump box, Word Pictures, Strong's ---------- */

.jump-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.jump-input {
  width: 150px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}

.jump-input:focus {
  outline: none;
  border-color: var(--primary);
}

.jump-note {
  font-size: 12px;
  color: var(--bad);
  margin-left: 4px;
}

.drawer-tabs {
  display: flex;
  gap: 4px;
  margin: -4px 0 10px;
}

.drawer-tab {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
}

.drawer-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.drawer-ref {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
}

.wp-text {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
}

.wp-text .gr, .wp-text i {
  font-family: var(--font-greek, var(--font-display));
  font-style: normal;
  font-weight: 700;
}

.wp-source {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.xref-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.xref {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
}

.xref.ot {
  color: var(--muted);
  cursor: default;
}

.strongs {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
}

.strongs .k {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.strongs .pron {
  color: var(--muted);
}

.more-btn {
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
}

.wp-card {
  margin-top: 4px;
}

.wp-card .rule-title {
  font-size: 15px;
}

.pv-row.target {
  background: var(--primary-tint);
  border-radius: 10px;
}

.pv-num {
  cursor: pointer;
}

@media (min-width: 900px) {
  .reader-shell .gloss-sheet {
    width: 420px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
}

/* =====================================================================
   Font mix-and-match (Settings → Style → Fonts). Three slots — Greek text,
   headings, body — each either the theme's own choice or one of the five
   families every theme already loads. Selectors on <html> outrank the
   theme files' [data-theme] blocks regardless of stylesheet order.
   ===================================================================== */

html[data-font-greek="baloo"]    { --font-greek: 'Baloo 2', sans-serif; }
html[data-font-greek="garamond"] { --font-greek: 'EB Garamond', serif; }
html[data-font-greek="grotesk"]  { --font-greek: 'Space Grotesk', sans-serif; }
html[data-font-greek="noto-sans"]  { --font-greek: 'Noto Sans', sans-serif; }
html[data-font-greek="noto-serif"] { --font-greek: 'Noto Serif', serif; }

html[data-font-display="baloo"]    { --font-display: 'Baloo 2', sans-serif; }
html[data-font-display="garamond"] { --font-display: 'EB Garamond', serif; }
html[data-font-display="grotesk"]  { --font-display: 'Space Grotesk', sans-serif; }
html[data-font-display="noto-sans"]  { --font-display: 'Noto Sans', sans-serif; }
html[data-font-display="noto-serif"] { --font-display: 'Noto Serif', serif; }

html[data-font-body="baloo"]    { --font-body: 'Baloo 2', sans-serif; }
html[data-font-body="garamond"] { --font-body: 'EB Garamond', serif; }
html[data-font-body="grotesk"]  { --font-body: 'Space Grotesk', sans-serif; }
html[data-font-body="noto-sans"]  { --font-body: 'Noto Sans', sans-serif; }
html[data-font-body="noto-serif"] { --font-body: 'Noto Serif', serif; }

/* Garamond and Noto Serif run small at a given px size; nudge Greek set in them. */
html[data-font-greek="garamond"] .verse, html[data-font-greek="garamond"] .pv-gr, html[data-font-greek="garamond"] .prompt-main,
html[data-font-greek="noto-serif"] .verse, html[data-font-greek="noto-serif"] .pv-gr { font-size: 1.08em; }

.font-preview {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 14px);
  background: var(--bg);
}

.font-preview .fp-head { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: var(--ink); }
.font-preview .fp-greek { font-family: var(--font-greek, var(--font-display)); font-weight: 600; font-size: 22px; line-height: 1.5; color: var(--ink); margin-top: 4px; }
.font-preview .fp-body { font-family: var(--font-body); font-size: 14px; color: var(--muted); margin-top: 4px; }

/* ---------- Lemma hits (reader, arriving from the Lexicon) ---------- */

.pv-gr .w.hit {
  background: var(--primary-tint);
  color: var(--primary);
  border-radius: 6px;
  box-shadow: 0 0 0 2px var(--primary-tint);
}

a.xref {
  text-decoration: none;
}

/* ---------- Keyboard hint beside the action button (desktop only) ---------- */

.key-hint {
  display: none;
  margin-left: 14px;
  font-size: 12.5px;
  color: var(--muted);
  align-self: center;
}

.key-hint kbd {
  font-family: var(--font-display);
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

/* ---------- Dev mode ---------- */

.dev-badge {
  position: fixed;
  top: calc(6px + env(safe-area-inset-top));
  right: 8px;
  z-index: 50;
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--bad);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 1px;
  text-decoration: none;
  opacity: 0.85;
}

.dev-pill {
  border-color: var(--bad);
  color: var(--bad);
  white-space: nowrap;
}

/* ---------- Handwriting (tracing + writing pad) ---------- */

.scribe-wrap {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

canvas.scribe {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg, 14px);
  background: var(--bg);
  max-width: 100%;
  cursor: crosshair;
}

.scribe-tools {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.assign-input {
  width: 100%;
  font-size: 16px;
  line-height: 1.5;
  resize: vertical;
  margin-top: 8px;
}

/* =====================================================================
   Compact study drawers, phone reader ergonomics (YouVersion-style)
   ===================================================================== */

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

.gloss-sheet {
  max-height: min(46vh, 46dvh);
  display: flex;
  flex-direction: column;
  padding: 12px 14px 12px 16px;
}

.gloss-sheet[hidden] {
  display: none;
}

.drawer-head {
  flex-shrink: 0;
  padding-right: 34px;
}

.sheet-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding-right: 4px;
  overflow-wrap: anywhere;
}

.gloss-sheet .sheet-close {
  top: 6px;
  right: 6px;
  z-index: 2;
  background: var(--surface);
}

.gloss-sheet .more-btn,
.gloss-panel .more-btn {
  display: inline-block;
  text-decoration: none;
  margin-top: 10px;
}

.gloss-panel {
  overflow-wrap: anywhere;
}

.wp-text, .gloss-lemma, .gloss-form, .strongs, .lex-form {
  overflow-wrap: anywhere;
}

.study-word {
  display: grid;
  grid-template-columns: minmax(84px, auto) 1fr;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}

.study-word .greek {
  font-family: var(--font-greek, var(--font-display));
  font-weight: 700;
  font-size: 18px;
}

.study-word a {
  color: var(--primary);
}

/* reader header: never wider than the phone */
.reader-bar {
  overflow: hidden;
}

.reader-nav {
  flex-wrap: wrap;
  max-width: 100%;
}

.reader-nav .select {
  max-width: 128px;
}

.jump-input {
  width: 118px;
}

.fab {
  display: none;
}

@media (max-width: 899px) {
  /* Bottom nav pinned: Home is always one tap away, even mid-chapter */
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .app-shell {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  /* the reader's own scroller is the page now; keep the top bar in view */
  .reader-bar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .reader-body {
    flex: none;
    overflow: visible;
    padding-bottom: 40px;
  }

  .reader-foot {
    display: none;
  }

  /* floating chapter arrows above the nav, as in YouVersion */
  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 24px;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    z-index: 5;
  }

  .fab-prev { left: calc(12px + env(safe-area-inset-left)); }
  .fab-next { right: calc(12px + env(safe-area-inset-right)); }

  /* the drawer sits above the nav and never covers the arrows' row entirely */
  .gloss-sheet {
    bottom: calc(70px + env(safe-area-inset-bottom));
    width: calc(100% - 16px);
  }

  .jump-form {
    flex-basis: 100%;
  }

  .jump-input {
    flex: 1;
    width: auto;
  }

  /* lists that used to be page scrollers scroll with the page */
  .lex-body, .settings-body, .lesson-path {
    flex: none;
    overflow: visible;
  }

  .lesson-path {
    padding-bottom: 24px;
  }
}

/* ---------- iOS: inputs under 16px zoom the page on focus; never let that happen on phones ---------- */

@media (max-width: 899px) {
  input, select, textarea, .type-input, .jump-input, .select, .lex-search .type-input {
    font-size: 16px;
  }
}

.pill .beta, .btn .beta {
  margin-left: 4px;
  padding: 0 5px;
  font-size: 9px;
}

/* ---------- Handwriting tab (write.html) ---------- */

.write-modes {
  padding: 8px 20px 4px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.write-modes .chips {
  justify-content: center;
}

.write-body {
  max-width: 680px;
  gap: 12px;
}

.write-summary {
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.write-letters {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.write-letter {
  font-family: var(--font-greek, var(--font-display));
  font-size: 22px;
  font-weight: 600;
  padding: 6px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  position: relative;
}

.write-letter.done::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
}

.write-letter.active {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent);
}

.write-card .write-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.write-card .write-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 2px;
}

.write-msg {
  margin-top: 10px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 1.4em;
}

.write-xp {
  color: var(--gold, var(--primary));
  font-weight: 700;
}

.write-verse-text {
  margin-top: 12px;
  font-family: var(--font-greek, var(--font-display));
  font-size: 17px;
  line-height: 1.6;
}

.write-picker {
  display: flex;
  gap: 8px;
}

.write-picker .select {
  flex: 1;
  min-width: 0;
}

.write-picker .select:first-child {
  flex: 2;
}

.write-picker .jump-input {
  width: 100%;
  flex: 1;
}

.write-list .lex-row {
  padding-left: 12px;
  padding-right: 12px;
}

.write-list .lex-lemma.done::after {
  content: ' ✓';
  color: var(--ok);
  font-size: 13px;
}

.jump-input.bad {
  border-color: var(--bad);
}

@media (max-width: 420px) {
  .write-letters {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ---------- Lexicon detail sheet: compact, pinned header, body scrolls ---------- */

#sheetBody {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.gloss-sheet [hidden] {
  display: none !important;
}

.lex-head {
  padding-right: 34px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.lex-head .gloss-form {
  font-size: 20px;
  line-height: 1.25;
}

.lex-sub {
  margin-top: 3px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
}

.lex-sub .gloss-pos {
  font-size: 10.5px;
}

.lex-sheet-body {
  padding-top: 4px;
}

.lex-sheet-body .strongs {
  font-size: 13px;
}

.lex-section {
  margin: 12px 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.lex-sheet-body .lex-form {
  grid-template-columns: minmax(64px, auto) 1fr auto;
  gap: 8px;
  font-size: 12.5px;
}

.lex-sheet-body .lex-form .greek {
  font-size: 15px;
}

.lex-sheet-body .xref {
  font-size: 12px;
  padding: 4px 8px;
}

.occ-more {
  display: contents;
}

.more-toggle {
  display: inline-block;
  margin-top: 4px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
}

.lex-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lex-actions .btn {
  padding: 8px 12px;
  font-size: 13px;
  text-decoration: none;
}

@media (max-width: 899px) {
  .lex-detail .gloss-sheet {
    max-height: min(48vh, 48dvh);
  }
}

/* Lexicon search: the inflected form or transliteration that matched (λόγου → λόγος) */
.lex-via {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 11.5px;
  color: var(--muted);
}

/* ---------- Write tab v2: header, controls, verse parts, full screen ---------- */

.write-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.write-head-text {
  flex: 1;
  min-width: 0;
}

.write-fs-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.write-fs-btn svg {
  width: 18px;
  height: 18px;
}

.write-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.write-ctrl-spacer {
  flex: 1;
}

.write-ctrl-label {
  font-size: 12.5px;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12.5px;
  padding: 6px 11px;
}

.seg button + button {
  border-left: 1.5px solid var(--border);
}

.seg button.active {
  background: var(--primary);
  color: #fff;
}

.ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  padding: 0;
}

.ctrl-btn small {
  font-size: 9px;
  margin-left: 1px;
  color: var(--muted);
}

.pen-dot {
  display: block;
  border-radius: 50%;
  background: var(--ink);
}

.write-card .scribe-tools .btn {
  padding: 8px 20px;
}

.write-parts {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.write-parts-label {
  font-size: 12px;
  color: var(--muted);
  margin-right: 4px;
}

.part-dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent;
}

.part-dot.done {
  background: var(--ok);
  border-color: var(--ok);
}

.part-dot.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent);
}

.write-card canvas.scribe {
  border-style: solid;
  border-width: 1px;
}

/* full screen: the card covers the app; the canvas takes all the room between the controls */
.write-card.fs {
  position: fixed;
  inset: 0;
  z-index: 100;
  margin: 0;
  border: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.write-card.fs .write-title {
  font-size: 16px;
}

.write-card.fs .write-sub {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}

.write-card.fs .write-ctrl,
.write-card.fs .write-parts {
  margin-top: 6px;
}

.write-card.fs .scribe-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 8px;
  align-items: center;
}

.write-card.fs .scribe-tools {
  margin-top: 8px;
}

.write-card.fs .write-msg {
  margin-top: 6px;
  min-height: 1.2em;
}

html.write-fs-open,
html.write-fs-open body {
  overflow: hidden;
}

@media (orientation: landscape) and (max-height: 520px) {
  .write-card.fs .write-sub,
  .write-card.fs .write-msg:empty {
    display: none;
  }
}

/* Write tab: letters in one scrollable row so the canvas stays on screen */
.write-letter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.write-letter-bar .seg button {
  font-family: var(--font-greek, var(--font-display));
  font-size: 15px;
  padding: 5px 10px;
}

.write-letter-bar .write-letters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 3px 2px;
  flex: 1;
  min-width: 0;
  scroll-snap-type: x proximity;
}

.write-letter-bar .write-letters::-webkit-scrollbar {
  display: none;
}

.write-letter-bar .write-letter {
  flex: 0 0 40px;
  height: 40px;
  padding: 0;
  font-size: 20px;
  scroll-snap-align: center;
}

/* ---------- Write & translate: automatic grade ---------- */

.grade-card {
  border-width: 1.5px;
}

.grade-card.grade-nailed { border-color: var(--ok); }
.grade-card.grade-close { border-color: var(--gold); }
.grade-card.grade-miss { border-color: var(--bad); }

.grade-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.grade-badge {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
}

.grade-nailed .grade-badge { color: var(--ok); }
.grade-close .grade-badge { color: var(--gold-dark, var(--gold)); }
.grade-miss .grade-badge { color: var(--bad); }

.grade-score {
  font-size: 13px;
  color: var(--muted);
}

.grade-verse {
  margin-top: 10px;
  font-family: var(--font-greek, var(--font-display));
  font-size: 19px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.gw.ok {
  text-decoration: underline;
  text-decoration-color: var(--ok);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.gw.missed {
  background: color-mix(in srgb, var(--gold) 28%, transparent);
  border-radius: 4px;
  padding: 0 2px;
}

.gw.optional {
  color: var(--muted);
}

.grade-missed {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink);
}

.grade-missed .gm {
  color: var(--muted);
}

.grade-note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.grade-refs {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.grade-refs .wp-text + .wp-text {
  margin-top: 6px;
}
