/* ==========================================================================
   PIE BAKERY — "Pixel Bakery" theme
   베이커리 색감 + 말랑 + 레트로 픽셀: 통통한 카드, 단단한 픽셀 그림자, 픽셀 폰트 포인트
   ========================================================================== */

@font-face {
  font-family: "NeoDunggeunmo";
  src: url("/vendor/fonts/NeoDunggeunmo.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Galmuri11";
  src: url("/vendor/fonts/Galmuri11.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Galmuri11";
  src: url("/vendor/fonts/Galmuri11-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --font-body: "Pretendard", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
  --font-pixel: "Galmuri11", "Noto Sans KR", monospace;                 /* small labels, buttons */
  --font-title: "NeoDunggeunmo", "Galmuri11", "Noto Sans KR", monospace;  /* headings: crisp at 16px steps */
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* bakery showcase palette (names kept from the candy theme) */
  --pink: #ffd3cc;          /* strawberry cream */
  --mint: #d6ebc1;          /* pistachio */
  --lavender: #e6d8f0;      /* taro / blueberry cream */
  --butter: #ffe9a6;        /* butter */
  --sky: #ffdcae;           /* caramel glaze */
  --peach: #f6d9bd;         /* milk tea */

  --bg: #fff8ea;            /* flour cream */
  --bg-dot: #f1e0c2;
  --paper: #fffdf7;
  --fg: #4b3224;            /* cocoa */
  --muted: #8b705c;
  --line: #4b3224;          /* pixel shadow */
  --outline: #4b3224;       /* pixel border */
  --line-soft: #efdfc6;     /* inner hairlines */
  --soft: #fff1da;
  --accent: #b2452f;        /* cinnamon, readable for text & links */
  --accent-bg: #f4a55a;     /* baked crust fill */
  --accent-hover: #ee9440;
  --jam: #e8616b;
  --accent2: #f0cf9f;
  --hover: #ffefd2;
  --code: #fbf3e4;
  --danger: #c0392b;
  --ok: #4f7f2c;
  --px: 3px;                /* pixel shadow size */
  --shadow: var(--px) var(--px) 0 var(--line);
  --shadow-lg: 5px 5px 0 var(--line);
  --radius: 14px;
  --radius-sm: 10px;

  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.75;
}

html[data-theme=dark] {   /* late-night chocolate oven */
  --pink: #7a4440;
  --mint: #4c5f37;
  --lavender: #5a4a66;
  --butter: #73602a;
  --sky: #7a5630;
  --peach: #66503d;

  --bg: #231913;
  --bg-dot: #33261c;
  --paper: #2e221a;
  --fg: #fcefdc;
  --muted: #cdb39b;
  --line: #110b07;
  --outline: #93725a;
  --line-soft: #46362a;
  --soft: #382a20;
  --accent: #ffb78c;
  --accent-bg: #f4a55a;
  --accent-hover: #ffb872;
  --jam: #ff8f8f;
  --accent2: #5c4634;
  --hover: #3d2e23;
  --code: #1d1510;
  --danger: #ff9a8c;
  --ok: #b7dc8e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  /* tiny pixel dot grid */
  background-image: radial-gradient(var(--bg-dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
}

::selection { background: var(--pink); color: var(--fg); }

button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea { outline-offset: 3px; }
:focus-visible { outline: 3px dashed var(--accent); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 4px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.skip { position: absolute; top: -100px; z-index: 100; }
.skip:focus { top: 8px; background: var(--paper); padding: 8px; border: 2px solid var(--outline); border-radius: 8px; }

/* pixel sprites ---------------------------------------------------------- */
:root {
  --sprite-pie: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 9' shape-rendering='crispEdges'%3E%3Cpath fill='%234b3224' d='M4 0h1v1h-1zM5 0h1v1h-1zM6 0h1v1h-1zM7 0h1v1h-1zM8 0h1v1h-1zM9 0h1v1h-1zM2 1h1v1h-1zM3 1h1v1h-1zM11 1h1v1h-1zM12 1h1v1h-1zM1 2h1v1h-1zM13 2h1v1h-1zM0 3h1v1h-1zM13 3h1v1h-1zM0 4h1v1h-1zM13 4h1v1h-1zM0 5h1v1h-1zM1 5h1v1h-1zM12 5h1v1h-1zM13 5h1v1h-1zM1 6h1v1h-1zM12 6h1v1h-1zM2 7h1v1h-1zM11 7h1v1h-1zM3 8h1v1h-1zM4 8h1v1h-1zM5 8h1v1h-1zM6 8h1v1h-1zM7 8h1v1h-1zM8 8h1v1h-1zM9 8h1v1h-1zM10 8h1v1h-1z'/%3E%3Cpath fill='%23f7c873' d='M4 1h1v1h-1zM5 1h1v1h-1zM6 1h1v1h-1zM7 1h1v1h-1zM8 1h1v1h-1zM9 1h1v1h-1zM10 1h1v1h-1zM2 2h1v1h-1zM3 2h1v1h-1zM5 2h1v1h-1zM6 2h1v1h-1zM8 2h1v1h-1zM9 2h1v1h-1zM11 2h1v1h-1zM12 2h1v1h-1zM1 3h1v1h-1zM2 3h1v1h-1zM4 3h1v1h-1zM5 3h1v1h-1zM7 3h1v1h-1zM8 3h1v1h-1zM10 3h1v1h-1zM11 3h1v1h-1zM12 3h1v1h-1z'/%3E%3Cpath fill='%23e8616b' d='M4 2h1v1h-1zM7 2h1v1h-1zM10 2h1v1h-1zM3 3h1v1h-1zM6 3h1v1h-1zM9 3h1v1h-1z'/%3E%3Cpath fill='%23e09a4a' d='M1 4h1v1h-1zM2 4h1v1h-1zM3 4h1v1h-1zM4 4h1v1h-1zM5 4h1v1h-1zM6 4h1v1h-1zM7 4h1v1h-1zM8 4h1v1h-1zM9 4h1v1h-1zM10 4h1v1h-1zM11 4h1v1h-1zM12 4h1v1h-1zM2 5h1v1h-1zM3 5h1v1h-1zM4 5h1v1h-1zM5 5h1v1h-1zM6 5h1v1h-1zM7 5h1v1h-1zM8 5h1v1h-1zM9 5h1v1h-1zM10 5h1v1h-1zM11 5h1v1h-1z'/%3E%3Cpath fill='%23d8c7b2' d='M2 6h1v1h-1zM3 6h1v1h-1zM4 6h1v1h-1zM5 6h1v1h-1zM6 6h1v1h-1zM7 6h1v1h-1zM8 6h1v1h-1zM9 6h1v1h-1zM10 6h1v1h-1zM11 6h1v1h-1zM3 7h1v1h-1zM4 7h1v1h-1zM5 7h1v1h-1zM6 7h1v1h-1zM7 7h1v1h-1zM8 7h1v1h-1zM9 7h1v1h-1zM10 7h1v1h-1z'/%3E%3C/svg%3E");
  --sprite-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 6' shape-rendering='crispEdges'%3E%3Cpath fill='%23e8616b' d='M1 0h2v1H1zM4 0h2v1H4zM0 1h7v2H0zM1 3h5v1H1zM2 4h3v1H2zM3 5h1v1H3z'/%3E%3Cpath fill='%23fff' d='M1 1h1v1H1z'/%3E%3C/svg%3E");
  --sprite-star: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'%3E%3Cpath fill='%23ffd84d' d='M2 0h1v5H2zM0 2h5v1H0zM1 1h3v3H1z'/%3E%3C/svg%3E");
  --sprite-sparkle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 5' shape-rendering='crispEdges'%3E%3Cpath fill='%23f4a55a' d='M2 0h1v5H2zM0 2h5v1H0z'/%3E%3C/svg%3E");
}

/* top bar ---------------------------------------------------------------- */
.topbar {
  height: 70px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--paper);
  border-bottom: 3px solid var(--outline);
  padding: 0 26px;
}
.topbar::after { /* scalloped bakery awning */
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 3px;
  height: 11px;
  background:
    radial-gradient(circle at 11px 0, var(--pink) 10px, transparent 10.5px) 0 0 / 44px 11px repeat-x,
    radial-gradient(circle at 33px 0, var(--butter) 10px, transparent 10.5px) 0 0 / 44px 11px repeat-x;
  filter: drop-shadow(0 2px 0 var(--outline));
  pointer-events: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  line-height: 1.2;
}
.brand:hover { text-decoration: none; }
.brand:hover .brand-icon { transform: translateY(-3px) rotate(-6deg); }
.brand-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--accent-bg);
  color: #fff;
  border: 3px solid var(--outline);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: 700 22px var(--font-pixel);
  text-shadow: 2px 2px 0 var(--line);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.brand-accent { color: var(--accent); }
.brand small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
  font-weight: 400;
}
.brand small::before { content: "♥ "; color: var(--jam); }

.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  min-width: 270px;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: var(--soft);
  padding: 7px 14px;
  color: var(--muted);
  text-align: left;
  font-size: 13px;
  transition: transform .15s, box-shadow .15s;
}
.search-trigger:hover { box-shadow: var(--shadow); transform: translate(-1px, -1px); }
.search-trigger kbd {
  margin-left: auto;
  font: 11px var(--font-pixel);
  background: var(--paper);
  border: 2px solid var(--outline);
  border-radius: 6px;
  padding: 0 6px;
  color: var(--fg);
}
.top-links { display: flex; align-items: center; gap: 12px; font-size: 13px; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center;
  min-width: 36px; height: 36px;
  border: 2px solid var(--outline);
  border-radius: 10px;
  background: var(--paper);
  color: var(--fg);
  text-decoration: none;
  font-size: 17px;
  box-shadow: 2px 2px 0 var(--line);
  transition: transform .12s, box-shadow .12s, background .12s;
}
.icon-btn:hover { background: var(--butter); text-decoration: none; transform: translate(-1px, -1px); box-shadow: var(--shadow); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--line); }
.mobile-only { display: none; }

/* layout ----------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr) 216px;
  max-width: 1600px;
  margin: auto;
  min-height: calc(100vh - 70px);
}

/* sidebar ---------------------------------------------------------------- */
.sidebar {
  position: sticky;
  top: 70px;
  height: calc(100dvh - 70px);
  overflow: auto;
  padding: 28px 16px 16px;
  display: flex;
  flex-direction: column;
}
.side-intro {
  padding: 14px 14px 16px;
  margin-bottom: 8px;
  background: var(--paper);
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.eyebrow {
  font: 700 10px var(--font-pixel);
  color: var(--accent);
  letter-spacing: .08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.progress-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
#progress-count { font-family: var(--font-pixel); color: var(--fg); }
.progress-track {
  height: 14px;
  background: var(--soft);
  border: 2px solid var(--outline);
  border-radius: 4px;
  margin-top: 9px;
  overflow: hidden;
  padding: 1px;
}
.progress-track div {
  height: 100%;
  border-radius: 1px;
  /* segmented pixel progress */
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, var(--paper) 8px 10px),
    linear-gradient(90deg, #f7c873, var(--accent-bg) 55%, #d9783f);
  transition: width .4s steps(8);
}

#nav .group-label {
  padding: 16px 10px 5px;
  color: var(--muted);
  font: 700 10px var(--font-pixel);
  letter-spacing: .06em;
  text-transform: uppercase;
}
#nav .group-label::before {
  content: "";
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 6px;
  vertical-align: -1px;
  background: var(--sprite-star) center / contain no-repeat;
  image-rendering: pixelated;
}
#nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px;
  margin: 2px 0;
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--fg);
  opacity: .82;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  transition: background .12s, transform .12s;
}
#nav a:hover { background: var(--hover); opacity: 1; text-decoration: none; transform: translateX(3px); }
#nav a.active {
  background: var(--pink);
  color: var(--fg);
  opacity: 1;
  font-weight: 700;
  border-color: var(--outline);
  box-shadow: 2px 2px 0 var(--line);
}
.nav-index { font: 10px var(--font-pixel); color: var(--muted); width: 20px; flex-shrink: 0; }
#nav a.active .nav-index { color: var(--fg); }
.nav-check { margin-left: auto; color: var(--ok); font-weight: 750; }

