:root {
  color-scheme: light;
  --surface-base: #f8f7f3;
  --surface-panel: #ffffff;
  --surface-raised: #f1efe8;
  --surface-command: #ffffff;
  --surface-left: #edf4f1;
  --surface-rail: #dfece8;
  --surface-workspace: #f8f7f3;
  --surface-reader: #fffdf9;
  --surface-reader-header: #efe7d4;
  --surface-study: #f4f0f8;
  --surface-study-card: #ffffff;
  --surface-cell: #fff8ee;
  --surface-cell-item: #f2ecdf;
  --surface-status: #ebe4d2;
  --border-subtle: #ddd8cb;
  --border-strong: #c8bfaf;
  --text-primary: #1c1d1f;
  --text-secondary: #5f6368;
  --accent-reference: #2f6f73;
  --accent-strong: #7b4e9a;
  --accent-note: #9a6a21;
  --accent-warning: #9b3a2f;
  --accent-generated: #5c6f91;
  --text-on-accent: #ffffff;
  --focus-ring: #1f8a94;
  --reader-font-size: 18px;
  --reader-line-height: 32px;
  font-family: "Pretendard Variable", "Noto Sans CJK KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--surface-workspace);
  color: var(--text-primary);
}

body.has-mobile-bible-picker {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
input,
textarea,
select {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

button {
  min-height: 34px;
  background: var(--surface-panel);
  color: var(--text-primary);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:hover,
button.is-active {
  border-color: var(--accent-reference);
  background: color-mix(in srgb, var(--accent-reference) 11%, var(--surface-panel));
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.strong-token:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

input,
textarea,
select {
  background: var(--surface-panel);
  color: var(--text-primary);
  padding: 7px 9px;
}

textarea {
  width: 100%;
  resize: vertical;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--left-rail-width, 360px) minmax(0, 1fr) var(--study-panel-width, 420px);
  grid-template-rows: auto minmax(0, 1fr) 30px;
  grid-template-areas:
    "command command command"
    "left workspace study"
    "status status status";
}

.app-shell[data-theme="dark"] {
  color-scheme: dark;
  --surface-base: #07090c;
  --surface-panel: #11161d;
  --surface-raised: #1b222d;
  --surface-command: #11161d;
  --surface-left: #101a1d;
  --surface-rail: #172328;
  --surface-workspace: #07090c;
  --surface-reader: #11161d;
  --surface-reader-header: #1b222d;
  --surface-study: #17131d;
  --surface-study-card: #11161d;
  --surface-cell: #151b18;
  --surface-cell-item: #1b222d;
  --surface-status: #16181d;
  --border-subtle: #5b6675;
  --border-strong: #778293;
  --text-primary: #ffffff;
  --text-secondary: #e3e8ef;
  --accent-reference: #9ff6ff;
  --accent-strong: #f0c2ff;
  --accent-note: #ffdc78;
  --accent-warning: #ffb1a6;
  --accent-generated: #c6d5ff;
  --text-on-accent: #001316;
  --focus-ring: #ffffff;
}

.app-shell[data-theme="contrast"] {
  color-scheme: dark;
  --surface-base: #000000;
  --surface-panel: #0b0b0c;
  --surface-raised: #161616;
  --surface-command: #000000;
  --surface-left: #050f10;
  --surface-rail: #10191a;
  --surface-workspace: #000000;
  --surface-reader: #0b0b0c;
  --surface-reader-header: #161616;
  --surface-study: #120814;
  --surface-study-card: #0b0b0c;
  --surface-cell: #101008;
  --surface-cell-item: #161616;
  --surface-status: #0f0f0f;
  --border-subtle: #f3f3f3;
  --border-strong: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #f0f0f0;
  --accent-reference: #00f0ff;
  --accent-strong: #ffb3ff;
  --accent-note: #ffd166;
  --accent-warning: #ff6b6b;
  --accent-generated: #b8c7ff;
  --text-on-accent: #000000;
  --focus-ring: #ffffff;
}

.command-bar {
  grid-area: command;
  display: grid;
  grid-template-columns: minmax(160px, auto) minmax(220px, 380px) minmax(200px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: var(--surface-command);
  border-bottom: 1px solid var(--border-strong);
}

.brand-block {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  justify-self: start;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.brand-mark:hover,
.brand-mark.is-active {
  border-color: transparent;
  background: transparent;
}

.brand-mark,
.reference-form,
.search-form,
.toolbar-actions,
.version-selector,
.reference-picker,
.reader-controls,
.status-bar,
.study-tabs,
.rail-tabs,
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workspace-health {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.workspace-health span {
  min-width: 0;
  max-width: 112px;
  overflow: hidden;
  padding: 1px 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar-actions button {
  min-width: 42px;
  padding-inline: 9px;
  white-space: nowrap;
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--accent-reference);
  color: var(--text-on-accent);
  font-weight: 800;
}

.brand-mark:hover .brand-symbol {
  background: color-mix(in srgb, var(--accent-reference) 86%, var(--text-primary));
}

.brand-name,
.module-code,
.source-label,
.badge {
  font-size: 12px;
  line-height: 16px;
}

.brand-name {
  font-weight: 700;
}

.reference-form input,
.search-form input {
  min-width: 0;
  width: 100%;
}

.reference-form,
.search-form {
  min-width: 0;
}

.reference-form {
  position: relative;
}

.recent-reference-popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  display: none;
  gap: 6px;
  max-height: min(300px, 54vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-panel);
  box-shadow: 0 16px 40px var(--shadow);
}

.reference-form:focus-within .recent-reference-popover {
  display: grid;
}

.recent-reference-menu-title,
.recent-reference-empty {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
}

.recent-reference-menu-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.recent-reference-menu-list button {
  min-width: 0;
  min-height: 34px;
  overflow: hidden;
  padding: 6px 8px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-reference-menu-list button.is-current {
  box-shadow: inset 3px 0 0 var(--accent-reference);
}

.recent-reference-menu-list button.is-active,
.recent-reference-menu-list button:focus-visible {
  border-color: var(--accent-reference);
  background: var(--surface-left);
}

.primary-action {
  padding-inline: 14px;
  background: var(--accent-reference);
  color: var(--text-on-accent);
  border-color: transparent;
  font-weight: 700;
}

.version-selector {
  display: block;
  overflow: visible;
  min-width: 0;
}

.panel-heading.bible-panel-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 144px;
  align-items: start;
  gap: 8px;
}

.bible-title-group {
  display: contents;
}

.bible-title-line {
  display: flex;
  grid-column: 1;
  grid-row: 1;
  align-items: baseline;
  gap: 8px;
  min-height: 32px;
}

.selected-version-slot {
  grid-column: 1 / -1;
  grid-row: 2;
  min-width: 0;
  width: 100%;
}

.bible-version-slot {
  display: block;
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  width: 144px;
}

.bible-version-slot .version-selector {
  width: 100%;
  max-width: 100%;
  padding-bottom: 2px;
}

.bible-version-slot .version-add-control {
  position: relative;
}

/* Keep the selector self-contained instead of relying on display: contents. */
.bible-version-slot > .version-selector {
  display: block;
  min-width: 0;
}

.selected-version-list {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 5px;
  min-width: 0;
}

.selected-version-group {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 38px;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-panel) 88%, var(--surface-left));
  min-width: 0;
}

.selected-version-heading,
.selected-version-empty {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}

.selected-version-empty {
  padding: 2px 6px;
  border: 1px dashed var(--border-subtle);
  border-radius: 4px;
}

.selected-version-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 128px;
  min-height: 30px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--accent-reference);
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent-reference) 12%, var(--surface-panel));
  color: var(--text-primary);
}

