/* Shell: a quiet catalog (after whatships.com) — every agenda brings its own material inside the stage. */
:root {
  --bg: #fafafa;
  --fg: #0b0b0c;
  --muted: #6b6b70;
  --line: #e3e3e6;
  --line-strong: #c9c9ce;
  --card: #ffffff;
  --accent: #0b0b0c;
  --sans: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0c0c0d;
  --fg: #f2f2f3;
  --muted: #9a9aa2;
  --line: #232326;
  --line-strong: #3a3a3f;
  --card: #121214;
  --accent: #f2f2f3;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0d; --fg: #f2f2f3; --muted: #9a9aa2; --line: #232326; --line-strong: #3a3a3f;
    --card: #121214; --accent: #f2f2f3; color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 15px/1.6 var(--sans); letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: break-word;
}
a { color: inherit; }
.mono { font-family: var(--mono); }
.label {
  font: 500 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 28px; height: 56px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { font: 600 13px/1 var(--mono); letter-spacing: .12em; text-decoration: none; white-space: nowrap; }
.brand b { font-weight: 600; color: var(--muted); }
.nav { display: flex; gap: 22px; }
.nav a { font: 500 12px/1 var(--mono); letter-spacing: .08em; text-decoration: none; color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--fg); }
.bar .grow { flex: 1; }
.find {
  display: flex; align-items: center; gap: 10px; width: min(280px, 32vw); height: 34px; padding: 0 12px;
  border: 1px solid var(--line-strong); background: var(--card);
  font: 500 11px/1 var(--mono); letter-spacing: .08em; color: var(--muted);
}
.find kbd { margin-left: auto; font: inherit; opacity: .7; }
.iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--fg);
}
.solid {
  white-space: nowrap; height: 34px; padding: 0 16px; display: inline-flex; align-items: center; text-decoration: none;
  background: var(--accent); color: var(--bg); font: 600 12px/1 var(--mono); letter-spacing: .08em;
}
@media (max-width: 760px) { .nav, .find { display: none; } }
@media (max-width: 420px) { .bar .solid { display: none; } }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 88px 16px 72px; }
.hero h1 {
  margin: 0 auto; max-width: 14em; font-weight: 600; letter-spacing: -0.035em;
  font-size: clamp(30px, 4.6vw, 46px); line-height: 1.12; text-wrap: balance;
}
.hero p {
  margin: 18px auto 0; max-width: 38em; font: 400 13px/1.75 var(--mono); color: var(--muted); text-wrap: balance;
}
.hero .tally { display: flex; justify-content: center; gap: 28px; margin-top: 30px; flex-wrap: wrap; }
.hero .tally div { text-align: left; }
.hero .tally strong { display: block; font: 600 22px/1.1 var(--sans); letter-spacing: -.02em; }

