:root {
  color-scheme: light;
  --paper: #FDF8F0;
  --surface: #FFFDF8;
  --warm: #F5EDE0;
  --ink: #2C2416;
  --muted: #6F604B;
  --gold: #8B6914;
  --gold-deep: #6B4F0E;
  --rule: #D8C7AB;
  --error: #B54B3A;
  --success: #5A7B3A;
  --shell: 1080px;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.72;
  overflow-wrap: break-word;
  word-break: keep-all;
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--gold-deep); text-underline-offset: 4px; }
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration-thickness: 2px; }
}
::selection { background: var(--gold); color: var(--surface); }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 16px;
  padding: 10px 14px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 180ms ease;
}

.skip-link:focus { transform: translateY(0); }

.masthead {
  border-top: 1px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: rgba(253, 248, 240, .98);
}

.masthead-inner,
.page-shell,
.footer-inner {
  width: min(var(--shell), calc(100% - 40px));
  margin: 0 auto;
}

.masthead-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 10px 0;
}

.brand,
h1,
h2,
h3 {
  font-family: "Nanum Myeongjo", "Batang", Georgia, serif;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -.04em;
  text-decoration: none;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  transition: border-color 200ms ease, color 200ms ease;
}

.nav-toggle:focus-visible {
  border-color: var(--gold);
  color: var(--gold-deep);
}

@media (hover: hover) and (pointer: fine) {
  .nav-toggle:hover {
    border-color: var(--gold);
    color: var(--gold-deep);
  }
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 12px;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink);
  font-size: .94rem;
  font-weight: 700;
  text-decoration: none;
}

.site-nav a[aria-current="page"] { color: var(--gold-deep); text-decoration: underline; }

.archive-hero {
  padding: 6px 0;
  border-bottom: 3px solid var(--ink);
  background: var(--surface);
}

.hero-folio {
  display: grid;
  grid-template-columns: minmax(0, .94fr) minmax(360px, 1.06fr);
  align-items: end;
  gap: clamp(28px, 5vw, 74px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gold-deep);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
}

.eyebrow::before { content: "· "; }

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -.03em;
  text-wrap: balance;
}

h1 {
  max-width: none;
  font-size: clamp(2.25rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -.05em;
  line-height: 1.12;
}

h2 { font-size: clamp(1.65rem, 4vw, 2.65rem); line-height: 1.25; }
h3 { font-size: clamp(1.18rem, 2vw, 1.5rem); line-height: 1.38; }

.hero-copy {
  max-width: 52ch;
  margin: 0;
  color: #554731;
  font-size: .96rem;
  line-height: 1.65;
}

.consult-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(44, 36, 22, .18);
}

.consult-cta p { flex: 1 1 220px; margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.55; }

.primary-button,
.text-button,
.pagination button,
.qna-row {
  min-height: 44px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border-color: var(--gold);
  background: var(--gold);
  color: var(--surface);
  text-decoration: none;
}

.primary-button:focus-visible { background: var(--gold-deep); }

@media (hover: hover) and (pointer: fine) {
  .primary-button:hover { background: var(--gold-deep); }
}

.archive-layout { padding: 24px 0 72px; }

.archive-instrument {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 28px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.archive-filters { min-width: 0; padding: 12px 0 10px; }

.field { display: grid; gap: 4px; }

.search-control { display: flex; gap: 8px; }
.search-control input { flex: 1 1 auto; width: auto; min-width: 0; }

label { color: var(--muted); font-size: .82rem; font-weight: 800; }

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #BCA98A;
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 11px;
  font-size: 16px;
  line-height: 1.5;
}

input:focus,
select:focus {
  border-color: var(--gold-deep);
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.search-submit {
  min-width: 72px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--gold);
  border-radius: 0;
  background: var(--gold);
  color: var(--surface);
  font-weight: 800;
}

.search-submit:focus-visible { background: var(--gold-deep); }

@media (hover: hover) and (pointer: fine) {
  .search-submit:hover { background: var(--gold-deep); }
}