.selected-version-chip > span {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-version-chip button {
  display: grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  min-height: 20px;
  padding: 0;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
}

.version-add-control {
  display: block;
  width: 144px;
  min-width: 0;
  position: relative;
  z-index: 2;
}

.version-add-label {
  display: block;
  position: relative;
  width: 100%;
  padding: 6px 9px;
  padding-right: 26px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--surface-panel);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  min-height: 32px;
  line-height: 18px;
}

.version-add-label::after {
  content: "▾";
  position: absolute;
  right: 9px;
  top: 50%;
  color: var(--accent-reference);
  font-size: 13px;
  transform: translateY(-55%);
  transition: transform 150ms ease;
}

.version-add-control:has(.version-options:popover-open) .version-add-label::after {
  transform: translateY(-45%) rotate(180deg);
}

.version-add-control:has(.version-options:popover-open) .version-add-label,
.version-add-label:hover {
  border-color: var(--accent-reference);
  background: color-mix(in srgb, var(--accent-reference) 10%, var(--surface-panel));
  color: var(--text-primary);
}

.version-options {
  position: fixed;
  inset: auto;
  top: 0;
  left: 0;
  z-index: 30;
  display: none;
  width: min(220px, 60vw);
  max-height: min(520px, calc(100dvh - 16px));
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: var(--accent-reference) var(--surface-raised);
  scrollbar-width: auto;
  pointer-events: auto;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-panel);
  box-shadow: 0 10px 24px color-mix(in srgb, var(--text-primary) 18%, transparent);
}

