:root {
  --ink: #1c1712;
  --parchment: #f4efe6;
  --paper: #fffdf8;
  --muted: #6b6258;
  --line: #e3d7c6;
  --accent: #3c2868;
  --on-accent: #ffffff;
  --fill: #1d1d1f;
  --on-fill: #ffffff;
  --chip: #e8e8ed;
  --danger: #b42318;
  --display: "Iowan Old Style", "Source Serif 4", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Source Sans 3", "Segoe UI", sans-serif;
  --header: rgba(245, 245, 247, 0.8);
}

.dark {
  --ink: #f5f5f7;
  --parchment: #000000;
  --paper: #1c1c1e;
  --muted: #98989d;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #2997ff;
  --on-accent: #ffffff;
  --fill: #f5f5f7;
  --on-fill: #1d1d1f;
  --chip: #2c2c2e;
  --danger: #ff6961;
  --header: rgba(0, 0, 0, 0.72);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 0.15em; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip:focus {
  left: 12px; top: 12px; z-index: 6;
  background: var(--fill); color: var(--on-fill);
  padding: 8px 14px; border-radius: 999px;
}
.wrap { width: min(980px, calc(100% - 40px)); margin: 0 auto; }
.narrow { width: min(720px, calc(100% - 40px)); margin: 0 auto; }

header.site {
  position: sticky;
  top: 0;
  z-index: 4;
  border-bottom: 1px solid var(--line);
  background: var(--header);
  backdrop-filter: saturate(180%) blur(20px);
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 0;
}
.brand { text-decoration: none; color: inherit; min-width: 0; }
.brand strong {
  display: block;
  font-family: var(--sans);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
}
.brand span { display: none; }
.nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 2px; }
.nav a {
  color: var(--ink);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.82rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  opacity: 0.8;
}
.nav a[aria-current="page"] { opacity: 1; font-weight: 600; color: var(--ink); }
.theme {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink);
}
.theme svg { width: 18px; height: 18px; display: block; }

