@font-face {
  font-family: "Gentium Plus";
  src: url(../../fonts/GentiumPlus-Regular.woff2) format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Gentium Plus";
  src: url(../../fonts/GentiumPlus-Bold.woff2) format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --bg-page: #fbf8f2;
  --bg-elev: #ffffff;
  --text: #2a2420;
  --text-2: #6f655c;
  --border: #e4dccf;
  --border-strong: #6f655c;
  --accent: #7a3e1d;
  --accent-hover: #5e2f15;
  --accent-soft: #f0e6d8;
  --primary-fg: #fffdf8;
  --success-bg: #e6f2e7;
  --success-text: #1d4a28;
  --warn-bg: #f8ecd3;
  --warn-text: #5a3b0c;
  --info-bg: #e8eef6;
  --info-text: #1e3358;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", "Noto Serif", serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --greek: "Gentium Plus", "Gentium Book Plus", "Noto Serif", "Times New Roman", serif;
  --shadow: 0 1px 2px rgba(40, 28, 16, 0.06);
  --radius: 12px;
  --max: 44rem;
}

[data-theme="dark"] {
  --bg: #16130f;
  --bg-page: #1b1713;
  --bg-elev: #221d18;
  --text: #ebe3d6;
  --text-2: #a89c8d;
  --border: #3a322a;
  --border-strong: #a89c8d;
  --accent: #e0a06a;
  --accent-hover: #ebb484;
  --accent-soft: #31271f;
  --primary-fg: #16130f;
  --success-bg: #1c3322;
  --success-text: #cfe8d4;
  --warn-bg: #3a2e16;
  --warn-text: #f0d7a4;
  --info-bg: #1d2a3c;
  --info-text: #c9d8ef;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f;
    --bg-page: #1b1713;
    --bg-elev: #221d18;
    --text: #ebe3d6;
    --text-2: #a89c8d;
    --border: #3a322a;
    --border-strong: #a89c8d;
    --accent: #e0a06a;
    --accent-hover: #ebb484;
    --accent-soft: #31271f;
    --primary-fg: #16130f;
    --success-bg: #1c3322;
    --success-text: #cfe8d4;
    --warn-bg: #3a2e16;
    --warn-text: #f0d7a4;
    --info-bg: #1d2a3c;
    --info-text: #c9d8ef;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
}

.wb-top {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.75rem;
  padding-top: max(0.4rem, env(safe-area-inset-top));
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-ui);
}
.wb-back {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--greek);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.5rem;
}
.wb-back:hover { background: var(--accent-soft); }
.wb-top-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-2);
}
.wb-iconbtn {
  background: none;
  border: 0;
  min-width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.5rem;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  text-align: center;
  padding: 0;
  color: var(--text);
}
.wb-iconbtn:hover { background: var(--accent-soft); filter: none; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.55;
  min-height: 100vh;
}

.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: 24px 20px 40px;
  background: var(--bg-page);
  min-height: 100vh;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}
.page-header h1 {
  font-size: 1.65rem;
  line-height: 1.25;
  margin: 0;
  font-weight: 650;
}
.toc-back {
  flex-shrink: 0;
  font-size: 0.9rem;
  padding: 6px 10px;
}
.lede { color: var(--text-2); margin: 0 0 20px; font-size: 1rem; }

.section { margin: 0 0 28px; }
.section h2 {
  font-size: 1.2rem;
  margin: 0 0 10px;
  font-weight: 650;
}
.section p { margin: 0 0 10px; }
.caption { color: var(--text-2); font-size: 0.92rem; margin: 0 0 10px; }

.collapsible > summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 1.2rem;
  margin-bottom: 10px;
  list-style: none;
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::after {
  content: " ▾";
  color: var(--text-2);
  font-weight: 400;
}
.collapsible:not([open]) > summary::after { content: " ▸"; }

.stack { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.row-2 { display: flex; gap: 16px; width: 100%; }
.row-2 > * { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }

button {
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.3;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
button.primary {
  background: var(--accent);
  color: var(--primary-fg);
  border-color: var(--accent);
}
button.quiet { border-color: var(--border); background: transparent; }
button:hover:not(:disabled) { filter: brightness(0.97); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.greek, .greek { font-family: var(--greek); }

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--accent-soft);
  border-radius: 12px;
  margin: 0 0 16px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 9px;
  font-weight: 600;
}
.seg button[aria-pressed="true"] {
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  color: var(--text);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
  font-size: 0.98rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.data th, table.data td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-family: var(--greek);
}
table.data th {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--accent-soft);
}
table.data tr:last-child td { border-bottom: 0; }