.version-options:popover-open {
  display: grid;
}

.version-options::-webkit-scrollbar {
  width: 12px;
}

.version-options::-webkit-scrollbar-track {
  background: var(--surface-raised);
  border-left: 1px solid var(--border-subtle);
}

.version-options::-webkit-scrollbar-thumb {
  border: 3px solid var(--surface-raised);
  border-radius: 999px;
  background: var(--accent-reference);
}

.version-options-meta {
  position: sticky;
  top: -6px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: -6px -6px 4px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.version-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 6px;
  padding: 6px;
  color: var(--text-primary);
  cursor: pointer;
}

.version-option:hover {
  background: color-mix(in srgb, var(--accent-reference) 12%, var(--surface-panel));
}

.version-option small {
  grid-column: 2;
  color: var(--text-secondary);
  font-size: 12px;
}

.version-options-empty {
  padding: 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.switch,
.filter-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  white-space: nowrap;
}

.app-shell[data-theme="dark"] button:hover,
.app-shell[data-theme="dark"] button.is-active {
  color: var(--text-primary);
  background: #263241;
}

.app-shell[data-theme="dark"] input::placeholder {
  color: #f0f4f8;
}

.app-shell[data-theme="dark"] button,
.app-shell[data-theme="dark"] input,
.app-shell[data-theme="dark"] textarea,
.app-shell[data-theme="dark"] select,
.app-shell[data-theme="dark"] .switch,
.app-shell[data-theme="dark"] .filter-row label {
  border-color: var(--border-subtle);
}

.app-shell[data-theme="dark"] .source-label,
.app-shell[data-theme="dark"] .module-code,
.app-shell[data-theme="dark"] .badge {
  color: var(--text-primary);
  background: #0c1117;
}

.app-shell[data-theme="dark"] .primary-action {
  color: var(--text-on-accent);
  background: var(--accent-reference);
}

.app-shell[data-theme="dark"] .verse-ref-button,
.app-shell[data-theme="dark"] .eyebrow {
  color: var(--accent-reference);
}

.app-shell[data-theme="dark"] mark {
  color: #000000;
  background: #ffe184;
}

.switch input,
.filter-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.left-rail {
  grid-area: left;
  position: relative;
  display: flex;
  min-height: 0;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-left);
}

.resize-handle {
  position: absolute;
  top: 0;
  right: -5px;
  z-index: 6;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: var(--accent-reference);
  opacity: 0;
}

.resize-handle:hover::after,
.resize-handle:focus-visible::after,
.resize-handle.is-resizing::after {
  opacity: 1;
}

.rail-tabs {
  width: 48px;
  flex-direction: column;
  padding: 8px 6px;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-rail);
}

.rail-tab {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  width: 34px;
  min-height: 92px;
  padding: 8px 2px;
  background: color-mix(in srgb, var(--surface-rail) 78%, var(--surface-panel));
}

