:root {
  color-scheme: light;
  --ink: #213c35;
  --forest: #173e36;
  --muted: #526760;
  --paper: #f5f5ed;
  --white: #fffefa;
  --line: #d3ded1;
  --selection: #e5efe3;
  --masthead: #173e36;
  --marker: #42715d;
  --hover: #edf1e8;
  --focus: #a46926;
  --serif: Georgia, "Times New Roman", serif;
  font: 16px/1.5 "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef3e9;
  --forest: #b6dfca;
  --muted: #adbbb2;
  --paper: #19241f;
  --white: #202e27;
  --line: #41544a;
  --selection: #30463b;
  --masthead: #172721;
  --marker: #87baa1;
  --hover: #27392f;
  --focus: #dfaf72;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; opacity: .35; }
a { color: var(--forest); text-underline-offset: .19em; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
p, h1, h2, h3 { margin: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.masthead { color: #edf5eb; background: var(--masthead); }
.masthead-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 75px;
  max-width: 1340px;
  padding: 12px 36px;
  margin: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  font: 23px/1.2 var(--serif);
}
.brand img { flex: none; }
#jump { display: flex; gap: 5px; padding: 3px; border: 1px solid #709488; border-radius: 8px; }
#reference {
  min-width: 0;
  width: 180px;
  padding: 5px 8px;
  color: #fff;
  background: transparent;
  border: 0;
}
#reference::placeholder { color: #c6d9d0; }
#jump button {
  padding: 3px 12px;
  border: 0;
  border-radius: 5px;
  background: #deeae1;
  color: #173e36;
  font-weight: 650;
}
.source-button { border: 0; background: transparent; color: inherit; padding: 8px 0; }
.source-button:hover { text-decoration: underline; }
.masthead-actions { display: flex; gap: 14px; }
.source-button[aria-pressed="true"] { text-decoration: underline; text-underline-offset: 4px; }
#jump-error { padding: 0 36px 12px; text-align: right; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 445px);
  align-items: start;
  gap: clamp(32px, 6vw, 92px);
  max-width: 1340px;
  margin: auto;
  padding: 44px 36px 80px;
}
.reading-heading { margin: 0 0 12px; padding: 4px 0 16px; border-bottom: 1px solid var(--line); }
h1 { font: 400 clamp(32px, 4vw, 46px)/1.12 var(--serif); letter-spacing: -.025em; margin: 0 0 12px; }
.reading-controls { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.chapter-nav, .edition-field {
  display: flex; align-items: center; min-width: 0; border: 1px solid var(--line);
  border-radius: 10px; background: var(--white); color: var(--ink);
}
.chapter-nav button {
  min-width: 44px; min-height: 44px; border: 0; border-radius: 9px;
  color: inherit; background: transparent; font: 23px/1 var(--serif);
}
.chapter-nav #chapter {
  border-inline: 1px solid var(--line); border-radius: 0; padding: 0 12px; line-height: 1.3;
  font-family: inherit; font-size: 14px; font-weight: 600;
}
.chapter-nav button:enabled:hover, #chapter-grid button:hover { background: var(--hover); }
.chapter-nav #chapter::after {
  content: ''; display: inline-block; width: 5px; height: 5px; margin: 0 0 3px 7px;
  border: solid var(--marker); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.edition-field { position: relative; flex: 1 1 160px; max-width: 310px; }
