:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #66726b;
  --line: #d8ded8;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --sage: #4d6f5c;
  --clay: #9f5b42;
  --gold: #b48a30;
  --mist: #eef3ef;
  --shadow: 0 18px 50px rgba(23, 32, 27, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.search-panel {
  display: grid;
  gap: 22px;
  padding: 26px;
  background: linear-gradient(120deg, #f7f5ed, #edf4ef 52%, #f8efe9);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand-row,
.reader-top,
.card-head,
.section-head,
.search-line,
.quick-row,
.top-actions,
.language-control {
  display: flex;
  align-items: center;
}

.brand-row,
.reader-top,
.card-head,
.section-head {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sage);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.04;
}

h2 {
  margin-bottom: 0;
  font-size: 25px;
}

h3 {
  margin-bottom: 0;
  font-size: 17px;
}

.status-pill,
.section-head span,
.card-head span {
  flex: 0 0 auto;
  border: 1px solid rgba(77, 111, 92, 0.3);
  background: rgba(255, 255, 255, 0.62);
  color: var(--sage);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
}

.top-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.language-control {
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.language-control select {
  min-width: 118px;
  background: rgba(255, 255, 255, 0.7);
}

.search-box {
  display: grid;
  gap: 8px;
}

.search-box label {
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.search-line {
  min-height: 58px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(23, 32, 27, 0.06);
}

.search-line input {
  width: 100%;
  border: 0;
  outline: 0;
  padding: 0 18px;
  background: transparent;
  font-size: 18px;
}

.search-line button,
.text-button,
.outline-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.search-line button {
  width: 58px;
  align-self: stretch;
  background: var(--sage);
  color: white;
  font-size: 28px;
}

.quick-row,
.browse-row {
  flex-wrap: wrap;
  gap: 8px;
}

.quick-row button,
.result-item,
.text-button,
.outline-button,
.icon-button,
select {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.browse-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(110px, 160px);
  gap: 10px;
}

.quick-row button {
  padding: 9px 12px;
  color: var(--ink);
  cursor: pointer;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 18px;
  margin-top: 18px;
}

.result-list,
.reader {
  min-width: 0;
}

.result-list {
  display: grid;
  align-content: start;
  gap: 12px;
}

#results {
  display: grid;
  gap: 10px;
}

.result-item {
  width: 100%;
  text-align: left;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(23, 32, 27, 0.04);
}

.result-item[aria-current="true"] {
  border-color: var(--sage);
  background: var(--mist);
}

.result-item strong {
  display: block;
  margin-bottom: 5px;
}

.result-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.reader {
  display: grid;
  align-content: start;
  gap: 14px;
}

.reader-top,
.scripture-card,
.context-card,
.commentary-card,
.links-card {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

select {
  min-height: 40px;
  padding: 0 12px;
  color: var(--ink);
}

.text-button {
  padding: 8px 11px;
  color: white;
  background: var(--clay);
}

.outline-button,
.icon-button {
  color: var(--sage);
  font-weight: 800;
}

.outline-button {
  min-height: 40px;
  padding: 0 13px;
  background: rgba(255, 255, 255, 0.7);
}

.icon-button {
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 1;
}

.scripture-text,
.commentary-text {
  margin-top: 16px;
  color: #26322b;
  line-height: 1.78;
  word-break: keep-all;
}

.scripture-text .notice {
  color: var(--muted);
}

.scripture-empty-state {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(77, 111, 92, 0.24);
  border-radius: 8px;
  background: #f8fbf8;
}

.scripture-empty-state strong {
  color: var(--sage);
  font-size: 15px;
}

.scripture-empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.verse-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.verse-line {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  margin-bottom: 0;
}

.verse-number {
  color: var(--sage);
  font-weight: 800;
  text-align: right;
}

.thai-bible-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(77, 111, 92, 0.22);
  border-radius: 8px;
  background: #f8fbf8;
  overflow-x: auto;
}

.thai-bible-head {
  flex: 0 0 auto;
  color: var(--sage);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.thai-bible-head span {
  display: none;
}

.thai-bible-grid {
  display: flex;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
}

.thai-bible-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: white;
  white-space: nowrap;
}

.thai-bible-button strong {
  color: var(--sage);
  font-size: 13px;
}

.thai-bible-button span {
  display: none;
}

.thai-bible-button.is-current {
  border-color: rgba(77, 111, 92, 0.48);
  background: var(--mist);
}

.commentary-text p {
  margin-bottom: 12px;
}

.commentary-card {
  border-color: rgba(77, 111, 92, 0.34);
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
}

.context-card[hidden] {
  display: none;
}

.context-sections {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

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

.context-section-title {
  margin: 0;
  color: var(--sage);
  font-size: 14px;
  font-weight: 900;
}

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

.context-item {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  color: var(--ink);
  background: #f9fbf7;
  overflow: hidden;
}

.context-item.is-open {
  border-color: rgba(77, 111, 92, 0.45);
  background: #fffdf8;
}

.context-toggle {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 14px;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.context-toggle span,
.context-toggle b {
  color: var(--sage);
  font-size: 12px;
  font-weight: 800;
}

.context-toggle strong {
  line-height: 1.45;
}

.context-toggle em,
.context-toggle small {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
}

.context-toggle small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.context-toggle b {
  justify-self: start;
  margin-top: 2px;
}

.context-expanded {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(77, 111, 92, 0.18);
  color: #26322b;
  line-height: 1.72;
  word-break: keep-all;
}

.context-expanded p {
  margin: 10px 0 0;
}

.about-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.about-dialog::backdrop {
  background: rgba(23, 32, 27, 0.28);
}

.about-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.about-content {
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 150px);
  margin-top: 16px;
  overflow: auto;
  line-height: 1.75;
}

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

.about-content h3,
.about-content p {
  margin-bottom: 0;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.resource-link {
  display: block;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  background: #fffdf8;
}

.resource-link strong {
  display: block;
  margin-bottom: 6px;
}

.resource-link span {
  color: var(--muted);
  font-size: 13px;
}

mark {
  background: rgba(180, 138, 48, 0.26);
  padding: 0 2px;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

  .search-panel,
  .reader-top,
  .scripture-card,
  .context-card,
  .commentary-card,
  .links-card {
    padding: 16px;
  }

  .brand-row,
  .reader-top,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .resource-grid {
    grid-template-columns: 1fr;
  }

  .context-grid {
    grid-template-columns: 1fr;
  }

  .thai-bible-grid {
    overflow-x: auto;
  }

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