.rail-tab.is-active {
  box-shadow: inset 3px 0 0 var(--accent-reference);
}

.left-panel {
  min-width: 0;
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: var(--surface-left);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.library-summary {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-panel);
  color: var(--text-primary);
}

.library-summary strong {
  color: var(--accent-reference);
  font-size: 22px;
}

.library-summary span {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 18px;
}

.panel-heading h2,
.study-heading h2,
.passage-toolbar h1 {
  margin: 0;
}

.panel-heading > span,
.bible-title-group span,
.study-heading .eyebrow,
.passage-toolbar .eyebrow,
.source-block small,
.module-row small,
.search-result small,
.collection-row small,
.candidate-row small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
}

.workspace {
  grid-area: workspace;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--surface-workspace);
}

.passage-toolbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "passage-title passage-picker"
    "passage-reader passage-reader";
  align-items: center;
  gap: 10px 16px;
  padding: 14px 16px;
  background: var(--surface-workspace);
  border-bottom: 1px solid var(--border-strong);
}

.passage-title-block {
  grid-area: passage-title;
  min-width: 0;
}

.passage-toolbar h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-reference);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.reader-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.reference-picker {
  grid-area: passage-picker;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
}

.reference-picker label {
  display: grid;
  grid-template-columns: auto minmax(52px, auto);
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.reference-picker select {
  min-height: 34px;
}

#book-select {
  width: min(120px, 28vw);
}

#chapter-select {
  width: 56px;
}

.reader-controls input {
  width: 92px;
}

.reader-controls {
  grid-area: passage-reader;
  justify-content: flex-end;
  min-width: 0;
}

.passage-grid {
  display: grid;
  column-gap: 12px;
  row-gap: 0;
  padding: 12px 16px 24px;
  align-items: stretch;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

.version-column {
  min-width: 0;
  background: var(--surface-reader);
  border: 1px solid var(--border-subtle);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}

.version-column > header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-reader-header);
}

.version-column h2 {
  min-width: 0;
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-code,
.source-label,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 6px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--surface-panel);
}

.mobile-version-badge {
  display: none;
}

.verse-row {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border-subtle);
  scroll-margin-top: 92px;
}

.version-verse-cell {
  min-width: 0;
  background: var(--surface-reader);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  border-left: 1px solid var(--border-subtle);
}

.verse-row.is-active {
  background: color-mix(in srgb, var(--accent-reference) 10%, var(--surface-panel));
  box-shadow: inset 3px 0 0 var(--accent-reference);
}

.verse-row.has-highlight {
  background: color-mix(in srgb, var(--accent-note) 14%, var(--surface-panel));
}

.verse-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.verse-ref-button {
  min-height: 26px;
  padding: 2px 6px;
  color: var(--accent-reference);
  border-color: transparent;
  background: transparent;
  font-weight: 700;
}

.verse-text {
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
}

.verse-text.is-korean {
  line-height: max(var(--reader-line-height), 34px);
  word-break: keep-all;
}

.strong-token {
  color: var(--accent-strong);
  border-bottom: 1px dotted var(--accent-strong);
  cursor: pointer;
}

.english-word-token {
  border-radius: 3px;
  border-bottom: 1px dotted color-mix(in srgb, var(--accent-reference) 60%, transparent);
  cursor: help;
}

.english-word-token:hover,
.english-word-token:focus {
  background: color-mix(in srgb, var(--accent-reference) 12%, transparent);
  outline: none;
}

.english-word-token:focus-visible {
  outline: 2px solid var(--accent-reference);
  outline-offset: 2px;
}

.word-tooltip {
  position: fixed;
  z-index: 30;
  display: grid;
  gap: 3px;
  max-width: 240px;
  padding: 8px 10px;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface-panel);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--text-primary) 18%, transparent);
  pointer-events: none;
}

.word-tooltip strong {
  font-size: 13px;
  line-height: 17px;
}

.word-tooltip span {
  font-size: 12px;
  line-height: 16px;
}

.word-tooltip small {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 14px;
}

.study-panel {
  grid-area: study;
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-study);
}

