:root {
  --bg: #fafafa; --fg: #18181b; --muted: #52525b; --line: #e4e4e7;
  --card: #ffffff; --accent: #2563eb; --chip: #f1f1f3; --label: #3f3f46;
  --header-h: 64px;
  /* Open contents card: a soft blue-grey, apart from the neutral page but quiet enough to read on. */
  --toc-bg: #f1f5fc; --toc-head: #e7eef9; --toc-line: #d5e0f1; --toc-chip: #dfe8f7;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113; --fg: #ececee; --muted: #a1a1aa; --line: #2a2a2e;
    --card: #19191c; --accent: #8ab4ff; --chip: #232327; --label: #d4d4d8;
    --toc-bg: #1a1e26; --toc-head: #1f2430; --toc-line: #2c3442; --toc-chip: #273041;
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 12px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
/* Links inside running text need more than colour to stand out (WCAG link-in-text-block). */
.doc :is(p, li, td) a { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; z-index: 20; background: var(--fg); color: var(--bg); padding: 8px 12px; border-radius: 6px; }
.skip:focus { top: 8px; }

/* Header */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-top: 10px; padding-bottom: 10px; }
.who { display: flex; flex-direction: column; }
.name { margin: 0; font-size: 1.1rem; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
.name a { color: var(--fg); }
.role { color: var(--muted); font-size: .8rem; }
.links { display: flex; gap: 14px; font-size: .85rem; margin-top: 2px; }
/* Taller hit area (WCAG 2.2 target size) without changing the header's height. */
.links a { padding: 3px 0; margin: -3px 0; }
.top nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.top nav a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 7px; color: var(--muted); font-size: .9rem; transition: background-color .15s, color .15s; }
.top nav a:hover { color: var(--fg); text-decoration: none; }
.top nav a.apps:hover { background: var(--chip); }
/* Segmented toggles: the current option is a raised pill inside a sunken track. */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--chip); border: 1px solid var(--line); border-radius: 10px; }
.seg a[aria-current="page"] { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 0 0 1px var(--line); }
/* On phones the header wraps to three rows — let it scroll away instead of covering the page. */
@media (max-width: 639px) { .top { position: static; } html { scroll-padding-top: 12px; } }

