/* ══════════════════════════════════════════════════════════
   EXEGEO — Design Improvements
   Modern · Minimal · Cohesive
   Layers on top of existing styles — no JS changes needed
   ══════════════════════════════════════════════════════════ */

/* ── Additional tokens ── */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --transition: all .15s ease;
  --header-h: 52px;
  --tabs-h: 44px;
}

/* ════════════════════════════════════════
   GLOBAL RESETS
   ════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
body { font-size: 14px; -webkit-font-smoothing: antialiased; }

/* ════════════════════════════════════════
   HEADER
   ════════════════════════════════════════ */
.hdr {
  height: var(--header-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  background: var(--surface);
}

.hdr-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.hdr-sub {
  font-size: 10px;
  color: var(--text4);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-top: 2px;
}

.hdr-right { gap: 6px; }

/* Unified header button */
.hdr-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  letter-spacing: 0;
}
.hdr-btn:hover { background: var(--bg2); color: var(--text); border-color: var(--border2); }

/* Colored variants — use border + text color only, no fill at rest */
.hdr-btn.save  { color: var(--green);  border-color: transparent; }
.hdr-btn.save:hover  { background: var(--green);  color: #fff; border-color: var(--green); }
.hdr-btn.load  { color: var(--accent); border-color: transparent; }
.hdr-btn.load:hover  { background: var(--accent); color: #fff; border-color: var(--accent); }
.hdr-btn.demo  { color: var(--gold);   border-color: transparent; }
.hdr-btn.demo:hover  { background: var(--gold);   color: #fff; border-color: var(--gold); }

#autosave-status { font-size: 10px; color: var(--text4); }

/* Theme toggle */
#theme-toggle {
  width: 32px; height: 18px;
  border-radius: 9px;
  background: var(--bg3);
  border: 1px solid var(--border2);
}
#theme-toggle::after {
  width: 12px; height: 12px;
  top: 2px; left: 2px;
  background: var(--text3);
}
[data-theme="dark"] #theme-toggle { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] #theme-toggle::after { background: #fff; transform: translateX(14px); }

/* Passage badge */
.passage-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 99px;
  border-color: var(--border);
  color: var(--text2);
  letter-spacing: -.01em;
}

/* Demo dropdown */
.demo-menu { border-radius: var(--radius-lg); border-color: var(--border); }
.demo-item { font-size: 12px; padding: 9px 16px; transition: var(--transition); }
.demo-item:hover { background: var(--bg2); color: var(--text); }

/* ════════════════════════════════════════
   STAGE TABS
   ════════════════════════════════════════ */
.stage-tabs {
  display: flex;
  flex-shrink: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  height: var(--tabs-h);
  scrollbar-width: none;
}
.stage-tabs::-webkit-scrollbar { display: none; }

.stage-tab {
  height: var(--tabs-h);
  padding: 0 18px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-ui);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: var(--transition);
  letter-spacing: .01em;
  flex-shrink: 0;
}
.stage-tab:hover { color: var(--text2); background: var(--bg2); }

.snum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  background: var(--bg3);
  color: var(--text4);
  transition: var(--transition);
  flex-shrink: 0;
}