.study-resize-handle {
  position: absolute;
  top: 0;
  left: -5px;
  z-index: 6;
  width: 10px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.study-resize-handle::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: var(--accent-reference);
  opacity: 0;
}

.study-resize-handle:hover::after,
.study-resize-handle:focus-visible::after,
.study-resize-handle.is-resizing::after {
  opacity: 1;
}

.study-collapse-toggle {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-color: var(--border-strong);
  background: var(--surface-study-card);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

.study-collapse-toggle:hover,
.study-collapse-toggle:focus-visible {
  border-color: var(--accent-reference);
  color: var(--accent-strong);
}

.study-tabs {
  overflow-x: auto;
  padding: 8px 48px 8px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-study);
}

.study-tabs button {
  white-space: nowrap;
  padding-inline: 10px;
  background: var(--surface-study-card);
}

.study-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  background: var(--surface-study);
}

@media (min-width: 1181px) {
  .app-shell[data-study-collapsed="true"] {
    grid-template-columns: var(--left-rail-width, 360px) minmax(0, 1fr) 44px;
  }

  .app-shell[data-study-collapsed="true"] .study-panel {
    align-items: center;
  }

  .app-shell[data-study-collapsed="true"] .study-collapse-toggle {
    position: static;
    margin-top: 8px;
  }

  .app-shell[data-study-collapsed="true"] .study-resize-handle,
  .app-shell[data-study-collapsed="true"] .study-tabs,
  .app-shell[data-study-collapsed="true"] .study-content {
    display: none;
  }
}

.study-heading {
  margin-bottom: 12px;
}

.source-block,
.module-row,
.candidate-row,
.collection-row button,
.search-result,
.diff-row,
.research-question-card,
.research-summary-grid article,
.research-evidence,
.research-synthesis,
.empty-state {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-study-card);
}

.source-block,
.diff-row,
.research-question-card,
.research-summary-grid article,
.research-evidence,
.research-synthesis,
.empty-state {
  padding: 10px;
  margin-bottom: 10px;
}

.source-block header,
.research-evidence header,
.module-row,
.candidate-row,
.search-result,
.collection-row button,
.occurrence-row,
.xref-row {
  display: grid;
  gap: 4px;
}

.source-block.is-generated {
  border-color: var(--accent-generated);
  box-shadow: inset 3px 0 0 var(--accent-generated);
}

.research-evidence.is-generated {
  border-color: var(--accent-generated);
  box-shadow: inset 3px 0 0 var(--accent-generated);
}

.source-block p,
.search-result p,
.diff-row p,
.research-question-card p,
.research-evidence p,
.research-synthesis p,
.research-note {
  margin: 4px 0 0;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 22px;
}

.field-label {
  display: block;
  margin: 10px 0 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.file-picker {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px dashed var(--border-subtle);
  border-radius: 8px;
}

.file-picker input {
  width: 100%;
}

.module-list,
.search-results,
.collection-list,
.import-report {
  display: grid;
  gap: 8px;
}

.panel-search-input {
  width: 100%;
  margin-bottom: 10px;
}

.testament-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.testament-switch button {
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 44px;
  padding: 8px;
}

.testament-switch span,
.book-button small,
.chapter-group small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
}

.book-group,
.chapter-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.bible-picker-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(112px, 0.72fr);
  gap: 8px;
  align-items: start;
}

.book-browser {
  min-width: 0;
}

.bible-picker-shell .book-group,
.bible-picker-shell .chapter-group {
  margin-bottom: 0;
}

.book-group h3,
.chapter-group h3 {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.bible-picker-shell .book-grid {
  grid-template-columns: 1fr;
}

.book-button {
  display: grid;
  gap: 2px;
  justify-items: start;
  min-height: 48px;
  padding: 8px;
  text-align: left;
}

.book-button strong {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 18px;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(36px, 1fr));
  gap: 6px;
}

.bible-picker-shell .chapter-group {
  position: sticky;
  top: 0;
  max-height: min(560px, calc(100vh - 220px));
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-cell);
}

