/* 아미고 곳간 — 좁은 화면 먼저. 외부 글꼴 없음(기기 기본 글꼴 사용). */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1f2327;
  --muted: #595f66;
  --line: #d9d6cd;
  --accent: #1d6a58;
  --accent-text: #ffffff;
  --accent-soft: #e3efeb;
  --ok-bg: #dff0e6;   --ok-text: #17553a;
  --draft-bg: #fbecc9; --draft-text: #6b4a00;
  --wait-bg: #e8e8e6;  --wait-text: #474c52;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1e2124;
    --text: #e9e7e2;
    --muted: #a6abb1;
    --line: #353a3f;
    --accent: #74c7b0;
    --accent-text: #0e211c;
    --accent-soft: #1f332e;
    --ok-bg: #1d3a2b;   --ok-text: #a5dfbf;
    --draft-bg: #40330f; --draft-text: #f1d48a;
    --wait-bg: #2e3236;  --wait-text: #c3c7cc;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  padding: 10px 14px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); text-decoration: none;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.cards:focus { outline: none; }

h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

/* 머리 */
.site-head { padding: 22px 0 14px; }
.site-head h1 { font-size: 1.6rem; line-height: 1.25; letter-spacing: -0.01em; }
.tagline { margin-top: 4px; color: var(--muted); font-size: .95rem; }

/* 분류 탭 */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .95rem; cursor: pointer;
}
.tab__n { color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }
.tab[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600;
}
.tab[aria-pressed="true"] .tab__n { color: inherit; opacity: .85; }

/* 검색·필터 */
.search input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit;
}
.search input::placeholder { color: var(--muted); }

.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.field { display: block; }
.field > span { display: block; margin-bottom: 2px; color: var(--muted); font-size: .82rem; }
.field select {
  width: 100%; min-height: 44px; padding: 8px 8px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .95rem;
}

.result-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 44px; margin: 10px 0 6px;
}
.count { color: var(--muted); font-size: .9rem; }

.notice {
  margin: 12px 0; padding: 12px 14px;
  border: 1px solid var(--line); border-left: 4px solid var(--draft-text);
  border-radius: var(--radius); background: var(--surface);
}
.empty { padding: 28px 8px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); font-size: .92rem; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .95rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--text { border-color: transparent; background: transparent; color: var(--accent); }
.btn--big { min-height: 48px; padding: 10px 18px; }
@media (hover: hover) {
  .btn:hover, .tab:hover { border-color: var(--accent); }
  .btn--primary:hover { filter: brightness(1.08); }
}

/* 카드 */
.cards { display: grid; grid-template-columns: 1fr; gap: 12px; padding-bottom: 8px; }
.card {
  position: relative;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.card:focus-within, .card:hover { border-color: var(--accent); }
.card__top, .detail__bar { display: flex; align-items: center; gap: 8px; }
.card__cat { color: var(--muted); font-size: .85rem; }
.card__title { font-size: 1.12rem; line-height: 1.35; }
.card__title a { color: inherit; text-decoration: none; }
.card__title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.card__title a:focus-visible { outline: none; }
.card__title a:focus-visible::after { outline: 3px solid var(--accent); outline-offset: 2px; }
.card__summary { color: var(--text); font-size: .95rem; }
.card__actions { position: relative; z-index: 1; margin-top: auto; padding-top: 4px; }
.card__actions .pending { pointer-events: none; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pending { color: var(--muted); font-size: .9rem; }

.badge {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; white-space: nowrap;
  background: var(--wait-bg); color: var(--wait-text);
}
.badge--ok { background: var(--ok-bg); color: var(--ok-text); }
.badge--draft { background: var(--draft-bg); color: var(--draft-text); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 1px 8px; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); font-size: .82rem; white-space: nowrap;
}
.tag--aud { border-color: transparent; background: var(--accent-soft); color: var(--text); }

/* 상세(대화 상자) — 좁은 화면에서는 화면 전체 */
.detail {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%;
  margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--text);
  overflow-y: auto; overscroll-behavior: contain;
}
.detail::backdrop { background: rgba(0, 0, 0, .5); }
.detail__inner { display: flex; flex-direction: column; gap: 12px; padding: 0 16px 28px; min-height: 100%; }
.detail__bar {
  position: sticky; top: 0; z-index: 1;
  margin: 0 -16px; padding: 10px 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.detail__close { margin-left: auto; }
.detail__title { font-size: 1.4rem; line-height: 1.3; }
.detail__title:focus-visible { outline: none; }
.detail__summary { font-size: 1.02rem; }
.detail__desc { color: var(--text); }

.sec { padding-top: 14px; border-top: 1px solid var(--line); }
.sec h3 { margin-bottom: 6px; font-size: 1rem; }
.facts { display: grid; grid-template-columns: 1fr; gap: 2px 12px; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin-bottom: 6px; }
.records { display: grid; gap: 10px; }
.records li { padding-left: 12px; border-left: 3px solid var(--line); }
.records__meta { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }

.detail__foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--line);
}
.detail__foot .muted { flex-basis: 100%; }

/* 발 */
.site-foot { margin-top: 28px; padding: 18px 0 32px; border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }

/* 넓은 화면 */
@media (min-width: 640px) {
  .site-head { padding-top: 32px; }
  .site-head h1 { font-size: 1.9rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .filters { max-width: 520px; }
  .search input { max-width: 520px; }
  .detail {
    width: min(680px, calc(100% - 32px)); height: auto; max-height: min(90vh, 900px);
    margin: auto; border: 1px solid var(--line); border-radius: 14px;
  }
  .facts { grid-template-columns: max-content 1fr; }
  .facts dd { margin-bottom: 0; }
}
@media (min-width: 980px) {
  .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .tab, .card { transition: border-color .12s ease; }
}

@media print {
  .tabs, .search, .filters, .result-bar, .skip, .card__actions, .detail__close { display: none; }
  body { background: #fff; color: #000; }
}
