/* Beside the Waters — engineering-paper aesthetic: off-white, hairline grid,
   near-black ink, monospace labels, stream-blue accents. */

:root {
  --paper: #fafaf8;
  --paper-deep: #f2f2ee;
  --paper-card: #ffffff;
  --ink: #18181a;
  --ink-soft: #4c4c48;
  --ink-faint: #8f8f88;
  --rule: #e3e3dd;
  --accent: #18181a;          /* primary accent: ink black */
  --accent-deep: #000000;
  --neutral: #6e6e68;
  --wash: #f0f0ea;            /* hover wash */
  --highlight: #8fd8ff;       /* stream blue */
  --highlight-soft: #d4eeff;
  --serif: "Gentium Book Plus", "Times New Roman", serif;
  --sans: "Schibsted Grotesk", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

::selection { background: var(--highlight); color: var(--ink); }

/* ------------------------------------------------ masthead */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  padding: 1rem 1.6rem 0.85rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper-card);
}

.wordmark h1 {
  margin: 0;
  display: inline-block;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--highlight);
  padding: 0.05em 0.4em 0.05em 0.5em;
}

.tagline {
  margin: 0.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-faint);
}

.search-group { display: flex; flex: 0 1 27rem; }
.search { display: flex; flex: 1; min-width: 0; }

.search select {
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid var(--rule);
  border-right: none;
  background: var(--paper);
  color: var(--ink-soft);
  padding: 0 0.4rem;
  max-width: 7rem;
}
.search select:focus { outline: none; border-color: var(--ink); }

.search input {
  flex: 1;
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.45rem 0.8rem;
  color: var(--ink);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-right: none;
  outline: none;
}
.search input:focus { border-color: var(--ink); }
.search button {
  font-size: 1.05rem;
  padding: 0 0.9rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
}
.search button:hover { background: var(--highlight); border-color: var(--ink); }

.help-link {
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-weight: 600;
  border: 1px solid var(--rule);
  border-left: none;
  background: var(--paper);
  color: var(--ink-faint);
  padding: 0 0.7rem;
  text-decoration: none;
}
.help-link:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

.account-link {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule);
  border-left: none;
  background: var(--paper);
  color: var(--ink-soft);
  padding: 0 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
.account-link:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.account-link.signed-in { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------ auth overlay */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 26, 0.35);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
}
.overlay[hidden] { display: none; }

.auth-box {
  position: relative;
  width: min(92vw, 21rem);
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--ink);
  padding: 1.2rem 1.4rem 1.1rem;
  box-shadow: 0 12px 40px rgba(24, 24, 26, 0.25);
}
.auth-box h2 { font-family: var(--sans); margin: 0 0 0.8rem; font-size: 1.15rem; }
.auth-box form { display: flex; flex-direction: column; gap: 0.5rem; }
.auth-box input {
  font-family: var(--sans);
  font-size: 0.92rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  outline: none;
}
.auth-box input:focus { border-color: var(--ink); }
.auth-box .primary { padding: 0.5rem; }
.auth-error {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink);
  background: var(--highlight-soft);
  border-left: 3px solid var(--highlight);
  padding: 0.3rem 0.5rem;
  margin: 0;
}
.auth-switch {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
  cursor: pointer;
  margin: 0.7rem 0 0;
}
.auth-switch:hover b { background: var(--highlight-soft); }
.auth-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  color: var(--ink-faint);
  cursor: pointer;
}
.auth-close:hover { color: var(--ink); }
.auth-session p { font-family: var(--sans); font-size: 0.88rem; }
.auth-session button {
  font-family: var(--mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  margin: 0.2rem 0.3rem 0 0;
}
.auth-session button:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

/* ------------------------------------------------ frame */

.frame {
  flex: 1;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) var(--study-w, 26rem);
  min-height: 0;
  position: relative; /* anchors the study-panel resizer */
}

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

.nav {
  border-right: 1px solid var(--rule);
  overflow-y: auto;
  padding: 0.8rem 0;
  font-family: var(--sans);
  background: var(--paper);
}

.nav-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.7rem 0.5rem 1.1rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
}
.nav-tabs { display: flex; gap: 0.9rem; }
.nav-tab {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0 0 0.15rem;
  cursor: pointer;
}
.nav-tab:hover { color: var(--ink); }
.nav-tab.active { color: var(--ink); border-bottom-color: var(--highlight); }