/* Active stage tab — color injected per stage via JS, replicated here for all 8 */
.stage-tab.active { color: var(--text); font-weight: 600; }
.stage-tab[data-stage="1"].active { border-bottom-color: var(--s1); }
.stage-tab[data-stage="1"].active .snum { background: var(--s1); color: #fff; }
.stage-tab[data-stage="2"].active { border-bottom-color: var(--s2); }
.stage-tab[data-stage="2"].active .snum { background: var(--s2); color: #fff; }
.stage-tab[data-stage="3"].active { border-bottom-color: var(--s3); }
.stage-tab[data-stage="3"].active .snum { background: var(--s3); color: #fff; }
.stage-tab[data-stage="4"].active { border-bottom-color: var(--s4); }
.stage-tab[data-stage="4"].active .snum { background: var(--s4); color: #fff; }
.stage-tab[data-stage="5"].active { border-bottom-color: var(--s5); }
.stage-tab[data-stage="5"].active .snum { background: var(--s5); color: #fff; }
.stage-tab[data-stage="6"].active { border-bottom-color: var(--s6); }
.stage-tab[data-stage="6"].active .snum { background: var(--s6); color: #fff; }
.stage-tab[data-stage="7"].active { border-bottom-color: var(--s7); }
.stage-tab[data-stage="7"].active .snum { background: var(--s7); color: #fff; }
.stage-tab[data-stage="8"].active { border-bottom-color: var(--s8); }
.stage-tab[data-stage="8"].active .snum { background: var(--s8); color: #fff; }

/* ════════════════════════════════════════
   PASSAGE BAR
   ════════════════════════════════════════ */
.passage-bar {
  padding: 8px 24px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.tb-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--text4);
}

.p-input {
  font-size: 13px;
  padding: 6px 10px;
  border-color: var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  width: 220px;
}
.p-input:focus { border-color: var(--accent); background: var(--surface); }

.p-select {
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
}

.p-status {
  font-size: 11px;
  color: var(--text4);
  font-style: italic;
}

/* Toolbar buttons — unified */
.tb-btn {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.tb-btn:hover { background: var(--bg3); border-color: var(--border2); color: var(--text); }

/* ════════════════════════════════════════
   BUTTONS — cohesive system
   ════════════════════════════════════════ */
.btn {
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-ui);
  line-height: 1.4;
}
.btn:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }

.btn.prim {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.prim:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text3);
}
.btn.ghost:hover { background: var(--bg3); color: var(--text); border-color: transparent; }

.btn.sm { font-size: 12px; padding: 5px 12px; }

/* AI button */
.ai-btn {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.ai-btn:hover { background: var(--accent-h); }

/* ════════════════════════════════════════
   LAYOUT & WORK AREAS
   ════════════════════════════════════════ */
.work-area { padding: 36px 0; }
.work-inner { padding: 0 48px; }

.field-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 6px;
  margin-top: 24px;
}
.field-label:first-child { margin-top: 0; }

.field-hint {
  font-size: 12px;
  color: var(--text4);
  margin-bottom: 10px;
  line-height: 1.6;
}

/* Textareas */
textarea.work-field {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
  padding: 12px 14px;
  border-radius: var(--radius);
  transition: var(--transition);
  resize: vertical;
}
textarea.work-field:focus {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}

/* Resize handle */
.resize-handle {
  width: 4px;
  background: transparent;
  transition: background .15s;
}
.resize-handle:hover, .resize-handle.dragging { background: var(--accent); opacity: .5; }

/* ════════════════════════════════════════
   PASSAGE DISPLAY
   ════════════════════════════════════════ */
.passage-display {
  background: var(--surface);
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 0;
  padding: 20px 28px;
  margin-bottom: 20px;
  line-height: 2;
  font-size: 16px;
  font-family: Georgia, 'Times New Roman', serif;
}

.verse-line { margin-bottom: 2px; }

.verse-num {
  font-size: 9px;
  color: var(--text4);
  margin-right: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  letter-spacing: .02em;
}

/* ════════════════════════════════════════
   STAGE 1 — OBSERVATION
   ════════════════════════════════════════ */
.s1-scripture-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}

.s1-tabbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px 0;
  gap: 2px;
}

.s1-trans-tab {
  font-size: 11px;
  min-height: 36px;
  padding: 5px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text3);
  font-weight: 500;
  transition: var(--transition);
}
.s1-trans-tab.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}

.s1-lookup-row {
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.s1-layout-btn {
  font-size: 11px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}
.s1-layout-btn:hover { background: var(--bg2); color: var(--text2); }
.s1-layout-btn.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* Rich observation editor */
#s1-toolbar {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 6px 12px;
  gap: 4px;
}

#s1-observations {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.9;
  padding: 32px 36px;
  min-height: 540px;
  color: var(--text);
}
#s1-observations:empty::before {
  color: var(--text4);
  font-style: italic;
}

