:root {
  --paper: #f1e9dd;
  --paper-2: #f5eee3;
  --card: #faf5ec;
  --card-2: #f7f0e5;
  --line: #d9cfbf;
  --line-soft: #e5dccd;
  --line-strong: #c3b8a7;
  --ink: #1c1a17;
  --ink-2: #35312c;
  --muted: #6d675f;
  --muted-2: #8d867b;
  --green: #cde2ae;
  --green-2: #b1d28d;
  --green-3: #7ec177;
  --violet: #e7ddf5;
  --orange: #fbdcbc;
  --mint: #dcefdc;
  --amber: #fdeec4;
  --red: #c0392b;
  --rust: #cf6a3c;
  --pop: 1.5px 2.5px 0 var(--ink);
  --radius: 12px;
  --font: 'JetBrains Mono', 'Nanum Gothic Coding', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--paper);
  /* 종이 결 */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .27 0 0 0 0 .17 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.i { width: 14px; height: 14px; flex: none; }
code, kbd, pre { font-family: var(--font); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 6px; }

.app {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr) 318px;
  grid-template-rows: 50px minmax(0, 1fr);
  grid-template-areas: 'top top top' 'side main right';
  gap: 0 12px;
  height: 100vh;
  padding: 0 12px 12px;
}

/* ── 상단 ── */
.top { grid-area: top; display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line-strong); margin: 0 -12px 12px; padding: 0 22px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 16px; letter-spacing: -.2px; }
.brand svg { width: 26px; height: 26px; }
.brand mark { background: linear-gradient(transparent 55%, var(--green) 55%); color: inherit; padding: 0 2px; }
.top-mid { flex: 1; display: flex; align-items: center; gap: 14px; padding-left: 40px; min-width: 0; }
.navpill { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; padding: 5px 16px; border-radius: 9px; background: var(--green); border: 1.5px solid var(--ink); box-shadow: var(--pop); }
.top-tag { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ghost-btn { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 700; font-size: 12px; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--card); }
.ghost-btn:hover { border-color: var(--ink); }
.menu-btn { display: inline-flex; border: 1px solid var(--line-strong); background: var(--card); border-radius: 9px; padding: 6px 8px; }
.menu-btn.on { background: var(--green); border-color: var(--ink); }
.menu-btn .i { width: 15px; height: 15px; }