/* studies tab */
.nav-studies { padding: 0.5rem 1.1rem; font-family: var(--sans); }
.study-new {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.6rem;
}
.study-new:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.study-create input {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.85rem;
  border: 1px solid var(--ink);
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.6rem;
  background: var(--paper-card);
  outline: none;
}
.study-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 1px solid var(--rule);
  padding: 0.45rem 0.1rem;
  cursor: pointer;
}
.study-item:hover { background: var(--wash); }
.study-item.on { border-left: 3px solid var(--highlight); padding-left: 0.35rem; }
.study-item .study-body { flex: 1; min-width: 0; }
.study-item .study-edit {
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-faint);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
}
.study-item .study-edit:hover { background: var(--highlight); color: var(--ink); }
.study-item .study-title { font-size: 0.88rem; color: var(--ink); }
.study-item.archived .study-title { color: var(--ink-faint); text-decoration: line-through; }
.study-item .study-meta {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--ink-faint);
  margin-top: 0.1rem;
}
.study-editor { padding: 0.4rem 0.1rem 0.6rem; border-bottom: 1px solid var(--rule); }
.study-editor input, .study-editor textarea {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.85rem;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  padding: 0.3rem 0.5rem;
  margin-bottom: 0.4rem;
  outline: none;
}
.study-editor input:focus, .study-editor textarea:focus { border-color: var(--ink); }
.study-editor textarea { min-height: 4.5rem; resize: vertical; }
.study-editor .row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.study-editor .row button {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.study-editor .row button:hover { background: var(--wash); color: var(--ink); }
.study-editor .row button.save { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.study-editor .row button.save:hover { background: var(--highlight); }
.study-editor .row button.danger:hover { background: var(--ink); color: var(--paper-card); }
.show-archived {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-top: 0.7rem;
  cursor: pointer;
}
.studies-help-link {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  margin-top: 0.8rem;
}
.studies-help-link:hover { color: var(--ink); border-bottom-color: var(--ink); }
#nav-hide {
  font-size: 0.9rem;
  line-height: 1;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-faint);
  padding: 0.18rem 0.5rem;
  cursor: pointer;
}
#nav-hide:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

.nav-show { display: none; }
.nav-mobile { display: none; }

/* desktop-only "collapse to rail" state — disabled on phones, where the nav
   becomes a slide-in drawer instead (see the max-width:700px block) */
@media (min-width: 701px) {
  .frame.nav-hidden { grid-template-columns: 2.3rem minmax(0, 1fr) var(--study-w, 26rem); }
  .frame.nav-hidden .nav-head,
  .frame.nav-hidden .nav-scroll,
  .frame.nav-hidden .nav-chapters,
  .frame.nav-hidden .nav-studies { display: none !important; }
  .frame.nav-hidden .nav { padding: 0.4rem 0 0; }
  .frame.nav-hidden .nav-show {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    border: none;
    background: none;
    color: var(--ink-faint);
    font-size: 1rem;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    cursor: pointer;
    padding: 0.4rem 0;
  }
  .frame.nav-hidden .nav-show span { writing-mode: vertical-rl; font-size: 0.65rem; }
  .frame.nav-hidden .nav-show:hover { color: var(--ink); }
}

.nav h2 {
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  margin: 1.1rem 1.1rem 0.3rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}
.nav h2:first-child { margin-top: 0; }

.nav h2.group-toggle { cursor: pointer; user-select: none; }
.nav h2.group-toggle:hover { color: var(--ink); }
.nav h2.group-toggle .tri { font-size: 0.7rem; }

.nav button.book {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--sans);
  font-size: 0.88rem;
  padding: 0.22rem 1.1rem;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
}
.nav button.book:hover { background: var(--wash); color: var(--ink); }
.nav button.book.active {
  background: var(--ink);
  color: var(--paper-card);
}

.nav-chapters { padding: 0.4rem 1rem; }
.nav-chapters .nav-chapter-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0 0.6rem;
  font-family: var(--sans);
}
.nav-chapters .back {
  font-size: 0.95rem;
  line-height: 1.25;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  cursor: pointer;
  color: var(--ink-soft);
  padding: 0.02rem 0.45rem;
}
.nav-chapters .back:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.2rem, 1fr));
  gap: 0.3rem;
}
.chapter-grid button {
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.35rem 0;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  cursor: pointer;
}
.chapter-grid button:hover { background: var(--highlight); border-color: var(--ink); color: var(--ink); }
.chapter-grid button.active { background: var(--ink); color: var(--paper-card); border-color: var(--ink); }

/* ------------------------------------------------ reader */

.reader { overflow-y: auto; padding: 1.4rem 2.4rem 7rem; background: var(--paper-card); }

.reader-head h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.15rem;
}
.reader-head .crumb {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}
.reader-head { margin-bottom: 1.2rem; }
.reader-head .pager { float: right; }
.reader-head .pager button {
  font-family: var(--mono); font-size: 0.78rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  cursor: pointer; padding: 0.3rem 0.7rem; color: var(--ink-soft);
}
.reader-head .pager button:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