/* ════════════════════════════════════════
   STAGE 2 — BLOCK DIAGRAM
   ════════════════════════════════════════ */
.diag-toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 7px 16px;
  gap: 6px;
}

.diag-tool-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 2px;
}

.diag-icon-btn {
  width: 28px; height: 26px;
  border-radius: 4px;
  color: var(--text3);
  transition: var(--transition);
}
.diag-icon-btn:hover { background: var(--bg2); color: var(--text); border-color: transparent; }

.diag-tool-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--text4);
}

.diag-statusbar {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 4px 16px;
  font-size: 10px;
  color: var(--text4);
  font-family: 'JetBrains Mono', monospace;
}

.CodeMirror {
  font-size: 16px;
  line-height: 2;
  background: var(--surface);
  color: var(--text);
}

/* ════════════════════════════════════════
   SYNTHESIS (Stage 6) EDITOR
   ════════════════════════════════════════ */
#s4-toolbar, #s6-toolbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 6px 20px;
  gap: 4px;
}

#s4-editor, #s6-editor {
  padding: 48px 0;
  background: var(--surface);
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 2;
  color: var(--text);
}

#s4-editor > *, #s6-editor > * {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 48px;
  padding-right: 48px;
}

#s4-editor h1, #s6-editor h1 {
  font-size: 22px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin: 28px 0 10px;
  color: var(--text);
}

#s4-editor blockquote, #s6-editor blockquote {
  border-left: 3px solid var(--border2);
  background: var(--bg2);
  padding: 14px 20px;
  color: var(--text2);
  font-style: italic;
  margin: 20px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

#s6-editor .illustration {
  border-left: 3px solid var(--teal);
  background: var(--bg2);
  padding: 14px 20px;
  margin: 20px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

#s6-editor .scripture-verse {
  border-left: 3px solid var(--purple);
  background: var(--bg2);
  padding: 14px 20px;
  margin: 20px 0;
  font-style: italic;
  color: var(--text2);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ════════════════════════════════════════
   MANUSCRIPT (Stage 8) OUTLINE
   ════════════════════════════════════════ */
#s6-outline-panel {
  width: 200px;
  min-width: 180px;
  border-right: 1px solid var(--border);
  background: var(--bg2);
}

#s6-outline-head {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}

.s6-outline-item {
  font-size: 12px;
  color: var(--text3);
  padding: 4px 14px;
  border-left: 2px solid transparent;
  transition: var(--transition);
}
.s6-outline-item:hover { color: var(--text2); background: var(--bg3); border-left-color: var(--accent); }
.s6-outline-h1 { font-weight: 600; color: var(--text2); font-size: 12px; padding-left: 14px; }
.s6-outline-h2 { padding-left: 22px; font-size: 11px; }
.s6-outline-h3 { padding-left: 30px; font-size: 11px; color: var(--text4); }

/* Manuscript toolbar buttons */
.s6-tb-btn {
  font-size: 12px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}
.s6-tb-btn:hover, .s6-tb-btn.active { background: var(--text); color: var(--surface); border-color: var(--text); }

/* ════════════════════════════════════════
   AI PANELS
   ════════════════════════════════════════ */
.ai-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--surface);
}

.ai-head {
  padding: 9px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text4);
}

.ai-body {
  padding: 14px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text2);
}

/* Right panel tabs */
.r-tab {
  font-size: 11px;
  font-weight: 500;
  padding: 9px 14px;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.r-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.r-head {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 6px;
}

/* ════════════════════════════════════════
   WORD CARDS (Stage 4)
   ════════════════════════════════════════ */
.word-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: box-shadow .15s;
}
.word-card:hover { box-shadow: var(--shadow); }

.word-card-term {
  font-size: 22px;
  font-family: 'SBL Greek', Cardo, 'Times New Roman', serif;
  color: var(--purple);
  font-weight: 600;
  letter-spacing: .01em;
}

