:root {
  --bg: #f4f0e8;
  --paper: #fffdf8;
  --paper-soft: #faf6ee;
  --ink: #1c1b19;
  --muted: #746f66;
  --line: #ded7ca;
  --accent: #7b2f2f;
  --accent-soft: #f3e4df;
  --tip: #2f7a4d;
  --warn: #9b6800;
  --danger: #a33434;
  --note: #506d9b;
  --code: #24221f;
  --shadow: 0 20px 55px rgba(45, 37, 24, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, rgba(123, 47, 47, .07), transparent 28%),
    linear-gradient(180deg, #f8f5ef 0, var(--bg) 420px);
  line-height: 1.72;
}

a { color: inherit; }
code, pre { font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(222, 215, 202, .88);
  background: rgba(248, 245, 239, .9);
  backdrop-filter: blur(14px);
}
.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { font-weight: 900; letter-spacing: -.03em; text-decoration: none; }
.top-actions { display: flex; gap: 16px; font-size: 14px; color: var(--muted); }
.top-actions a { text-decoration: none; }
.top-actions a:hover { color: var(--accent); }

.shell { max-width: 1200px; margin: 0 auto; padding: 54px 24px 90px; }
.hero { padding: 24px 0 38px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
}
.hero h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.08;
  letter-spacing: -.05em;
}
.hero-copy { max-width: 760px; margin: 18px 0 0; color: var(--muted); font-size: 18px; }
.badges { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.badge {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.58);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.reader-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.toc-card {
  position: sticky;
  top: 76px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, .86);
  box-shadow: 0 10px 28px rgba(45, 37, 24, .05);
}
.toc-title { margin-bottom: 10px; font-size: 13px; font-weight: 900; color: var(--muted); }
.toc { display: grid; gap: 5px; }
.toc a {
  display: block;
  padding: 7px 9px;
  border-radius: 9px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.toc a.sub { padding-left: 18px; font-size: 12px; }
.toc a:hover, .toc a.active { background: var(--accent-soft); color: var(--accent); }

.reader-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.status { padding: 70px 30px; text-align: center; color: var(--muted); }
.reader { padding: clamp(30px, 5vw, 62px); }
.reader > h1:first-child { display: none; }
.reader h1, .reader h2, .reader h3, .reader h4 { line-height: 1.28; letter-spacing: -.035em; scroll-margin-top: 88px; }
.reader h2 {
  margin: 54px 0 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 30px;
}
.reader h2:first-of-type { margin-top: 8px; }
.reader h3 { margin: 34px 0 14px; font-size: 22px; }
.reader h4 { margin: 26px 0 10px; font-size: 18px; }
.reader p, .reader li { font-size: 16px; }
.reader ul, .reader ol { padding-left: 1.4em; }
.reader li + li { margin-top: 7px; }
.reader a { color: var(--accent); text-underline-offset: 3px; }
.reader strong { font-weight: 850; }
.reader hr { margin: 42px 0; border: 0; border-top: 1px solid var(--line); }
.reader code { padding: 2px 6px; border-radius: 6px; background: #eee9df; font-size: .92em; }
.reader pre {
  position: relative;
  overflow-x: auto;
  margin: 18px 0 24px;
  padding: 18px;
  border-radius: 14px;
  background: var(--code);
  color: #f7f3eb;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.reader pre code { padding: 0; background: transparent; color: inherit; }
.copy-btn {
  position: absolute;
  top: 9px;
  right: 9px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  padding: 5px 8px;
  background: rgba(255,255,255,.08);
  color: #ddd7cd;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.15); }
.reader table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 22px 0;
}
.reader th, .reader td { padding: 11px 13px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.reader th { background: var(--paper-soft); }
.reader img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 20px auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(45, 37, 24, .08);
}

.callout {
  margin: 22px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 14px;
  background: var(--paper-soft);
}
.callout p:first-of-type { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout-label { margin-bottom: 7px; font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.callout.important { border-left-color: var(--accent); background: var(--accent-soft); }
.callout.important .callout-label { color: var(--accent); }
.callout.tip { border-left-color: var(--tip); background: #eaf4ed; }
.callout.tip .callout-label { color: var(--tip); }
.callout.warning { border-left-color: var(--warn); background: #fbf1d9; }
.callout.warning .callout-label { color: var(--warn); }
.callout.caution { border-left-color: var(--danger); background: #f8e3e1; }
.callout.caution .callout-label { color: var(--danger); }
.callout.note { border-left-color: var(--note); background: #e9eef6; }
.callout.note .callout-label { color: var(--note); }

.footer { margin-top: 24px; padding: 0 10px; color: var(--muted); font-size: 12px; text-align: center; }
.footer code { padding: 2px 5px; border-radius: 5px; background: rgba(255,255,255,.55); }

@media (max-width: 900px) {
  .reader-layout { grid-template-columns: 1fr; }
  .toc-card { position: static; }
  .toc { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .toc a.sub { display: none; }
}
@media (max-width: 640px) {
  .shell { padding: 34px 12px 64px; }
  .topbar-inner { padding: 11px 13px; }
  .top-actions a:first-child { display: none; }
  .hero { padding-top: 8px; }
  .hero-copy { font-size: 16px; }
  .reader-card { border-radius: 18px; }
  .reader { padding: 25px 18px 34px; }
  .reader h2 { font-size: 25px; }
  .toc-card { border-radius: 15px; }
  .toc { grid-template-columns: 1fr; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --paper: #201e1b;
    --paper-soft: #292620;
    --ink: #f3efe7;
    --muted: #aaa398;
    --line: #3b3731;
    --accent: #e69b8f;
    --accent-soft: #342522;
    --tip: #7fc99a;
    --warn: #e6b658;
    --danger: #e88f88;
    --note: #91acd7;
    --code: #12110f;
    --shadow: none;
  }
  body { background: var(--bg); }
  .topbar { background: rgba(23,22,20,.9); }
  .badge, .toc-card { background: rgba(255,255,255,.03); }
  .reader code { background: #302c27; }
  .callout.tip { background: #1f3026; }
  .callout.warning { background: #332a18; }
  .callout.caution { background: #352120; }
  .callout.note { background: #202938; }
  .footer code { background: rgba(255,255,255,.06); }
}