/* ---------- grid with crosshair corners ---------- */
.wrap { padding: 0 16px 80px; max-width: 1440px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.select {
  display: inline-flex; align-items: center; gap: 30px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); background: var(--card); font: 500 12px/1 var(--mono); letter-spacing: .08em;
}
.grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line); border-left: 1px solid var(--line); position: relative;
}
@media (max-width: 1080px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }
.cell {
  position: relative; padding: 12px 12px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  text-decoration: none; display: block;
}
.cell::before, .cell::after {
  content: ""; position: absolute; width: 9px; height: 9px; pointer-events: none;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) center / 1px 100% no-repeat,
    linear-gradient(var(--line-strong), var(--line-strong)) center / 100% 1px no-repeat;
}
.cell::before { right: -5px; bottom: -5px; }
.cell::after { left: -5px; top: -5px; }
.thumb {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #111;
  outline: 1px solid var(--line);
}
.thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.badge {
  position: absolute; left: 10px; top: 10px; z-index: 2; padding: 3px 7px;
  background: rgba(0, 0, 0, .62); color: #fff; font: 500 11px/1.2 var(--mono); letter-spacing: .02em;
}
.badge.light { background: rgba(255, 255, 255, .82); color: #111; }
.glyph {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; width: 26px; height: 26px; display: grid; place-items: center;
  background: #fff; color: #111; font: 600 12px/1 var(--mono); outline: 1px solid rgba(0,0,0,.12);
}
.play {
  position: absolute; inset: 0; margin: auto; width: 44px; height: 44px; z-index: 2; display: grid; place-items: center;
  background: rgba(10, 10, 10, .78); color: #fff; opacity: 0; transition: opacity .2s;
}
.cell:hover .play { opacity: 1; }
.cell h3 { margin: 14px 0 6px; font: 500 15px/1.4 var(--sans); letter-spacing: -.01em; }
.cell .meta { font: 500 11px/1.4 var(--mono); letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.cell.soon .thumb { background: repeating-linear-gradient(135deg, var(--card) 0 10px, var(--bg) 10px 20px); }
.cell.soon ul { position: absolute; inset: 0; margin: 0; padding: 22px 22px; list-style: none; font: 500 12px/2 var(--mono); color: var(--muted); }

/* ---------- detail ---------- */
.detail { max-width: 1060px; margin: 0 auto; padding: 36px 16px 40px; }
.detail-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.detail-top a { text-decoration: none; font: 500 14px/1 var(--sans); display: inline-flex; gap: 10px; align-items: center; }
.detail-top kbd { font: 500 10px/1 var(--mono); padding: 3px 5px; background: var(--line); color: var(--muted); }
.detail-top .glyph { position: static; }
.stage {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: #0d0d0d;
  outline: 1px solid var(--line); user-select: none;
}
@media (max-width: 640px) { .stage { aspect-ratio: 4 / 5; } }
.stage canvas, .stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.controls button, .controls label {
  height: 30px; padding: 0 12px; border: 1px solid var(--line-strong); background: var(--card); color: var(--fg);
  font: 500 11px/1 var(--mono); letter-spacing: .06em; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.controls button[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.controls input[type="range"] { width: min(360px, 60vw); accent-color: var(--fg); }
.controls .readout { font: 500 11px/1 var(--mono); color: var(--muted); letter-spacing: .06em; }

.detail h1 {
  text-align: center; margin: 44px auto 34px; max-width: 18em;
  font-weight: 600; font-size: clamp(24px, 3vw, 30px); letter-spacing: -.03em; line-height: 1.25; text-wrap: balance;
}
.facts { max-width: 680px; margin: 0 auto; border-top: 1px solid var(--line); }
.facts div { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.facts dt { margin: 0; }
.facts dd { margin: 0; text-align: right; }
@media (max-width: 520px) { .facts div { grid-template-columns: 1fr; gap: 4px; } .facts dd { text-align: left; } }

.essay { max-width: 680px; margin: 64px auto 0; font-size: 16px; line-height: 1.85; }
.essay h2 { font-size: 13px; margin: 48px 0 12px; font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.essay p { margin: 0 0 18px; }
.essay strong { font-weight: 650; }
.essay .num { font-family: var(--mono); font-weight: 600; letter-spacing: -.02em; }
.quiz { border: 1px solid var(--line-strong); background: var(--card); padding: 22px; margin: 0 0 12px; }
.quiz p { font-weight: 600; font-size: 18px; line-height: 1.5; margin: 6px 0 16px; letter-spacing: -.01em; }
.quiz button {
  display: block; width: 100%; text-align: left; padding: 12px 14px; margin: 0 0 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--fg); font: 500 15px/1.4 var(--sans);
}
.quiz button:hover { border-color: var(--fg); }
.quiz button.right { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.quiz button.wrong { text-decoration: line-through; color: var(--muted); }
.quiz .answer { display: none; margin-top: 10px; font-size: 15px; }
.quiz.done .answer { display: block; }
.essay ul { padding-left: 1.1em; margin: 0 0 18px; }
.essay li { margin-bottom: 8px; }
.tablewrap { overflow-x: auto; margin: 0 0 18px; }
.essay table { width: 100%; border-collapse: collapse; font-size: 14px; }
.essay th, .essay td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.essay th { font: 500 11px/1.4 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.essay td.r, .essay th.r { text-align: right; font-family: var(--mono); }
.essay .src a { font-family: var(--mono); }
.note { font-size: 14px; color: var(--muted); }

.more { max-width: 1440px; margin: 96px auto 0; padding: 0 16px; }
.more h2 { font: 600 14px/1 var(--sans); margin: 0 0 16px; }

footer { margin-top: 90px; padding: 26px 16px 40px; border-top: 1px solid var(--line); text-align: center; }
footer .links { margin-top: 14px; font: 500 11px/1.8 var(--mono); letter-spacing: .08em; color: var(--muted); }
footer .links a { text-decoration: none; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* category chips (index filter) */
.chip {
  height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); background: var(--card); color: var(--fg);
  font: 500 12px/1 var(--mono); letter-spacing: .04em; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.chip span { color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.chip[aria-pressed="true"] span { color: var(--bg); opacity: .7; }
#shown { margin-left: auto; }

/* ---------- book layers: hope block, method box, footnotes ---------- */
.essay .hope { margin: 44px 0 0; padding: 18px 22px 4px; border-left: 3px solid var(--fg); background: var(--card); }
.essay .hope h2 { margin: 0 0 10px; }
.essay .hope p { margin: 0 0 14px; }
.essay .method { margin: 56px 0 0; padding: 18px 22px 8px; border: 1px solid var(--line-strong); background: var(--card); font-size: 14px; line-height: 1.7; }
.essay .method h2 { margin: 0 0 12px; }
.essay .method dl { margin: 0; }
.essay .method dl > div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.essay .method dt { font: 500 11px/1.9 var(--mono); letter-spacing: .08em; color: var(--muted); }
.essay .method dd { margin: 0; }
.essay .method b { font: 500 11px/1 var(--mono); letter-spacing: .06em; color: var(--muted); margin-right: 6px; }
.essay .method .tech { display: inline-block; margin: 0 6px 6px 0; padding: 0 9px; border: 1px solid var(--line-strong); font-size: 13px; line-height: 1.7; cursor: help; }
@media (max-width: 520px) { .essay .method dl > div { grid-template-columns: 1fr; gap: 2px; } }
.essay sup.fn { margin-left: 1px; font: 500 10px/0 var(--mono); }
.essay sup.fn a { padding: 0 1px; color: var(--muted); text-decoration: none; }
.essay sup.fn a:hover, .essay .notes .back:hover { color: var(--fg); }
.essay .notes ol { margin: 0 0 18px; padding-left: 1.6em; font-size: 13px; line-height: 1.7; color: var(--muted); }
.essay .notes li { margin-bottom: 6px; }
.essay .notes a { color: var(--fg); text-underline-offset: 2px; }
.essay .notes .back { margin-left: 4px; color: var(--muted); text-decoration: none; }

/* ---------- contents: the book's table of contents as the hub ---------- */
body[data-page="contents"] {
  --bg: #f4f1e9; --card: #fbf9f3; --line: #e0dbcd; --line-strong: #c4bca8; --muted: #77705f; --ink-soft: #3a3630;
  --serif: "Nanum Myeongjo", "AppleMyungjo", serif;
}
:root[data-theme="dark"] body[data-page="contents"] {
  --bg: #12110f; --card: #1a1916; --line: #2a2823; --line-strong: #45413a; --muted: #9a937f; --ink-soft: #d6d1c4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-page="contents"] {
    --bg: #12110f; --card: #1a1916; --line: #2a2823; --line-strong: #45413a; --muted: #9a937f; --ink-soft: #d6d1c4;
  }
}
.toc { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.toc-head { padding: 84px 0 56px; border-bottom: 1px solid var(--fg); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 48px; align-items: end; }
.toc-head .label { grid-column: 1 / -1; margin: 0 0 18px; }
.toc-head .draft { margin-left: 10px; padding: 2px 7px; border: 1px solid var(--line-strong); letter-spacing: .04em; }
.toc-head h1 { margin: 0; font: 700 clamp(40px, 6.4vw, 76px)/1.08 var(--serif); letter-spacing: -.04em; }
.toc-head .sub { grid-column: 1; margin: 22px 0 0; max-width: 30em; font-size: 16px; line-height: 1.7; color: var(--ink-soft); }
.toc-head .stat { grid-column: 2; grid-row: 2 / 4; margin: 0; display: grid; grid-template-columns: repeat(4, auto); gap: 0; border-left: 1px solid var(--line); }
.toc-head .stat div { padding: 0 22px; border-right: 1px solid var(--line); }
.toc-head .stat dd { margin: 6px 0 0; font: 600 30px/1 var(--mono); letter-spacing: -.04em; }
@media (max-width: 860px) {
  .toc-head { grid-template-columns: 1fr; padding: 56px 0 36px; }
  .toc-head .stat { grid-column: 1; grid-row: auto; margin-top: 28px; border-left: 0; }
  .toc-head .stat div:first-child { padding-left: 0; }
  .toc-head .stat dd { font-size: 24px; }
}
@media (max-width: 400px) { .toc-head .stat div { padding: 0 12px; } }

.toc-body { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 64px; align-items: start; }
@media (max-width: 1000px) { .toc-body { grid-template-columns: 1fr; } .peek { display: none; } }

.legend { position: sticky; top: 56px; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 14px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.legend button {
  height: 28px; padding: 0 10px; display: inline-flex; gap: 6px; align-items: center; cursor: pointer;
  border: 1px solid var(--line-strong); background: transparent; color: var(--fg); font: 500 12px/1 var(--sans);
}
.legend button span { font-family: var(--mono); color: var(--muted); }
.legend button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.legend button[aria-pressed="true"] span { color: var(--bg); }
.legend .hint { margin-left: auto; text-transform: none; letter-spacing: .02em; }
@media (max-width: 560px) { .legend .hint { display: none; } }

.part { padding: 44px 0 8px; border-bottom: 1px solid var(--line); }
.part ol { list-style: none; margin: 0; padding: 0; }
.ph { display: grid; grid-template-columns: 64px auto 1fr auto; align-items: baseline; gap: 0 14px; margin: 0 0 6px; font-weight: 400; }
.ph .pn { grid-row: 1 / 3; font: 700 52px/0.9 var(--serif); letter-spacing: -.04em; }
.ph .pk { font: 500 11px/1 var(--mono); letter-spacing: .12em; color: var(--muted); align-self: end; }
.ph .pt { grid-column: 2 / 4; font: 700 clamp(21px, 2.4vw, 26px)/1.3 var(--serif); letter-spacing: -.03em; }
.ph .pc { grid-column: 4; grid-row: 1; font: 500 11px/1 var(--mono); letter-spacing: .08em; color: var(--muted); }
.prologue .ph, .epilogue .ph { grid-template-columns: 64px 1fr; }
.prologue .ph .pn, .epilogue .ph .pn, .appendix .ph .pn { font-size: 34px; color: var(--muted); }
.prologue .ph .pt, .epilogue .ph .pt { grid-column: 2; align-self: center; font-size: 19px; }
.plead { margin: 8px 0 18px 78px; max-width: 34em; font-size: 14px; line-height: 1.7; color: var(--muted); }
@media (max-width: 560px) {
  .ph { grid-template-columns: 44px auto 1fr auto; }
  .ph .pn { font-size: 38px; }
  .prologue .ph, .epilogue .ph { grid-template-columns: 44px 1fr; }
  .plead { margin-left: 0; }
}

.entry {
  display: flex; align-items: baseline; gap: 0; padding: 11px 0 11px 78px; position: relative;
  text-decoration: none; color: var(--fg); border-top: 1px solid transparent; transition: color .15s, opacity .15s;
}
.part li + li .entry { border-top-color: color-mix(in srgb, var(--line) 60%, transparent); }
.entry .ord { position: absolute; left: 0; width: 64px; text-align: right; padding-right: 14px; font: 500 13px/1.6 var(--mono); color: var(--muted); }
.entry .t { flex: 0 1 auto; font: 500 17px/1.55 var(--sans); letter-spacing: -.015em; }
.entry .lead { flex: 1 1 32px; min-width: 32px; margin: 0 12px; align-self: flex-end; transform: translateY(-.5em); border-bottom: 1.5px dotted var(--line-strong); }
.entry .mk { width: 1.4em; text-align: center; font: 500 12px/1 var(--mono); color: var(--muted); }
.entry .pg { min-width: 2.2em; text-align: right; font: 500 14px/1 var(--mono); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.entry .pg.wip { min-width: 0; font: 500 12px/1 var(--sans); color: var(--muted); letter-spacing: 0; }
.entry.off { cursor: default; }
.entry.off .t { color: var(--muted); font-family: var(--serif); font-weight: 700; }
a.entry:hover .lead, a.entry.on .lead { border-bottom-style: solid; border-bottom-color: var(--fg); }
a.entry.on .ord, a.entry:hover .ord { color: var(--fg); }
a.entry.on::before { content: ""; position: absolute; left: 70px; top: 50%; width: 3px; height: 1.1em; margin-top: -.55em; background: var(--fg); }
a.entry:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.entry.dim { opacity: .28; }
@media (max-width: 560px) {
  .entry { padding-left: 44px; }
  .entry .ord { width: 40px; padding-right: 10px; font-size: 12px; }
  .entry .t { font-size: 16px; }
  .entry .lead { margin: 0 8px; min-width: 16px; flex-basis: 16px; }
  a.entry.on::before { left: 38px; }
}

.appendix .ap { columns: 2 300px; column-gap: 40px; margin: 0 0 24px; }
.appendix .ag { break-inside: avoid; margin: 0 0 22px; }
.appendix h3 { margin: 0 0 4px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font: 600 13px/1.4 var(--sans); }
.appendix h3 span { font: 500 11px/1 var(--mono); color: var(--muted); margin-left: 4px; }
.entry.sm { padding: 7px 0; }
.entry.sm .ord { display: none; }
.entry.sm .t { font-size: 14px; }
.entry.sm .lead { margin: 0 8px; }
.entry.sm .pg { font-size: 12px; color: var(--muted); }
.appendix a.entry.on::before { display: none; }

.peek { position: sticky; top: 80px; padding: 30px 0 30px; }
.pv-stage { position: relative; aspect-ratio: 4 / 3; overflow: hidden; outline: 1px solid var(--line); background: #111; transition: background .25s; }
.pv-host { position: absolute; inset: 0; }
.pv-host canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pv-meta { padding: 18px 0 0; }
.pv-meta .label { margin: 0 0 8px; }
.pv-meta h2 { margin: 0 0 10px; font: 700 21px/1.35 var(--serif); letter-spacing: -.03em; text-wrap: balance; }
.pv-meta > p:not(.label) { margin: 0 0 16px; font-size: 14px; line-height: 1.7; color: var(--ink-soft); }
.pv-meta dl { margin: 0; border-top: 1px solid var(--line); }
.pv-meta dl div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pv-meta dt, .pv-meta dd { margin: 0; }
.pv-go {
  display: flex; justify-content: space-between; align-items: center; margin-top: 18px; height: 44px; padding: 0 16px;
  background: var(--fg); color: var(--bg); text-decoration: none; font: 600 13px/1 var(--sans);
}
.entry .t small { font-size: 14px; font-weight: 400; color: var(--muted); letter-spacing: -.01em; }
.entry .t small::before { content: "— "; }
.entry.sm .t small { display: none; }
.pv-meta .pv-s { margin: -4px 0 12px !important; font: 400 15px/1.5 var(--serif) !important; color: var(--muted) !important; }
.entry .ord { line-height: 26.4px; }
.entry.sm .t small { display: none; }
@media (max-width: 560px) { .entry .ord { line-height: 24.8px; } }

/* Way back to the host site */
.siteback { margin: 0 -18px 0 -6px; padding: 14px 10px; font: 500 15px/1 var(--mono); text-decoration: none; color: var(--muted); }
.siteback:hover { color: var(--fg); }