/* Contents: a floating island in the bottom-right corner — a button when folded, a card when open */
.layout { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.toc { position: fixed; right: 16px; bottom: 16px; z-index: 15; transition: opacity .2s, transform .2s; }
.toc.away { opacity: 0; transform: translateY(8px); pointer-events: none; }
.toc details { border-radius: 999px; box-shadow: 0 4px 16px rgb(0 0 0 / .18); }
.toc summary { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; list-style: none; cursor: pointer; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 600; font-size: .9rem; user-select: none; }
.toc summary::-webkit-details-marker { display: none; }
.toc summary .ic { width: 18px; height: 18px; flex: none; }
/* Inside the card, hover and current marks and dividers take the card's tint instead of plain grey. */
.toc details[open] { --chip: var(--toc-chip); --line: var(--toc-line); width: min(340px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 16px; background: var(--toc-bg); box-shadow: 0 12px 40px rgb(0 0 0 / .16), 0 2px 6px rgb(0 0 0 / .06); overflow: hidden; }
.toc details[open] summary { min-height: 40px; padding: 0 12px 0 14px; border-radius: 0; background: var(--toc-head); color: var(--label); font-size: .85rem; border-bottom: 1px solid var(--line); }
.toc details[open] summary:hover { background: var(--chip); }
.toc details[open] summary:focus-visible { outline-offset: -2px; border-radius: 15px 15px 0 0; }
.toc details[open] summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.toc ol { list-style: none; margin: 0; padding: 0; font-size: .875rem; line-height: 1.45; }
.toc details > ol { max-height: min(70vh, calc(100vh - var(--header-h) - 100px)); overflow-y: auto; overscroll-behavior: contain; padding: 8px; }
.toc li { margin: 0; }
.toc a { display: block; padding: 5px 8px; border-radius: 6px; color: var(--muted); }
.toc a:hover { background: var(--chip); color: var(--fg); text-decoration: none; }
.toc .l2 a { color: var(--fg); font-weight: 600; }
.toc .l2:not(:first-child) { margin-top: 6px; }
.toc .l3 a { padding-left: 18px; }
.toc ol ol { margin: 2px 0 0; }
.toc ol ol[hidden] { display: none; }
/* A group's heading link shares its row with the button that folds the projects under it. */
.toc .row { display: flex; align-items: flex-start; gap: 2px; }
.toc .row a { flex: 1; min-width: 0; }
.toc .fold { flex: none; display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.toc .fold:hover { background: var(--chip); color: var(--fg); }
.toc .fold svg { width: 18px; height: 18px; transition: transform .15s; }
.toc .fold[aria-expanded="false"] svg { transform: rotate(-90deg); }
/* The section being read sits in a folded group: mark the group instead. */
.toc .group.active:has(> ol[hidden]) > .row > a { background: var(--chip); box-shadow: inset 2px 0 var(--accent); }
.toc .tn, .toc .td { display: block; }
.toc .td { margin-top: 1px; font-size: .78rem; color: var(--muted); }
.toc a[aria-current] .tn { color: var(--fg); }
.toc a[aria-current] { background: var(--chip); color: var(--fg); box-shadow: inset 2px 0 var(--accent); }
/* Wide enough that the card fits in the margin beside the document. */
@media (min-width: 1280px) { .toc details[open] { width: 240px; } }

/* Document */
.doc { max-width: 760px; margin: 0 auto; padding: 24px 0 40px; word-break: keep-all; overflow-wrap: break-word; }
.doc h2 { font-size: 1.55rem; line-height: 1.3; letter-spacing: -0.015em; margin: 56px 0 14px; }
.doc h3 { font-size: 1.2rem; line-height: 1.4; margin: 40px 0 8px; }
.doc h4 { font-size: 1.02rem; line-height: 1.45; margin: 28px 0 6px; }
.doc > :first-child { margin-top: 0; }
.doc .anchor { color: inherit; }
.doc .anchor:hover { text-decoration: none; }
.doc .anchor:hover::after { content: " #"; color: var(--muted); font-weight: 400; }
.doc p { margin: 8px 0; }
.doc ul { margin: 10px 0; padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--muted); }
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.doc blockquote {
  margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--accent);
  background: var(--card); border-radius: 0 10px 10px 0; color: var(--muted);
}
.doc blockquote p { margin: 0; }
.doc code { font-size: .85em; background: var(--chip); border-radius: 4px; padding: 1px 5px; }
.doc h3 code, .doc h4 code { font-size: .68em; font-weight: 500; color: var(--muted); vertical-align: 2px; margin-left: 2px; }

/* Problem / Challenge / Decision / Evidence */
.doc ul.facts { list-style: none; padding: 0; margin: 14px 0 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.doc .fact { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 0; padding: 12px 16px; }
.doc .fact + .fact { border-top: 1px solid var(--line); }
.doc .fact .k { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
@media (min-width: 640px) {
  .doc .fact { grid-template-columns: 9.5rem minmax(0, 1fr); gap: 16px; }
  .doc .fact .k { padding-top: .2rem; }
}

/* Tables */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.doc table { border-collapse: collapse; width: 100%; min-width: 600px; font-size: .9rem; line-height: 1.55; font-variant-numeric: tabular-nums; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.doc th { background: var(--chip); font-weight: 600; white-space: nowrap; }
.doc tr:last-child td { border-bottom: 0; }
.doc .pn, .doc .pd { display: block; }
.doc .pn { font-weight: 600; }
.doc .pd { margin-top: 2px; font-size: .82rem; color: var(--muted); }
@media (min-width: 640px) { .doc table.projects td:nth-child(2) { white-space: nowrap; } }
/* Phones: a 600px table would be cut off, so each row becomes a card of label · value lines. */
@media screen and (max-width: 639px) {
  .table-wrap { overflow: visible; }
  .doc table, .doc tbody, .doc tr { display: block; min-width: 0; }
  .doc thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .doc tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .doc tr:last-child { border-bottom: 0; }
  .doc td { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 12px; padding: 2px 0; border: 0; }
  .doc td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; padding-top: .15rem; }
  .doc td:first-child { display: block; margin-bottom: 4px; font-weight: 600; }
  .doc td:first-child::before { content: none; }
}

/* Footer */
.foot { margin-top: 24px; border-top: 1px solid var(--line); background: var(--card); }
.foot .wrap { padding-top: 40px; padding-bottom: 32px; }
.foot-cta { max-width: 760px; margin: 0 auto; text-align: center; }
.foot-cta h2 { margin: 0 0 6px; font-size: 1.3rem; letter-spacing: -0.01em; }
.foot-cta p { margin: 0; color: var(--muted); word-break: keep-all; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
/* 휴대폰: 아이콘+글자 버튼 셋이 한 줄에 안 들어가 2+1로 갈리므로 세로로 쌓는다 */
@media (max-width: 479px) { .foot-links { flex-direction: column; max-width: 320px; margin-inline: auto; } .foot-links .btn { justify-content: center; } }
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 10px; color: var(--fg); font-weight: 600; font-size: .95rem; transition: background-color .15s, border-color .15s; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: var(--chip); text-decoration: none; }
.btn.primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn.primary:hover { background: color-mix(in srgb, var(--fg) 85%, var(--bg)); }
.foot-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.foot-bottom a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.foot-bottom a:hover { color: var(--fg); }
@media (max-width: 639px) { .foot-bottom { justify-content: center; text-align: center; } }

/* Contact form (/contact) */
.contact { max-width: 592px; margin: 0 auto; padding: 32px 16px 48px; }
.contact h1 { margin: 0 0 6px; font-size: 1.55rem; letter-spacing: -0.015em; }
.contact .lead { color: var(--muted); margin: 0 0 24px; }
.contact form { display: grid; gap: 16px; }
.contact label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--label); }
.contact select, .contact textarea, .contact input { width: 100%; font: inherit; font-weight: 400; color: var(--fg); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
.contact textarea { resize: vertical; line-height: 1.55; }
.contact .meta { margin: 0; color: var(--muted); font-size: .85rem; }
.contact .btn { justify-self: start; cursor: pointer; font: inherit; font-weight: 600; }
.contact .btn:disabled { opacity: .6; cursor: progress; }
.contact .status { margin: 0; min-height: 1.7em; }
.contact .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Not found (/404.html) */
.notfound { padding: 64px 16px; text-align: center; }
.notfound .code { margin: 0; font-size: .85rem; font-weight: 700; letter-spacing: .1em; color: var(--muted); }
.notfound h1 { margin: 4px 0 8px; font-size: 1.55rem; letter-spacing: -0.015em; }
.notfound p { color: var(--muted); }
.notfound .foot-links { margin-top: 24px; }

/* Print / Save as PDF */
@media print {
  :root { --bg: #fff; --fg: #000; --muted: #333; --line: #ccc; --card: #fff; --chip: #f2f2f2; --accent: #000; --label: #000; }
  body { font-size: 11pt; line-height: 1.5; }
  .top { position: static; backdrop-filter: none; }
  .top nav, .toc, .skip, .foot { display: none; }
  /* On paper the contact labels alone are useless — print where they lead. */
  .links { flex-wrap: wrap; gap: 2px 16px; }
  .links a[data-print]::after { content: ": " attr(data-print); }
  .layout { display: block; }
  .doc { max-width: none; padding: 0; }
  .doc h2, .doc h3, .doc h4 { break-after: avoid; }
  .doc .fact, .doc tr, .doc blockquote { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .doc table { min-width: 0; }
  a { color: inherit; }
}