.welcome { max-width: 34rem; margin: 14vh auto 0; text-align: center; color: var(--ink-soft); }
.boot-spinner {
  font-family: var(--mono);
  letter-spacing: 0.4em;
  color: var(--ink-faint);
  margin: 0.9rem 0 0.3rem;
  animation: boot-pulse 1.2s ease-in-out infinite;
}
.nav-loading {
  font-family: var(--mono);
  letter-spacing: 0.35em;
  color: var(--ink-faint);
  text-align: center;
  padding: 1.2rem 0;
  animation: boot-pulse 1.2s ease-in-out infinite;
}
@keyframes boot-pulse {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.boot-retry {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--ink);
  background: var(--paper-card);
  color: var(--ink);
  cursor: pointer;
  padding: 0.4rem 0.9rem;
  margin-top: 0.6rem;
}
.boot-retry:hover { background: var(--highlight); }
.welcome-greek {
  font-size: 2rem;
  display: inline-block;
  background: var(--highlight);
  padding: 0.05em 0.3em;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.hint { font-family: var(--sans); font-size: 0.85rem; color: var(--ink-faint); }
.kbd {
  font-family: var(--mono); font-size: 0.8em; border: 1px solid var(--rule);
  padding: 0 0.35em; background: var(--paper);
}

.text-toggle {
  display: inline-flex;
  margin-left: 0.8rem;
  vertical-align: middle;
  border: 1px solid var(--rule);
  overflow: hidden;
}
.text-toggle button {
  font-family: var(--mono);
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: none;
  background: var(--paper-card);
  color: var(--ink-soft);
  padding: 0.28rem 0.6rem;
  cursor: pointer;
}
.text-toggle button:hover { background: var(--wash); }
.text-toggle button.active { background: var(--ink); color: var(--paper-card); }

.verse { margin: 0 0 0.9rem; max-width: 46rem; }
.verse .vnum {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--ink-faint);
  vertical-align: super;
  margin-right: 0.35rem;
  user-select: none;
}
.verse .greek { font-size: 1.22rem; line-height: 2.05; }
.verse .greek.hebrew {
  direction: rtl;
  text-align: right;
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", var(--serif);
  font-size: 1.38rem;
  line-height: 2.3;
}
.verse .greek .w {
  cursor: pointer;
  padding: 0.05em 0.08em;
  transition: background 0.12s;
}
.verse .greek .w:hover { background: var(--highlight-soft); }
.verse .greek .w.sel {
  background: var(--highlight);
  color: var(--ink);
}
.verse .greek .w.flash { background: var(--highlight); }
.verse .english {
  font-size: 0.95rem;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0.1rem 0 0 1.2rem;
}
.verse.en-only .english { font-style: normal; font-size: 1.05rem; margin-left: 0; color: var(--ink); }
.verse.target { animation: pulse 1.6s ease-out 1; }
@keyframes pulse {
  0% { background: var(--highlight); }
  100% { background: transparent; }
}

/* clickable English words */
.verse .english .ew { cursor: pointer; padding: 0.05em 0.05em; }
.verse .english .ew:hover { background: var(--highlight-soft); color: var(--ink); }
.verse .english .ew.sel { background: var(--highlight); color: var(--ink); font-style: normal; }
.verse .english .vnum-en { display: none; }

/* English-only reading mode */
.hide-orig .verse .greek { display: none; }
.hide-orig .verse .english {
  font-style: normal;
  font-size: 1.08rem;
  line-height: 1.75;
  margin-left: 0;
  color: var(--ink);
}
.hide-orig .verse .english .vnum-en { display: inline; }

.note {
  font-family: var(--sans); font-size: 0.8rem; color: var(--ink-faint);
  border-left: 2px solid var(--rule); padding-left: 0.7rem; margin: 0.6rem 0 1rem;
}

.copyright {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-faint);
  margin-top: 1.4rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.45rem;
}

/* ------------------------------------------------ reference drawer (study trail) */

.reader-col {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.reader-col .reader { flex: 1; min-width: 0; }

.drawer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 48%;
  display: flex;
  flex-direction: column;
  background: var(--paper-card);
  border-top: 2px solid var(--ink);
  box-shadow: 0 -8px 26px rgba(24, 24, 26, 0.12);
  z-index: 30;
  transition: transform 0.18s ease-out, visibility 0.18s;
}
.drawer.closed { transform: translateY(105%); visibility: hidden; }

.trail {
  flex: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  overflow-x: auto;
}
.trail-label {
  font-family: var(--mono); font-size: 0.6rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-right: 0.3rem;
  user-select: none;
}
.trail-stops { display: flex; align-items: center; gap: 0.4rem; }
.trail-origin, .trail-stop {
  font-family: var(--mono); font-size: 0.68rem; font-weight: 600;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  padding: 0.18rem 0.5rem;
  cursor: pointer;
  white-space: nowrap;
}
.trail-stop { display: inline-flex; align-items: center; gap: 0.4rem; }
.trail-stop .trail-x {
  font-size: 0.85rem;
  line-height: 1;
  color: var(--ink-faint);
  padding: 0 0.1rem;
}
.trail-stop .trail-x:hover { color: var(--ink); background: var(--highlight); }
.trail-stop.on .trail-x { color: var(--ink-soft); }
.trail-stop.on .trail-x:hover { color: var(--ink); background: var(--paper-card); }
.trail-origin { border-style: dashed; }
.trail-origin:hover, .trail-stop:hover { background: var(--wash); color: var(--ink); }
.trail-stop.on { background: var(--highlight); border-color: var(--highlight); color: var(--ink); }
.trail-sep { color: var(--ink-faint); font-size: 0.65rem; user-select: none; }
.trail-tools { margin-left: auto; display: flex; gap: 0.35rem; padding-left: 0.6rem; }
.trail-tools button {
  font-family: var(--mono); font-size: 0.64rem; text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  padding: 0.22rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
}
.trail-tools button:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

.drawer-body {
  position: relative; /* offsetTop anchor for verse centering */
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 2.4rem 2.5rem;
}
.drawer-crumb {
  font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-bottom: 0.8rem;
}

/* ------------------------------------------------ study panel */

.study {
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  padding: 1.2rem 1.3rem 7rem;
  background: var(--paper);
}