.edition-field > span { position: absolute; top: 3px; left: 12px; font-size: 11px; color: var(--muted); pointer-events: none; }
.edition-field::after {
  content: ''; position: absolute; right: 14px; top: 43%; width: 6px; height: 6px;
  border: solid var(--marker); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none;
}
.edition-field select {
  appearance: none; width: 100%; min-width: 0; min-height: 45px; padding: 16px 30px 2px 12px;
  color: inherit; background: transparent; border: 0; border-radius: inherit; font-size: 14px; font-weight: 600;
}
.edition-field option, .edition-field optgroup { background: var(--white); color: var(--ink); }
#chapter-picker { max-width: 365px; padding: 20px; }
#chapter-picker h2 { font-size: 25px; margin: 2px 0 16px; }
#chapter-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
#chapter-grid button {
  min-height: 44px; color: var(--ink); background: var(--paper); border: 1px solid var(--line);
  border-radius: 7px; font-variant-numeric: tabular-nums;
}
#chapter-grid [aria-current="true"] { color: var(--white); background: var(--forest); font-weight: 700; }
.reader-loading { margin: 22px 0 0 2.3rem; color: var(--muted); font-size: 14px; }
.reader-loading i { display: block; margin-top: 14px; height: .7rem; width: 87%; border-radius: 3px; background: var(--line); }
.reader-loading i:nth-child(2) { width: 95%; }
.reader-loading i:last-child { width: 58%; }
.verse {
  display: grid;
  grid-template-columns: 2.3rem minmax(0, 1fr);
  align-items: baseline;
  text-align: left;
  width: 100%;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-left: 3px solid transparent;
  padding: 11px 14px 11px 3px;
}
.verse:hover { background: var(--hover); }
.verse.is-selected { background: var(--selection); border-left-color: var(--marker); }
.verse-number { color: var(--forest); font-size: 13px; text-align: center; font-variant-numeric: tabular-nums; padding: 8px 0; border: 0; border-radius: 4px; background: transparent; }
.verse-number:hover { background: var(--selection); }
.verse.is-selected .verse-number { font-weight: 700; }
.verse-text { font: 400 clamp(19px, 2vw, 24px)/1.49 var(--serif); overflow-wrap: anywhere; user-select: text; cursor: text; }
.verse-text::selection { background: var(--marker); color: var(--paper); }
.saved-highlight { background: #f0df98; color: #27342a; border-radius: 2px; }
[data-theme="dark"] .saved-highlight { background: #766131; color: #fff8e6; }
#explore-selection {
  position: fixed; z-index: 1; display: flex; align-items: center; gap: 3px;
  width: max-content; max-width: calc(100vw - 16px); padding: 4px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--white);
  color: var(--ink); box-shadow: 0 6px 20px #10251e32;
}
#selection-reference { padding: 0 9px 0 7px; border-right: 1px solid var(--line); color: var(--muted); font-size: 12px; white-space: nowrap; }
.selection-actions { display: flex; min-width: 0; }
#explore-selection .selection-action {
  position: relative; flex: 0 1 36px; width: 36px; min-width: 0; height: 36px;
  display: grid; place-items: center; padding: 0; color: var(--ink);
  border: 1px solid transparent; border-radius: 8px; background: transparent;
}
#explore-selection .selection-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
#explore-selection #close-selection { flex: 0 0 28px; width: 28px; color: var(--muted); }
#explore-selection #close-selection svg { width: 16px; height: 16px; }
#explore-selection .selection-action:hover { background: var(--hover); }
#explore-selection .selection-action[aria-pressed="true"] { color: var(--forest); background: var(--selection); border-color: var(--line); }
.selection-action::after {
  content: attr(aria-label); display: none; position: absolute; z-index: 1; bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%); width: max-content; padding: 3px 7px; pointer-events: none;
  border-radius: 5px; background: var(--masthead); color: #eef3e9; font: 12px/1.5 "Segoe UI", sans-serif;
}
#explore-selection[data-tooltip-below] .selection-action::after { top: calc(100% + 8px); bottom: auto; }
.selection-action:focus-visible::after { display: block; }
@media (hover: hover) { .selection-action:hover::after { display: block; } }
.passage-actions button, .saved-tabs button, .saved-card button, .note-editor-actions button, .verse-note {
  border: 1px solid transparent; padding: 7px 9px; background: transparent; color: inherit; font-size: 13px; border-radius: 6px;
}
.passage-actions button:hover, .saved-tabs button:hover, .saved-card button:hover, .note-editor-actions button:hover, .verse-note:hover { background: var(--hover); }
.passage-actions [aria-pressed="true"], .saved-tabs [aria-pressed="true"] { background: var(--selection); border-color: var(--line); font-weight: 600; }
.verse-note { grid-column: 2; justify-self: start; padding-inline: 0; color: var(--forest); text-decoration: underline; text-underline-offset: 3px; }
.passage-actions { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px 18px; border-bottom: 1px solid var(--line); }
.passage-actions button { color: var(--forest); }
.study-action-status:empty { display: none; }
.study-action-status { position: fixed; z-index: 4; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); max-width: 90vw; text-align: center; padding: 8px 14px; border-radius: 8px; background: var(--masthead); color: #fff; }
#saved-studies { max-height: 88dvh; overflow: auto; }
.saved-tabs, .saved-card-actions, .note-editor-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.saved-tabs { margin: 12px 0; }
.saved-card { padding: 12px 0; border-top: 1px solid var(--line); }
.saved-card p, #note-excerpt { overflow-wrap: anywhere; white-space: pre-wrap; }
.saved-card h3 { font: 21px var(--serif); margin: 0; }
.saved-edition { font-size: 13px; color: var(--muted); }
.saved-note-text { padding-left: 10px; border-left: 2px solid var(--marker); }
#note-passage { margin-top: 14px; font-weight: 600; }
#note-excerpt { margin: 8px 0 16px; padding-left: 12px; border-left: 2px solid var(--marker); font: 17px var(--serif); }
#note-text { display: block; width: 100%; margin: 6px 0 12px; font: inherit; resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: var(--paper); color: var(--ink); }
#save-note { background: var(--masthead); color: #fff; }
#note-error { margin: 6px 0; }
.omitted { font: 14px/1.5 "Segoe UI", sans-serif; color: var(--muted); }