.search-submit:disabled { cursor: wait; opacity: .65; }

.result-count {
  align-self: end;
  margin: 0;
  padding: 0 0 12px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.category-toggles {
  display: flex;
  grid-column: 1 / -1;
  gap: 4px 18px;
  min-width: 0;
  padding: 8px 0 7px;
  border-top: 1px solid var(--rule);
}

.category-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.category-toggle:focus-visible,
.category-toggle[aria-pressed="true"] {
  border-bottom-color: var(--gold);
  color: var(--gold-deep);
}

@media (hover: hover) and (pointer: fine) {
  .category-toggle:hover {
    border-bottom-color: var(--gold);
    color: var(--gold-deep);
  }
}

.state-message {
  margin: 0;
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  text-align: center;
}

.state-message[hidden] { display: none; }

.state-message.is-error { color: var(--error); font-weight: 700; }

.retry-button {
  min-height: 44px;
  margin-left: 8px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--surface);
  color: var(--gold-deep);
  font-weight: 800;
}

.qna-list { margin: 0; padding: 0; list-style: none; }
.qna-list > li { border-bottom: 1px solid var(--rule); }

.qna-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) minmax(112px, .3fr);
  column-gap: 10px;
  width: 100%;
  padding: 11px 0;
  border: 0;
  text-align: left;
}

.qna-ordinal {
  padding-top: 4px;
  color: var(--muted);
  font-family: "Nanum Myeongjo", "Batang", Georgia, serif;
  font-size: .82rem;
  letter-spacing: .05em;
}

.qna-copy { min-width: 0; }

.qna-title {
  display: block;
  color: var(--ink);
  font-family: "Nanum Myeongjo", "Batang", Georgia, serif;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.42;
}