/* close button — only meaningful when the study panel is an overlay drawer
   (≤1100px); hidden in the desktop three-column layout */
.study-close {
  display: none;
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  z-index: 8;
  font-size: 0.95rem;
  line-height: 1;
  border: 1px solid var(--rule);
  background: var(--paper-card);
  color: var(--ink-soft);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
}
.study-close:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

/* drag the study panel's left edge to widen it (double-click resets);
   absolutely positioned so it never disturbs the grid placement */
.study-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  right: var(--study-w, 26rem);
  width: 7px;
  cursor: col-resize;
  z-index: 20;
}
.study-resizer:hover, body.resizing .study-resizer { background: var(--highlight); }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .study, body.resizing .reader-col { pointer-events: none; }

/* ---- pinned active-study card (capture HQ while reading) ---- */

.study-pin {
  position: sticky;
  top: -1.2rem; /* counter the panel padding so it docks flush */
  z-index: 6;
  background: var(--paper);
  margin: -1.2rem -1.3rem 0.9rem; /* bleed over the panel padding */
  padding: 0.75rem 1.3rem 0.6rem;
  border-bottom: 2px solid var(--ink);
}
.pin-head { display: flex; align-items: baseline; gap: 0.5rem; }
.pin-label {
  font-family: var(--mono); font-size: 0.56rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  background: var(--highlight); padding: 0 0.4em;
}
.pin-title {
  flex: 1; font-family: var(--sans); font-weight: 700; font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pin-close, .pin-open {
  font-size: 0.8rem; border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink-faint); cursor: pointer; padding: 0.08rem 0.4rem;
}
.pin-close:hover, .pin-open:hover { background: var(--wash); color: var(--ink); }
.study-pin .anchors { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0; }
.study-pin .anchor {
  font-family: var(--serif); font-size: 0.85rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  padding: 0.05rem 0.45rem; cursor: pointer;
}
.study-pin .anchor:hover { background: var(--highlight-soft); }
.study-pin .anchor.heb { font-family: "Noto Serif Hebrew", var(--serif); }
.study-pin .anchor small {
  font-family: var(--mono); font-size: 0.56rem; color: var(--ink-faint); margin-left: 0.3em;
}
.study-pin .anchor .anchor-x {
  font-style: normal; color: var(--ink-faint); margin-left: 0.35em; padding: 0 0.1em;
}
.study-pin .anchor .anchor-x:hover { color: var(--ink); background: var(--highlight); }
.study-pin .hint-inline { font-family: var(--sans); font-size: 0.68rem; color: var(--ink-faint); }
.pin-row {
  display: flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono); font-size: 0.62rem; color: var(--ink-soft);
}
.pin-row select {
  font-family: var(--mono); font-size: 0.62rem; max-width: 9rem;
  border: 1px solid var(--rule); background: var(--paper-card); padding: 0.1rem;
}
.pin-row .counts { margin-left: auto; }
.pin-row .counts b { color: var(--ink); }
.pin-row .pin-triage {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink-soft); cursor: pointer; padding: 0.12rem 0.45rem;
}
.pin-row .pin-triage:hover { background: var(--wash); }
.pin-row .pin-triage.on { background: var(--ink); color: var(--highlight); border-color: var(--ink); }
.pin-add { display: flex; gap: 0.3rem; margin-top: 0.45rem; }
.pin-add input {
  flex: 1; font-family: var(--sans); font-size: 0.78rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  padding: 0.22rem 0.5rem; outline: none;
}
.pin-add input:focus { border-color: var(--ink); }
.pin-add button {
  font-family: var(--mono); font-size: 0.7rem; border: 1px solid var(--rule);
  background: var(--highlight); cursor: pointer; padding: 0 0.55rem;
}

/* ---- capture states on hit rows ---- */

.hit .cap-state {
  font-family: var(--mono); font-size: 0.56rem; text-transform: uppercase;
  letter-spacing: 0.05em; white-space: nowrap;
}
.hit.cap-added .cap-state { background: var(--highlight); padding: 0.08rem 0.35rem; cursor: pointer; }
.hit.cap-dismissed { opacity: 0.38; }
.hit.cap-dismissed .cap-state { color: var(--ink-faint); }
.hit .hit-actions { margin-left: auto; display: flex; gap: 0.25rem; opacity: 0; transition: opacity 0.12s; }
body.study-active .hit:hover .hit-actions { opacity: 1; }
body:not(.study-active) .hit-actions, body:not(.study-active) .cap-state { display: none; }
.hit-actions button {
  font-family: var(--mono); font-size: 0.58rem; border: 1px solid var(--rule);
  background: var(--paper-card); cursor: pointer; padding: 0.08rem 0.35rem; color: var(--ink-soft);
  white-space: nowrap;
}
.hit-actions .cap-add:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.hit-actions .cap-dis:hover { background: var(--wash); color: var(--ink); }
.hit.cap-added .cap-add, .hit.cap-dismissed .cap-dis { background: var(--ink); color: var(--paper-card); }
.cap-comment { margin-top: 0.35rem; display: flex; gap: 0.3rem; }
.cap-comment textarea {
  flex: 1; font-family: var(--sans); font-size: 0.78rem; min-height: 2.6rem;
  border: 1px solid var(--rule); background: var(--paper-card); padding: 0.25rem 0.4rem;
  resize: vertical; outline: none;
}
.cap-comment textarea:focus { border-color: var(--ink); }
.cap-comment button {
  font-family: var(--mono); font-size: 0.6rem; border: 1px solid var(--ink);
  background: var(--paper-card); cursor: pointer; padding: 0 0.5rem; align-self: flex-start;
}
.cap-comment button:hover { background: var(--highlight); }