.side-footer {
  border-top: 2px dashed var(--line-soft);
  margin-top: auto;
  padding: 14px 10px 0;
  font-size: 11px;
  color: var(--muted);
  display: flex; gap: 8px; align-items: center;
}
.status-dot {
  width: 8px; height: 8px;
  background: var(--ok);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--mint);
  animation: blink 1.6s steps(2) infinite;
}

/* main ------------------------------------------------------------------- */
main { min-width: 0; padding: 38px 42px 90px; max-width: 1040px; width: 100%; margin: auto; align-self: start; }
#view { min-width: 0; }

.toc {
  position: sticky;
  top: 70px;
  height: calc(100dvh - 70px);
  padding: 38px 18px;
  overflow: auto;
  font-size: 12px;
}
.toc .eyebrow::before { content: "✦ "; color: var(--accent-bg); }
.toc a {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  padding: 5px 8px;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.toc a:hover { color: var(--fg); background: var(--hover); text-decoration: none; }
.toc a.sub { padding-left: 18px; font-size: 11px; }

.crumb { color: var(--muted); font: 12px var(--font-pixel); margin-bottom: 16px; }
.page-title {
  font-family: var(--font-pixel);
  font-size: clamp(26px, 3.1vw, 38px);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 12px;
  text-shadow: 3px 3px 0 var(--pink);
}
.subtitle { color: var(--muted); font-size: 14px; margin: 0 0 25px; }

/* article ---------------------------------------------------------------- */
.article { min-width: 0; }
.article h1, .article h2, .article h3, .article h4 {
  scroll-margin-top: 92px;
  font-family: var(--font-pixel);
  font-weight: 700;
  line-height: 1.4;
}
.article h1 {
  font-size: 23px;
  margin: 44px 0 16px;
  padding: 10px 16px;
  background: var(--lavender);
  border: 2px solid var(--outline);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.article h2 { font-size: 18px; margin: 30px 0 12px; display: flex; align-items: center; gap: 10px; }
.article h2::before {
  content: "";
  flex-shrink: 0;
  width: 18px; height: 16px;
  background: var(--sprite-heart) center / contain no-repeat;
  image-rendering: pixelated;
}
.article h3 { font-size: 15px; margin: 22px 0 10px; }
.article h3::before { content: "▸ "; color: var(--accent); }
.article p { margin: 12px 0; overflow-wrap: break-word; }
.article ul, .article ol { padding-left: 24px; }
.article li { margin: 5px 0; }
.article ul > li::marker { content: "◆ "; color: var(--accent-bg); font-size: .8em; }
.article a {
  text-decoration: none;
  background: linear-gradient(transparent 62%, var(--pink) 62%);
  color: var(--fg);
  font-weight: 600;
  padding: 0 1px;
}
.article a:hover { background: var(--pink); text-decoration: none; }
.article blockquote {
  margin: 18px 0;
  border: 2px solid var(--outline);
  background: var(--butter);
  padding: 10px 16px;
  color: var(--fg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.article code {
  font-family: var(--font-mono);
  font-size: .87em;
  background: var(--code);
  padding: 2px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}
.article pre { margin: 0; white-space: pre; overflow: auto; background: var(--code); padding: 17px; line-height: 1.6; }
.article pre code { padding: 0; background: none; border: 0; white-space: pre; font-size: 12px; }

.code-wrap, .equation-wrap, .diagram-wrap {
  border: 2px solid var(--outline);
  border-radius: var(--radius-sm);
  margin: 18px 0;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px;
  border-bottom: 2px solid var(--outline);
  background: var(--sky);
  font: 11px var(--font-pixel);
  color: var(--fg);
}
.code-head::before { /* window dots */
  content: "";
  width: 34px; height: 8px;
  margin-right: 8px;
  background:
    radial-gradient(circle at 4px 4px, #e8616b 3px, transparent 3.5px),
    radial-gradient(circle at 17px 4px, #ffd84d 3px, transparent 3.5px),
    radial-gradient(circle at 30px 4px, #9cc56b 3px, transparent 3.5px);
}
.code-head > :first-child { margin-right: auto; }
.equation-wrap .code-head { background: var(--mint); }
.diagram-wrap .code-head { background: var(--peach); }
.tiny-btn {
  border: 2px solid var(--outline);
  background: var(--paper);
  color: var(--fg);
  border-radius: 7px;
  padding: 1px 8px;
  font: 11px var(--font-pixel);
  box-shadow: 2px 2px 0 var(--line);
}
.tiny-btn:hover { background: var(--butter); }
.tiny-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.equation-wrap .math-display { padding: 14px 16px; overflow-x: auto; min-width: 0; text-align: center; font-size: 1.04em; }
.equation-wrap mjx-container { max-width: 100%; margin: 8px 0 !important; }
.diagram-wrap svg { display: block; width: 100%; height: auto; max-height: 650px; }
.diagram-source { padding: 8px 12px; font-size: 12px; }

/* tables ----------------------------------------------------------------- */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  border: 2px solid var(--outline);
  border-radius: var(--radius-sm);
  margin: 18px 0;
  background: var(--paper);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.55; }
td, th { text-align: left; padding: 10px 12px; border-bottom: 1px dashed var(--line-soft); vertical-align: top; min-width: 65px; overflow-wrap: anywhere; }
th { background: var(--pink); font-family: var(--font-pixel); font-weight: 700; font-size: 12px; border-bottom: 2px solid var(--outline); }
tbody tr:nth-child(even) td { background: var(--soft); }
tr:last-child td { border-bottom: 0; }

/* answers & checklists --------------------------------------------------- */
.answer {
  border: 2px solid var(--outline);
  background: var(--paper);
  padding: 10px 14px;
  margin: 16px 0;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.answer summary { cursor: pointer; font: 700 13px var(--font-pixel); color: var(--accent); list-style: none; }
.answer summary::-webkit-details-marker { display: none; }
.answer summary::before { content: "▶ "; display: inline-block; transition: transform .15s; }
.answer[open] summary::before { transform: rotate(90deg); }
.answer[open] { background: var(--soft); }
.answer .table-scroll { margin-bottom: 0; }
.checklist { accent-color: var(--accent-bg); }
.article input[type=checkbox] { margin-right: 7px; accent-color: var(--accent-bg); width: 15px; height: 15px; vertical-align: -2px; }

/* buttons ---------------------------------------------------------------- */
.page-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 18px 0 28px; }
.button {
  border: 2px solid var(--outline);
  background: var(--paper);
  color: var(--fg);
  border-radius: 12px;
  padding: 8px 15px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 13px var(--font-pixel);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .12s cubic-bezier(.3, 1.6, .5, 1), box-shadow .12s, background .12s;
}
.button:hover { background: var(--butter); text-decoration: none; transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.button:active { transform: translate(var(--px), var(--px)); box-shadow: 0 0 0 var(--line); }
.button.primary { background: var(--accent-bg); color: #3a2416; border-color: var(--outline); }
.button.primary:hover { background: var(--accent-hover); }
.button.active { background: var(--mint); color: var(--fg); }

.page-end {
  border-top: 2px dashed var(--line-soft);
  margin-top: 40px;
  padding-top: 22px;
  display: flex; justify-content: space-between; gap: 16px;
}
.page-end a {
  flex: 1;
  padding: 12px 14px;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--fg);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s, background .12s;
}
.page-end a:hover { background: var(--sky); text-decoration: none; transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); }
.page-end a:last-child { text-align: right; }
.page-end small { display: block; color: var(--muted); font: 11px var(--font-pixel); }

/* home ------------------------------------------------------------------- */
.hero {
  background:
    linear-gradient(135deg, var(--butter) 0%, var(--pink) 58%, var(--sky) 100%);
  border: 3px solid var(--outline);
  padding: 32px 30px;
  border-radius: 20px;
  box-shadow: 6px 6px 0 var(--line);
  position: relative;
  overflow: hidden;
}
.hero::before { /* pixel sparkle field */
  content: "";
  position: absolute; inset: 0;
  background:
    var(--sprite-pie) right 40px top 30px / 84px 54px no-repeat,
    var(--sprite-star) right 130px top 26px / 25px 25px no-repeat,
    var(--sprite-sparkle) right 28px top 112px / 20px 20px no-repeat,
    var(--sprite-star) right 112px bottom 40px / 15px 15px no-repeat,
    var(--sprite-sparkle) right 200px top 90px / 15px 15px no-repeat;
  image-rendering: pixelated;
  pointer-events: none;
  animation: float 3s ease-in-out infinite;
}
.hero::after {
  content: "∑";
  font: 700 150px var(--font-pixel);
  position: absolute;
  right: 36px; bottom: -48px;
  color: #fff;
  opacity: .45;
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow {
  display: inline-block;
  background: var(--paper);
  border: 2px solid var(--outline);
  border-radius: 999px;
  padding: 2px 12px;
  color: var(--fg);
}
html[data-theme=dark] .hero .eyebrow { color: var(--fg); }
.hero h1 {
  font-family: var(--font-pixel);
  font-size: 34px;
  line-height: 1.3;
  margin: 12px 0 12px;
  max-width: 600px;
  text-shadow: 2px 2px 0 color-mix(in srgb, var(--paper) 70%, transparent);
}
.hero p { max-width: 590px; color: var(--fg); opacity: .85; font-size: 14px; }
.hero .page-actions { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 30px; }
.stat {
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--mint);
  box-shadow: var(--shadow);
  transition: transform .2s cubic-bezier(.3, 1.6, .5, 1);
}
.stat:nth-child(2) { background: var(--butter); }
.stat:nth-child(3) { background: var(--sky); }
.stat:hover { transform: translateY(-4px) rotate(-1deg); }
.stat strong { display: block; font: 700 28px var(--font-pixel); line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat small { color: var(--fg); opacity: .75; font-size: 12px; }

.section-title {
  margin: 34px 0 14px;
  font: 700 20px var(--font-pixel);
  display: flex; align-items: center; gap: 10px;
}
.section-title::before {
  content: "";
  flex-shrink: 0;
  width: 31px; height: 20px;
  background: var(--sprite-pie) center / contain no-repeat;
  image-rendering: pixelated;
}

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.lesson-card {
  --card: var(--pink);
  display: flex; flex-direction: column; gap: 5px;
  min-height: 124px;
  border: 2px solid var(--outline);
  background: var(--paper);
  padding: 0 18px 16px;
  border-radius: var(--radius);
  color: var(--fg);
  text-decoration: none;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .15s cubic-bezier(.3, 1.6, .5, 1), box-shadow .15s;
}
.lesson-card:nth-child(5n+2) { --card: var(--mint); }
.lesson-card:nth-child(5n+3) { --card: var(--lavender); }
.lesson-card:nth-child(5n+4) { --card: var(--butter); }
.lesson-card:nth-child(5n+5) { --card: var(--sky); }
.lesson-card > :first-child { /* coloured label strip */
  margin: 0 -18px 8px;
  padding: 8px 18px 6px;
  background: var(--card);
  border-bottom: 2px solid var(--outline);
  color: var(--fg);
}
.lesson-card:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--line); text-decoration: none; }
.lesson-card:hover small { animation: bounce .5s ease; }
.lesson-card strong { font-family: var(--font-pixel); font-size: 15px; line-height: 1.45; }
.lesson-card span { color: var(--muted); font-size: 12px; }
.lesson-card small { margin-top: auto; font: 700 11px var(--font-pixel); color: var(--accent); display: inline-block; }

.notice {
  padding: 12px 16px;
  margin: 18px 0;
  background: var(--butter);
  border: 2px dashed var(--outline);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--fg);
}
.notice strong { color: var(--fg); }

/* tools ------------------------------------------------------------------ */
.toolbox {
  margin: 26px 0;
  border: 2px solid var(--outline);
  border-radius: var(--radius);
  background: var(--paper);
  overflow: hidden;
  box-shadow: 5px 5px 0 var(--line);
  scroll-margin-top: 88px;
}
.tool-head {
  padding: 15px 18px;
  border-bottom: 2px solid var(--outline);
  background: var(--lavender);
  background-image: radial-gradient(#ffffff55 1.2px, transparent 1.3px);
  background-size: 10px 10px;
}
.toolbox:nth-of-type(4n+2) .tool-head { background-color: var(--mint); }
.toolbox:nth-of-type(4n+3) .tool-head { background-color: var(--pink); }
.toolbox:nth-of-type(4n+4) .tool-head { background-color: var(--sky); }
.tool-head .eyebrow { margin-bottom: 2px; color: var(--fg); opacity: .75; }
.tool-head h3 { font: 700 18px var(--font-pixel); margin: 0; line-height: 1.4; }
.tool-head p { font-size: 12px; color: var(--fg); opacity: .8; margin: 5px 0 0; }
.tool-body { padding: 18px; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.control { display: flex; flex-direction: column; gap: 5px; font: 12px var(--font-pixel); color: var(--muted); min-width: 0; }
.control.wide { grid-column: 1 / -1; }
input[type=number], input[type=text], select, textarea {
  width: 100%;
  min-width: 0;
  border: 2px solid var(--outline);
  background: var(--soft);
  padding: 8px 11px;
  border-radius: 10px;
  color: var(--fg);
  font-family: var(--font-body);
  transition: background .12s, box-shadow .12s;
}
input[type=number]:focus, input[type=text]:focus, select:focus, textarea:focus {
  background: var(--paper);
  box-shadow: 0 0 0 3px var(--pink);
  outline: none;
}
input[type=range] { width: 100%; accent-color: var(--accent-bg); }
textarea { resize: vertical; font-family: var(--font-mono); min-height: 110px; }
.tool-ops { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 15px; }
.tool-output {
  padding: 14px;
  border: 2px dashed var(--outline);
  border-radius: var(--radius-sm);
  margin-top: 16px;
  background: var(--code);
  font-size: 13px;
  overflow-wrap: anywhere;
  overflow: auto;
}
.tool-output p { margin: 5px 0; }
.tool-output .big-value { font: 700 28px var(--font-pixel); color: var(--accent); font-variant-numeric: tabular-nums; }
.tool-output .data-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 9px 0; }
.data-chip {
  padding: 4px 9px;
  border: 2px solid var(--outline);
  background: var(--paper);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  box-shadow: 2px 2px 0 var(--line);
}
.data-chip:nth-child(4n+1) { background: var(--pink); }
.data-chip:nth-child(4n+2) { background: var(--mint); }
.data-chip:nth-child(4n+3) { background: var(--butter); }
.data-chip:nth-child(4n+4) { background: var(--sky); }
.data-chip.error { border-color: var(--danger); color: var(--danger); background: var(--paper); box-shadow: 2px 2px 0 var(--danger); }
.tool-output .formula { font-family: var(--font-mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tool-error { color: var(--danger); font-weight: 650; }
.result-ok { color: var(--ok); font-weight: 700; }
.result-ok::before { content: "✔ "; }
.result-bad { color: var(--danger); font-weight: 700; }
.result-bad::before { content: "✖ "; }
.tool-output .table-scroll { margin: 8px 0; box-shadow: none; }
.tool-output svg { max-width: 100%; height: auto; }
.legend { display: flex; gap: 15px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 4px; background: var(--legend); vertical-align: middle; margin-right: 5px; }
.hash-grid { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 12px 0; }
.hash-level { display: flex; justify-content: center; gap: 7px; width: 100%; flex-wrap: wrap; }
.hash-node { font: 10px var(--font-mono); background: var(--paper); border: 2px solid var(--outline); padding: 6px 8px; border-radius: 8px; }
.hash-node.highlight { background: var(--pink); box-shadow: 2px 2px 0 var(--line); }
.tool-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 24px; }
.tool-nav a {
  font: 12px var(--font-pixel);
  color: var(--fg);
  border: 2px solid var(--outline);
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--paper);
  transition: transform .12s, background .12s;
}
.tool-nav a:nth-child(5n+1):hover { background: var(--pink); }
.tool-nav a:nth-child(5n+2):hover { background: var(--mint); }
.tool-nav a:nth-child(5n+3):hover { background: var(--lavender); }
.tool-nav a:nth-child(5n+4):hover { background: var(--butter); }
.tool-nav a:nth-child(5n+5):hover { background: var(--sky); }
.tool-nav a:hover { text-decoration: none; transform: translateY(-2px); }

/* dialogs & toast -------------------------------------------------------- */
dialog {
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: var(--paper);
  color: var(--fg);
  width: min(600px, 90vw);
  padding: 18px;
  box-shadow: 7px 7px 0 var(--line);
  max-height: 78vh;
  overflow: auto;
}
dialog[open] { animation: pop .22s cubic-bezier(.3, 1.6, .5, 1); }
dialog::backdrop { background: #3a241699; backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; font: 700 14px var(--font-pixel); margin-bottom: 12px; }
#search-input { font-size: 15px; padding: 11px 14px; }
#search-results { max-height: 58vh; overflow: auto; margin-top: 10px; }
.search-result { display: block; border-bottom: 2px dashed var(--line-soft); padding: 10px 8px; text-decoration: none; border-radius: 8px; }
.search-result:hover { background: var(--hover); text-decoration: none; }
.search-result strong { display: block; color: var(--fg); font-family: var(--font-pixel); }
.search-result small { display: block; color: var(--muted); overflow-wrap: anywhere; }

#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  padding: 9px 16px;
  background: var(--butter);
  color: var(--fg);
  border: 2px solid var(--outline);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 50;
  font: 13px var(--font-pixel);
  max-width: 90vw;
  display: none;
}
#toast.on { display: block; animation: pop .22s cubic-bezier(.3, 1.6, .5, 1); }
#toast::before { content: "★ "; color: var(--accent); }

/* settings --------------------------------------------------------------- */
.settings-panel {
  border: 2px solid var(--outline);
  background: var(--paper);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow);
}
.settings-panel h2 { font: 700 17px var(--font-pixel); margin-top: 0; }
.settings-panel p { font-size: 13px; color: var(--muted); }
.settings-panel label { display: block; font: 700 12px var(--font-pixel); margin: 14px 0 6px; }
.settings-panel input[type=file] { max-width: 100%; font-size: 13px; }
.settings-panel textarea { min-height: 160px; }
.settings-panel .button { margin-top: 8px; }
.settings-panel .error { color: var(--danger); }

/* site tabs (홈 / 블로그 / Lab) ------------------------------------------- */
.site-tabs { display: flex; align-items: center; gap: 6px; margin-left: 10px; }
.site-tabs a {
  font: 700 13px var(--font-pixel);
  color: var(--fg);
  padding: 4px 13px;
  border: 2px solid transparent;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .12s, transform .12s;
}
.site-tabs a:hover { background: var(--hover); text-decoration: none; transform: translateY(-2px); }
.site-tabs a.active { background: var(--butter); border-color: var(--outline); box-shadow: 2px 2px 0 var(--line); }
.topbar .top-links:only-of-type, .topbar .site-tabs + .top-links { margin-left: auto; }
.topbar .search-trigger + .top-links { margin-left: 0; }

/* scrollbars ------------------------------------------------------------- */
* { scrollbar-width: thin; scrollbar-color: var(--accent2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--accent2); border: 2px solid var(--bg); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* motion ----------------------------------------------------------------- */
@keyframes float { 50% { transform: translateY(-5px); } }
@keyframes bounce { 40% { transform: translateX(4px); } 70% { transform: translateX(-1px); } }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
#toast.on { animation-name: toastpop; }
@keyframes toastpop { from { transform: translate(-50%, 8px) scale(.92); opacity: 0; } }
@keyframes blink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* responsive ------------------------------------------------------------- */
@media (max-width: 1200px) {
  .shell { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
  main { padding: 32px 34px 70px; }
}
@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 8px; height: 62px; }
  .brand { font-size: 15px; gap: 9px; }
  .brand small { display: none; }
  .brand-icon { width: 32px; height: 32px; font-size: 18px; border-radius: 10px; }
  .mobile-only { display: grid; }
  .search-trigger { margin-left: auto; min-width: 0; width: 36px; height: 36px; justify-content: center; padding: 0; border-radius: 10px; }
  .search-trigger span:nth-child(2), .search-trigger kbd { display: none; }
  .top-links { gap: 6px; }
  .shell { display: block; min-height: calc(100vh - 62px); }
  .sidebar {
    display: none;
    position: fixed;
    top: 62px; left: 0;
    width: min(300px, 85vw);
    height: calc(100dvh - 62px);
    z-index: 19;
    background: var(--bg);
    border-right: 3px solid var(--outline);
    box-shadow: 6px 0 0 #4b322422;
  }
  .sidebar.open { display: flex; }
  main { padding: 26px 16px 60px; }
  .hero { padding: 22px 18px; border-radius: 16px; }
  .hero h1 { font-size: 24px; }
  .hero::before { background-size: 50px 32px, 16px 16px, 13px 13px, 10px 10px, 10px 10px; background-position: right 14px top 14px, right 60px top 10px, right 10px top 56px, right 80px bottom 20px, right 120px top 50px; }
  .hero::after { font-size: 100px; right: 12px; bottom: -32px; }
  .cards { grid-template-columns: 1fr; }
  .stats { gap: 8px; }
  .stat { padding: 10px; }
  .stat strong { font-size: 21px; }
  .stat small { font-size: 10px; }
  .page-title { font-size: 25px; }
  .article h1 { font-size: 19px; }
  .tool-body { padding: 13px; }
  .tool-head { padding: 12px; }
  .tool-grid { gap: 9px; }
  .tool-output { padding: 10px; }
  .article table { font-size: 12px; }
  td, th { padding: 7px 9px; }
  .top-links .icon-btn { width: 32px; min-width: 32px; height: 32px; }
  .page-end { flex-direction: column; }
  .page-end a:last-child { text-align: left; }
  .site-tabs { gap: 2px; margin-left: 0; }
  .site-tabs a { font-size: 12px; padding: 3px 8px; }
  .has-sidebar .brand > span:last-child { display: none; }
}
@media (max-width: 440px) {
  .brand { font-size: 14px; }
}

/* keep Korean words whole in headings */
.hero h1, .page-title, .section-title, .lesson-card strong { word-break: keep-all; }

/* Headings use Neo둥근모, a 16px bitmap face: sizes stay near 16px steps so pixels stay crisp. */
.brand, .page-title, .hero h1, .article h1, .article h2, .article h3, .article h4, .section-title, .stat strong,
.lesson-card strong, .tool-head h3, .tool-output .big-value,
.settings-panel h2, .brand-icon { font-family: var(--font-title); }
.brand { font-size: 20px; }
.page-title, .hero h1 { font-size: 32px; }
.article h1 { font-size: 24px; }
.article h2 { font-size: 20px; }
.article h3 { font-size: 16px; }
.section-title { font-size: 24px; }
.stat strong, .tool-output .big-value { font-size: 32px; }
.lesson-card strong { font-size: 16px; }
.tool-head h3, .settings-panel h2 { font-size: 20px; }
@media (max-width: 760px) {
  .brand { font-size: 16px; }
  .page-title, .hero h1 { font-size: 24px; }
  .article h1 { font-size: 20px; }
  .article h2 { font-size: 18px; }
  .section-title { font-size: 20px; }
  .stat strong { font-size: 24px; }
}
.brand small { font-family: var(--font-pixel); }

/* chapter pages listed under their parent in the Lab sidebar */
#nav a.sub { margin-left: 18px; padding: 4px 10px; font-size: 12px; border-left: 2px dashed var(--line-soft); border-radius: 0 10px 10px 0; }
#nav a.sub.active { border-left: 2px solid var(--outline); }