.bible-picker-shell .chapter-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.chapter-grid button {
  min-height: 36px;
  padding: 4px;
}

.mobile-bible-picker {
  display: none;
}

.module-row,
.candidate-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 8px;
}

.candidate-row {
  grid-template-columns: 1fr auto;
}

.warning-text {
  color: var(--accent-warning);
  font-size: 13px;
}

.filter-row {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.search-result,
.collection-row button,
.occurrence-row,
.xref-row {
  width: 100%;
  padding: 9px;
  text-align: left;
}

.occurrence-row,
.xref-row {
  grid-template-columns: 1fr auto;
  margin-bottom: 8px;
}

.badge.generated {
  border-color: var(--accent-generated);
  color: var(--accent-generated);
}

.badge.private,
.note-badge {
  border-color: var(--accent-note);
  color: var(--accent-note);
}

.missing-text {
  color: var(--text-secondary);
  font-style: italic;
}

mark {
  background: color-mix(in srgb, var(--accent-note) 35%, transparent);
  color: var(--text-primary);
  border-radius: 4px;
  padding-inline: 2px;
}

.research-workbench {
  display: grid;
  gap: 12px;
}

.research-question-card {
  display: grid;
  gap: 8px;
}

.research-question-card textarea {
  min-height: 92px;
  resize: vertical;
}

.research-question-card small,
.research-evidence small,
.research-synthesis small {
  color: var(--text-secondary);
}

.research-mode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.research-mode-row label {
  display: grid;
  gap: 4px;
}

.research-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.research-summary-grid article {
  display: grid;
  gap: 3px;
}

.research-summary-grid span {
  color: var(--accent-reference);
  font-size: 18px;
  font-weight: 800;
}

.research-section {
  display: grid;
  gap: 8px;
}

.research-section h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 18px;
  text-transform: uppercase;
}

.research-evidence {
  display: grid;
  gap: 8px;
}

.research-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.research-synthesis {
  display: grid;
  gap: 8px;
}

.research-synthesis ol {
  margin: 0;
  padding-left: 20px;
}

.research-synthesis li {
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 22px;
}

.research-occurrences {
  display: grid;
  gap: 8px;
}

.draw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.scripture-draw-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--accent-reference);
  border-radius: 8px;
  background: var(--surface-study-card);
  box-shadow: inset 3px 0 0 var(--accent-reference);
}

.scripture-draw-card blockquote {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--reader-font-size);
  line-height: var(--reader-line-height);
}

.scripture-draw-card small {
  color: var(--text-secondary);
  line-height: 18px;
}

.scripture-draw-translations {
  display: grid;
  gap: 10px;
}

.scripture-draw-translation {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-raised);
}

.draw-language-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.draw-language-label strong {
  color: var(--accent-reference);
  font-size: 13px;
}

.draw-language-label span {
  color: var(--text-secondary);
  font-size: 12px;
}

.cell-section {
  display: grid;
  gap: 8px;
  min-width: 0;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-cell);
}

.cell-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(240px, 1.1fr);
  gap: 12px;
  align-items: start;
}

.cell-workspace .cell-section.is-wide {
  grid-column: 1 / -1;
}

.cell-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cell-section h3,
.cell-card-slide h4 {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.live-memo-section {
  border-color: color-mix(in srgb, var(--accent-note) 42%, var(--border-subtle));
}

.memo-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.memo-header span {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
}

.memo-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.45fr);
  gap: 8px;
}

.live-memo-textarea {
  min-height: 260px;
  font-size: 16px;
  line-height: 26px;
}

.memo-tools {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
}

.memo-tools button {
  min-width: 0;
}

.cell-section input,
.cell-section textarea {
  width: 100%;
}

.cell-inline-actions {
  flex-wrap: wrap;
}

.cell-inline-actions button {
  flex: 1 1 112px;
}

.cell-rail-actions,
.cell-rail-status {
  display: grid;
  gap: 8px;
}

.cell-rail-draw {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.cell-rail-draw .panel-heading {
  margin-bottom: 0;
}

.cell-rail-draw .panel-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
}

