@font-face { font-family: "HBIOS SYS"; src: url("./assets/fonts/HBIOS-SYS-prop.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "DOS Gothic"; src: url("./assets/fonts/DOSGothic.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "DOS Iyagi"; src: url("./assets/fonts/DOSIyagiBoldface.ttf") format("truetype"); font-display: swap; font-weight: 700 900; }
@font-face { font-family: "DOS Myungjo"; src: url("./assets/fonts/DOSMyungjo.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "DOS Pilgi"; src: url("./assets/fonts/DOSPilgi.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "DOS Saemmul"; src: url("./assets/fonts/DOSSaemmul.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Hangang"; src: url("./assets/fonts/Hangang.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Neo Dunggeunmo"; src: url("./assets/fonts/NeoDunggeunmoPro-Regular.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Sam3KR"; src: url("./assets/fonts/Sam3KRFont.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Seoul"; src: url("./assets/fonts/Seoul.ttf") format("truetype"); font-display: swap; }

:root {
  --paper: #f0e7cf;
  --paper-deep: #dfd0ac;
  --ink: #172321;
  --muted: #64706c;
  --blue: #124f86;
  --blue-deep: #092f57;
  --cyan: #65d8e5;
  --yellow: #f5c84c;
  --red: #b43b32;
  --green: #2f7c62;
  --screen: #061d41;
  --screen-text: #f5f1d5;
  --line: rgba(23, 35, 33, 0.2);
  --shadow: 0 16px 48px rgba(12, 29, 30, 0.16);
  --sidebar: 286px;
  --topbar: 72px;
  --font-scale: 1.1;
  --font-dos: "HBIOS SYS", "DOS Gothic", monospace;
  --font-gothic: "DOS Gothic", "Malgun Gothic", sans-serif;
  --font-title: "DOS Iyagi", "DOS Gothic", sans-serif;
  --font-body: "DOS Myungjo", "Batang", serif;
  --font-note: "DOS Pilgi", "DOS Myungjo", serif;
  --font-friendly: "DOS Saemmul", "DOS Gothic", sans-serif;
  --font-editorial: "Hangang", "DOS Myungjo", serif;
  --font-pixel: "Neo Dunggeunmo", "DOS Gothic", monospace;
  --font-win: "Sam3KR", "DOS Gothic", sans-serif;
  --font-mac: "Seoul", "DOS Gothic", sans-serif;
  --font-ui: var(--font-mac);
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

html { max-width: 100%; overflow-x: hidden; scroll-behavior: smooth; }

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(23, 35, 33, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 35, 33, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 4px 4px, 4px 4px, auto;
}

button, input, textarea { font: inherit; }
button { color: inherit; }

button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 200;
  left: 16px;
  top: -80px;
  padding: 12px 18px;
  background: var(--ink);
  color: white;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.boot-screen {
  position: fixed;
  z-index: 999;
  inset: 0;
  display: grid;
  place-items: center;
  background: #030b17;
  color: #9ce7db;
  font: 16px/1.8 "Consolas", "Courier New", monospace;
  transition: opacity 350ms ease, visibility 350ms ease;
}
.boot-screen.done { opacity: 0; visibility: hidden; }
.boot-copy { width: min(560px, calc(100% - 48px)); }
.boot-copy p { margin: 0; }
.boot-cursor { animation: blink 650ms steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.topbar {
  position: fixed;
  z-index: 50;
  inset: 0 0 auto 0;
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  color: white;
  background: var(--blue-deep);
  border-bottom: 4px solid var(--cyan);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.16);
}

.brand {
  border: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: white;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--yellow);
  color: var(--yellow);
  font: 800 19px/1 Georgia, serif;
  transform: rotate(-2deg);
}
.brand strong { display: block; font: 800 16px/1.05 "Consolas", monospace; letter-spacing: .04em; }
.brand small { display: block; margin-top: 5px; color: #b8d7e1; font: 10px/1 monospace; letter-spacing: .08em; }

.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.theme-switch { display: flex; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.45); padding: 2px; background: rgba(0,0,0,.24); }
.theme-switch button { border: 0; padding: 7px 9px; color: inherit; background: transparent; cursor: pointer; font: 10px/1 var(--font-pixel); white-space: nowrap; }
.theme-switch button.active { color: var(--blue-deep); background: white; }
.font-scale-control { display: flex; flex: 0 0 auto; border: 1px solid rgba(255,255,255,.45); padding: 2px; background: rgba(0,0,0,.24); }
.font-scale-control button, .font-scale-control select { min-width: 30px; border: 0; padding: 7px 6px; color: inherit; background: transparent; cursor: pointer; font: 10px/1 var(--font-pixel); white-space: nowrap; }
.font-scale-control #font-scale-select { min-width: 68px; border-inline: 1px solid rgba(255,255,255,.35); text-align: center; }
.search-box {
  width: min(30vw, 360px);
  height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: #b8d7e1;
  background: rgba(1, 10, 25, .42);
  border: 1px solid rgba(255,255,255,.22);
}
.search-box input { width: 100%; border: 0; outline: 0; color: white; background: transparent; }
.search-box input::placeholder { color: #9db6c1; }
.progress-chip { min-width: 104px; border: 0; padding: 8px 10px; color: white; background: transparent; cursor: pointer; }
.progress-chip > span:first-child { display: block; text-align: right; font: 700 12px monospace; }
.progress-track { display: block; height: 4px; margin-top: 5px; background: rgba(255,255,255,.2); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--yellow); transition: width .3s ease; }

.sidebar {
  position: fixed;
  z-index: 40;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  width: var(--sidebar);
  overflow-y: auto;
  background: #e4d8ba;
  border-right: 1px solid var(--line);
}
.book-plate { display: flex; gap: 13px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.plate-year { writing-mode: vertical-rl; color: var(--red); font: 800 12px/1 monospace; letter-spacing: .14em; }
.book-plate p { margin: 0; font: 12px/1.55 Georgia, "Batang", serif; }

.chapter-nav { border-bottom: 1px solid var(--line); }
.chapter-button {
  width: 100%;
  display: grid;
  grid-template-columns: 36px 1fr 18px;
  align-items: center;
  gap: 8px;
  border: 0;
  padding: 15px 18px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.chapter-button:hover, .chapter-button.active { background: rgba(255,255,255,.48); }
.chapter-no { color: var(--red); font: 800 19px/1 Georgia, serif; }
.chapter-button strong { display: block; font-size: 13px; }
.chapter-button small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.chapter-arrow { font-size: 11px; transition: transform .2s ease; }
.chapter-nav.open .chapter-arrow { transform: rotate(90deg); }
.lesson-list { display: none; margin: 0; padding: 0 12px 12px 54px; list-style: none; }
.chapter-nav.open .lesson-list { display: block; }
.lesson-list button { width: 100%; border: 0; padding: 7px 8px; color: #46514e; background: transparent; text-align: left; font-size: 11px; line-height: 1.4; cursor: pointer; }
.lesson-list button:hover, .lesson-list button.active { color: var(--blue); background: rgba(255,255,255,.45); }
.lesson-list button.completed::before { content: "✓ "; color: var(--green); font-weight: 800; }

.sidebar-foot { padding: 14px; }
.side-action { width: 100%; border: 0; border-bottom: 1px dashed var(--line); padding: 10px 8px; background: transparent; text-align: left; font-size: 12px; cursor: pointer; }
.side-action:hover { color: var(--blue); }

main { min-height: 100vh; margin-left: var(--sidebar); padding-top: var(--topbar); }
.view { width: min(1180px, calc(100% - 64px)); margin: 0 auto; padding: 54px 0 80px; }

.hero { position: relative; display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; min-height: calc(100vh - 190px); }
.kicker { margin: 0 0 18px; color: var(--red); font: 800 12px/1 monospace; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { max-width: 720px; margin: 0; font: 800 clamp(42px, 6.2vw, 84px)/.94 Georgia, "Batang", serif; letter-spacing: -.055em; }
.hero h1 span { display: block; color: var(--blue); }
.hero-deck { max-width: 660px; margin: 25px 0 0; color: #3e4b48; font: 17px/1.82 Georgia, "Batang", serif; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.primary-button, .secondary-button {
  border: 2px solid var(--ink);
  padding: 13px 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
}
.primary-button { color: white; background: var(--blue); }
.secondary-button { background: var(--paper); }
.primary-button:hover, .secondary-button:hover { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }

.book-cover {
  position: relative;
  width: min(340px, 90%);
  aspect-ratio: .72;
  margin: auto;
  padding: 34px 28px;
  color: #f9edbd;
  background: var(--blue-deep);
  border: 8px double #f9edbd;
  box-shadow: 18px 20px 0 rgba(23,35,33,.18), var(--shadow);
  transform: rotate(1.2deg);
}
.book-cover::after { content: ""; position: absolute; left: 17px; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.22); }
.cover-top { font: 12px/1.5 monospace; letter-spacing: .11em; }
.cover-title { margin: 72px 0 16px; font: 800 clamp(36px,5vw,58px)/.9 Georgia, serif; }
.cover-title em { display: block; color: var(--cyan); font-style: normal; }
.cover-rule { width: 64px; height: 7px; margin: 24px 0; background: var(--yellow); }
.cover-meta { position: absolute; left: 28px; right: 28px; bottom: 30px; display: flex; justify-content: space-between; font: 11px/1.5 monospace; }

.chapter-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-top: 58px; }
.chapter-card { min-height: 210px; border: 1px solid var(--line); padding: 18px; background: rgba(255,255,255,.32); cursor: pointer; transition: transform .2s, box-shadow .2s; }
.chapter-card:hover { transform: translateY(-4px); box-shadow: 0 10px 0 rgba(23,35,33,.1); }
.chapter-card .big-no { color: var(--red); font: 800 38px/1 Georgia, serif; }
.chapter-card h2 { margin: 36px 0 10px; font: 800 17px/1.3 Georgia, "Batang", serif; }
.chapter-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

.page-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; padding-bottom: 26px; border-bottom: 3px double var(--ink); }
.eyebrow { margin: 0 0 10px; color: var(--red); font: 800 11px/1 monospace; letter-spacing: .12em; }
.page-head h1 { margin: 0; font: 800 clamp(32px,5vw,58px)/1.06 Georgia, "Batang", serif; letter-spacing: -.035em; }
.page-lead { max-width: 750px; margin: 16px 0 0; color: #46514e; font: 16px/1.8 Georgia, "Batang", serif; }
.page-stamp { width: 94px; height: 94px; display: grid; place-items: center; border: 3px double var(--red); border-radius: 50%; color: var(--red); font: 800 11px/1.25 monospace; text-align: center; transform: rotate(6deg); }

.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 48px; margin-top: 34px; }
.lesson-body { min-width: 0; }
.lesson-body h2 { margin: 44px 0 16px; font: 800 25px/1.25 Georgia, "Batang", serif; }
.lesson-body h3 { margin: 30px 0 12px; font-size: 17px; }
.lesson-body p, .lesson-body li { font: 15px/1.85 Georgia, "Batang", serif; }
.lesson-body ul, .lesson-body ol { padding-left: 22px; }
.lesson-body code { padding: 2px 5px; color: var(--blue-deep); background: rgba(18,79,134,.1); font-family: Consolas, monospace; font-size: .92em; }
.margin-note { position: sticky; top: 106px; align-self: start; }
.note-card { margin-bottom: 14px; border-top: 4px solid var(--ink); padding: 14px 3px; }
.note-card strong { display: block; margin-bottom: 8px; font: 800 11px/1 monospace; letter-spacing: .08em; }
.note-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }

.manual-box, .warning-box, .modern-box {
  margin: 24px 0;
  padding: 18px 20px;
  border-left: 6px solid var(--blue);
  background: rgba(255,255,255,.42);
}
.warning-box { border-color: var(--red); }
.modern-box { border-color: var(--green); }
.manual-box strong, .warning-box strong, .modern-box strong { display: block; margin-bottom: 7px; font-size: 12px; }
.manual-box p, .warning-box p, .modern-box p { margin: 0; font-size: 13px; line-height: 1.75; }

.flow-diagram { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin: 25px 0; }
.flow-step { position: relative; padding: 16px 10px; border: 1px solid var(--ink); background: rgba(255,255,255,.38); text-align: center; font: 800 11px/1.45 monospace; }
.flow-step:not(:last-child)::after { content: "▶"; position: absolute; z-index: 2; right: -11px; top: 50%; padding: 2px; color: var(--red); background: var(--paper); transform: translateY(-50%); }

.code-card { width: 100%; max-width: 100%; overflow: hidden; margin: 22px 0; border: 1px solid var(--ink); background: var(--screen); box-shadow: 6px 6px 0 rgba(23,35,33,.13); }
.code-card-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 13px; color: var(--screen-text); background: var(--blue); font: 11px/1 monospace; }
.code-card-head button { border: 1px solid rgba(255,255,255,.4); padding: 5px 8px; color: white; background: transparent; cursor: pointer; }
.code-card pre { margin: 0; padding: 18px; overflow: auto; color: #e8f4dc; font: 13px/1.65 Consolas, "Courier New", monospace; tab-size: 4; }
.lesson-body .code-card code { padding: 0; color: inherit; background: transparent; font: inherit; }
.token-keyword { color: #7de2ee; }
.token-string { color: #f2ce66; }
.token-comment { color: #85a799; }

.lesson-complete { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 46px; padding-top: 24px; border-top: 1px solid var(--line); }
.lesson-complete label { display: flex; align-items: center; gap: 9px; font-weight: 800; }

.sandbox { margin-top: 26px; border: 2px solid var(--ink); background: #d8cba8; box-shadow: 9px 9px 0 rgba(23,35,33,.14); }
.sandbox-titlebar { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; color: white; background: var(--blue); font: 12px/1 monospace; }
.sandbox-lights { display: flex; gap: 5px; }
.sandbox-lights i { width: 9px; height: 9px; display: block; border: 1px solid white; }
.sandbox-lights i:nth-child(1) { background: var(--red); }
.sandbox-lights i:nth-child(2) { background: var(--yellow); }
.sandbox-lights i:nth-child(3) { background: var(--green); }
.sandbox-menubar { display: flex; gap: 20px; padding: 7px 12px; color: white; background: #127ca2; font: 11px/1 monospace; }
.sandbox-grid { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(280px,.7fr); min-height: 440px; }
.editor-pane { position: relative; display: grid; grid-template-columns: 44px 1fr; background: #f4eed7; border-right: 2px solid var(--ink); }
.line-numbers { padding: 15px 8px; color: #8b8d7f; background: #ded5b9; text-align: right; white-space: pre; user-select: none; font: 13px/1.55 Consolas, monospace; }
.code-editor { width: 100%; min-height: 390px; border: 0; outline: 0; resize: vertical; padding: 15px; color: #182622; background: transparent; font: 13px/1.55 Consolas, monospace; tab-size: 4; white-space: pre; }
.output-pane { display: flex; flex-direction: column; min-width: 0; background: var(--screen); }
.output-head { display: flex; justify-content: space-between; padding: 10px 12px; color: #b8d7e1; border-bottom: 1px solid #22507b; font: 11px/1 monospace; }
.dos-output { flex: 1; min-height: 230px; margin: 0; padding: 14px; overflow: auto; color: var(--screen-text); font: 13px/1.55 Consolas, monospace; white-space: pre-wrap; }
.stdin-wrap { display: block; padding: 10px 12px; color: #9db6c1; border-top: 1px solid #22507b; font: 10px/1.4 monospace; }
.stdin-wrap input { width: 100%; margin-top: 6px; border: 1px solid #3e6990; padding: 8px; color: white; background: #03142e; font: 12px/1 monospace; }
.sandbox-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 11px; border-top: 1px solid var(--ink); }
.run-button { border: 1px solid var(--ink); padding: 9px 14px; color: white; background: var(--red); font-weight: 800; cursor: pointer; }
.tool-button { border: 1px solid var(--ink); padding: 8px 11px; background: var(--paper); cursor: pointer; }
.shortcut-hint { margin-left: auto; color: var(--muted); font: 10px/1 monospace; }
kbd { border: 1px solid currentColor; padding: 2px 5px; background: rgba(255,255,255,.2); font: 10px/1.2 monospace; box-shadow: 1px 1px 0 currentColor; }

.v86-shell { margin: 22px 0; border: 2px solid var(--ink); background: #050d1d; box-shadow: 9px 9px 0 rgba(23,35,33,.14); }
.v86-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; color: #d5e4df; background: #d8cba8; border-bottom: 2px solid var(--ink); }
.v86-toolbar #v86-status { margin-left: auto; color: var(--ink); font: 10px/1.4 Consolas, monospace; }
.v86-root { display: grid; place-items: center; width: 100%; min-height: 480px; overflow: auto; color: #d5e4df; background: #000; outline: 0; }
.v86-root:focus { box-shadow: inset 0 0 0 3px #27a9ca; }
.v86-root:fullscreen { min-height: 100vh; }
.v86-root canvas { max-width: 100%; height: auto; image-rendering: pixelated; }
.v86-text-screen { white-space: pre; font: 14px/14px monospace; }
.v86-canvas { display: none; }
.v86-placeholder { padding: 30px; color: #9db6c1; text-align: center; font: 12px/1.6 Consolas, monospace; }
.advanced-dos { margin: 28px 0; border: 1px solid var(--ink); background: rgba(255,255,255,.3); }
.advanced-dos summary { padding: 14px 16px; color: var(--blue-deep); cursor: pointer; font: 800 12px/1.4 monospace; }
.dos-loader { padding: 0 16px 16px; }
.jsdos-root { display: grid; place-items: center; height: 600px; max-height: 70vh; border: 2px solid var(--ink); color: #9db6c1; background: #050d1d; font: 12px/1.5 monospace; }

.mission-card { margin-top: 26px; border: 2px solid var(--red); padding: 18px; background: rgba(255,255,255,.36); }
.mission-card h3 { margin: 0 0 8px; font: 800 19px/1.3 Georgia, "Batang", serif; }
.mission-badge { display: inline-block; margin-bottom: 10px; padding: 4px 7px; color: white; background: var(--red); font: 800 9px/1 monospace; letter-spacing: .08em; }
.mission-checks { display: grid; gap: 6px; margin: 13px 0; padding: 0; list-style: none; }
.mission-checks li { font: 12px/1.5 monospace; }
.mission-checks li::before { content: "□ "; color: var(--red); }
.mission-result { min-height: 22px; margin-top: 10px; font-size: 12px; font-weight: 800; }
.mission-result.pass { color: var(--green); }
.mission-result.fail { color: var(--red); }

.reference-toolbar { position: sticky; z-index: 10; top: calc(var(--topbar) + 4px); display: flex; flex-wrap: wrap; gap: 9px; margin: 25px 0; padding: 12px; background: rgba(240,231,207,.94); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.reference-toolbar input, .reference-toolbar select { border: 1px solid var(--ink); padding: 9px 11px; background: #fffaf0; }
.reference-toolbar input { flex: 1; min-width: 220px; }
.reference-count { align-self: center; color: var(--muted); font: 11px/1 monospace; }
.reference-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.reference-card { border: 1px solid var(--line); padding: 16px; background: rgba(255,255,255,.36); cursor: pointer; }
.reference-card:hover { border-color: var(--blue); background: rgba(255,255,255,.65); }
.reference-card-head { display: flex; justify-content: space-between; gap: 12px; }
.reference-card h3 { margin: 0; color: var(--blue); font: 800 20px/1 Consolas, monospace; }
.header-tag, .status-tag { display: inline-block; padding: 4px 6px; background: var(--ink); color: white; font: 9px/1 monospace; }
.status-tag.ansi { background: var(--green); }
.status-tag.borland { background: var(--red); }
.reference-card p { margin: 12px 0 0; color: #46514e; font-size: 12px; line-height: 1.6; }
.reference-detail { max-width: 900px; }
.prototype { margin: 18px 0; padding: 14px; color: #e8f4dc; background: var(--screen); font: 13px/1.6 Consolas, monospace; overflow: auto; }
.fact-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 18px 0; }
.fact { padding: 12px; border-top: 3px solid var(--ink); background: rgba(255,255,255,.32); }
.fact small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.fact strong { display: block; margin-top: 6px; font-size: 12px; }

.utility-table { width: 100%; border-collapse: collapse; margin: 24px 0; background: rgba(255,255,255,.28); }
.utility-table th, .utility-table td { border: 1px solid var(--line); padding: 12px; text-align: left; vertical-align: top; font-size: 12px; line-height: 1.6; }
.utility-table th { color: white; background: var(--blue-deep); font: 800 11px/1.3 monospace; }
.utility-table code { color: var(--blue-deep); font-family: Consolas, monospace; }

.search-panel { position: fixed; z-index: 80; top: var(--topbar); right: 24px; width: min(560px, calc(100% - 48px)); max-height: min(70vh, 680px); overflow: auto; border: 2px solid var(--ink); background: #fffaf0; box-shadow: var(--shadow); }
.search-panel-head { position: sticky; top: 0; display: flex; justify-content: space-between; padding: 12px 14px; color: white; background: var(--blue-deep); }
.search-result { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 13px 15px; background: transparent; text-align: left; cursor: pointer; }
.search-result:hover { background: var(--paper); }
.search-result small { display: block; margin-bottom: 4px; color: var(--red); font: 9px/1 monospace; }
.search-result strong { display: block; }
.search-result span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.empty-state { padding: 42px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; z-index: 120; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 16px; color: white; background: var(--ink); box-shadow: 5px 5px 0 rgba(23,35,33,.22); opacity: 0; transform: translateY(20px); pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-only { display: none; }

/* Supplied Korean type collection: printed guide, UI chrome, notes and DOS screen. */
body, button, input, textarea, select { font-family: var(--font-ui); }
.hero h1, .page-head h1, .chapter-card h2, .lesson-body h2, .mission-card h3, .cover-title { font-family: var(--font-title); }
.lesson-body p, .lesson-body li, .reference-detail > p, .reference-detail > ul, .hero-deck { font-family: var(--font-body); }
.hero-deck { font-family: var(--font-editorial); }
.page-lead { font-family: var(--font-friendly); }
.book-plate p, .note-card p { font-family: var(--font-note); }
.chapter-button strong, .chapter-button small, .lesson-list button, .reference-card p, .utility-table td { font-family: var(--font-gothic); }
.kicker, .eyebrow, .brand strong, .brand small, .plate-year, .chapter-no, .page-stamp, .cover-top, .cover-meta,
.code-card-head, .code-card pre, .prototype, .line-numbers, .code-editor, .dos-output, .output-head, .stdin-wrap,
.sandbox-titlebar, .sandbox-menubar, .mission-badge, .mission-checks li, .reference-count, .reference-card h3,
.header-tag, .status-tag, .utility-table th, .v86-toolbar #v86-status, .v86-placeholder, .jsdos-root, .boot-screen {
  font-family: var(--font-dos);
}
#v86-root .v86-text-screen { font-family: var(--font-dos) !important; font-size: 16px !important; line-height: 16px !important; }
.primary-button, .secondary-button, .run-button, .tool-button, .side-action, .theme-switch button { font-family: var(--font-pixel); }

/* User-adjustable type scale. Every fixed guide size follows this single factor. */
body { font-size: calc(16px * var(--font-scale)); }
.mission-badge, .header-tag, .status-tag, .fact small, .search-result small { font-size: calc(9px * var(--font-scale)); }
.brand small, .theme-switch button, .font-scale-control button, .font-scale-control select, .chapter-button small, .stdin-wrap, .shortcut-hint, kbd, .v86-toolbar #v86-status { font-size: calc(10px * var(--font-scale)); }
.chapter-arrow, .lesson-list button, .cover-meta, .eyebrow, .page-stamp, .note-card strong, .flow-step, .code-card-head,
.sandbox-menubar, .output-head, .reference-count, .utility-table th, .search-result span { font-size: calc(11px * var(--font-scale)); }
.progress-chip > span:first-child, .plate-year, .book-plate p, .side-action, .kicker, .cover-top, .chapter-card p,
.manual-box strong, .sandbox-titlebar, .v86-placeholder, .advanced-dos summary, .jsdos-root, .mission-checks li,
.mission-result, .reference-card p, .fact strong, .utility-table td { font-size: calc(12px * var(--font-scale)); }
.chapter-button strong, .manual-box p, .warning-box p, .modern-box p, .code-card pre, .line-numbers, .code-editor, .dos-output,
.prototype { font-size: calc(13px * var(--font-scale)); }
.v86-text-screen { font-size: calc(14px * var(--font-scale)); line-height: calc(14px * var(--font-scale)); }
.lesson-body p, .lesson-body li { font-size: calc(15px * var(--font-scale)); }
.boot-screen, .brand strong, .page-lead { font-size: calc(16px * var(--font-scale)); }
.hero-deck, .chapter-card h2, .lesson-body h3 { font-size: calc(17px * var(--font-scale)); }
.brand-mark, .chapter-no, .mission-card h3 { font-size: calc(19px * var(--font-scale)); }
.reference-card h3 { font-size: calc(20px * var(--font-scale)); }
.lesson-body h2 { font-size: calc(25px * var(--font-scale)); }
.chapter-card .big-no { font-size: calc(38px * var(--font-scale)); }
.hero h1 { font-size: clamp(calc(42px * var(--font-scale)), calc(6.2vw * var(--font-scale)), calc(84px * var(--font-scale))); }
.page-head h1 { font-size: clamp(calc(32px * var(--font-scale)), calc(5vw * var(--font-scale)), calc(58px * var(--font-scale))); }
.cover-title { font-size: clamp(calc(36px * var(--font-scale)), calc(5vw * var(--font-scale)), calc(58px * var(--font-scale))); }
#v86-root .v86-text-screen { font-size: calc(16px * var(--font-scale)) !important; line-height: calc(16px * var(--font-scale)) !important; }

/* Macintosh 1984: monochrome menu bar, one-bit desktop pattern and framed document windows. */
html[data-theme="mac1984"] {
  --paper: #ffffff;
  --paper-deep: #d9d9d9;
  --ink: #000000;
  --muted: #3f3f3f;
  --blue: #000000;
  --blue-deep: #000000;
  --cyan: #000000;
  --yellow: #000000;
  --red: #000000;
  --green: #000000;
  --screen: #000000;
  --screen-text: #ffffff;
  --line: rgba(0,0,0,.36);
  --shadow: 7px 7px 0 #000;
  --font-ui: var(--font-mac);
  --font-gothic: var(--font-mac);
  --font-title: var(--font-mac);
  --font-body: var(--font-mac);
  --font-note: var(--font-mac);
  --font-friendly: var(--font-mac);
  --font-editorial: var(--font-mac);
  --font-pixel: var(--font-mac);
  color-scheme: light;
}
html[data-theme="mac1984"] body {
  background-color: #d8d8d8;
  background-image: repeating-conic-gradient(#c8c8c8 0 25%, #f3f3f3 0 50%);
  background-size: 4px 4px;
}
html[data-theme="mac1984"] .topbar { color: #000; background: #fff; border-bottom: 2px solid #000; box-shadow: 0 2px 0 #fff, 0 4px 0 #000; }
html[data-theme="mac1984"] .brand, html[data-theme="mac1984"] .brand small { color: #000; }
html[data-theme="mac1984"] .brand-mark { color: #fff; background: #000; border-color: #000; transform: none; }
html[data-theme="mac1984"] .theme-switch { color: #000; background: #fff; border: 2px solid #000; border-radius: 7px; }
html[data-theme="mac1984"] .theme-switch button { color: #000; }
html[data-theme="mac1984"] .theme-switch button.active { color: #fff; background: #000; border-radius: 4px; }
html[data-theme="mac1984"] .font-scale-control { color: #000; background: #fff; border: 2px solid #000; border-radius: 7px; }
html[data-theme="mac1984"] .font-scale-control #font-scale-select { border-color: #000; background: #fff; }
html[data-theme="mac1984"] .search-box { color: #000; background: #fff; border: 2px solid #000; border-radius: 5px; }
html[data-theme="mac1984"] .search-box input { color: #000; }
html[data-theme="mac1984"] .search-box input::placeholder { color: #4c4c4c; }
html[data-theme="mac1984"] .progress-chip { color: #000; }
html[data-theme="mac1984"] .progress-track { background: #fff; border: 1px solid #000; }
html[data-theme="mac1984"] .progress-track span { background: #000; }
html[data-theme="mac1984"] .sidebar { background-color: #fff; background-image: radial-gradient(#888 1px, transparent 1px); background-size: 4px 4px; border-right: 2px solid #000; }
html[data-theme="mac1984"] .book-plate, html[data-theme="mac1984"] .chapter-nav { background: rgba(255,255,255,.9); border-color: #000; }
html[data-theme="mac1984"] .chapter-button:hover, html[data-theme="mac1984"] .chapter-button.active { color: #fff; background: #000; }
html[data-theme="mac1984"] .chapter-button:hover small, html[data-theme="mac1984"] .chapter-button.active small { color: #fff; }
html[data-theme="mac1984"] .lesson-list { background: #fff; border-top: 1px solid #000; }
html[data-theme="mac1984"] .lesson-list button:hover, html[data-theme="mac1984"] .lesson-list button.active { color: #fff; background: #000; }
html[data-theme="mac1984"] .sidebar-foot { background: #fff; }
html[data-theme="mac1984"] main { background: rgba(255,255,255,.58); }
html[data-theme="mac1984"] .hero { margin: 22px 0; padding: 34px; background: #fff; border: 2px solid #000; box-shadow: var(--shadow); }
html[data-theme="mac1984"] .page-head { position: relative; padding: 48px 20px 22px; background: #fff; border: 2px solid #000; }
html[data-theme="mac1984"] .page-head::before { content: "TURBO C GUIDE"; position: absolute; inset: 5px 5px auto; height: 24px; display: grid; place-items: center; color: #000; background: repeating-linear-gradient(0deg,#000 0 1px,#fff 1px 3px); border-bottom: 1px solid #000; font: 12px/1 var(--font-pixel); text-shadow: -2px 0 #fff, 0 2px #fff, 2px 0 #fff, 0 -2px #fff; }
html[data-theme="mac1984"] .page-lead, html[data-theme="mac1984"] .hero-deck, html[data-theme="mac1984"] .reference-card p { color: #111; }
html[data-theme="mac1984"] .primary-button, html[data-theme="mac1984"] .secondary-button, html[data-theme="mac1984"] .tool-button, html[data-theme="mac1984"] .run-button { border-color: #000; border-radius: 7px; box-shadow: 2px 2px 0 #000; }
html[data-theme="mac1984"] .primary-button, html[data-theme="mac1984"] .run-button { color: #fff; background: #000; }
html[data-theme="mac1984"] .secondary-button, html[data-theme="mac1984"] .tool-button { color: #000; background: #fff; }
html[data-theme="mac1984"] .book-cover { color: #fff; background: #000; border-color: #fff; box-shadow: 9px 9px 0 #000; }
html[data-theme="mac1984"] .chapter-card, html[data-theme="mac1984"] .reference-card, html[data-theme="mac1984"] .fact,
html[data-theme="mac1984"] .manual-box, html[data-theme="mac1984"] .warning-box, html[data-theme="mac1984"] .modern-box,
html[data-theme="mac1984"] .mission-card { background: #fff; border-color: #000; }
html[data-theme="mac1984"] .sandbox, html[data-theme="mac1984"] .v86-toolbar { background: #dedede; }
html[data-theme="mac1984"] .sandbox-titlebar, html[data-theme="mac1984"] .code-card-head { color: #fff; background: #000; }
html[data-theme="mac1984"] .sandbox-menubar { color: #000; background: #fff; border-bottom: 1px solid #000; }
html[data-theme="mac1984"] .editor-pane { background: #fff; }
html[data-theme="mac1984"] .line-numbers { color: #000; background: #ddd; }
html[data-theme="mac1984"] .reference-toolbar, html[data-theme="mac1984"] .search-panel { background: #fff; border-color: #000; }

/* Windows 1.0, 1985: tiled blue title bars, cyan desktop and flat low-resolution controls. */
html[data-theme="win1985"] {
  --paper: #e8e8e3;
  --paper-deep: #c9c9c3;
  --ink: #000000;
  --muted: #444444;
  --blue: #0000aa;
  --blue-deep: #0000aa;
  --cyan: #00aaaa;
  --yellow: #ffff55;
  --red: #aa0000;
  --green: #008800;
  --screen: #000000;
  --screen-text: #ffffff;
  --line: #000000;
  --shadow: 5px 5px 0 #000;
  --font-ui: var(--font-win);
  color-scheme: light;
}
html[data-theme="win1985"] body { background-color: #00aaaa; background-image: linear-gradient(90deg,rgba(255,255,255,.08) 1px,transparent 1px),linear-gradient(rgba(255,255,255,.08) 1px,transparent 1px); background-size: 8px 8px; }
html[data-theme="win1985"] .topbar { color: #fff; background: #0000aa; border-bottom: 3px solid #000; box-shadow: none; }
html[data-theme="win1985"] .brand, html[data-theme="win1985"] .brand small { color: #fff; }
html[data-theme="win1985"] .brand-mark { color: #ffff55; border-color: #fff; transform: none; }
html[data-theme="win1985"] .theme-switch { color: #000; background: #fff; border: 2px solid #000; }
html[data-theme="win1985"] .theme-switch button { color: #000; }
html[data-theme="win1985"] .theme-switch button.active { color: #fff; background: #0000aa; }
html[data-theme="win1985"] .font-scale-control { color: #000; background: #deded8; border: 2px solid #000; }
html[data-theme="win1985"] .font-scale-control #font-scale-select { border-color: #000; background: #deded8; }
html[data-theme="win1985"] .search-box { color: #000; background: #eeeeea; border: 2px solid #000; }
html[data-theme="win1985"] .search-box input { color: #000; }
html[data-theme="win1985"] .search-box input::placeholder { color: #444; }
html[data-theme="win1985"] .progress-track { background: #deded8; border: 1px solid #000; }
html[data-theme="win1985"] .progress-track span { background: #ffff55; }
html[data-theme="win1985"] .sidebar { background: #deded8; border-right: 3px solid #000; }
html[data-theme="win1985"] .book-plate { color: #fff; background: #0000aa; border-color: #000; }
html[data-theme="win1985"] .plate-year, html[data-theme="win1985"] .book-plate p { color: #fff; }
html[data-theme="win1985"] .chapter-nav { border-color: #000; }
html[data-theme="win1985"] .chapter-button:hover, html[data-theme="win1985"] .chapter-button.active { color: #fff; background: #0000aa; }
html[data-theme="win1985"] .chapter-button:hover small, html[data-theme="win1985"] .chapter-button.active small { color: #fff; }
html[data-theme="win1985"] .lesson-list button:hover, html[data-theme="win1985"] .lesson-list button.active { color: #fff; background: #0000aa; }
html[data-theme="win1985"] main { background: transparent; }
html[data-theme="win1985"] .view { width: min(1140px, calc(100% - 46px)); margin-top: 24px; margin-bottom: 50px; padding: 28px; background: #e8e8e3; border: 3px solid #000; box-shadow: var(--shadow); }
html[data-theme="win1985"] .page-head { position: relative; padding: 48px 20px 22px; background: #e8e8e3; border: 2px solid #000; }
html[data-theme="win1985"] .page-head::before { content: "TURBO C GUIDE.EXE"; position: absolute; inset: 3px 3px auto; height: 25px; display: flex; align-items: center; padding: 0 8px; color: #fff; background: #0000aa; font: 12px/1 var(--font-win); }
html[data-theme="win1985"] .primary-button, html[data-theme="win1985"] .secondary-button, html[data-theme="win1985"] .tool-button, html[data-theme="win1985"] .run-button { border: 2px solid #000; border-radius: 0; box-shadow: 3px 3px 0 #000; }
html[data-theme="win1985"] .primary-button, html[data-theme="win1985"] .run-button { color: #fff; background: #0000aa; }
html[data-theme="win1985"] .secondary-button, html[data-theme="win1985"] .tool-button { color: #000; background: #d8d8d2; }
html[data-theme="win1985"] .book-cover { color: #ffff55; background: #0000aa; border-color: #fff; box-shadow: 9px 9px 0 #000; transform: none; }
html[data-theme="win1985"] .chapter-card, html[data-theme="win1985"] .reference-card, html[data-theme="win1985"] .fact,
html[data-theme="win1985"] .manual-box, html[data-theme="win1985"] .warning-box, html[data-theme="win1985"] .modern-box,
html[data-theme="win1985"] .mission-card { background: #e8e8e3; border-color: #000; }
html[data-theme="win1985"] .sandbox, html[data-theme="win1985"] .v86-toolbar { background: #c0c0c0; }
html[data-theme="win1985"] .sandbox-titlebar, html[data-theme="win1985"] .code-card-head, html[data-theme="win1985"] .search-panel-head { color: #fff; background: #0000aa; }
html[data-theme="win1985"] .sandbox-menubar { color: #000; background: #deded8; border-bottom: 2px solid #000; }
html[data-theme="win1985"] .editor-pane { background: #eeeeea; }
html[data-theme="win1985"] .line-numbers { color: #000; background: #c0c0c0; }
html[data-theme="win1985"] .reference-toolbar, html[data-theme="win1985"] .search-panel { background: #e8e8e3; border-color: #000; }
html[data-theme="win1985"] .reference-toolbar input, html[data-theme="win1985"] .reference-toolbar select { background: #f1f1ed; }
html[data-theme="win1985"] .utility-table { background: #deded8; }

@media (max-width: 980px) {
  :root { --sidebar: 260px; }
  .hero { grid-template-columns: 1fr; padding-top: 20px; }
  .book-cover { display: none; }
  .chapter-grid { grid-template-columns: repeat(2,1fr); }
  .lesson-layout { grid-template-columns: 1fr; }
  .margin-note { position: static; display: grid; grid-template-columns: repeat(2,1fr); gap: 14px; }
  .sandbox-grid { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 2px solid var(--ink); }
  .v86-root { min-height: 360px; }
  .v86-toolbar #v86-status { width: 100%; margin-left: 0; }
}

@media (max-width: 760px) {
  :root { --topbar: 64px; }
  .mobile-only { display: block; }
  .icon-button { border: 0; color: white; background: transparent; font-size: 20px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand small, .progress-chip { display: none; }
  .brand strong { font-size: 13px; }
  .brand-mark { width: 34px; height: 34px; font-size: 15px; }
  .theme-switch button { padding: 7px; font-size: 0; }
  .theme-switch button span { font-size: calc(13px * var(--font-scale)); }
  #font-scale-down, #font-scale-up { display: none; }
  .font-scale-control #font-scale-select { min-width: 54px; border-inline: 0; font-size: calc(10px * var(--font-scale)); }
  .search-box { width: 42px; padding: 0 11px; }
  .search-box:focus-within { position: fixed; z-index: 90; left: 12px; right: 12px; top: 11px; width: auto; background: var(--blue-deep); }
  .search-box input { width: 0; }
  .search-box:focus-within input { width: 100%; }
  .sidebar { transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  main { margin-left: 0; }
  .view { width: min(100% - 32px, 1180px); padding-top: 34px; }
  .hero { min-height: auto; padding: 30px 0; }
  .hero h1 { font-size: calc(43px * var(--font-scale)); }
  .chapter-grid, .reference-list { grid-template-columns: 1fr; }
  .page-head { grid-template-columns: 1fr; }
  .page-stamp { display: none; }
  .flow-diagram { grid-template-columns: 1fr; }
  .flow-step:not(:last-child)::after { content: "▼"; right: auto; left: 50%; top: auto; bottom: -12px; transform: translateX(-50%); }
  .margin-note { grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: 1fr; }
  .lesson-complete { align-items: flex-start; flex-direction: column; }
  .shortcut-hint { width: 100%; margin: 4px 0 0; }
  .code-card { max-width: calc(100vw - 32px); }
  .code-card-head { gap: 8px; }
  .code-card-head > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .code-card-head button { white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