main { flex: 1; padding: 56px 0 72px; }
h1, h2, h3 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
h1 { font-size: clamp(2.6rem, 6vw, 3.5rem); line-height: 1.05; margin: 0; max-width: 18em; }
h2 { font-size: 1.7rem; margin: 0 0 8px; }
.lede {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.4;
  max-width: 36rem;
  margin: 16px 0 0;
}
.card, .desk, .result, .guide, details { background: transparent; border: 0; box-shadow: none; }
.desk, .result { padding: 0; }
.cards { display: grid; gap: 16px; margin-top: 28px; }
.card p, .guide p { color: var(--muted); }
input[type="text"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 12px;
  padding: 14px 16px;
}
textarea { min-height: 140px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.primary, .ghost {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 16px;
  font-size: 0.95rem;
  font-weight: 500;
}
.primary { border: 0; background: var(--fill); color: var(--on-fill); }
.primary:disabled { opacity: 0.45; }
.primary:active { transform: scale(0.98); }
.ghost { border: 0; background: var(--chip); color: var(--ink); }
.muted { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; list-style: none; }
.chip {
  min-height: 32px;
  border-radius: 999px;
  border: 0;
  background: var(--chip);
  padding: 0 12px;
  color: var(--ink);
  font-size: 0.85rem;
}
.error {
  color: var(--danger);
  margin: 16px 0 0;
}
.stack { display: grid; gap: 4px; margin-top: 8px; }
.stack h2 { margin-bottom: 8px; }
.stack p { margin: 0 0 12px; }
.guides { display: grid; gap: 0; margin: 8px 0 0; padding: 0; list-style: none; }
.guide { padding: 0; }
.guide a {
  display: block;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.guide h2 { font-family: var(--sans); font-size: 1.05rem; font-weight: 600; letter-spacing: -0.015em; }
.guide p { margin: 4px 0 0; font-size: 0.95rem; }
.guide a:hover h2 { color: var(--accent); }
details { padding: 16px 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 600; }
.further { margin-top: 88px; }
.further h2 { margin-top: 40px; }
.back { margin: 0 0 12px; font-size: 0.95rem; }
.back a { color: var(--accent); text-decoration: none; }
.saved { list-style: none; margin: 8px 0 0; padding: 0; background: var(--paper); border-radius: 16px; overflow: hidden; }
.saved-row {
  display: flex;
  width: 100%;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font-size: 1.02rem;
}
.saved-row:last-child { border-bottom: 0; }
.saved-row::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  flex: none;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
footer { padding: 28px 0 40px; color: var(--muted); font-size: 0.8rem; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 20px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 14px; }
.foot a { color: var(--muted); text-decoration: none; }
.foot p { margin: 0; max-width: 36rem; }

.study-body h2 { font-size: 1.7rem; margin: 0 0 12px; }
.study-body h3 {
  margin: 22px 0 8px;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.study-body ul { list-style: none; padding: 0; margin: 0; }
.study-body li { padding: 12px 0; border-bottom: 1px solid var(--line); line-height: 1.5; }
.original-term { border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); cursor: help; }
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 28px;
  padding: 6px 6px 6px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.06);
}
.dark .search { box-shadow: none; border: 1px solid var(--line); }
.search input[type="text"] {
  flex: 1 1 auto;
  width: 0;
  min-width: 0;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 10px 0;
  font-size: 1.05rem;
  min-height: 44px;
}
.search .primary { flex: 0 0 auto; position: relative; z-index: 1; min-height: 40px; padding-inline: 18px; }
.search input::placeholder { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin: 14px 2px 0; }
.suggest, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.suggest { margin-top: 14px; }
.row.tight { margin-top: 28px; }
.row.tight .muted { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.texty {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 500;
  padding: 0 4px;
}
.study { margin-top: 36px; scroll-margin-top: 72px; animation: rise 280ms ease; }
.study:focus { outline: none; }
.actions { margin: 0 0 18px; }
.kicker {
  margin: 28px 0 8px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.verse-text {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.55rem, 3vw, 2rem);
  line-height: 1.45;
  letter-spacing: -0.02em;
  margin: 0;
}
.verse-word {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  border-bottom: 1px solid transparent;
}
.verse-word.is-open { border-bottom-color: var(--accent); }
.move { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.move h2 { margin: 0; font-size: 1.7rem; text-align: center; }
.move-gap { width: 5.5rem; }
.chapter { list-style: none; margin: 0; padding: 0; }
.chapter-row, .where-list button {
  display: flex;
  width: 100%;
  gap: 14px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  font: inherit;
}
.chapter-row span:first-child { width: 2rem; color: var(--muted); }
.where-list { list-style: none; margin: 8px 0 0; padding: 0; }
.where-list button { flex-direction: column; gap: 4px; }
.where-list span { color: var(--muted); font-size: 0.92rem; }
.verse-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip.is-open { background: var(--fill); color: var(--on-fill); }
.word-list {
  margin-top: 20px;
  background: var(--paper);
  border-radius: 18px;
  overflow: hidden;
}
.word { border-bottom: 1px solid var(--line); }
.word:last-child { border-bottom: 0; }
.word-pick {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  text-align: left;
}
.word-en { font-weight: 500; font-size: 1.02rem; flex: 1; }
.word-meta { color: var(--muted); font-size: 0.95rem; }
.word-pick::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  flex: none;
  margin-left: 4px;
}
.word-pick[aria-expanded="true"] { background: color-mix(in srgb, var(--accent) 7%, var(--paper)); }
.word-pick[aria-expanded="true"]::after { transform: rotate(45deg); }
.word-pick[aria-expanded="true"] .word-en { color: var(--ink); }
.word-detail { padding: 4px 20px 22px; }
.word-detail .lemma {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.say { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }
.lexicon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-top: 12px;
  padding: 0 12px;
  border-radius: 12px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: transform 150ms ease, background 150ms ease;
}
.lexicon:active {
  transform: scale(0.98);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
@media (prefers-reduced-motion: reduce) {
  .lexicon { transition: none; }
  .lexicon:active { transform: none; }
}
.lexicon span:last-child { color: var(--accent); font-weight: 500; letter-spacing: 0; font-size: 0.95rem; }
.listen {
  border: 0;
  background: var(--chip);
  color: var(--ink);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 500;
}
.listen[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); }
.word-detail .kicker { margin: 20px 0 6px; }
.word-detail p { margin-top: 0; margin-bottom: 0; }
.fine-print { color: var(--muted); font-size: 0.85rem; line-height: 1.45; margin: 14px 0 0; }
.strong { color: var(--accent); font-weight: 500; text-decoration: none; }
.strong:hover { text-decoration: underline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
header.site { padding-top: env(safe-area-inset-top); }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .study { animation: none; }
  html { scroll-behavior: auto; }
}
@media (max-width: 720px) {
  .nav a { padding: 0 7px; }
  .wrap, .narrow { width: min(100% - 32px, 720px); }
}
[hidden] { display: none !important; }

body.is-reading h1,
body.is-reading .lede,
body.is-reading .hint,
body.is-reading .suggest,
body.is-reading .further,
body.is-reading #library-block {
  display: none;
}
body.is-reading main { padding-top: 28px; }
.reader {
  max-width: 40rem;
  font-family: var(--display);
  font-size: 1.28rem;
  line-height: 1.75;
}
.reader-verse { border-radius: 0.2rem; }
.verse-mark {
  border: 0;
  background: transparent;
  margin-right: 0.28rem;
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 650;
  color: var(--muted);
  vertical-align: super;
  cursor: pointer;
}
.reader .verse-word {
  display: inline;
  padding: 0.12em 0.04em;
  border-radius: 0.2rem;
  cursor: pointer;
}
.reader .verse-word.is-open {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-bottom-color: transparent;
}
.chapter-sheet { margin-top: 1.5rem; }

