:root {
  --background: #f7f8f5;
  --surface: #ffffff;
  --foreground: #17211e;
  --muted: #68736f;
  --line: #d9ded5;
  --accent: #188064;
  --accent-dark: #0f5e49;
  --accent-soft: #e5f2ec;
  --warning: #a96a12;
  --danger: #b94747;
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-noto-sans-kr);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-noto-sans-kr), system-ui, sans-serif;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  margin: 0 auto;
  max-width: 1080px;
  min-height: 100vh;
  padding: 18px;
}

.search-hub {
  background: rgba(247, 248, 245, 0.94);
  margin-bottom: 14px;
  padding: 10px 0 2px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: auto 1fr;
  margin-bottom: 16px;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: #10231f;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}

.category-nav,
.filter-row,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-nav {
  justify-content: flex-end;
}

.category-nav button,
.category-nav a,
.filter-row button,
.filter-row a {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.category-nav button,
.category-nav a {
  font-size: 12px;
}

.filter-row button,
.filter-row a {
  font-size: 13px;
}

.category-nav button.active,
.category-nav a.active,
.filter-row button.active,
.filter-row a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

.search-only {
  margin-bottom: 14px;
}

.search-panel,
.doc-card,
.detail-card,
.document-switcher {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-panel {
  padding: 14px;
}

.search-panel label {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.search-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 10px;
}

.search-row input {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
}

.search-row input:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.search-row button,
.source-link {
  background: #10231f;
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  min-height: 44px;
  padding: 0 16px;
}

.results-section {
  margin-top: 14px;
}

[hidden] {
  display: none !important;
}

.empty-results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin: 0;
  padding: 18px;
}

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

.result-wrap {
  min-width: 0;
}

.doc-card {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 128px;
  padding: 14px;
}

.linked-card {
  display: block;
  min-width: 0;
}

.linked-card:hover h2 {
  color: var(--accent-dark);
}

.doc-kicker {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px;
  margin-bottom: 10px;
}

.doc-kicker span {
  background: #f1f3ef;
  border-radius: 999px;
  padding: 4px 8px;
}

.doc-card h2,
.detail-card h1 {
  font-size: 22px;
  line-height: 1.35;
  margin: 0;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.doc-card p,
.lead,
.detail-body p {
  color: var(--muted);
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

.doc-card p {
  margin: 8px 0 0;
}

.tag-list {
  margin-top: 10px;
}

.tag-list span,
.tag-list a {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  padding: 4px 8px;
  white-space: nowrap;
}

.doc-side {
  align-items: flex-start;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 14px;
}

.doc-side strong {
  font-size: 14px;
}

.doc-side a {
  border-bottom: 1px solid var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
}

.risk {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
}

.risk-참고 {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.risk-확인필요 {
  background: #fff0d9;
  color: var(--warning);
}

.risk-중요 {
  background: #fee8e8;
  color: var(--danger);
}

.reader-shell {
  max-width: 1080px;
}

.reader-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.reader-nav a {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 11px;
}

.reader-layout {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) 300px;
}

.detail-card {
  padding: 18px;
}

.lead {
  font-size: 17px;
  margin: 12px 0 0;
}

.detail-meta {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.detail-meta div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.detail-meta dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-meta dd {
  font-weight: 800;
  margin: 0;
}

.detail-body {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 8px;
}

.detail-body p {
  margin: 12px 0 0;
}

.detail-body strong {
  color: var(--ink);
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.detail-body span {
  display: block;
}

.source-link {
  align-items: center;
  display: inline-flex;
  margin-top: 16px;
}

.document-switcher {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 164px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  position: sticky;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  top: 148px;
  z-index: 4;
}

.document-switcher h2 {
  background: var(--surface);
  font-size: 18px;
  margin: 0 0 6px;
  padding-bottom: 6px;
  position: sticky;
  top: 0;
  z-index: 1;
}

.document-switcher a {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 9px 0 2px;
}

.document-switcher a.active {
  color: var(--accent-dark);
}

.document-switcher span {
  color: var(--muted);
  font-size: 12px;
}

.document-switcher strong {
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: keep-all;
}

@media (max-width: 780px) {
  .topbar,
  .doc-card,
  .reader-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 10px;
  }

  .search-hub {
    position: static;
  }

  .category-nav,
  .filter-row {
    flex-wrap: nowrap;
    margin-inline: -12px;
    overflow-x: auto;
    padding: 0 12px 4px;
    scrollbar-width: none;
  }

  .category-nav::-webkit-scrollbar,
  .filter-row::-webkit-scrollbar {
    display: none;
  }

  .category-nav {
    justify-content: flex-start;
  }

  .category-nav button,
  .category-nav a,
  .filter-row a,
  .filter-row button {
    flex: 0 0 auto;
  }

  .doc-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: wrap;
    padding-left: 0;
    padding-top: 10px;
  }

  .document-switcher {
    max-height: none;
    overflow: visible;
    position: static;
  }

  .document-switcher h2 {
    position: static;
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding: 12px;
  }

  .brand-mark {
    height: 32px;
    width: 32px;
  }

  .search-panel,
  .doc-card,
  .detail-card,
  .document-switcher {
    border-radius: 6px;
  }

  .search-row,
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .search-row button {
    width: 100%;
  }

  .doc-card h2,
  .detail-card h1 {
    font-size: 20px;
  }

  .lead {
    font-size: 15px;
  }
}
