:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-alt: #f7f8fa;
  --ink: #151922;
  --muted: #66717e;
  --soft: #8b95a1;
  --line: #d8dde3;
  --line-strong: #bcc5cf;
  --nav: #1d252f;
  --nav-soft: #2d3845;
  --blue: #245f95;
  --teal: #187f7a;
  --green: #387a55;
  --amber: #b66a1e;
  --red: #ad4f47;
  --violet: #6c5a91;
  --shadow: 0 18px 60px rgba(20, 28, 38, .12);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "Pretendard", "Noto Sans KR", "Malgun Gothic", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }

.wiki-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 18px;
  background: var(--nav);
  color: #fff;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 5px 4px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background:
    linear-gradient(135deg, #ffffff 0 18%, transparent 18% 100%),
    linear-gradient(135deg, var(--teal), var(--blue));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

.brand strong,
.brand span { display: block; }
.brand strong { font-size: 17px; }
.brand span { margin-top: 3px; color: #9eaab6; font-size: 11px; font-weight: 700; }

.search-box {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 7px;
  background: rgba(255,255,255,.07);
}

.search-box span { color: #aeb9c4; font-size: 19px; }
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 13px;
}
.search-box input::placeholder { color: #9ca8b4; }

.category-nav { display: grid; gap: 6px; }
.category-button {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 0;
  border-radius: 6px;
  color: #d9e0e7;
  background: transparent;
  text-align: left;
}
.category-button:hover,
.category-button.is-active { background: var(--nav-soft); color: #fff; }
.category-button small { color: #95a1ad; font-size: 10px; font-weight: 800; }
.category-button span { font-size: 13px; font-weight: 800; }

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.tag-chip,
.article-tag,
.meta-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: #4f5a66;
  font-size: 11px;
  font-weight: 800;
}
.tag-chip {
  padding: 7px 9px;
  border-color: rgba(255,255,255,.13);
  background: rgba(255,255,255,.06);
  color: #cbd4dd;
}
.tag-chip:hover,
.tag-chip.is-active { border-color: #78c9c4; color: #fff; background: rgba(24,127,122,.36); }

.main-panel { min-width: 0; display: grid; grid-template-rows: 58px minmax(0, 1fr); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(14px);
}

.menu-button { display: none; }
.current-path { color: var(--muted); font-size: 12px; font-weight: 800; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.ghost-button,
.primary-button,
.menu-button {
  min-height: 34px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}
.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: #47515d;
}
.primary-button {
  padding: 0 14px;
  border: 1px solid #1b587d;
  background: var(--blue);
  color: #fff;
}
.menu-button {
  width: 36px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
}

.doc-list-panel {
  align-self: start;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 102px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.doc-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
}
.doc-list-head strong { font-size: 12px; }
.doc-list-head span { color: var(--muted); font-size: 11px; font-weight: 800; }

.doc-list { overflow: auto; padding: 8px; }
.doc-card {
  width: 100%;
  display: block;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: #fff;
  text-align: left;
}
.doc-card:hover,
.doc-card.is-active { border-color: var(--line-strong); background: #f4f7f9; }
.doc-card.is-active { box-shadow: inset 3px 0 0 var(--teal); }
.doc-card small { color: var(--amber); font-size: 10px; font-weight: 900; }
.doc-card strong { display: block; margin-top: 5px; font-size: 14px; line-height: 1.35; }
.doc-card span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.article-view {
  min-width: 0;
  max-width: 1040px;
  width: 100%;
  margin: 0 auto;
  padding: 34px 42px 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  outline: 0;
}

.article-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.article-kicker { color: var(--teal); font-size: 11px; font-weight: 900; text-transform: uppercase; }
.article-hero h1 { margin: 9px 0 12px; font-size: 38px; line-height: 1.18; }
.article-summary { max-width: 760px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.article-meta { display: grid; gap: 9px; justify-items: end; }
.meta-chip { padding: 7px 10px; }

.article-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
.article-tag { padding: 7px 10px; }

.article-section { padding-top: 30px; }
.article-section h2 { margin: 0 0 13px; font-size: 23px; line-height: 1.3; }
.article-section p { margin: 0 0 14px; color: #46515d; font-size: 15px; line-height: 1.75; }
.article-section ul,
.article-section ol { margin: 0; padding-left: 20px; color: #46515d; font-size: 15px; line-height: 1.75; }
.article-section li + li { margin-top: 6px; }

.callout {
  margin-top: 18px;
  padding: 16px 18px;
  border-left: 4px solid var(--amber);
  background: #fbf3e9;
  color: #574232;
  font-size: 14px;
  line-height: 1.65;
}
.callout strong { display: block; margin-bottom: 5px; color: #8a551d; }

.code-block {
  margin: 18px 0 0;
  padding: 16px;
  border-radius: 7px;
  background: #18202a;
  color: #e9edf2;
  overflow: auto;
  font: 13px/1.6 Consolas, "SFMono-Regular", Menlo, monospace;
}

.matrix,
.checklist,
.metric-grid,
.flow-diagram {
  margin-top: 18px;
}

.matrix {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.matrix-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr);
  border-top: 1px solid var(--line);
}
.matrix-row:first-child { border-top: 0; background: var(--surface-alt); font-weight: 900; }
.matrix-row > * { padding: 12px 14px; font-size: 13px; line-height: 1.55; }
.matrix-row strong { color: var(--ink); }
.matrix-row span { color: #515b67; }

.checklist { display: grid; gap: 9px; }
.check-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.check-item b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
}
.check-item span { color: #46515d; font-size: 14px; line-height: 1.55; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.metric {
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--teal);
  border-radius: 7px;
  background: var(--surface-alt);
}
.metric:nth-child(2) { border-top-color: var(--amber); }
.metric:nth-child(3) { border-top-color: var(--violet); }
.metric span { display: block; color: var(--muted); font-size: 11px; font-weight: 900; }
.metric strong { display: block; margin-top: 12px; font-size: 24px; }
.metric p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.flow-diagram {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: stretch;
}
.flow-node {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-alt);
}
.flow-node small { color: var(--teal); font-size: 10px; font-weight: 900; }
.flow-node strong { margin-top: 12px; font-size: 16px; }
.flow-node span { margin-top: auto; color: var(--muted); font-size: 11px; line-height: 1.45; }

.empty-state {
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  transform: translateY(20px);
  opacity: 0;
  padding: 11px 14px;
  border-radius: 7px;
  background: #18202a;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  transition: .18s ease;
  pointer-events: none;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .wiki-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 15;
    width: min(320px, 86vw);
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: 22px 0 50px rgba(0,0,0,.24);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .menu-button { display: inline-grid; place-items: center; }
  .workspace { grid-template-columns: 280px minmax(0, 1fr); padding: 18px; }
}

@media (max-width: 820px) {
  .topbar { padding: 0 14px; }
  .current-path { display: none; }
  .workspace { grid-template-columns: 1fr; gap: 14px; }
  .doc-list-panel { position: relative; top: auto; max-height: 300px; }
  .article-view { padding: 26px 22px 40px; }
  .article-hero { grid-template-columns: 1fr; }
  .article-meta { justify-items: start; display: flex; flex-wrap: wrap; }
  .article-hero h1 { font-size: 30px; }
  .metric-grid { grid-template-columns: 1fr; }
  .flow-diagram { grid-template-columns: 1fr; }
  .matrix-row { grid-template-columns: 1fr; }
  .matrix-row:first-child { display: none; }
  .matrix-row > * { padding: 10px 12px; }
}

@media (max-width: 520px) {
  .topbar-actions { gap: 6px; }
  .ghost-button, .primary-button { padding: 0 9px; }
  .article-view { border-radius: 0; margin: 0 -18px; width: auto; }
  .workspace { padding-bottom: 0; }
}