/* ---- triage mode ---- */

#results.triage .hit-actions { opacity: 1; }
#results.triage .hit { border-left: 3px solid transparent; padding-left: 0.45rem; }
#results.triage .hit.cur { border-left-color: var(--highlight); background: var(--paper-card); }
.triage-bar {
  border: 1px solid var(--rule); border-top: 2px solid var(--ink);
  background: var(--paper-card); padding: 0.45rem 0.7rem; margin-bottom: 0.6rem;
}
.triage-bar .bar { height: 0.45rem; background: var(--wash); position: relative; }
.triage-bar .fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--highlight); border-right: 2px solid var(--ink);
  transition: width 0.15s;
}
.triage-bar .bar-meta {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 0.58rem; color: var(--ink-soft); margin-top: 0.3rem;
}
.triage-bar b { color: var(--ink); }

/* anchor-save button shares .counts button styling via .cap-anchor */
.counts .cap-anchor, .results-head .cap-anchor {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  border: 1px solid var(--highlight); background: var(--highlight-soft);
  cursor: pointer; padding: 0.2rem 0.45rem; color: var(--ink);
}
.counts .cap-anchor:hover, .results-head .cap-anchor:hover { background: var(--highlight); }

.study-empty { text-align: center; margin-top: 12vh; color: var(--ink-faint); }
.study-empty p:first-child { font-size: 1.1rem; letter-spacing: 0.3em; }

.card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-top: 2px solid var(--ink);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

/* anchor + sub cards: "reading" = main-reader word, "trail" = drawer word */
.role-label {
  display: inline-block;
  font-family: var(--mono); font-size: 0.56rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 0.2rem;
}
.role-label.trail { color: var(--ink); background: var(--highlight); padding: 0 0.4em; }

.card.compact {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.45rem 0.8rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  border-top: 2px solid var(--ink-faint);
}
.card.compact:hover { background: var(--wash); border-top-color: var(--ink); }
.card.compact .role-label { margin: 0; flex: none; }
.card.compact .mini-lemma { font-size: 1.05rem; font-weight: 700; white-space: nowrap; }
.card.compact .mini-lemma.hebrew {
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", var(--serif);
  direction: rtl;
}
.card.compact .mini-gloss {
  flex: 1;
  font-family: var(--sans); font-size: 0.78rem; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card.compact .mini-ids { flex: none; font-family: var(--mono); font-size: 0.6rem; color: var(--ink-faint); }

.card .lemma { font-size: 1.7rem; font-weight: 700; }
.card .translit { font-style: italic; color: var(--ink-soft); margin-left: 0.5rem; }
.card .ids {
  float: right; font-family: var(--mono); font-size: 0.65rem;
  color: var(--ink-faint); text-align: right;
}
.card .parse {
  font-family: var(--mono); font-size: 0.72rem; color: var(--ink-soft);
  margin: 0.3rem 0 0.5rem;
}
.card .gloss { font-size: 1rem; margin-bottom: 0.5rem; }
.card .etym {
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--highlight-soft);
  border-left: 3px solid var(--highlight);
  padding: 0.3rem 0.6rem;
  margin: 0.45rem 0;
}
.card .etym b { background: var(--highlight); padding: 0 0.15em; }
.card .bridge {
  display: block;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0.25rem 0 0.4rem;
}
/* Hebrew⇄LXX language toggle on the card sits on its own row so the lemma
   below it isn't pushed inline */
.card .card-lang { display: flex; width: fit-content; margin: 0 0 0.55rem; }
.card .counts { margin: 0.5rem 0; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.counts button, .occ-actions button {
  font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule);
  background: var(--paper); cursor: pointer; padding: 0.3rem 0.6rem;
  color: var(--ink-soft);
}
.counts button:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.counts button strong { color: var(--ink); }

.definition {
  font-size: 0.92rem; line-height: 1.55; color: var(--ink);
  border-top: 1px solid var(--rule); padding-top: 0.55rem; margin-top: 0.3rem;
  max-height: 21rem; overflow-y: auto;
}
.definition b { color: var(--ink); }
.definition a.xref { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--ink-faint); cursor: pointer; }
.definition a.xref:hover { background: var(--highlight-soft); color: var(--ink); }

/* breakdown → word card return */
.bk-back {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink-soft); cursor: pointer; padding: 0.2rem 0.5rem;
  margin-bottom: 0.4rem;
}
.bk-back:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

/* word already anchored in the active study */
.counts .in-study {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-soft);
  padding: 0.3rem 0.2rem;
}