.cell-rail-draw-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--accent-reference);
  border-radius: 8px;
  background: var(--surface-cell);
  box-shadow: inset 3px 0 0 var(--accent-reference);
}

.cell-rail-draw-card section {
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--surface-cell-item);
}

.cell-rail-draw-card strong {
  color: var(--accent-reference);
  font-size: 12px;
  line-height: 16px;
}

.cell-rail-draw-card p {
  margin: 0;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 20px;
  overflow-wrap: anywhere;
}

.cell-rail-draw-card small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
}

.cell-rail-status {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-cell);
}

.cell-rail-status span {
  color: var(--text-secondary);
  font-size: 12px;
}

.cell-rail-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.cell-member-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.cell-member-list,
.cell-guide-list,
.cell-card-deck {
  display: grid;
  gap: 8px;
}

.cell-member-row,
.cell-guide-item,
.cell-card-slide,
.cell-card-frame {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-cell-item);
}

.cell-member-row,
.cell-guide-item,
.cell-card-slide {
  padding: 8px;
}

.cell-member-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.cell-member-header button {
  width: 30px;
  min-height: 30px;
  padding: 0;
}

.attendance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.attendance-grid label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  padding: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: var(--surface-panel);
  color: var(--text-primary);
  font-size: 12px;
}

.attendance-grid input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.cell-question-input {
  margin-bottom: 6px;
}

.cell-card-preview {
  display: grid;
  gap: 8px;
}

.cell-card-frame {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
}

.cell-card-frame img {
  display: block;
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  background: #000000;
}

.cell-card-frame figcaption {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 16px;
}

.cell-card-slide {
  min-height: 124px;
}

.cell-card-slide strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 22px;
}

.cell-card-slide p,
.cell-card-slide li {
  color: var(--text-primary);
  font-size: 13px;
  line-height: 20px;
}

.cell-card-slide p {
  margin: 8px 0 0;
}

.cell-card-slide ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.status-bar {
  grid-area: status;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--surface-status);
  border-top: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 12px;
}

.status-bar.has-error {
  color: var(--accent-warning);
}

.export-dialog {
  width: min(840px, calc(100vw - 24px));
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-panel);
  color: var(--text-primary);
}

.export-dialog::backdrop {
  background: rgb(0 0 0 / 40%);
}

.export-dialog header,
.export-dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.export-dialog h2 {
  margin: 0;
}

.export-dialog textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
}

@media (max-width: 1180px) {
  .app-shell {
    height: auto;
    overflow: visible;
    grid-template-columns: minmax(280px, var(--left-rail-width, 360px)) minmax(0, 1fr);
    grid-template-rows: auto max(320px, 48vh) max(320px, 42vh) 30px;
    grid-template-areas:
      "command command"
      "left workspace"
      "study study"
      "status status";
  }

  .command-bar {
    grid-template-columns: 1fr;
  }

  .study-resize-handle {
    display: none;
  }

  .study-collapse-toggle {
    display: none;
  }

  .study-tabs {
    padding-right: 8px;
  }
}