.word-card-remove {
  font-size: 10px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text4);
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}
.word-card-remove:hover { border-color: var(--red); color: var(--red); background: transparent; }

.word-card label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  display: block;
  margin-bottom: 4px;
  margin-top: 12px;
}

.word-card textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  font-size: 13px;
  padding: 8px 10px;
  line-height: 1.7;
  transition: var(--transition);
}
.word-card textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }

.word-ai-out {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.75;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--bg2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ════════════════════════════════════════
   QUESTION CARDS
   ════════════════════════════════════════ */
.q-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.q-num {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 6px;
}

.q-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 12px;
  font-family: Georgia, 'Times New Roman', serif;
}

.q-answer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  font-size: 14px;
  padding: 10px 12px;
  line-height: 1.75;
  transition: var(--transition);
}
.q-answer:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }

.q-check-btn {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text3);
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 8px;
  transition: var(--transition);
}
.q-check-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ════════════════════════════════════════
   STAGE FOOTER
   ════════════════════════════════════════ */
.stage-footer {
  padding: 10px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
}

/* ════════════════════════════════════════
   OVERLAYS & MODALS
   ════════════════════════════════════════ */
.intro-card {
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}

.intro-card h2 {
  font-size: 20px;
  font-weight: 700;
  font-family: Georgia, serif;
  margin-bottom: 6px;
}

/* Synthesis sidebar */
.synth-sidebar {
  width: 260px;
  min-width: 220px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  padding: 14px;
}

.synth-note {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 12px;
  margin-bottom: 8px;
}

.synth-note-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 4px;
}

.synth-note-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text3);
}

/* Stage 4 workspace */
#stage-4 {
  min-height: 0;
}

#stage-4 .s4-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) 10px minmax(380px, .92fr);
  overflow: hidden;
  background: var(--bg);
}

#stage-4 .s4-reader-pane,
#stage-4 .s4-work-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#stage-4 .s4-reader-pane {
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#stage-4 .s4-reader-inner {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#stage-4 .s4-work-pane {
  padding: 0;
}

#stage-4 .s4-reader-pane {
  background: linear-gradient(to bottom, var(--surface), var(--bg2));
  border-right: 1px solid var(--border);
}

#stage-4 .s4-work-pane {
  background: var(--bg2);
}

#stage-4 .s4-pane-head {
  position: sticky;
  top: 0;
  z-index: 6;
  padding: 14px 18px 12px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

#stage-4 .s4-pane-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 4px;
}

#stage-4 .s4-pane-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

#stage-4 .s4-pane-subtitle {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text4);
}

#stage-4 .s4-reader-scroll,
#stage-4 .s4-work-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

#stage-4 .s4-reader-scroll {
  padding: 16px 0 22px;
}

#stage-4 .s4-work-scroll {
  padding: 14px 14px 18px;
}

#stage-4 .s4-reader-body {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 22px;
}

#stage-4 .s4-reader-ref {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 10px;
}

#stage-4 .s4-reader-chapter {
  margin-bottom: 20px;
}

#stage-4 .s4-reader-chapter-head {
  position: sticky;
  top: 84px;
  z-index: 4;
  margin: 0 -6px 8px;
  padding: 10px 6px 8px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--surface) 72%, transparent));
  border-bottom: 1px solid rgba(0, 0, 0, 0);
}

#stage-4 .s4-reader-chapter-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text4);
}

#stage-4 .s4-reader-chapter-title {
  margin-top: 2px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

#stage-4 .s4-reader-chapter-note {
  margin-top: 3px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text4);
}

#stage-4 .greek-verse {
  padding: 6px 10px 6px 0;
  border-radius: 12px;
  transition: background .12s;
}

#stage-4 .greek-verse.is-anchor,
#stage-4 .greek-verse.is-current {
  background: color-mix(in srgb, var(--accent-soft, rgba(60, 92, 160, .10)) 100%, transparent);
}

#stage-4 .greek-vnum {
  min-width: 34px;
}

#stage-4 .s4-reader-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

#stage-4 .s4-reader-footer-head,
#stage-4 .s4-work-section-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 8px;
}