/* verse breakdown (English word → originals) */
.breakdown {
  border-top: 1px solid var(--rule);
  margin-top: 0.5rem;
  max-height: 24rem;
  overflow-y: auto;
}
.bk-row {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  grid-template-areas: "orig gloss" "orig lemma";
  column-gap: 0.7rem;
  padding: 0.3rem 0.3rem;
  border-bottom: 1px solid var(--paper-deep);
  cursor: pointer;
  align-items: baseline;
}
.bk-row:hover { background: var(--wash); }
.bk-row.match { background: var(--highlight-soft); }
.bk-row.match .bk-orig { background: var(--highlight); }
.bk-orig { grid-area: orig; font-size: 1.15rem; }
.bk-orig.hebrew { font-family: "Noto Serif Hebrew", var(--serif); direction: rtl; text-align: right; }
.bk-gloss { grid-area: gloss; font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); }
.bk-lemma { grid-area: lemma; font-family: var(--mono); font-size: 0.65rem; color: var(--ink-faint); }

/* results */

.results-head {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink); border-bottom: 2px solid var(--ink);
  padding-bottom: 0.35rem; margin: 0.4rem 0 0.7rem;
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.6rem;
}
.results-head .meta { color: var(--ink-faint); font-size: 0.62rem; }

.apoc-toggle {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap;
}
.apoc-toggle input { accent-color: var(--ink); margin: 0; }
.apoc-toggle:hover { color: var(--ink); }

.sort-row {
  display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem;
  font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint);
}
.sort-row select {
  font-family: var(--mono); font-size: 0.62rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink); padding: 0.1rem 0.25rem;
}

.hit {
  padding: 0.55rem 0.2rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}
.hit .ref-row { display: flex; align-items: baseline; gap: 0.5rem; }
.hit .ref {
  font-family: var(--mono); font-weight: 600; font-size: 0.75rem;
  color: var(--ink); cursor: pointer; text-decoration: none;
  border-bottom: 1px solid transparent;
}
.hit .ref:hover { border-bottom-color: var(--ink); }
.badge {
  font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.1rem 0.4rem;
}
.badge.quotation { background: var(--ink); color: var(--paper-card); }
.badge.close { background: var(--highlight); color: var(--ink); }
.badge.allusion { background: var(--paper-card); color: var(--ink-soft); border: 1px solid var(--rule); }

.hit .greek { font-size: 1.05rem; line-height: 1.7; margin: 0.15rem 0; }
.hit .greek.hebrew {
  direction: rtl;
  text-align: right;
  font-family: "Noto Serif Hebrew", "SBL Hebrew", "Ezra SIL", var(--serif);
  font-size: 1.15rem;
}
.hit .greek .m { background: var(--highlight); color: var(--ink); padding: 0 0.07em; }
.hit .english { font-size: 0.85rem; font-style: italic; color: var(--ink-soft); }
.hit .english mark { background: var(--highlight); color: var(--ink); font-style: normal; }

.bybook { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.6rem; }
.bybook .chip-book {
  font-family: var(--sans); font-size: 0.75rem; color: var(--ink-soft);
  background: var(--paper-card); border: 1px solid var(--rule);
  padding: 0.1rem 0.4rem;
  cursor: pointer;
}
.bybook .chip-book:hover { background: var(--highlight-soft); color: var(--ink); border-color: var(--ink); }
.bybook .chip-book b { color: var(--ink); }
.bybook .chip-book.active { background: var(--ink); color: var(--paper-card); border-color: var(--ink); }
.bybook .chip-book.active b { color: var(--highlight); }

.spinner {
  font-family: var(--mono); color: var(--ink-faint); text-align: center;
  padding: 1rem; letter-spacing: 0.2em;
}

.more, .primary {
  font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rule); cursor: pointer;
  background: var(--paper-card); color: var(--ink-soft); padding: 0.4rem 0.8rem;
}
.more { width: 100%; margin-top: 0.6rem; }
.more:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

/* ------------------------------------------------ selection tray */

.tray[hidden] { display: none; }

.tray {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: min(92vw, 60rem);
  background: var(--ink);
  color: var(--paper-card);
  padding: 0.55rem 0.9rem;
  box-shadow: 0 6px 24px rgba(24, 24, 26, 0.3);
  z-index: 50;
}

.phrase-toggle {
  font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex; align-items: center; gap: 0.3rem; cursor: pointer;
  color: var(--highlight);
  border-right: 1px solid rgba(250,250,248,0.25); padding-right: 0.7rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; max-width: 32rem; }
.chip {
  font-family: var(--serif); font-size: 0.95rem;
  background: rgba(250,250,248,0.1);
  border: 1px solid rgba(250,250,248,0.3);
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}
.chip:hover { background: var(--highlight); color: var(--ink); }
.chip small { font-family: var(--mono); font-size: 0.62rem; opacity: 0.65; margin-left: 0.3em; }

