/* 디자인 값은 DESIGN.md("Die on a Board")를 따른다. 테마는 어두운 기판 하나다. */
:root {
  --board: #0A0D10; --board-2: #10151A; --rule: #212A32; --grid: #1B242B; --ice: #D5F3F6; --text: #E7EEF0; --soft: #93A3AB;
  --runtime: #22D3EE; --library: #FFDD33; --app: #C83CFF; --asset: #F04A1F; --unid: #5F6970; --overhead: #2B333A; --substrate: #161C22;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--board); scrollbar-color: var(--rule) var(--board); color-scheme: dark; }
body { margin: 0; background: var(--board); color: var(--text); font: 400 16px/1.55 "Archivo", "Pretendard Variable", sans-serif; -webkit-font-smoothing: antialiased; word-break: keep-all; overflow-wrap: anywhere; overflow-x: hidden; }
::selection { background: var(--ice); color: var(--board); }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.num, code { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.display { font-family: "Archivo", "Pretendard Variable", sans-serif; font-stretch: 118%; font-weight: 800; letter-spacing: -0.015em; line-height: 1.14; text-wrap: balance; }
/* 모서리 표시: 회로도의 부품 테두리처럼 네 귀퉁이만 긋는다 */
.frame { --c: var(--ice); --s: 10px; background:
  linear-gradient(var(--c), var(--c)) top left / var(--s) 1px no-repeat, linear-gradient(var(--c), var(--c)) top left / 1px var(--s) no-repeat,
  linear-gradient(var(--c), var(--c)) top right / var(--s) 1px no-repeat, linear-gradient(var(--c), var(--c)) top right / 1px var(--s) no-repeat,
  linear-gradient(var(--c), var(--c)) bottom left / var(--s) 1px no-repeat, linear-gradient(var(--c), var(--c)) bottom left / 1px var(--s) no-repeat,
  linear-gradient(var(--c), var(--c)) bottom right / var(--s) 1px no-repeat, linear-gradient(var(--c), var(--c)) bottom right / 1px var(--s) no-repeat; }

/* ---------- 첫 화면: 기판 전체가 무대 ---------- */
.hero { position: relative; min-height: 100svh; overflow: hidden; }
.stage { position: absolute; inset: 0; }
.gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.gl.drag { cursor: grabbing; }
.tip { position: absolute; left: 0; top: 0; z-index: 6; padding: 7px 10px; background: var(--board-2); color: var(--text); border: 1px solid var(--ice); font: 500 12px/1.4 "JetBrains Mono", monospace; white-space: pre; pointer-events: none; max-width: 440px; overflow: hidden; text-overflow: ellipsis; }
.nogl { position: absolute; left: 66%; top: 50%; transform: translate(-50%, -50%); width: min(34ch, 80%); margin: 0; color: var(--soft); font-size: 14px; text-align: center; }
.no3d #tabs, .no3d #fold, .no3d #hint { display: none; }
/* 좁은 화면용 2D 트리맵: 보기 전용이라 층 단추와 열기·닫기가 없다 */
.flat2d #tabs, .flat2d #fold, .flat2d #hint { display: none; }
.flat { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; }
.flat.away { opacity: .25; }
.flatcap { position: absolute; left: 12px; right: 12px; bottom: 8px; height: 38px; margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); border-top: 1px solid var(--rule); overflow: hidden; white-space: nowrap; }
.flatcap b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.flatcap .num { font-size: 12px; flex: none; }
.hud { position: relative; z-index: 2; width: min(430px, 36vw); min-height: 100svh; padding: clamp(18px, 2.4vw, 32px) 0 26px clamp(20px, 3vw, 44px); display: flex; flex-direction: column; gap: 20px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: min(620px, 52vw); z-index: 1; background: linear-gradient(90deg, var(--board) 46%, transparent); pointer-events: none; }
.runhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 14px; color: var(--soft); }
.runhead #nav-note { display: flex; gap: 12px; font-size: 13px; }
.lang { color: var(--soft); text-decoration: none; }
.lang:hover { color: #fff; }
.lang[aria-current="true"] { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.runhead strong { color: var(--text); font-weight: 700; font-stretch: 118%; letter-spacing: 0.04em; text-transform: uppercase; }
#head { display: grid; gap: 14px; margin-top: 10px; }
#head h1 { font-size: clamp(2.1rem, 3.5vw, 3.4rem); margin: 0; }
#head h1.long { font-size: clamp(1.6rem, 2.4vw, 2.3rem); }
#head p { margin: 0; }
.eyebrow { font-size: 13px; color: var(--soft); }
.lede { color: var(--soft); font-size: 16px; max-width: 36ch; }
.lede b { color: var(--text); font-weight: 600; }
.meta { color: var(--soft); font-size: 13px; }
.badge { display: inline-block; margin-left: 8px; padding: 0 6px; border: 1px solid var(--soft); color: var(--text); font-size: 12px; }
/* 빼 보기: 부품을 뺐을 때의 크기 */
.whatif { padding: 12px 14px; display: grid; gap: 6px; background-color: color-mix(in srgb, var(--board-2) 82%, transparent); font-size: 14px; }
.whatif .sum { font-size: 15px; color: var(--text); }
.whatif .sum b { font-weight: 700; }
.whatif .what { color: var(--soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatif .falls { color: var(--text); font-size: 13px; }
.whatif .falls b { font-weight: 700; }
.whatif .fine { color: var(--soft); font-size: 12px; }
.whatif .acts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.key tbody tr { cursor: pointer; }
.key tr.gone td { color: var(--soft); text-decoration: line-through; }
.key tr.gone .chip { opacity: .3; }
.drop { padding: 18px; display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; background-color: color-mix(in srgb, var(--board-2) 82%, transparent); }
.drop p { margin: 0; flex: 1 1 150px; font-weight: 600; }
.drop small { flex-basis: 100%; color: var(--soft); font-size: 13px; }
.btn { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border: 1px solid var(--ice); background: var(--ice); color: var(--board); font-weight: 700; cursor: pointer; }
.btn:hover { background: #fff; border-color: #fff; }
.btn.line { background: transparent; color: var(--text); }
.btn.line:hover { background: color-mix(in srgb, var(--ice) 14%, transparent); border-color: var(--ice); }
.btn[disabled] { opacity: .45; cursor: default; }
label.btn:focus-within { outline: 2px solid var(--ice); outline-offset: 3px; }
button.link { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
button.link:hover { color: #fff; }
.key { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: auto; }
.key caption { text-align: left; padding-bottom: 8px; color: var(--soft); font-size: 13px; }
.key td { padding: 5px 0; border-top: 1px solid var(--rule); vertical-align: baseline; }
.key td:first-child { width: 28px; }
.key td.b, .key td.p { text-align: right; white-space: nowrap; padding-left: 12px; color: var(--soft); }
.key tr.hot td { background: var(--rule); color: #fff; }
.key small { color: var(--soft); font-size: 12px; }
.chip { display: inline-block; flex: none; width: 16px; height: 10px; vertical-align: -1px; background-color: var(--overhead); }
.chip.o-runtime { background-color: var(--runtime); } .chip.o-library { background-color: var(--library); } .chip.o-app { background-color: var(--app); }
.chip.o-asset { background-color: var(--asset); } .chip.o-unid { background-color: var(--unid); }
.hatch { background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--board) 3px 4.5px); }
.side { position: absolute; right: clamp(14px, 2vw, 28px); top: clamp(16px, 2.2vw, 28px); bottom: 22px; z-index: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.side > * { pointer-events: auto; }
.tabs { display: flex; flex-direction: column; gap: 6px; margin: auto 0; }
.tabs button, .tog { display: grid; grid-template-columns: 30px auto; align-items: center; height: 40px; padding: 0 14px 0 0; border: 0; background-color: color-mix(in srgb, var(--board-2) 86%, transparent); color: var(--soft); cursor: pointer; text-align: left; font-size: 13px; --c: var(--rule); }
.tabs button i { font: 700 12px/1 "JetBrains Mono", monospace; font-style: normal; text-align: center; }
.tabs button[aria-pressed="true"] { color: var(--text); --c: var(--ice); }
.tabs button:hover, .tog:hover { color: #fff; --c: var(--ice); }
.tog { grid-template-columns: auto; padding: 0 14px; height: 34px; --c: var(--soft); color: var(--text); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; font-size: 13px; color: var(--soft); max-width: 46vw; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.hint { margin: 0; font-size: 13px; color: var(--soft); }

/* ---------- 해석 중, 오류 ---------- */
#head h1.stagename, #head .err h1 { font-size: clamp(1.5rem, 2.2vw, 2.1rem); }
.err { display: grid; gap: 12px; justify-items: start; }
.err p { max-width: 40ch; }
.applist { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.small { font-size: 13px; color: var(--soft); }

/* ---------- 부품 목록 ---------- */
.band { padding: clamp(36px, 5vw, 72px) clamp(20px, 3vw, 44px); border-top: 1px solid var(--rule); }
.band h2 { font-size: clamp(1.4rem, 2.2vw, 2rem); margin: 0 0 6px; }
.band .sub { margin: 0 0 20px; max-width: 62ch; color: var(--soft); font-size: 14px; }
.notes { display: grid; gap: 0; margin: 0 0 20px; max-width: 84ch; border-top: 1px solid var(--rule); }
.note { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--rule); color: var(--soft); font-size: 14px; }
.note.warn { color: var(--text); }
.note.warn::before { content: "! "; font-family: "JetBrains Mono", monospace; color: var(--ice); }
details.warnings { padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; color: var(--soft); }
details.warnings summary { cursor: pointer; color: var(--text); }
details.warnings ul { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 20px; }
.tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin: 0 0 12px; max-width: 1100px; }
.tools input { flex: 0 1 320px; min-width: 0; height: 36px; border: 1px solid var(--rule); border-radius: 0; padding: 0 10px; background: var(--board-2); color: var(--text); font: inherit; font-size: 14px; caret-color: var(--ice); -webkit-appearance: none; appearance: none; }
.tools input::placeholder { color: var(--soft); opacity: 1; }
.tools input:hover { border-color: var(--soft); }
.row .in { color: var(--soft); font-family: "Archivo", "Pretendard Variable", sans-serif; font-size: 12px; }
.none { margin: 0; padding: 18px 16px; color: var(--soft); font-size: 14px; }
.panel { background-color: var(--board-2); padding: 6px 0; max-width: 1100px; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 22px; border-left: 1px solid var(--rule); }
.row { display: grid; grid-template-columns: 20px 16px minmax(0, 1fr) auto 84px 52px; gap: 10px; align-items: center; min-height: 36px; padding: 0 16px; border-bottom: 1px solid var(--rule); font-size: 13px; }
.row:hover, .row:focus-within { background: var(--rule); }
.row button.tw { width: 20px; height: 28px; padding: 0; border: 0; background: none; color: var(--soft); cursor: pointer; font-family: "JetBrains Mono", monospace; }
.row button.tw[disabled] { cursor: default; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .ow { color: var(--soft); white-space: nowrap; }
.row .sz, .row .pc { text-align: right; color: var(--soft); }
.more { margin: 8px 16px 8px 46px; }

/* ---------- 갤러리 ---------- */
.gallist { list-style: none; margin: 0 0 10px; padding: 0; max-width: 1100px; border-top: 1px solid var(--rule); }
.gallist li { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); align-items: stretch; border-bottom: 1px solid var(--rule); }
.gsrc { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 0 12px; font-size: 13px; color: var(--soft); min-width: 0; white-space: nowrap; }
.gsrc .num { font-size: 12px; }
.gsrc a { overflow: hidden; text-overflow: ellipsis; }
.gsrc a:hover, .src a:hover { color: #fff; }
.sub.fine { font-size: 13px; margin: 12px 0 0; max-width: 84ch; }
.gal { display: grid; grid-template-columns: minmax(0, 1.5fr) 84px minmax(0, 1fr) 92px minmax(140px, 1.4fr); gap: 14px; align-items: center; width: 100%; min-height: 46px; padding: 6px 12px; border: 0; background: none; color: var(--text); text-align: left; cursor: pointer; font-size: 14px; }
.gal:hover { background: var(--rule); }
.gal[aria-current="true"] { background: color-mix(in srgb, var(--ice) 14%, transparent); box-shadow: inset 0 0 0 1px var(--ice); }
.gal .gn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal .gn .num { font-weight: 400; font-size: 12px; color: var(--soft); }
.gal .gp, .gal .gr, .gal .gs { color: var(--soft); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal .gs { text-align: right; }
.gbar { display: flex; height: 12px; background: var(--overhead); overflow: hidden; }
.gbar .chip { width: auto; height: 100%; flex: none; }

#overlay { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; background: color-mix(in srgb, var(--board) 78%, transparent); box-shadow: inset 0 0 0 2px var(--ice); pointer-events: none; }
#overlay-text { padding: 18px 28px; font-size: 22px; font-weight: 800; font-stretch: 118%; background-color: var(--board-2); }
footer { padding: 24px clamp(20px, 3vw, 44px) 48px; font-size: 13px; color: var(--soft); border-top: 1px solid var(--rule); }
footer p { margin: 0 0 4px; max-width: 84ch; }

@media (max-width: 900px) {
  .hero { display: flex; flex-direction: column; min-height: 0; }
  .hero::before { display: none; }
  .hud { display: contents; }
  .hud > * { margin-inline: 20px; }
  .runhead { order: 0; margin-top: 20px; } #head { order: 1; margin-top: 18px; margin-bottom: 18px; }
  .stage { order: 3; position: relative; height: 62svh; min-height: 400px; }
  .flat2d .stage { background-color: var(--board-2); }
  .flat2d .side { padding-top: 14px; }
  .side { order: 4; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 12px 20px; }
  .tabs { flex-direction: row; margin: 0; } .tabs button { grid-template-columns: 34px; padding: 0; } .tabs button span { display: none; }
  .legend { max-width: none; justify-content: flex-start; flex-basis: 100%; } .hint { display: none; }
  .whatif { order: 2; margin-bottom: 14px; }
  .drop { order: 5; margin-top: 8px; } .key { order: 6; width: auto; margin: 22px 20px 28px; }
  .nogl { left: 50%; }
  .row { grid-template-columns: 20px 16px minmax(0, 1fr) 76px 46px; padding: 4px 10px; gap: 0 8px; }
  .row .ow { grid-column: 3; grid-row: 2; font-size: 12px; }
  .row .tw { grid-area: 1 / 1; } .row .chip { grid-area: 1 / 2; } .row .nm { grid-area: 1 / 3; } .row .sz { grid-area: 1 / 4; } .row .pc { grid-area: 1 / 5; }
  .tree .tree { margin-left: 12px; }
  .gal { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 8px; }
  .gallist li { grid-template-columns: 1fr; }
  .gsrc { justify-content: space-between; padding: 0 8px 10px; }
  .gal .gn { grid-area: 1 / 1; } .gal .gs { grid-area: 1 / 2; } .gal .gp { grid-area: 2 / 1; } .gal .gr { grid-area: 2 / 2; text-align: right; } .gal .gbar { grid-area: 3 / 1 / 4 / 3; }
}