@media (min-width: 1181px) and (max-width: 1360px) {
  .command-bar {
    grid-template-columns: minmax(160px, auto) minmax(220px, 1fr) minmax(200px, 1fr);
  }

  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto 34px;
    grid-template-areas:
      "command"
      "left"
      "workspace"
      "study"
      "status";
  }

  .command-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 6px;
  }

  .reference-form,
  .search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .version-selector {
    padding-bottom: 2px;
  }

  .bible-panel-heading {
    grid-template-columns: minmax(0, 1fr) 144px;
  }

  .bible-version-slot {
    width: 100%;
  }

  .bible-version-slot .version-add-control {
    width: 144px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .toolbar-actions button {
    min-width: 0;
    padding-inline: 4px;
    font-size: 13px;
  }

  .left-rail {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 0;
    max-height: none;
    border-right: 0;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
  }

  .resize-handle {
    display: none;
  }

  .study-resize-handle {
    display: none;
  }

  .study-collapse-toggle {
    display: none;
  }

  .rail-tabs {
    width: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px;
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
  }

  .rail-tab {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    width: auto;
    min-width: 72px;
    min-height: 36px;
    padding: 6px 10px;
  }

  .left-panel {
    max-height: 280px;
  }

  .left-panel .bible-picker-shell {
    display: none;
  }

  .mobile-bible-picker {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    align-items: end;
  }

  .mobile-picker-backdrop {
    position: absolute;
    inset: 0;
    min-height: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgb(0 0 0 / 42%);
  }

  .mobile-picker-backdrop:hover,
  .mobile-picker-backdrop:focus-visible {
    background: rgb(0 0 0 / 42%);
  }

  .mobile-picker-sheet {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
    max-height: min(78vh, 680px);
    overflow: auto;
    padding: 14px 12px 16px;
    border: 1px solid var(--border-strong);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: var(--surface-left);
    box-shadow: 0 -12px 30px rgb(0 0 0 / 24%);
  }

  .mobile-picker-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-picker-header h2 {
    margin: 0;
    font-size: 22px;
    line-height: 28px;
  }

  .mobile-picker-header span {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 18px;
  }

  .mobile-picker-header button {
    flex: 0 0 auto;
    padding-inline: 12px;
  }

  .mobile-picker-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-picker-tabs button {
    display: grid;
    gap: 2px;
    justify-items: start;
    min-height: 48px;
    padding: 8px;
  }

  .mobile-picker-tabs span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 16px;
  }

  .mobile-picker-section {
    display: grid;
    gap: 8px;
  }

  .mobile-picker-section h3 {
    margin: 0;
    font-size: 14px;
    line-height: 20px;
  }

  .mobile-picker-book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 220px;
    overflow: auto;
    padding-right: 2px;
  }

  .mobile-picker-chapters {
    padding: 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: var(--surface-cell);
  }

  .mobile-picker-chapter-grid {
    grid-template-columns: repeat(5, minmax(38px, 1fr));
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chapter-grid {
    grid-template-columns: repeat(5, minmax(38px, 1fr));
  }

  .bible-picker-shell {
    grid-template-columns: minmax(0, 0.9fr) minmax(100px, 0.72fr);
  }

  .bible-picker-shell .chapter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .passage-toolbar,
  .reader-controls,
  .reference-picker,
  .status-bar {
    flex-wrap: wrap;
  }

  .passage-toolbar {
    position: static;
    grid-template-columns: 1fr;
    grid-template-areas:
      "passage-title"
      "passage-picker"
      "passage-reader";
    align-items: flex-start;
    padding: 12px;
  }

  .reference-picker {
    width: 100%;
  }

  #book-select {
    width: min(100%, 260px);
  }

  .reader-controls {
    width: 100%;
  }

  .reader-controls label {
    flex: 1 1 118px;
  }

  .reader-controls input {
    width: 100%;
  }

  .research-mode-row,
  .research-summary-grid {
    grid-template-columns: 1fr;
  }

  .passage-grid {
    grid-template-columns: 1fr !important;
    padding: 10px;
    overflow-x: hidden;
  }

  .version-header-cell {
    display: none;
  }

  .version-verse-cell {
    grid-column: auto !important;
    grid-row: auto !important;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
  }

  .version-verse-cell + .version-verse-cell {
    margin-top: 8px;
  }

  .verse-meta {
    justify-content: flex-start;
  }

  .mobile-version-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 7px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: var(--surface-reader-header);
    color: var(--accent-reference);
    font-size: 12px;
    font-weight: 800;
    line-height: 18px;
  }

  .cell-workspace,
  .cell-form-grid,
  .memo-meta-grid {
    grid-template-columns: 1fr;
  }

  .memo-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .live-memo-textarea {
    min-height: 220px;
  }

  .memo-tools {
    grid-template-columns: 1fr;
  }

  .study-panel {
    min-height: 320px;
    border-left: 0;
    border-top: 1px solid var(--border-subtle);
  }

  .brand-name {
    display: none;
  }

  .workspace-health {
    display: none;
  }
}