.tray-controls { display: flex; gap: 0.4rem; align-items: center; }
.tray-controls select {
  font-family: var(--mono); font-size: 0.7rem;
  background: rgba(250,250,248,0.08); color: var(--paper-card);
  border: 1px solid rgba(250,250,248,0.3); padding: 0.25rem 0.3rem;
}
.tray-controls select option { color: var(--ink); }
.tray-controls .primary {
  background: var(--highlight); color: var(--ink); border-color: var(--highlight);
  font-weight: 600;
}
.tray-controls .primary:hover { background: #e8e44a; }
.tray-controls button:not(.primary) {
  background: none; border: 1px solid rgba(250,250,248,0.3);
  color: var(--paper-card); cursor: pointer; padding: 0.3rem 0.55rem;
}
.tray-controls button:not(.primary):hover { border-color: var(--paper-card); }

/* ------------------------------------------------ help page */

.help-body { display: block; min-height: 100%; }
.back-to-app {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-decoration: none;
  border: 1px solid var(--rule);
  padding: 0.3rem 0.6rem;
}
.back-to-app:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }

article.help {
  max-width: 44rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
  font-size: 1.05rem;
  line-height: 1.65;
}
article.help h1 {
  font-family: var(--sans);
  font-size: 1.7rem;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 0.4rem;
}
article.help h2 {
  font-family: var(--mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink);
  margin-top: 2.2rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}
article.help .lede { font-size: 1.15rem; color: var(--ink-soft); }
article.help li { margin-bottom: 0.55rem; }
article.help b { background: var(--highlight-soft); padding: 0 0.12em; }
article.help .fineprint {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--ink-faint);
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem;
  padding-top: 0.6rem;
}

/* ------------------------------------------------ study page (study.html) */

.study-page .sp-title { font-family: var(--sans); font-size: 1.7rem; border-bottom: 1px solid var(--ink); padding-bottom: 0.4rem; margin-bottom: 0.3rem; }
.study-page .sp-meta {
  font-family: var(--mono); font-size: 0.65rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-faint); margin: 0 0 1rem;
}
.sp-toolbar { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.sp-btn {
  font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink-soft); cursor: pointer; padding: 0.32rem 0.6rem;
  text-decoration: none; display: inline-block;
}
.sp-btn:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.sp-share { font-family: var(--mono); font-size: 0.68rem; background: var(--highlight-soft); border-left: 3px solid var(--highlight); padding: 0.35rem 0.6rem; margin-bottom: 0.8rem; word-break: break-all; }
.sp-desc { font-size: 1.02rem; line-height: 1.6; margin-bottom: 1rem; }
.sp-desc .hint, .sp-group-desc .hint { font-style: italic; color: var(--ink-faint); cursor: pointer; }

/* selected word(s) the study is built around */
.sp-anchors { display: flex; flex-direction: column; gap: 0.7rem; margin-bottom: 1.6rem; }
.sp-anchor-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sp-anchor {
  font-family: var(--serif); font-size: 0.95rem;
  border: 1px solid var(--rule); background: var(--paper-card); padding: 0.1rem 0.5rem;
}
.sp-anchor.heb { font-family: "Noto Serif Hebrew", var(--serif); }
.sp-anchor small { font-family: var(--mono); font-size: 0.58rem; color: var(--ink-faint); margin-left: 0.4em; }
.sp-wordcard {
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  background: var(--paper-card); padding: 0.75rem 0.95rem;
}
.sp-wc-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.1rem 0.5rem; }
.sp-wc-lemma { font-family: var(--serif); font-size: 1.55rem; line-height: 1.1; color: var(--ink); }
.sp-wc-lemma.heb { font-family: "Noto Serif Hebrew", var(--serif); }
.sp-wc-translit { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }
.sp-wc-strongs { font-family: var(--mono); font-size: 0.6rem; color: var(--ink-faint); margin-left: auto; letter-spacing: 0.05em; }
.sp-wc-gloss { font-family: var(--serif); font-style: italic; font-size: 1.02rem; color: var(--ink-soft); margin-top: 0.2rem; }
.sp-wc-counts {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); margin-top: 0.45rem;
  display: flex; flex-wrap: wrap; gap: 0.7rem;
}
.sp-wc-def { font-size: 0.9rem; line-height: 1.55; color: var(--ink-soft); margin-top: 0.55rem; }
.sp-wc-def p { margin: 0.2rem 0; }
.sp-wc-def.clamped {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sp-wc-more {
  font-family: var(--mono); font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.05em;
  background: none; border: none; color: var(--ink-faint); cursor: pointer; padding: 0.25rem 0 0;
}
.sp-wc-more:hover { color: var(--ink); }
.study-page h2.sp-group {
  font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink);
  margin-top: 2rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.25rem;
  display: flex; align-items: baseline; gap: 0.5rem;
}
.sp-group .sp-count { margin-left: auto; color: var(--ink-faint); font-size: 0.65rem; }
.sp-group-desc {
  font-size: 0.96rem; line-height: 1.55; color: var(--ink-soft);
  margin: 0.5rem 0 0.2rem; cursor: pointer;
}
.sp-group-desc p { margin: 0.25rem 0; }
.sp-addsection { margin: 1.4rem 0 0.5rem; }
.sp-addref { display: flex; gap: 0.4rem; margin: 0.6rem 0 0.2rem; }
.sp-addref-input {
  flex: 1; max-width: 22rem; font-family: var(--mono); font-size: 0.72rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink); padding: 0.3rem 0.5rem; outline: none;
}
.sp-addref-input:focus { border-color: var(--ink); }
.sp-addref-input.err { border-color: #c0392b; }
.sp-addref-input::placeholder { color: var(--ink-faint); }
.sp-addref-go { align-self: stretch; padding: 0.05rem 0.6rem; }
.sp-mini {
  font-family: var(--mono); font-size: 0.62rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink-faint); cursor: pointer; padding: 0.05rem 0.35rem;
}
.sp-mini:hover:not(:disabled) { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
.sp-mini:disabled { opacity: 0.35; cursor: default; }
.sref {
  border: 1px solid var(--rule); background: var(--paper-card);
  padding: 0.6rem 0.75rem 0.7rem; margin: 0.7rem 0;
}
.sref-head { display: flex; align-items: baseline; gap: 0.5rem; }
.sref-head .ref {
  font-family: var(--mono); font-weight: 600; font-size: 0.78rem;
  color: var(--ink); text-decoration: none;
  background: var(--paper-deep); border: 1px solid var(--rule);
  padding: 0.12rem 0.45rem; border-radius: 2px; white-space: nowrap;
}
.sref-head .ref:hover { background: var(--highlight); border-color: var(--ink); }
.sref-tools { margin-left: auto; display: flex; align-items: center; gap: 0.25rem; }
.rf-move {
  font-family: var(--mono); font-size: 0.62rem;
  border: 1px solid var(--rule); background: var(--paper-card);
  color: var(--ink-faint); cursor: pointer; padding: 0.05rem 0.2rem; max-width: 9rem;
}
.sref-text {
  margin: 0.5rem 0 0.4rem; padding: 0.1rem 0 0.1rem 0.8rem;
  border-left: 3px solid var(--rule);
  font-size: 1rem; color: var(--ink); font-style: italic;
}
.sref-comment {
  font-family: var(--serif); font-size: 0.96rem; line-height: 1.55; color: var(--ink-soft);
  cursor: pointer; margin-top: 0.45rem; padding: 0.4rem 0.6rem;
  background: var(--paper-deep); border-radius: 3px;
}
.sref-comment.empty { background: none; padding: 0.2rem 0; }
.sref-comment p { margin: 0.25rem 0; }
.sref-comment p:first-child { margin-top: 0; }
.sref-comment p:last-child { margin-bottom: 0; }
.sref-note-label {
  display: block; font-family: var(--mono); font-size: 0.55rem; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--ink-faint); margin-bottom: 0.2rem;
}
.sp-edit {
  width: 100%; min-height: 6rem; font-family: var(--sans); font-size: 0.9rem;
  border: 1px solid var(--ink); background: var(--paper-card);
  padding: 0.4rem 0.6rem; margin: 0.3rem 0; resize: vertical; outline: none;
}
.sp-edit-tall { min-height: 9rem; }
.sp-seen { margin-top: 2rem; font-family: var(--sans); font-size: 0.85rem; color: var(--ink-soft); }
.sp-seen summary {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em; cursor: pointer; color: var(--ink-faint);
}
.sp-seen summary:hover { color: var(--ink); }

