:root {
  color-scheme: light;
  --bg: #f6f5f2;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #686b70;
  --line: #dedbd3;
  --accent: #1d6f5f;
  --accent-strong: #15594d;
  --selected: #e5f2ee;
  --hover: #f0f7f5;
  --danger: #9f3434;
  --clear-hover: #fff2f0;
  --clear-hover-ink: #8f2a2a;
  --focus: #0f766e;
  --font-sans: "본고딕", "Source Han Sans KR", "Noto Sans CJK KR", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic", "YuGothic", "Meiryo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  --weight-semibold: 600;
  --weight-bold: 700;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
}

.sidebar {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.app-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 1.45rem;
}

.control-section {
  padding: 20px 24px 26px;
}

.control-section h2 {
  margin-bottom: 12px;
  font-size: 0.98rem;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: var(--weight-semibold);
}

button {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--hover);
}

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

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.selector-scroll {
  min-height: 0;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f4f2ec;
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  background: transparent;
}

.segment.active {
  background: var(--panel);
  color: var(--accent-strong);
  box-shadow: 0 1px 4px rgba(32, 33, 36, 0.12);
}

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

.book-chip-list.collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.book-chip,
.chapter-chip {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.book-chip.selected-only {
  min-height: 44px;
  border-radius: 8px;
  padding-right: 34px;
  text-align: left;
}

.book-chip.selected-only::after {
  position: absolute;
  top: 50%;
  right: 12px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: currentColor;
  content: "×";
  font-size: 1rem;
  line-height: 17px;
  text-align: center;
  transform: translateY(-50%);
}

.book-chip.active,
.chapter-chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.book-chip.selected-only:hover:not(:disabled) {
  border-color: rgba(159, 52, 52, 0.34);
  background: var(--clear-hover);
  color: var(--clear-hover-ink);
}

.book-chip.selected-only:hover:not(:disabled)::after {
  background: rgba(159, 52, 52, 0.1);
}

.book-chip {
  position: relative;
}

.subheading {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.86rem;
  letter-spacing: 0;
}

.step-panel {
  margin-top: 16px;
}

.chapter-chip-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.chapter-chip {
  min-height: 42px;
  font-variant-numeric: tabular-nums;
}

.summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: var(--weight-semibold);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: var(--weight-semibold);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: var(--weight-bold);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.action-panel {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 20px rgba(32, 33, 36, 0.06);
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.reference-preview-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-bottom: 9px;
  padding: 5px 5px 5px 10px;
  border: 1px solid rgba(222, 219, 211, 0.86);
  border-radius: 8px;
  background: #fbfaf7;
}

.reference-preview-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: var(--weight-semibold);
}

.reference-preview-text {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  position: relative;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
}

.reference-copy-button::before,
.reference-copy-button::after {
  position: absolute;
  width: 12px;
  height: 14px;
  border: 1.8px solid currentColor;
  border-radius: 2px;
  content: "";
}

.reference-copy-button::before {
  top: 9px;
  left: 11px;
  opacity: 0.55;
}

.reference-copy-button::after {
  top: 12px;
  left: 14px;
  background: #fff;
}

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

.compact-actions button {
  min-height: 38px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 0.85rem;
}

.compact-actions .primary-button {
  grid-column: span 1;
}

.content {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.chapter-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.chapter-header > div {
  min-width: 0;
}

.chapter-header h2 {
  font-size: 1.28rem;
  line-height: 1.35;
}

.status {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: right;
}

.status.error {
  color: var(--danger);
}

.verse-list {
  overflow-y: auto;
  padding: 12px 28px 40px;
}

.verse-list.drag-selecting {
  cursor: crosshair;
  user-select: none;
}

.verse-row {
  display: grid;
  grid-template-columns: 96px 58px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(222, 219, 211, 0.72);
  cursor: pointer;
}

.verse-row:hover {
  background: var(--hover);
}

.verse-row.selected {
  background: var(--selected);
}

.verse-row.empty {
  color: var(--muted);
}

.verse-copy-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  align-self: start;
  margin-top: 4px;
}

.verse-copy-button {
  min-height: 28px;
  padding: 0 4px;
  border-radius: 6px;
  border-color: rgba(191, 199, 196, 0.9);
  background: rgba(255, 255, 255, 0.78);
  color: #3f4f4c;
  font-size: 0.74rem;
  line-height: 1;
  white-space: nowrap;
}

.verse-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  margin-top: 4px;
}

.verse-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.verse-number {
  color: var(--muted);
  font-weight: var(--weight-semibold);
  min-width: 22px;
  text-align: left;
  user-select: none;
}

.verse-text {
  min-width: 0;
  font-family: var(--font-sans);
  line-height: 1.78;
  font-size: 1.06rem;
}

ruby {
  ruby-align: center;
}

rt {
  color: #666;
  font-size: 0.58em;
  user-select: none;
}

.paragraph_indent {
  margin-left: 1em;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(16px);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #202124;
  color: #fff;
  font-weight: var(--weight-semibold);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    height: auto;
    max-height: 52vh;
    grid-template-rows: auto minmax(0, 1fr) auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-header {
    padding: 14px 16px 10px;
  }

  .control-section {
    padding: 12px 16px 16px;
  }

  .content {
    height: auto;
    min-height: 48vh;
  }

  .chapter-header {
    padding: 18px 16px 14px;
  }

  .verse-list {
    padding: 8px 12px 32px;
  }

  .verse-row {
    grid-template-columns: 86px 52px minmax(0, 1fr);
    gap: 8px;
    padding: 8px 4px;
  }

  .verse-copy-button {
    min-height: 26px;
    padding: 0 3px;
    font-size: 0.68rem;
  }

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

  .chapter-chip-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

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