.qna-meta {
  display: block;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.qna-category {
  align-self: start;
  padding-top: 4px;
  color: var(--gold-deep);
  font-size: .82rem;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.qna-row:focus-visible { background: rgba(245, 237, 224, .72); }

@media (hover: hover) and (pointer: fine) {
  .qna-row:hover { background: rgba(245, 237, 224, .72); }
}

.empty-state {
  margin: 0;
  padding: 34px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}

.pagination button {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 10px;
  transition: color 200ms ease, border-color 200ms ease, opacity 200ms ease;
}

.pagination button[aria-current="page"] {
  border-color: var(--gold);
  color: var(--gold-deep);
}

@media (hover: hover) and (pointer: fine) {
  .pagination button:hover:not(:disabled) {
    border-color: var(--gold);
    color: var(--gold-deep);
  }
}

.pagination button:disabled { cursor: not-allowed; opacity: .5; }
.pagination-gap { align-self: center; color: var(--muted); }

.detail-view { padding-top: 0; }

.detail-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.detail-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.text-button {
  padding: 10px 0;
  border-color: transparent;
  background: transparent;
  color: var(--gold-deep);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.detail-article {
  border-top: 3px solid var(--ink);
  border-bottom: 1px solid var(--rule);
  padding: clamp(24px, 5vw, 52px) 0;
}

.detail-category {
  margin: 0;
  color: var(--gold-deep);
  font-size: .95rem;
  font-weight: 800;
}

.detail-title {
  max-width: 20ch;
  margin-top: 12px;
  font-size: clamp(2rem, 5vw, 3.55rem);
  line-height: 1.25;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 24px;
  max-width: 660px;
  margin: 24px 0 0;
  padding: 18px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.detail-facts div { min-width: 0; }
.detail-facts dt { color: var(--muted); font-size: .86rem; }
.detail-facts dd { margin: 2px 0 0; color: var(--ink); font-weight: 700; }

.detail-block { max-width: 660px; padding-top: 28px; }
.detail-block + .detail-block { margin-top: 32px; border-top: 1px solid var(--rule); }
.detail-block h3 { margin-bottom: 14px; }

.detail-question {
  padding-left: 16px;
  border-left: 1px solid var(--gold);
}

.detail-question + .detail-block { margin-top: 32px; }

.detail-body {
  margin: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.82;
  white-space: pre-wrap;
}

.footer { border-top: 3px solid var(--ink); background: var(--warm); }

.footer-inner {
  padding: 24px 0 34px;
  color: var(--muted);
  font-size: .92rem;
}

@media (hover: hover) and (pointer: fine) {
  .qna-row,
  .primary-button,
  .search-submit,
  .retry-button,
  .pagination button,
  .category-toggle {
    transition: color 200ms ease, opacity 200ms ease, transform 200ms ease, border-color 200ms ease, background-color 200ms ease;
  }
}

.primary-button:active,
.search-submit:active,
.retry-button:active,
.pagination button:active,
.qna-row:active,
.category-toggle:active,
.text-button:active { transform: translateY(1px); }

@media (max-width: 720px) {
  .masthead-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    padding: 12px 0;
  }

  .brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav-toggle {
    flex: 0 0 auto;
  }

  /* Progressive enhancement: without JS, mobile links stay usable. */
  .site-nav {
    display: grid;
    flex: 1 0 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2px 8px;
    justify-content: stretch;
    max-width: 100%;
    min-width: 0;
  }

  .site-nav a {
    justify-content: center;
    min-height: 44px;
    font-size: .88rem;
    text-align: center;
  }

  .masthead[data-nav-enhanced] .nav-toggle {
    display: inline-flex;
  }

  .masthead[data-nav-enhanced]:not([data-nav-open]) .site-nav {
    display: none;
  }

  .masthead[data-nav-enhanced][data-nav-open] .site-nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
  }

  .masthead[data-nav-enhanced][data-nav-open] .site-nav a {
    justify-content: flex-start;
    width: 100%;
    padding: 10px 2px;
    border-top: 1px solid var(--rule);
    text-align: left;
  }

  .masthead-inner, .page-shell, .footer-inner { width: min(var(--shell), calc(100% - 32px)); }
  .archive-hero { padding: 14px 0 15px; }
  .hero-folio { grid-template-columns: 1fr; gap: 9px; }
  h1 { max-width: 14ch; font-size: clamp(2.1rem, 10vw, 2.6rem); }
  .hero-copy { max-width: none; font-size: .88rem; line-height: 1.6; }
  .consult-cta { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 7px 12px; margin-top: 9px; padding-top: 9px; }
  .consult-cta p { min-width: 0; font-size: .78rem; word-break: normal; }
  .archive-layout { padding-top: 16px; }
  .archive-instrument { grid-template-columns: minmax(0, 1fr); }
  .archive-filters { padding: 9px 0 8px; }
  .search-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: stretch;
  }
  .search-control input,
  .search-submit {
    min-height: 44px;
  }
  .result-count { padding: 0 0 7px; font-size: .76rem; text-align: left; }
  .category-toggles {
    flex-wrap: wrap;
    gap: 4px 8px;
    overflow-x: visible;
    padding: 6px 0;
  }
  .category-toggle {
    flex: 1 1 auto;
    min-height: 44px;
    min-width: 44px;
    font-size: .82rem;
    padding: 10px 8px;
  }
  .detail-topline { align-items: stretch; flex-direction: column; }
  .detail-facts { grid-template-columns: 1fr; gap: 12px; }
  .detail-body { font-size: 1rem; }
}

@media (min-width: 721px) {
  .nav-toggle {
    display: none !important;
  }

  .site-nav {
    display: flex !important;
  }
}

@media (max-width: 380px) {
  .masthead:not([data-nav-enhanced]) .site-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qna-row { grid-template-columns: 43px minmax(0, 1fr) minmax(88px, .28fr); column-gap: 7px; }
  .qna-title { font-size: 1rem; }
  .qna-category { font-size: .76rem; white-space: normal; word-break: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
  }

  .primary-button:active,
  .search-submit:active,
  .retry-button:active,
  .pagination button:active,
  .qna-row:active,
  .category-toggle:active,
  .text-button:active { transform: none; }
}