.study {
  position: sticky;
  top: 22px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 44px);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
  overflow: hidden;
}
.study-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  padding: 21px 25px 18px;
  background: var(--selection);
}
.study-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.study-head h2 { font: 400 clamp(29px, 3vw, 38px)/1.15 var(--serif); letter-spacing: -.025em; }
.study-head h2:focus { outline: none; }
.study-head h2:focus-visible { outline: 2px solid var(--marker); outline-offset: 3px; border-radius: 2px; }
.chapter-footer, .backup-controls { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; margin-top: 12px; border-top: 1px solid var(--line); }
.chapter-footer button, .backup-controls button, .other-highlight {
  min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--forest); background: var(--white);
}
#next-chapter { margin-inline-start: auto; }
.other-highlight { grid-column: 2; justify-self: start; font-size: 12px; }
#backup-status { color: var(--forest); font-size: 14px; }
.mobile-verse { display: none; }
@media (max-width: 940px) { .mobile-verse { display: block; } }
.close-study, .dialog-close {
  background: transparent;
  color: var(--ink);
  border: 0;
  width: 38px;
  height: 38px;
  font-size: 28px;
  line-height: 1;
}
.close-study { display: none; }
.study-nav { display: flex; gap: 0; padding: 0 14px; border-bottom: 1px solid var(--line); }
.study-nav button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  min-height: 47px;
  padding: 8px 3px 5px;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 600;
}
.study-nav button[aria-pressed="true"] { color: var(--forest); border-color: var(--marker); }
.passage-controls { display: flex; justify-content: space-between; padding: 4px 25px; border-bottom: 1px solid var(--line); }
.passage-controls button { color: var(--forest); background: transparent; border: 0; padding: 5px 0; font-size: 13px; }
.selected-excerpt { margin: 12px 0 0; padding: 7px 11px; border-inline-start: 2px solid var(--marker); font: 17px/1.45 var(--serif); overflow-wrap: anywhere; }
.quoted-verse + .quoted-verse { margin-top: 4px; }
#study-content { overflow: auto; overscroll-behavior: contain; padding: 3px 25px 21px; }
.note { padding: 17px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note-kind, .citation, .edition-credit { color: var(--muted); font-size: 13px; }
.note h3 { font: 400 23px/1.2 var(--serif); margin: 4px 0 3px; }
.note-text { font-size: 15px; margin: 8px 0; }
.reading-by-theme { margin: 18px 0 4px; padding: 14px 0 7px; border-block: 1px solid var(--line); }
.reading-by-theme-title { font: 25px/1.2 var(--serif); }
.reading-by-theme h4, .reading-by-theme h5 { margin: 0; }
.reading-by-theme h4 { margin-top: 8px; font-size: 15px; color: var(--forest); }
.theme-context { margin-top: 4px; font-size: 14px; color: var(--muted); }
.themed-book { padding: 10px 0; }
.themed-book h5 { font: 19px/1.25 var(--serif); }
.source-link {
  display: inline-block;
  background: transparent;
  padding: 0;
  border: 0;
  color: var(--forest);
  font-size: 14px;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .19em;
}
.quoted-verse { font: 20px/1.5 var(--serif); margin-top: 8px; }
.translation-cards { display: grid; gap: 12px; margin: 12px 0; }
.translation { min-width: 0; padding: 15px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.translation-current { border-inline-start: 3px solid var(--marker); padding-inline-start: 14px; }
.translation :is(h3, h4) { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 0; font-size: 14px; line-height: 1.4; }
.translation-reference { color: var(--forest); white-space: nowrap; }
.translation-title { font-weight: 600; overflow-wrap: anywhere; }
.translation-text { margin: 10px 0 12px; }
.translation-text p { margin: 0; overflow-wrap: anywhere; }
.translation-text p + p { margin-top: 6px; }
.translation-unavailable, .translation-verse-number { color: var(--muted); font: 13px/1.5 "Segoe UI", sans-serif; }
.translation-actions { display: flex; justify-content: end; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 9px; }
.translation-actions :is(button, a) { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 9px; color: var(--forest); background: transparent; border: 1px solid transparent; border-radius: 16px; font: 600 13px/1.25 "Segoe UI", sans-serif; text-decoration: none; }
.translation-actions .translation-link { border-color: var(--line); }
.translation-actions :is(button, a):hover { background: var(--hover); }
.translation-actions button:disabled { color: var(--muted); cursor: default; }
.translation-badge { margin-inline-end: auto; color: var(--muted); font-size: 12px; }
.translation-online > h3 { font: 20px/1.35 var(--serif); margin: 22px 0 0; }
@media (pointer: coarse) { .translation-actions :is(button, a) { min-height: 44px; } }
.empty, .edition-credit { padding-top: 16px; }
.greek-line { margin: 12px 0; font: 25px/1.5 "Palatino Linotype", "Times New Roman", serif; }
.greek-word { background: transparent; border: 0; border-radius: 4px; color: var(--ink); padding: 2px 4px; }
.greek-word:hover, .greek-word[aria-pressed="true"] { background: var(--selection); }
.word-detail { padding: 12px 14px; border-left: 3px solid var(--marker); background: var(--paper); font-size: 14px; }
.word-detail .word-meaning { font: 23px/1.3 var(--serif); margin: 2px 0 6px; }
.word-context { margin: 4px 0 8px; }
.word-occurrences { margin: 12px 0; }
.word-occurrences > button { margin-top: 5px; }
.word-original { margin-top: 8px; }
.lemma, .lemma-form { font: 17px/1.4 "Palatino Linotype", "Times New Roman", serif; }
.word-matches { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 5px 0 8px; }
.whole-greek { margin-top: 10px; }
.whole-greek summary { color: var(--forest); cursor: pointer; }
dialog { width: min(600px, 94vw); border: 1px solid var(--line); border-radius: 13px; padding: 22px; color: var(--ink); background: var(--white); }
dialog::backdrop, .backdrop { background: #10251e88; }
dialog form { float: right; }
dialog h2 { font: 30px/1.3 var(--serif); }
dialog li { margin: 12px 0; }

@media (max-width: 940px) {
  .workspace { display: block; padding: 26px 24px 60px; max-width: 680px; }
  .masthead-inner { padding: 10px 24px; }
  .study-open { overflow: hidden; }
  .backdrop { position: fixed; inset: 0; width: 100%; border: 0; z-index: 1; }
  .study {
    display: none;
    position: fixed;
    inset: auto 0 0;
    z-index: 2;
    max-height: min(84dvh, 760px);
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .study.is-open { display: flex; }
  .close-study { display: block; }
}

@media (min-width: 601px) and (max-width: 940px) {
  .masthead-inner { gap: 16px; }
}

@media (max-width: 600px) {
  .masthead-inner { display: grid; grid-template-columns: 1fr auto; gap: 7px 14px; padding: 9px 16px 12px; }
  .brand { font-size: 21px; }
  .masthead-actions { gap: 8px; font-size: 13px; }
  .masthead-actions { flex-wrap: wrap; justify-content: end; }
  #jump { grid-row: 2; grid-column: 1 / -1; }
  #reference { width: 100%; }
  #jump-error { padding: 0 16px 10px; text-align: left; font-size: 14px; }
  .workspace { padding-inline: 16px; }
  .edition-field { max-width: none; }
  .study-head { padding: 15px 20px; }
  #study-content { padding-inline: 20px; }
}

.touch-label { display: none; }
@media (pointer: coarse) {
  .masthead-actions button, .reading-controls button, .reading-controls select,
  .close-study, .passage-controls button, .passage-actions button,
  .saved-tabs button, .saved-card button, .note-editor-actions button, .verse-note { min-height: 44px; }
  #explore-selection { bottom: max(8px, env(safe-area-inset-bottom)); }
  #explore-selection .selection-action { flex-basis: 44px; width: 44px; height: 44px; }
  #explore-selection .selection-actions .selection-action { align-content: center; gap: 2px; }
  .touch-label { display: block; font-size: 10px; line-height: 1.15; }
}

@media (max-width: 470px) {
  #selection-reference { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
  .selection-actions > :first-child::after { left: 0; transform: none; }
  #close-selection::after { right: 0; left: auto; transform: none; }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes sheet-in { from { transform: translateY(18px); opacity: .4; } }
  @keyframes picker-in { from { transform: translateY(5px); opacity: .45; } }
  @keyframes load-pulse { to { opacity: .45; } }
  dialog[open], #explore-selection:not([hidden]) { animation: picker-in 140ms ease-out; }
  .study.is-open { animation: sheet-in 180ms cubic-bezier(.2,.72,.2,1); }
  .reader-loading i { animation: load-pulse 900ms ease-in-out 3 alternate; }
  .verse { transition: background-color 130ms ease-out, border-color 130ms ease-out; }
}
