:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --sunken: #f1f3f6;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #5b6474;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --accent: #1d5fd6;
  --accent-hover: #174fb5;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fd;
  --accent-line: #b9cff5;
  --ok: #1f7a4d;
  --ok-soft: #e7f4ec;
  --warn: #8a5300;
  --warn-soft: #fdf3e1;
  --warn-line: #f0d29a;
  --focus: #1d5fd6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 4px 12px rgba(17, 24, 39, .06);
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --sunken: #1d222a;
    --ink: #e8ebf0;
    --ink-2: #c9ced8;
    --muted: #9aa3b2;
    --line: #2a3039;
    --line-strong: #3a424e;
    --accent: #6b9ff2;
    --accent-hover: #8db5f6;
    --accent-ink: #0b1220;
    --accent-soft: #1a2638;
    --accent-line: #2f4a75;
    --ok: #6cc596;
    --ok-soft: #17291f;
    --warn: #f0be6a;
    --warn-soft: #2a2215;
    --warn-line: #5a4520;
    --focus: #8db5f6;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 12px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Segoe UI", "Malgun Gothic", sans-serif;
  font-size: 1rem; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere;
}
:root { accent-color: var(--accent); caret-color: var(--accent); }
::selection { background: var(--accent-soft); color: var(--ink); }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
code, pre { font-family: var(--mono); font-size: .875em; }
h1, h2, h3 { text-wrap: balance; letter-spacing: -.02em; }
svg { flex: none; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 20; padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); }
.skip:focus { top: 12px; }
[hidden] { display: none !important; }

/* ---------- 상단 바 ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 32px; min-height: 64px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none;
  font-weight: 750; font-size: 1.0625rem; letter-spacing: -.02em; }
.logo:hover { color: var(--ink); }
.logo-mark { width: 22px; height: 22px; fill: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: var(--radius-sm); color: var(--ink-2); text-decoration: none; font-size: .9375rem; }
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 650; }
.meter { display: flex; gap: 20px; margin: 0 0 0 auto; font-size: .8125rem; color: var(--muted); }
.meter div { display: flex; align-items: baseline; gap: 6px; }
.meter .short { display: none; }
.meter dd { margin: 0; color: var(--ink); font-weight: 700; font-size: .9375rem; font-variant-numeric: tabular-nums; }

/* ---------- 홈 첫 화면 ---------- */
.hero { text-align: center; padding: 64px 0 40px; }
.hero h1 { font-size: 2.5rem; line-height: 1.2; margin: 0 0 14px; letter-spacing: -.035em; }
.lead { color: var(--ink-2); font-size: 1.0625rem; max-width: 640px; margin: 0 auto 10px; text-wrap: balance; }
.notice { color: var(--muted); font-size: .875rem; margin: 0 0 28px; }
.search { position: relative; max-width: 720px; margin: 0 auto; }
.search input { width: 100%; height: 56px; padding: 0 20px 0 52px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 1.0625rem;
  box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.search input::placeholder { color: var(--muted); }
.search input:hover { border-color: var(--accent-line); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-icon { position: absolute; left: 18px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-status { min-height: 1.5em; margin: 8px 0 0; color: var(--muted); font-size: .875rem; }
.hero-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0 0; }
.howto { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 28px; padding: 0;
  margin: 28px 0 0; color: var(--muted); font-size: .875rem; }
.howto li { display: flex; align-items: center; gap: 8px; }
.howto span { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line-strong); color: var(--ink-2); font-size: .75rem; font-weight: 700; }

/* ---------- 버튼 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: inherit; font-size: .9375rem; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--sunken); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: .8125rem; }
.btn[aria-busy="true"] { opacity: .7; cursor: progress; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.dl { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* ---------- 카탈로그 ---------- */
.catalog { padding: 8px 0 0; }
.catalog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 32px; }
.catalog-head h2 { font-size: 1.375rem; margin: 0; }
.count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; margin-left: 4px; }
.catalog-meta { margin: 0; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); font: inherit; font-size: .875rem;
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.chip span { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent-line); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip[aria-pressed="true"] span { color: inherit; opacity: .8; }

.cat { margin: 28px 0 0; }
.cat h3 { font-size: 1rem; margin: 0 0 12px; color: var(--ink-2); }
.cat h3 small { color: var(--muted); font-weight: 500; margin-left: 4px; font-size: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; min-height: 132px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none;
  transition: border-color .15s, box-shadow .15s; }
.card:hover { color: var(--ink); border-color: var(--accent-line); box-shadow: var(--shadow); }
.card:hover .card-title { color: var(--accent); }
.card-title { font-weight: 650; line-height: 1.4; font-size: 1rem; }
.card-meta { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto;
  padding-top: 8px; font-size: .8125rem; color: var(--muted); }