.chapter-sheet {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(72vh, 640px);
  overflow: auto;
  border-top: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.12);
  padding: 0.5rem 1.25rem 1.5rem;
}
.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  padding: 0.35rem 0;
}
.sheet-ref { margin: 0; font-weight: 650; }
.sheet-verse {
  font-family: var(--display);
  font-size: 1.15rem;
  line-height: 1.55;
  margin: 0.4rem 0 0;
}
.sheet-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 1rem 0; }
.sheet-chip {
  border: 0;
  background: transparent;
  padding: 0.2rem 0.35rem;
  border-radius: 0.5rem;
}
.sheet-chip.is-on { background: #f4e7c8; }
.chapter-sheet .lemma {
  font-family: var(--display);
  font-size: 2.15rem;
  line-height: 1.1;
  margin: 0.3rem 0 0;
}
.reader-tools { display: flex; justify-content: space-between; margin: 0 0 0.5rem; }
body.is-reading #study-note { display: none; }
@media (min-width: 960px) {
  .chapter-sheet {
    top: 4.5rem;
    bottom: 1rem;
    left: auto;
    width: min(28rem, 38vw);
    max-height: none;
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  }
}

.search-pill {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 52px;
  margin-top: 28px;
  padding: 4px 4px 4px 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 1px 1px rgba(28, 23, 18, 0.03), 0 10px 28px rgba(28, 23, 18, 0.05);
}
.search-pill:focus-within {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent), 0 12px 30px rgba(28, 23, 18, 0.07);
}
.search-icon { flex: 0 0 auto; color: var(--muted); }
.search-pill input {
  min-width: 0;
  flex: 1;
  border: 0;
  background: transparent;
  padding: 0.7rem 0.2rem;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ink);
  outline: none;
}
.search-pill input::placeholder { color: var(--muted); }
.search-go {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  padding: 0 1.05rem;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--on-accent);
}
.search-go:disabled { opacity: 0.55; }
.search-go:active { transform: scale(0.97); }
.search-clear {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.search-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: 0 18px 44px rgba(28, 23, 18, 0.12);
}
.search-row {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  background: transparent;
  text-align: left;
}
.search-row.is-active,
.search-row:hover { background: color-mix(in srgb, var(--accent) 8%, var(--paper)); }
.search-kind {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

body.is-reading .actions { display: none; }
.sheet-actions { display: flex; align-items: center; gap: 6px; }
.sheet-actions .ghost { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }

.verse-actions { display: flex; gap: 8px; margin: 0 0 12px; }
.verse-actions .ghost { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }
