:root {
  --bg: #f3f4f6;
  --panel: rgba(245, 249, 252, 0.95);
  --panel-soft: #eef3f7;
  --ink: #0f2031;
  --muted: #516478;
  --line: rgba(13, 34, 53, 0.14);
  --blue-1: #0a4e56;
  --blue-2: #106b75;
  --blue-soft: #e4f0f2;
  --green-verse: #16803d;
  --danger: #dc2626;
  --shadow: 0 18px 40px rgba(7, 27, 41, 0.18);
  --focus: 0 0 0 3px rgba(16, 107, 117, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard Variable", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, #2f5a78 0%, transparent 32%),
    radial-gradient(circle at 89% 22%, #355f56 0%, transparent 36%),
    linear-gradient(145deg, #0e1f2e, #102b40 50%, #0b1f31 100%);
  min-height: 100vh;
}

.aurora {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.aurora::before,
.aurora::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.36;
}

.aurora::before {
  width: 240px;
  height: 240px;
  right: 4%;
  bottom: 12%;
  background: #fdbf6f;
}

.aurora::after {
  width: 200px;
  height: 200px;
  left: 3%;
  top: 20%;
  background: #66cad6;
}

.layout {
  width: min(1480px, 96vw);
  margin: 18px auto 36px;
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.hero {
  padding: 10px 6px 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.hero h1 {
  margin: 4px 0 6px;
  font-size: clamp(2rem, 4.4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #eef8ff;
  text-shadow: 0 2px 10px rgba(7, 27, 41, 0.24);
}

.eyebrow {
  margin: 0;
  color: rgba(238, 248, 255, 0.88);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.subtitle {
  margin: 0 0 2px;
  color: rgba(235, 246, 255, 0.9);
  font-size: 1rem;
  line-height: 1.6;
  max-width: 980px;
  text-shadow: 0 1px 8px rgba(7, 27, 41, 0.2);
}

.top-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.reference-query {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: end;
  min-width: 0;
  max-width: 100%;
}

.reference-text {
  margin: 0;
  color: rgba(235, 246, 255, 0.9);
  font-weight: 600;
  min-width: 112px;
  padding-bottom: 2px;
  white-space: nowrap;
}

.reference-input-wrap {
  display: grid;
  gap: 4px;
  min-width: 190px;
  max-width: 210px;
  color: rgba(238, 248, 255, 0.92);
  font-size: 0.84rem;
  font-weight: 600;
}

.reference-input-wrap input {
  min-width: 190px;
  width: 190px;
}

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

.index-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}

.tab {
  border: 1px solid #c8d6df;
  background: #e8f0f4;
  color: #2f4a62;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.15s ease;
  text-align: center;
}

.index-tabs .tab {
  min-width: 104px;
  padding: 8px 12px;
  text-align: center;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  position: relative;
}

.tab:hover {
  background: #dde8ee;
}

.tab.active {
  border-color: #0c5d66;
  background: linear-gradient(180deg, var(--blue-2), var(--blue-1));
  color: #fff;
  transform: translateY(1px);
}

.workspace {
  display: block;
}

.panel-wrap {
  display: grid;
  gap: 0;
  min-width: 0;
}

.top-index-tabs {
  margin: 0 0 -1px auto;
  padding-left: 0;
  justify-content: flex-end;
}

.panel {
  display: none;
  padding: 14px;
  border-top-left-radius: 0;
}

.panel.active {
  display: block;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 10px;
}

.controls.inline {
  align-items: center;
}

label {
  display: grid;
  gap: 5px;
  font-size: 0.86rem;
  color: var(--muted);
}

label.wide {
  min-width: min(440px, 100%);
}

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

select,
input,
textarea {
  border: 1px solid #ccd6dd;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f7f9fb;
  color: var(--ink);
}

select,
input {
  min-width: 120px;
}

select:focus,
input:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: #b8c7e0;
}

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

.btn {
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--blue-2), var(--blue-1));
  color: #fff;
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 600;
}

.btn.alt {
  background: linear-gradient(135deg, #5f88c2, #3e6fb3);
}

.btn.ghost {
  border-color: #c8d6df;
  background: #e7eef2;
  color: #2f4a62;
}

.btn.ghost.active {
  background: #d9e8ec;
  border-color: #a9c9cf;
}

.status-inline {
  margin: 0;
  padding: 7px 10px;
  border: 1px solid #d5e0f2;
  border-radius: 8px;
  background: var(--blue-soft);
  color: #334f7f;
  font-size: 0.85rem;
}

.content-list,
.content-grid {
  display: grid;
  gap: 10px;
}

.content-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.content-list.compact {
  max-height: 360px;
  overflow: auto;
}

#readResult {
  max-height: 68vh;
  overflow: auto;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

.verse {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: start;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 1px 0;
  cursor: pointer;
}

.verse + .verse {
  border-top: 1px solid #f3f4f6;
}

.verse.active {
  background: #f7faff;
  border-radius: 6px;
}

.verse-main {
  display: block;
}

.verse-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.verse-lexicon {
  grid-column: 2 / 4;
  margin: 4px 0 2px;
}

.verse-lexicon.is-hidden {
  display: none;
}

.verse-lexicon-box {
  border: 1px solid #d4dfe6;
  border-radius: 8px;
  background: #eef3f6;
  padding: 8px 10px;
}

.verse-lexicon-list {
  margin: 6px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 5px;
}

.verse-lexicon-list li {
  line-height: 1.42;
  color: #0f2031;
}

.original-btn {
  border: 1px solid #b6c6d3;
  background: #eef4f8;
  color: #2f4a62;
  border-radius: 8px;
  padding: 2px 7px;
  font-size: 0.78rem;
  line-height: 1.25;
  cursor: pointer;
}

.original-btn:hover {
  background: #e3edf4;
}

.pdf-btn {
  border: 1px solid #c9d9bf;
  background: #edf6e8;
  color: #2f5e2d;
  border-radius: 8px;
  padding: 2px 7px;
  font-size: 0.78rem;
  line-height: 1.25;
  cursor: pointer;
}

.pdf-btn:hover {
  background: #e4f1dd;
}

.verse-number {
  display: inline;
  color: #1e3a8a;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1.5;
  margin-right: 6px;
}

.verse-text {
  display: inline;
  color: #111827;
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: -0.003em;
  white-space: normal;
}

.verse-meta {
  margin: 0 0 4px;
  color: #64748b;
  font-size: 0.86rem;
}

.verse-favorite .verse-main {
  display: block;
}

.verse-favorite .verse-main p {
  margin: 0;
}

.star-btn {
  margin-top: 4px;
  border: 0;
  background: transparent;
  color: #c2c9d6;
  width: 16px;
  height: 16px;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  font-size: 0.95rem;
  user-select: none;
  -webkit-user-select: none;
}

.star-btn::before {
  content: "☆";
}

.star-btn.on {
  color: #e7a308;
}

.star-btn.on::before {
  content: "★";
}

.card,
.hit,
.note,
.hymn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f1f5f8;
}

.hit strong,
.card h3,
.hymn h3 {
  color: #325285;
}

.hymn-score {
  display: grid;
  gap: 8px;
}

.score-link {
  color: #31568f;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.score-image {
  width: 100%;
  border: 1px solid #d3dde4;
  border-radius: 8px;
  background: #edf2f5;
  object-fit: contain;
  aspect-ratio: 3 / 4;
}

.score-file-tag {
  border: 1px dashed #c4d3dd;
  border-radius: 8px;
  padding: 20px 10px;
  text-align: center;
  color: #486174;
  background: #eef4f7;
  font-weight: 600;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.badge {
  border: 1px solid #cfdbe3;
  background: #e8eff4;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.badge:hover {
  border-color: #aec3cf;
  color: #1f5661;
}

.compare-pick-card {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

#panel-compare {
  --compare-columns: repeat(4, minmax(0, 1fr));
  --compare-gap: 8px;
}

.compare-slot-grid {
  display: grid;
  grid-template-columns: var(--compare-columns);
  gap: var(--compare-gap);
}

.compare-slot-row {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
  gap: 6px;
  align-items: center;
}

.compare-slot-row select {
  min-width: 0;
  width: 100%;
}

.compare-slot-tab {
  border: 1px solid #2a7a84;
  background: linear-gradient(180deg, #2f8a95, #1e7682);
  color: #f8fdff;
  border-radius: 10px;
  padding: 8px 8px;
  cursor: pointer;
  font-weight: 600;
  width: 100%;
}

.compare-slot-tab.active {
  border-color: #0a535c;
  background: linear-gradient(180deg, var(--blue-2), var(--blue-1));
  color: #fff;
}

.compare-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 6px;
}

.compare-ref {
  font-size: 0.84rem;
}

.compare-verse-list {
  display: grid;
  gap: 2px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 2px;
}

.compare-verse-line {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.45;
}

.compare-verse-no {
  color: #1e3a8a;
  font-weight: 600;
  margin-right: 6px;
}

.compare-verse-text {
  color: #111827;
}

#compareResult {
  grid-template-columns: var(--compare-columns);
  gap: var(--compare-gap);
  padding: 0 12px;
}

.empty {
  color: var(--muted);
  margin: 0;
}

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

.note header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.delete-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f7cdcd;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}

mark {
  background: #fff7bf;
  padding: 0 2px;
  border-radius: 4px;
}

.original-modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 18, 30, 0.46);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
}

.original-modal.active {
  display: flex;
}

.original-modal-card {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow: auto;
  background: #f5f8fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.original-modal-card p {
  margin: 6px 0;
  line-height: 1.45;
}

.original-modal-close {
  border: 1px solid #bfd0db;
  background: #e8f0f4;
  color: #2f4a62;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.82rem;
  cursor: pointer;
  float: right;
}

@media (max-width: 900px) {
  .layout {
    width: 96vw;
    margin-top: 12px;
  }

  .top-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .reference-query {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .reference-input-wrap,
  .reference-input-wrap input {
    min-width: 100%;
    max-width: 100%;
    width: 100%;
  }

  .index-tabs {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .top-index-tabs {
    justify-content: flex-start;
  }

  .index-tabs .tab {
    border-radius: 8px;
    border-bottom: 1px solid #c8d6df;
    flex: 1 1 30%;
    transform: none;
  }

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

  #compareResult {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0;
  }

  .compare-slot-row {
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  }

  .hero,
  .panel {
    padding: 12px;
  }

  label,
  label.wide,
  select,
  input {
    width: 100%;
  }

  #readResult {
    max-height: 62vh;
    padding: 12px;
  }

  .verse-text,
  .verse-number {
    font-size: 1rem;
  }
}