.card-src { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-rows { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: .75rem;
  font-weight: 600; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.card .tag { align-self: flex-start; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.caution { display: flex; gap: 12px; margin: 0 0 24px; padding: 16px 18px; border: 1px solid var(--warn-line);
  border-radius: var(--radius); background: var(--warn-soft); color: var(--ink); }
.caution svg { width: 22px; height: 22px; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.caution strong { display: block; color: var(--warn); font-size: .9375rem; }
.caution p { margin: 4px 0 0; font-size: .875rem; color: var(--ink-2); }
.caution a { white-space: nowrap; }
.empty { margin: 32px 0; padding: 32px; text-align: center; border: 1px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--ink-2); }
.empty p { margin: 0 0 16px; }

/* ---------- 데이터 상세 ---------- */
.crumb { margin: 24px 0 0; font-size: .875rem; color: var(--muted); }
.crumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; }
.crumb li + li::before { content: "/"; margin-right: 6px; color: var(--line-strong); }
.crumb a { color: var(--ink-2); text-decoration: none; }
.crumb a:hover { color: var(--accent); text-decoration: underline; }
.ds-head { padding: 12px 0 8px; }
.ds-head h1 { font-size: 2rem; line-height: 1.25; margin: 0 0 12px; }
.ds-summary { color: var(--ink-2); font-size: 1.0625rem; max-width: 72ch; margin: 0; }
.ds-about { margin: 0 0 32px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.ds-about summary { padding: 14px 18px; font-weight: 600; color: var(--ink); font-size: .9375rem; width: auto; }
.ds-about[open] summary { border-bottom: 1px solid var(--line); }
.ds-desc { color: var(--ink-2); white-space: pre-line; max-width: 72ch; margin: 0; padding: 16px 18px; font-size: .9375rem; }
.ds-head .notice { margin: 10px 0 0; }
.id-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.id-row code { font-size: .8125rem; white-space: nowrap; overflow-wrap: normal; }
.panel .id-row .btn { width: auto; flex: none; }
.ds-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; margin-top: 28px; }
.ds-main { min-width: 0; }
.ds-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel h2 { font-size: 1.0625rem; margin: 0 0 4px; }
.panel > p { margin: 0 0 14px; color: var(--muted); font-size: .875rem; }
.panel .btn { width: 100%; }
.panel .stack { display: flex; flex-direction: column; gap: 8px; }
.facts { display: grid; gap: 0; margin: 0; font-size: .875rem; }
.facts div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; padding-top: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); }
details { margin: 10px 0 0; }
details summary { display: flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; color: var(--ink-2);
  font-size: .875rem; padding: 4px 0; width: fit-content; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ""; width: 14px; height: 14px; flex: none; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .15s cubic-bezier(.16, 1, .3, 1); }
details[open] > summary::before { transform: rotate(90deg); }
details summary:hover { color: var(--accent); }
details summary:hover::before { background: var(--accent); }
pre.prompt { white-space: pre-wrap; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; max-height: 420px; overflow: auto; font-size: .8125rem; margin: 8px 0 0; }

.view { margin: 0 0 36px; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.view h2 { font-size: 1.25rem; margin: 0; }
.view h3 { font-size: .9375rem; margin: 20px 0 8px; color: var(--ink-2); }
.muted { color: var(--muted); font-size: .875rem; margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.scroll, pre.prompt { scrollbar-color: var(--line-strong) transparent; scrollbar-width: thin; }
.scroll { overflow: auto; max-width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.tbl { border-collapse: collapse; width: 100%; font-size: .8125rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { background: var(--sunken); font-weight: 600; color: var(--ink-2); position: sticky; top: 0; }
.tbl tbody tr:hover td { background: var(--sunken); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl th code { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; margin-top: 1px; }
.tbl code { font-size: .75rem; }
details .tbl { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.cols code { background: var(--sunken); padding: 1px 6px; border-radius: 4px; font-size: .75rem; }

/* ---------- 소개 ---------- */
.prose { max-width: 70ch; padding: 40px 0 24px; }
.prose h1 { font-size: 2rem; margin: 0 0 16px; }
.prose h2 { font-size: 1.25rem; margin: 36px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose li { margin: 4px 0; }
.prose code { background: var(--sunken); padding: 1px 6px; border-radius: 4px; }

/* ---------- 바닥 ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0 48px; color: var(--muted); font-size: .8125rem;
  background: var(--surface); }
.foot p { margin: 0 0 6px; max-width: 80ch; }
.foot-lead { color: var(--ink-2); font-size: .875rem; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-sm); font-size: .875rem;
  box-shadow: var(--shadow); transition: opacity .2s cubic-bezier(.16, 1, .3, 1), transform .2s cubic-bezier(.16, 1, .3, 1);
  pointer-events: none; z-index: 10; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 좁은 화면 ---------- */
@media (max-width: 960px) {
  .ds-layout { grid-template-columns: minmax(0, 1fr); }
  .ds-side { position: static; order: -1; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .top-in { flex-wrap: wrap; gap: 4px 16px; padding-top: 10px; padding-bottom: 6px; }
  .nav { order: 3; width: calc(100% + 10px); margin-left: -10px; overflow-x: auto; scrollbar-width: none; }
  .meter { gap: 12px; font-size: .75rem; }
  .meter dd { font-size: .8125rem; }
  .hero { padding: 40px 0 28px; text-align: left; }
  .hero h1 { font-size: 2rem; }
  .lead { font-size: 1rem; margin-left: 0; }
  .search input { height: 52px; font-size: 1rem; }
  .hero-actions { justify-content: flex-start; }
  .hero-actions .primary { width: 100%; }
  .howto { justify-content: flex-start; flex-direction: column; gap: 8px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .chip { flex: none; }
}
@media (max-width: 420px) {
  .meter .long { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .meter .short { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; }
}