/* ------------------------------------------------ responsive */

@media (max-width: 1100px) {
  .frame { grid-template-columns: 12rem minmax(0,1fr); }
  .frame.nav-hidden { grid-template-columns: 2.3rem minmax(0,1fr); }
  .study-resizer { display: none; }
  .study {
    position: fixed; right: 0; top: 0; bottom: 0; width: min(92vw, 26rem);
    background: var(--paper); z-index: 40;
    transform: translateX(100%); transition: transform 0.2s;
    box-shadow: -8px 0 30px rgba(24,24,26,0.15);
  }
  .study.open { transform: none; }
  .study-close { display: block; }
}

@media (max-width: 700px) {
  /* compact top bar: [☰ Books]  wordmark  [account], search on its own row */
  .masthead {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.7rem;
    padding: 0.6rem 0.9rem;
  }
  .nav-mobile {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: 1px solid var(--rule);
    background: var(--paper);
    color: var(--ink-soft);
    padding: 0.3rem 0.55rem;
    cursor: pointer;
  }
  .nav-mobile:hover { background: var(--highlight); color: var(--ink); border-color: var(--ink); }
  .wordmark { flex: 1; min-width: 0; }
  .wordmark h1 { font-size: 1.1rem; letter-spacing: 0.16em; }
  .tagline { display: none; }

  /* let the wrapper's children join the masthead flow so the actions (?,
     sign in) ride up onto the top row and search takes a full row of its own */
  .search-group { display: contents; }
  .search { order: 1; flex: 1 1 100%; }
  .help-link, .account-link { border-left: 1px solid var(--rule); }
  /* 16px input keeps iOS from auto-zooming on focus */
  .search input { font-size: 16px; }

  .frame,
  .frame.nav-hidden { grid-template-columns: minmax(0, 1fr); }

  /* nav becomes a left slide-in drawer instead of vanishing */
  .nav {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(85vw, 18rem);
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s;
    box-shadow: 8px 0 30px rgba(24, 24, 26, 0.18);
  }
  .nav.open { transform: none; }
  .nav-scrim {
    position: fixed; inset: 0;
    background: rgba(24, 24, 26, 0.35);
    z-index: 55;
  }
  .nav-scrim[hidden] { display: none; }

  /* phrase search is dropped on mobile (per issue #9) */
  .tray { display: none !important; }
}