.status, .callout {
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0 0 12px;
}
.status.success, .callout.info { background: var(--success-bg); color: var(--success-text); }
.status.warning { background: var(--warn-bg); color: var(--warn-text); }
.callout.info { background: var(--info-bg); color: var(--info-text); }
.callout .lead { font-weight: 650; margin-bottom: 4px; }

.props { margin: 0 0 12px; }
.props .row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.props .label { color: var(--text-2); min-width: 9rem; font-family: var(--font-ui); font-size: 0.92rem; }
.props .value { flex: 1; }

.gloss {
  margin-top: 8px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.gloss .word-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gloss .word { font-family: var(--greek); font-size: 22px; line-height: 28px; font-weight: 650; }
.gloss .tr { font-family: var(--font-ui); font-size: 0.92rem; color: var(--text-2); }
.gloss .meaning { font-size: 18px; line-height: 24px; font-weight: 500; }
.gloss .meta { font-size: 14px; line-height: 20px; color: var(--text-2); }

.links { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 0; }
.links a { color: var(--accent); }
.links .site { color: var(--text-2); font-size: 0.85rem; margin-left: 6px; font-family: var(--font-ui); }

.hint { color: var(--text-2); font-style: italic; }

.stepper-space { height: 160px; width: 100%; }

.floating {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-page);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 16px rgba(40, 28, 16, 0.08);
  z-index: 20;
}
.floating-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.step-label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-2);
  text-align: center;
}
.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.stepper button { text-align: center; min-width: 2.6rem; }
.stepper .count { font-family: var(--font-ui); font-weight: 600; }

.loading, .error { padding: 2rem 1rem; }

.notthis { color: var(--text-2); }
.notthis del, .notthis .bad { text-decoration: none; }

.toc-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
}
.toc-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
}
.toc-row:last-child { border-bottom: 0; }
.toc-row:hover:not(:disabled) { background: var(--accent-soft); filter: none; }
.toc-row.locked { opacity: 0.52; cursor: default; }
.toc-row.locked .toc-go { font-size: 0.9rem; }
.toc-row.toc-extra { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.toc-num {
  min-width: 3.1rem;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}
.toc-row.done .toc-num { color: var(--success-text); }
.toc-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-verses {
  font-weight: 650;
  font-size: 1rem;
  line-height: 1.3;
}
.toc-about {
  font-family: var(--greek);
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--text-2);
}
.toc-go {
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 1.15rem;
  align-self: center;
  flex-shrink: 0;
}

.prompt-card {
  padding: 12px 14px;
  margin: 0 0 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.answer-tray {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px 12px;
  margin: 0 0 12px;
  border-radius: 10px;
  border: 2px dashed var(--border-strong);
  background: var(--bg-elev);
}
.answer-tray.empty {
  border-color: var(--border);
}
.tray-tile {
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}
.tray-tile.dragging {
  opacity: 0.35;
  cursor: grabbing;
}
.tray-tile.drop-before::before,
.tray-tile.drop-after::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.tray-tile.drop-before::before { left: -6px; }
.tray-tile.drop-after::after { right: -6px; }
.tray-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  opacity: 0.92;
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
  cursor: grabbing;
}
.tray-placeholder {
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  font-style: italic;
}

.passage-flow {
  font-family: var(--greek);
  font-size: 1.45rem;
  line-height: 1.85;
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 5px;
}
.passage-flow .vn {
  font-family: var(--font-ui);
  font-size: 0.62em;
  color: var(--accent);
  font-weight: 700;
  vertical-align: super;
  margin-right: 2px;
  user-select: none;
  line-height: 1;
}
.obs-box {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.obs-box h2 {
  font-size: 1.05rem;
  margin: 0 0 10px;
  color: var(--text-2);
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.obs-list {
  margin: 0;
  padding-left: 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.obs-list li {
  font-family: var(--greek);
  font-size: 1.02rem;
  line-height: 1.55;
}
.w-tok {
  font-family: var(--greek);
  font-size: inherit;
  line-height: inherit;
  padding: 1px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.w-tok:hover {
  background: var(--accent-soft);
  filter: none;
}
.w-tok.on {
  background: var(--accent);
  color: var(--primary-fg);
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .page { padding: 16px 14px 32px; border: 0; }
  .row-2 { flex-direction: column; }
  .props .row { flex-direction: column; gap: 2px; }
}