#stage-4 .s4-reader-footer-note {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text3);
  margin-bottom: 12px;
}

#stage-4 .s4-split-handle {
  position: relative;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}

#stage-4 .s4-split-handle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 58px;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  background: linear-gradient(to bottom, transparent, var(--border), transparent);
}

#stage-4 .s4-split-handle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border2);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--surface) 70%, transparent);
}

#stage-4 .s4-split-handle:hover::before,
#stage-4 .s4-split-handle.dragging::before {
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
}

#stage-4 .s4-split-handle:hover::after,
#stage-4 .s4-split-handle.dragging::after {
  border-color: var(--accent);
}

#stage-4 .s4-work-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 14px;
}

#stage-4 .s4-work-section-head {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0;
  padding: 12px 14px 10px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

#stage-4 .s4-work-section-body {
  padding: 14px;
}

#stage-4 .s4-translation-editor {
  width: 100%;
  min-height: 190px;
  resize: vertical;
}

#stage-4 .s4-translation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

#stage-4 .s4-translation-help {
  font-size: 11px;
  color: var(--text4);
  line-height: 1.5;
}

#stage-4 .s4-study-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

#stage-4 .s4-study-actions .tb-btn {
  flex-shrink: 0;
}

#stage-4 .s4-work-section .ai-panel {
  margin-bottom: 0;
}

#stage-4 .s4-work-section .word-card:last-child {
  margin-bottom: 0;
}

#stage-4 .s4-tools-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 4;
}

#stage-4 .s4-tools-tabs .r-tab {
  flex: 1;
  text-align: center;
}

#stage-4 .s4-tools-panel {
  min-height: 0;
}

#stage-4 .s4-tools-panel#s2-rpanel-resources {
  display: block;
}

#stage-4 .s4-tools-panel#s2-rpanel-lexicon,
#stage-4 .s4-tools-panel#s2-rpanel-wordstudy {
  display: none;
  flex-direction: column;
}

#stage-4 .s4-tools-panel .r-body {
  padding: 12px 14px 16px;
}

#stage-4 .s4-lookup-shell {
  border-top: 1px solid var(--border);
}

@media (max-width: 1120px) {
  #stage-4 .s4-shell {
    grid-template-columns: minmax(0, 1.08fr) 10px minmax(340px, .92fr);
  }
}

@media (max-width: 940px) {
  #stage-4 .s4-shell {
    display: flex;
    flex-direction: column;
  }

  #stage-4 .s4-reader-pane,
  #stage-4 .s4-work-pane {
    flex: 1 1 auto;
    min-height: 0;
  }

  #stage-4 .s4-split-handle {
    display: none;
  }
}

/* ════════════════════════════════════════
   RESOURCE LINKS
   ════════════════════════════════════════ */
.res-section-head {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text4);
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.res-link {
  font-size: 11px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text2);
  background: var(--surface);
  transition: var(--transition);
}
.res-link:hover { background: var(--bg2); border-color: var(--border2); color: var(--text); }
.res-link.logos { border-color: var(--teal); color: var(--teal); }
.res-link.logos:hover { background: var(--teal); color: #fff; }
.res-link.precept { border-color: var(--purple); color: var(--purple); }
.res-link.precept:hover { background: var(--purple); color: #fff; }

/* ════════════════════════════════════════
   SCROLLBARS — minimal
   ════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text4); }

/* ════════════════════════════════════════
   DARK MODE REFINEMENTS
   ════════════════════════════════════════ */
[data-theme="dark"] .passage-display { border-left-color: var(--accent); }
[data-theme="dark"] textarea.work-field { background: var(--bg2); }
[data-theme="dark"] textarea.work-field:focus { background: var(--bg3); }
[data-theme="dark"] #s1-observations { background: var(--surface); }
[data-theme="dark"] .word-card { background: var(--surface); }
[data-theme="dark"] .q-item { background: var(--surface); }
[data-theme="dark"] .ai-panel { background: var(--surface); }