/* ── 사이드바 ── */
.side { grid-area: side; display: flex; flex-direction: column; min-height: 0; margin-top: 12px; }
.side-head { display: flex; align-items: center; gap: 9px; padding: 6px 10px 10px; font-size: 14px; }
.side-head .i { width: 17px; height: 17px; fill: var(--ink); }
.side-head span { margin-left: auto; color: var(--muted); font-size: 11px; }
.chapters { flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }
.chapter-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; background: none; border: 0; border-radius: 8px; text-align: left; }
.chapter-head:hover { background: rgba(255, 255, 255, .5); }
.chapter-head b { font-size: 13px; flex: 1; }
.chapter-head .chev { color: var(--muted); width: 13px; height: 13px; }
.chapter-head .cnt { color: var(--muted); font-size: 10.5px; }
.fold .i { width: 17px; height: 17px; stroke: var(--ink); stroke-width: 1.6; }
.c-sand .i { fill: #dcc7a3; } .c-green .i { fill: #9fce80; } .c-violet .i { fill: #b9a2e6; } .c-orange .i { fill: #f0a468; } .c-blue .i { fill: #8fb2e2; }
.chapter ul { display: none; list-style: none; margin: 2px 0 8px 22px; padding: 0 0 0 12px; border-left: 1px solid var(--line-strong); }
.chapter.open ul { display: block; }
.chapter li a, .chapter li > span { display: flex; align-items: center; gap: 8px; padding: 5px 9px; margin: 2px 0; border-radius: 8px; text-decoration: none; font-size: 12px; border: 1.5px solid transparent; }
.chapter li .i { color: var(--muted-2); width: 13px; height: 13px; }
.chapter li a:hover { background: rgba(255, 255, 255, .55); }
.chapter li.cur a { background: var(--green); border-color: var(--ink); box-shadow: var(--pop); font-weight: 700; }
.chapter li.cur .i, .chapter li.done .i { color: var(--ink); }
.chapter li.soon > span { color: var(--muted-2); }
.progress { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.progress-head { display: flex; justify-content: space-between; font-size: 11.5px; letter-spacing: .6px; }
.progress .bar { height: 7px; margin-top: 9px; border-radius: 4px; background: var(--line-soft); border: 1px solid var(--line-strong); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--green-3); transition: width .4s; }

/* 접힌 목차(레일) + 서랍 */
.rail { display: none; }
.backdrop { display: none; position: fixed; inset: 50px 0 0 0; z-index: 29; background: rgba(28, 26, 23, .16); }
body.side-open .backdrop { display: block; }
body.is-rail .app { grid-template-columns: 56px minmax(0, 1fr) 318px; }
body.is-rail .rail { grid-area: side; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; padding: 8px 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.rail-ch { display: flex; flex-direction: column; align-items: center; gap: 0; width: 46px; padding: 7px 0 5px; background: none; border: 1.5px solid transparent; border-radius: 9px; line-height: 1.25; }
.rail-ch:hover { background: #fff; }
.rail-ch.cur { background: var(--green); border-color: var(--ink); box-shadow: var(--pop); }
.rail-ch b { font-size: 11px; } .rail-ch i { font-style: normal; font-size: 9px; color: var(--muted); }
.rail-prog { margin-top: auto; text-align: center; font-size: 10px; color: var(--muted); line-height: 1.3; }
.rail-prog b { display: block; font-size: 15px; color: var(--ink); }
body.is-rail .side { position: fixed; z-index: 30; top: 50px; left: 0; bottom: 0; width: 292px; margin: 0; padding: 14px 12px 12px; background: var(--paper); border-right: 1.5px solid var(--ink); box-shadow: 8px 0 24px -14px rgba(28, 26, 23, .5); transform: translateX(-104%); transition: transform .2s; }
body.is-rail.side-open .side { transform: none; }

/* ── 카드 공통 ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 10px 22px -18px rgba(60, 44, 28, .5); }
.main { grid-area: main; min-height: 0; margin-top: 12px; display: flex; }
.lesson { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 16px 16px 14px; gap: 12px; }
.lesson-head { padding: 2px 12px 0; }
.crumb { font-size: 11.5px; color: var(--ink-2); }
.crumb span { color: var(--muted-2); margin: 0 6px; }
.lesson-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.title { margin: 2px 0; font-size: 27px; line-height: 1.25; font-weight: 800; letter-spacing: -.6px; }
.tags { margin-left: auto; display: flex; gap: 8px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 700; padding: 3px 10px; border: 1.5px solid var(--ink); border-radius: 999px; white-space: nowrap; }
.tag .i { width: 12px; height: 12px; }
.t-sand { background: #f6e3c2; } .t-mint { background: var(--mint); } .t-violet { background: var(--violet); }
.subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.soon-card { padding: 28px; }

/* ── 스테이지 ── */
.stage { position: relative; flex: 1; min-height: 300px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-2); overflow: hidden; }
.stage-host { position: absolute; inset: 0; }
.stage-host svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage-grid { -webkit-mask-image: radial-gradient(ellipse 62% 62% at 50% 52%, #000 35%, transparent 100%); mask-image: radial-gradient(ellipse 62% 62% at 50% 52%, #000 35%, transparent 100%); }
.stage-svg { font-family: var(--font); }
.stage-svg text { user-select: none; }
.hud { position: absolute; z-index: 2; top: 10px; left: 12px; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100% - 290px); }
.chip { min-width: 88px; padding: 6px 11px 5px; border: 1px solid var(--line-strong); border-left: 3px solid var(--line-strong); border-radius: 8px; background: rgba(252, 248, 241, .93); }
.chip-l { display: flex; align-items: center; gap: 5px; font-size: 9px; letter-spacing: .5px; color: var(--muted); white-space: nowrap; }
.chip-l .i { width: 10px; height: 10px; }
.chip-v { display: block; font-size: 13.5px; font-weight: 800; white-space: nowrap; }
.chip.tone-bad { border-left-color: var(--red); } .chip.tone-bad .chip-v { color: var(--red); }
.chip.tone-warn { border-left-color: #e3a23a; } .chip.tone-warn .chip-v { color: #a5650c; }
.chip.tone-good { border-left-color: var(--green-3); } .chip.tone-good .chip-v { color: #2a7a3d; }
.chip.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { background: var(--amber); transform: translateY(-2px); } 100% { background: rgba(252, 248, 241, .93); transform: none; } }
.tools { position: absolute; z-index: 3; top: 10px; right: 12px; display: flex; gap: 7px; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; font-size: 11.5px; font-weight: 700; background: var(--card); border: 1.5px solid var(--ink); border-radius: 8px; box-shadow: var(--pop); transition: transform .08s, box-shadow .08s; }
.btn:hover { background: #fff; }
.btn:active { transform: translate(1px, 2px); box-shadow: .5px .5px 0 var(--ink); }
.btn.on { background: var(--green); }
.btn[disabled] { opacity: .45; cursor: default; box-shadow: none; }
.btn[hidden] { display: none; }
.legend { position: absolute; z-index: 2; left: 14px; bottom: 9px; display: flex; gap: 14px; font-size: 10px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 9px; height: 9px; border-radius: 50%; border: 1.3px solid var(--ink); }
.lg-heavy { border-radius: 2.5px; } .lg-ctl, .lg-sync { border-radius: 2px; transform: rotate(45deg) scale(.86); }

/* 장면 애니메이션 */
.link.in, .linklabel.in { animation: fadein .32s ease-out; }
.link.out { animation: fadeout .24s ease-in forwards; }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
.ent.pop > * { animation: pop .4s ease-out; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes pop { 0% { transform: scale(.94); } 55% { transform: scale(1.04); } 100% { transform: none; } }
.ent.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.07) drop-shadow(0 0 7px rgba(232, 131, 77, .55)); } }
.dot.burst { animation: burst .45s ease-out; transform-box: fill-box; }
@keyframes burst { 50% { filter: drop-shadow(0 0 6px #e5534b); } }

/* ── 코드 · 실습 도크 ── */
.dock { position: absolute; z-index: 4; top: 50px; right: 12px; bottom: 12px; width: min(372px, 46%); display: flex; flex-direction: column; background: #fdfaf4; border: 1.5px solid var(--ink); border-radius: 10px; box-shadow: var(--pop); overflow: hidden; }
.dock[hidden] { display: none; }
.dock-tabs { display: flex; align-items: center; gap: 4px; padding: 6px 6px 0; border-bottom: 1.5px solid var(--ink); background: var(--card-2); }
.dock-tabs button { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; font-size: 11.5px; font-weight: 700; border: 1.5px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: none; color: var(--muted); position: relative; top: 1.5px; }
.dock-tabs button.on { background: #fdfaf4; border-color: var(--ink); color: var(--ink); }
.dock-tabs .pip { width: 6px; height: 6px; border-radius: 50%; background: var(--rust); }
.dock-tabs button.on .pip { display: none; }
.dock-tabs .dock-x { margin-left: auto; padding: 4px 6px; top: 0; }
.dock-body { flex: 1; min-height: 0; overflow: auto; font-size: 11.5px; }
.file { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 12px; background: #fdfaf4; border-bottom: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; }
.file span { display: inline-flex; align-items: center; gap: 6px; }
.copy { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; font-size: 10.5px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--card); color: var(--ink-2); }
.copy:hover { border-color: var(--ink); }
.copy .i { width: 11px; height: 11px; }
.dock-note { margin: 8px 12px 2px; color: var(--muted); font-size: 11px; line-height: 1.55; }
pre { margin: 0; }
.code { padding: 8px 0 12px; line-height: 1.62; tab-size: 2; }
.code code { display: block; min-width: max-content; }
.ln { display: block; padding: 0 12px 0 0; white-space: pre; }
.ln em { display: inline-block; width: 30px; margin-right: 10px; text-align: right; color: var(--muted-2); font-style: normal; font-size: 10px; user-select: none; opacity: .75; }
.ln.hl { background: #e3f0d0; box-shadow: inset 3px 0 0 var(--green-3); }
.c-key { color: #1f5fa0; font-style: normal; } .c-str { color: #2a7a3d; font-style: normal; } .c-num { color: #a8501c; font-style: normal; } .c-com { color: var(--muted-2); font-style: italic; }
.lab { padding: 10px 12px 14px; }
.lab h3 { display: flex; align-items: center; gap: 7px; margin: 0 0 4px; font-size: 12.5px; }
.lab .dock-note { margin: 0 0 8px; }
.lab-step { margin-top: 12px; }
.lab-step > p { margin: 0 0 5px; line-height: 1.55; }
.lab-step > p b { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-right: 7px; font-size: 10px; border: 1.5px solid var(--ink); border-radius: 50%; background: var(--green); }
.cmd { position: relative; border: 1.5px solid var(--ink); border-radius: 8px; background: #25221e; color: #f4ecdf; }
.cmd pre { padding: 8px 40px 8px 11px; overflow-x: auto; line-height: 1.55; white-space: pre; }
.cmd .c-key { color: #b9e39b; } .cmd .c-num { color: #f3c58f; } .cmd .c-com { color: #a49b8e; }
.cmd .copy { position: absolute; top: 5px; right: 5px; background: #3a352f; border-color: #5a544c; color: #f4ecdf; padding: 4px 6px; }
.lab details { margin-top: 5px; }
.lab summary { cursor: pointer; font-size: 10.5px; color: var(--muted); }
.out { margin-top: 4px; padding: 7px 10px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--card-2); overflow-x: auto; white-space: pre; line-height: 1.5; font-size: 10.5px; color: var(--ink-2); }
.lab-note { margin: 5px 0 0; font-size: 10.5px; color: var(--muted); }

/* ── 타임라인 ── */
.timeline { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card-2); padding: 10px 14px 10px; }
.tl-head { display: flex; justify-content: space-between; font-size: 11px; letter-spacing: .6px; }
.tl-head span { color: var(--muted); letter-spacing: 0; }
.tl { --p: 0; position: relative; display: flex; list-style: none; margin: 8px 0 0; padding: 0; }
.tl::before, .tl::after { content: ''; position: absolute; top: 12px; height: 2px; left: calc(50% / var(--n, 9)); }
.tl li { flex: 1; min-width: 0; text-align: center; position: relative; }
.tl li::before { content: ''; position: absolute; top: 12px; left: -50%; width: 100%; height: 1.5px; background: var(--line-strong); }
.tl li:first-child::before { display: none; }
.tl li.done::before, .tl li.cur::before { height: 2.5px; top: 11.5px; background: var(--ink); }
.tl button { position: relative; z-index: 1; display: inline-flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: 0; padding: 0 2px; max-width: 100%; }
.tl-n { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; border: 1.5px solid var(--muted-2); background: var(--card); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.tl-t { font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.tl li.done .tl-n { border-color: var(--ink); color: var(--ink); background: #edf3df; }
.tl li.done .tl-t { color: var(--ink-2); }
.tl li.cur .tl-n { border-color: var(--ink); color: var(--ink); background: var(--green-2); box-shadow: var(--pop); }
.tl li.cur .tl-t { color: var(--ink); font-weight: 700; }
.tl button:hover .tl-n { border-color: var(--ink); }

/* ── 오른쪽 패널 ── */
.right { grid-area: right; display: flex; flex-direction: column; gap: 12px; min-height: 0; margin-top: 12px; }
.step { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 16px 16px 10px; }
.step-top { display: flex; align-items: center; justify-content: space-between; }
.step-n { font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.badge { font-size: 9.5px; font-weight: 800; letter-spacing: .8px; padding: 2px 10px; border: 1.5px solid var(--ink); border-radius: 999px; box-shadow: var(--pop); }
.b-setup { background: #f6e3c2; } .b-problem { background: #f8cfc6; } .b-concept { background: #dde8f6; } .b-solution { background: var(--green); }
.b-technique { background: var(--violet); } .b-lab { background: var(--amber); } .b-apply { background: #cfe9e5; } .b-recap { background: var(--ink); color: #fffaf2; }
.step-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 10px -6px 0 0; padding-right: 6px; }
.step h2 { margin: 2px 0 10px; font-size: 17px; line-height: 1.4; font-weight: 800; letter-spacing: -.3px; }
.step p { margin: 0 0 11px; font-size: 12.3px; line-height: 1.75; color: var(--ink-2); }
.step b { color: var(--ink); }
.step code { font-size: 11.5px; padding: 1px 5px; border-radius: 5px; background: #efe6d8; border: 1px solid var(--line-soft); }
.term { font-weight: 700; color: var(--ink); background: linear-gradient(transparent 62%, var(--green) 62%); }
.callout { display: flex; gap: 10px; padding: 11px 12px; margin: 4px 0 12px; border-radius: 10px; border: 1px solid; }
.callout > div > b { display: block; font-size: 9.5px; letter-spacing: 1px; margin-bottom: 2px; }
.callout p { margin: 0; font-size: 11.8px; line-height: 1.65; }
.co-ic { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border: 1.5px solid var(--ink); border-radius: 7px; background: #fffcf6; }
.co-insight { background: #ebe3f6; border-color: #d3c6e6; } .co-tip { background: #e6efd8; border-color: #c8d7b2; } .co-warn { background: #fbe6c9; border-color: #e9cb9c; }
.co-next { background: #fbf7f0; border-color: var(--line-strong); } .co-spring { background: #dcefdc; border-color: #b9d6b9; }
.changes > b { display: block; font-size: 10.5px; letter-spacing: 1px; color: var(--muted); margin: 6px 0 6px; }
.changes ul, .goals ul, .recap { list-style: none; margin: 0; padding: 0; }
.changes li { display: flex; gap: 9px; margin-bottom: 7px; font-size: 11.5px; line-height: 1.55; }
.changes li i { flex: none; display: grid; place-items: center; width: 15px; height: 15px; margin-top: 1px; border-radius: 4px; font-style: normal; font-weight: 800; font-size: 11px; }
.changes .add i { background: #d6ebc4; color: #2a7a3d; } .changes .mod i { background: #fbe5bd; color: #a5650c; } .changes .del i { background: #f8d5cf; color: #8f2a22; }
.recap li { display: flex; gap: 9px; margin-bottom: 11px; font-size: 12px; line-height: 1.65; color: var(--ink-2); }
.recap .i { flex: none; margin-top: 3px; padding: 1.5px; width: 14px; height: 14px; border: 1.3px solid var(--ink); border-radius: 4px; background: var(--green); stroke-width: 3; }
.lab-jump { display: flex; align-items: center; gap: 8px; width: 100%; margin: 6px 0 4px; padding: 8px 11px; font-size: 11.5px; font-weight: 700; text-align: left; background: var(--amber); border: 1.5px solid var(--ink); border-radius: 9px; box-shadow: var(--pop); }
.lab-jump span { flex: 1; }
.step-nav { display: flex; gap: 8px; margin-top: 10px; }
.step-nav .btn { padding: 8px 13px; font-size: 12px; }
.step-nav .next { flex: 1; justify-content: space-between; background: var(--green); min-width: 0; }
.step-nav .next span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-nav .next:hover { background: var(--green-2); }
.keys { margin-top: 9px; text-align: center; font-size: 9.5px; color: var(--muted-2); }
kbd { display: inline-block; padding: 0 4px; margin: 0 1px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--card-2); font-size: 9.5px; }
.goals { padding: 14px 16px; max-height: 30%; overflow-y: auto; }
.goals-h { display: block; font-size: 11px; letter-spacing: 1px; margin-bottom: 9px; }
.goals li { display: flex; gap: 9px; margin-bottom: 7px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.goals li i { flex: none; display: grid; place-items: center; width: 14px; height: 14px; margin-top: 1px; border: 1.3px solid var(--muted-2); border-radius: 4px; background: var(--card); }
.goals li.ok { color: var(--ink); }
.goals li.ok i { border-color: var(--ink); background: var(--green-2); }
.goals li i .i { width: 9px; height: 9px; stroke-width: 3.5; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px); padding: 7px 16px; font-size: 12px; font-weight: 700; background: var(--ink); color: #fffaf2; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── 좁은 화면 ── */
@media (max-width: 1180px) {
  .app, body.is-rail .app { grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: 50px minmax(560px, 1fr) auto; grid-template-areas: 'top top' 'side main' 'side right'; height: auto; min-height: 100vh; }
  body:not(.is-rail) .app { grid-template-columns: 232px minmax(0, 1fr); }
  .right { flex-direction: row; align-items: flex-start; padding-bottom: 12px; }
  .step { flex: 1.6; } .goals { flex: 1; max-height: none; }
  .stage { min-height: 460px; }
  .top-tag { display: none; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'top' 'main' 'right'; grid-template-rows: 50px auto auto; padding: 0 8px 8px; }
  body.is-rail .app, .app { grid-template-columns: minmax(0, 1fr); }
  body.is-rail .rail { display: none; }
  .top { margin: 0 -8px 0; padding: 0 12px; gap: 10px; }
  .top-mid { display: none; }
  .ghost-btn { margin-left: auto; }
  .lesson { padding: 12px 10px; }
  .title { font-size: 21px; }
  .tags { margin-left: 0; }
  .stage { min-height: 0; display: flex; flex-direction: column; overflow: visible; }
  .stage-host { position: relative; inset: auto; height: 380px; }
  .hud { position: static; max-width: none; padding: 8px 8px 0; }
  .tools { top: auto; bottom: auto; position: static; padding: 8px; justify-content: flex-end; }
  .legend { position: static; padding: 0 10px 8px; flex-wrap: wrap; }
  .dock { position: static; width: auto; max-height: 420px; margin: 0 8px 8px; }
  .right { flex-direction: column; align-items: stretch; }
  .tl-t { display: none; }
  .tl li.cur .tl-t { display: block; position: absolute; top: 30px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
  .timeline { padding-bottom: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .chip.flash, .ent.pop > *, .ent.pulse, .link.in, .linklabel.in { animation: none; }
}
