/* 제타멜레온 — 공통 스타일
   레이아웃 개념: 밝은 작업대(종이) 위에 어두운 오실로스코프 화면 하나. 굵은 강조는 스코프에만, 나머지는 조용하게.
   CH1(입력)=금색, CH2(출력)=청록 — 스코프 관례를 그대로 쓰고, 화면 곳곳의 표시도 이 두 색을 따른다. */

:root {
  --paper: #eef2f0;
  --panel: #ffffff;
  --panel-2: #f5f8f6;
  --ink: #16211d;
  --ink-2: #4a5752;
  --ink-3: #66736e;
  --line: #d6dfdb;
  --line-2: #b9c6c0;
  --accent: #0b6b78;
  --accent-hover: #095863;
  --accent-ink: #ffffff;
  --accent-soft: #dcefef;

  --scope: #0d1714;
  --scope-bezel: #1c2824;
  --scope-grid: rgba(150, 205, 185, 0.12);
  --scope-axis: rgba(150, 205, 185, 0.32);
  --scope-text: #a8c0b6;
  --ch1: #b28b05;
  --ch2: #0fa4ba;
  --c-fixed0: #e05d3d;
  --c-fixed1: #9d69d2;
  --c-fixed2: #47ab4f;
  --theory: #cfdcd7;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --band-slow: #d3ddd9;
  --band-fast: #52645d;
  --band-fast-ink: #ffffff;

  --ok: #1d7f3b;
  --ok-bg: #e3f3e8;
  --warn: #8f5d00;
  --warn-bg: #fbefd6;
  --bad: #b3301d;
  --bad-bg: #fbe4df;
  --under-bg: #fbe8d8;
  --under-dot: #d26d22;
  --crit-bg: #dff2e5;
  --crit-dot: #2a9a52;
  --over-bg: #e2e8fb;
  --over-dot: #4d6bd1;

  --font: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "D2Coding", monospace;
  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1412;
    --panel: #151d1a;
    --panel-2: #1a2420;
    --ink: #e4ece8;
    --ink-2: #b0bdb7;
    --ink-3: #8f9d97;
    --line: #26322d;
    --line-2: #3a4943;
    --accent: #4cc3d3;
    --accent-hover: #6fd2df;
    --accent-ink: #062126;
    --accent-soft: #123338;
    --scope: #08100e;
    --scope-bezel: #1d2925;
    --theory: #cfdcd7;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --band-slow: #2b3833;
    --band-fast: #8ea29a;
    --band-fast-ink: #0b1210;
    --ok: #57c776;
    --ok-bg: #133020;
    --warn: #e3b04b;
    --warn-bg: #33270d;
    --bad: #f2806a;
    --bad-bg: #3b1b15;
    --under-bg: #3a2413;
    --under-dot: #ef9a55;
    --crit-bg: #13301f;
    --crit-dot: #5fd08a;
    --over-bg: #1b2547;
    --over-dot: #8fa8f5;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #0e1412;
  --panel: #151d1a;
  --panel-2: #1a2420;
  --ink: #e4ece8;
  --ink-2: #b0bdb7;
  --ink-3: #8f9d97;
  --line: #26322d;
  --line-2: #3a4943;
  --accent: #4cc3d3;
  --accent-hover: #6fd2df;
  --accent-ink: #062126;
  --accent-soft: #123338;
  --scope: #08100e;
  --scope-bezel: #1d2925;
  --theory: #cfdcd7;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --band-slow: #2b3833;
  --band-fast: #8ea29a;
  --band-fast-ink: #0b1210;
  --ok: #57c776;
  --ok-bg: #133020;
  --warn: #e3b04b;
  --warn-bg: #33270d;
  --bad: #f2806a;
  --bad-bg: #3b1b15;
  --under-bg: #3a2413;
  --under-dot: #ef9a55;
  --crit-bg: #13301f;
  --crit-dot: #5fd08a;
  --over-bg: #1b2547;
  --over-dot: #8fa8f5;
  color-scheme: dark;
}

/* ---------- 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-fs="s"] { font-size: 15px; }
html[data-fs="l"] { font-size: 18px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: break-word;
}
img, svg, canvas { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { line-height: 1.3; text-wrap: balance; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--mono); }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter-r);
}

/* ---------- 머리글 ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); }
.site-header .wrap { display: flex; align-items: center; gap: 12px 20px; min-height: 60px; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; }
.brand:hover { color: var(--ink); }
.brand svg { width: 30px; height: 30px; flex: none; }
.site-nav { display: flex; gap: 4px; margin-right: auto; }
.site-nav a {
  color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 0.9375rem; white-space: nowrap;
  padding: 8px 10px; border-radius: var(--r-s);
}
@media (max-width: 560px) {
  .site-header .wrap { flex-wrap: wrap; gap: 2px 8px; padding-block: 6px 0; }
  .brand { font-size: 1rem; gap: 8px; margin-right: auto; }
  .theme-btn { order: 2; }
  .site-nav { order: 3; width: 100%; margin: 0 -4px; gap: 0; justify-content: space-between; }
  .site-nav a { padding: 8px 6px; }
}
.site-nav a:hover { color: var(--ink); background: var(--panel-2); }
.site-nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.theme-btn { flex: none; }

/* ---------- 상태바 (FR-0.1) ---------- */
.statusbar { background: var(--panel); border-bottom: 1px solid var(--line); }
.statusbar .wrap { display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; padding-block: 8px; }
.sb-items { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-right: auto; align-items: baseline; }
.sb-item { display: inline-flex; gap: 6px; align-items: baseline; white-space: nowrap; }
.sb-item .k { color: var(--ink-3); font-size: 0.8125rem; }
.sb-item .v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.sb-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 420px) { .sb-actions { gap: 4px; } .sb-actions .btn { padding-inline: 8px; gap: 4px; } .sb-actions .btn svg { width: 14px; height: 14px; } }
@media (min-width: 720px) {
  .statusbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
}

/* ---------- 버튼·입력 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--panel); color: var(--ink);
  font-weight: 600; font-size: 0.9375rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--panel-2); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: 0.875rem; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-m); }
.seg button {
  border: 0; background: transparent; border-radius: 7px; padding: 6px 12px; min-height: 34px;
  font-weight: 600; font-size: 0.9375rem; color: var(--ink-2); cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 0 0 1px var(--line-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
@media (min-width: 760px) { .chips-scroll { flex-wrap: wrap; overflow-x: visible; } }
.chip {
  flex: none; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 6px 14px; min-height: 34px; font-size: 0.875rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }

.input, select.input {
  width: 100%; min-height: 38px; padding: 6px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--panel); color: var(--ink); font-variant-numeric: tabular-nums;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.input.is-invalid { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); }
.field-msg { font-size: 0.8125rem; color: var(--bad); min-height: 0; }
.field-msg:empty { display: none; }
.field-hint { font-size: 0.8125rem; color: var(--ink-3); }

input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); width: 18px; height: 18px; }

.field { display: grid; gap: 6px; }
.field-top { display: flex; align-items: center; gap: 8px; }
.field-top label, .field-top .label { font-weight: 600; font-size: 0.9375rem; margin-right: auto; }
.field-top .input { width: 7.5rem; text-align: right; }
.unit-in { display: flex; align-items: center; gap: 6px; }
.unit-in .u { color: var(--ink-3); font-size: 0.875rem; min-width: 1.5em; }
.formula { font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9375rem; cursor: pointer; }

/* 용어 ? 버튼 */
.term {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--panel); color: var(--ink-2);
  font-size: 0.75rem; font-weight: 700; cursor: help; vertical-align: middle; flex: none;
}
.term:hover, .term[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.pop {
  position: absolute; z-index: 60; max-width: min(320px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-m);
  padding: 10px 12px; font-size: 0.875rem; line-height: 1.55; box-shadow: 0 8px 24px rgba(10, 30, 25, 0.16);
}
.pop strong { display: block; margin-bottom: 2px; }
/* 최근 변경 기록 (FR-3.15) */
.sb-count { margin-left: 4px; min-width: 1.4em; padding: 0 5px; border-radius: 99px; background: var(--accent-soft); font-size: 0.75rem; font-variant-numeric: tabular-nums; line-height: 1.5; }
.sb-count:empty { display: none; }
.hist-pop { width: 360px; max-width: calc(100vw - 32px); padding: 12px; }
.hist-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hist-head strong { margin: 0; }
.hist-help { margin: 0 0 8px; }
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: min(52vh, 420px); overflow-y: auto; overscroll-behavior: contain; }
.hist-item { display: grid; gap: 1px; width: 100%; text-align: left; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-s, 8px); background: transparent; color: inherit; font: inherit; cursor: pointer; }
.hist-item:hover, .hist-item:focus-visible { border-color: var(--line-2); background: var(--panel-2); }
.hist-t { font-weight: 600; font-size: 0.875rem; overflow-wrap: anywhere; }
.hist-d { font-size: 0.8125rem; color: var(--ink-2); overflow-wrap: anywhere; }
.hist-m { font-size: 0.75rem; color: var(--ink-3); }
@media (hover: none) { .kbd-hint { display: none; } }
.hist-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.pop .f { display: block; margin-top: 6px; font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-2); }

/* ---------- 패널 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; min-width: 0; }
.panel-title { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.panel-title .sub { margin-left: auto; font-weight: 500; font-size: 0.8125rem; color: var(--ink-3); }
.stack { display: grid; gap: 14px; }
.stack > *, .lab-controls > *, .lab-main > *, .lab-side > * { min-width: 0; }
.key { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.key-ch1 { background: var(--ch1); }
.key-ch2 { background: var(--ch2); }
.line-key { width: 18px; height: 0; border-top: 3px solid; flex: none; display: inline-block; border-radius: 2px; }

/* ---------- 오실로스코프 ---------- */
.scope { background: var(--scope-bezel); border-radius: var(--r-l); padding: 10px; color: var(--scope-text); }
.scope-screen { position: relative; height: clamp(230px, 46vw, 430px); background: var(--scope); border-radius: 8px; overflow: hidden; touch-action: pan-y; }
.scope-screen canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scope-tags { position: absolute; z-index: 2; top: 8px; left: 10px; right: 10px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; }
.scope-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 4px;
  background: rgba(8, 16, 14, 0.72); color: #dbe7e2; font-size: 0.75rem; font-weight: 600; font-family: var(--mono);
}
.scope-tag .line-key { width: 14px; border-top-width: 2px; }
.scope-tag.right { margin-left: auto; }
.scope-readout { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 4px 0; font-family: var(--mono); font-size: 0.75rem; color: var(--scope-text); }
.scope-readout b { color: #e4eee9; font-weight: 600; }
.scope-tip {
  position: absolute; pointer-events: none; z-index: 3; min-width: 120px;
  background: rgba(8, 16, 14, 0.92); color: #e4eee9; border: 1px solid rgba(150, 205, 185, 0.3);
  border-radius: 6px; padding: 6px 8px; font-family: var(--mono); font-size: 0.75rem; line-height: 1.5;
}
.scope-tip .row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.scope-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.scope-toolbar .grow { margin-right: auto; }
.scope-toolbar label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 0.875rem; color: var(--ink-2); }
.scope-toolbar select.input { width: auto; min-height: 34px; padding: 4px 8px; }

.interpret {
  display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap;
  padding: 12px 14px; margin-top: 12px; border-radius: var(--r-m); background: var(--panel); border: 1px solid var(--line);
}
.interpret p { flex: 1 1 260px; min-width: 0; }
.sim-note { font-size: 0.8125rem; color: var(--ink-3); margin-top: 6px; }

.regime { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-weight: 700; font-size: 0.875rem; white-space: nowrap; }
.regime::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.regime.under { background: var(--under-bg); } .regime.under::before { background: var(--under-dot); }
.regime.crit { background: var(--crit-bg); } .regime.crit::before { background: var(--crit-dot); }
.regime.over { background: var(--over-bg); } .regime.over::before { background: var(--over-dot); }

/* ---------- 지표 ---------- */
.metrics { display: grid; grid-template-columns: 1fr auto auto; gap: 0; margin: 0; font-variant-numeric: tabular-nums; }
.metrics .hd { font-size: 0.75rem; color: var(--ink-3); padding: 0 0 6px; text-align: right; }
.metrics .hd:first-child { text-align: left; }
.metrics dt, .metrics dd { margin: 0; padding: 7px 0; border-top: 1px solid var(--line); }
.metrics dt { display: flex; align-items: center; gap: 6px; font-size: 0.9375rem; color: var(--ink-2); }
.metrics dd { text-align: right; font-weight: 700; padding-left: 14px; white-space: nowrap; }
.metrics dd.meas { color: var(--ink); }
.metrics dd.th { color: var(--ink-2); font-weight: 600; }

.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.checks .t { font-weight: 600; font-size: 0.9375rem; }
.checks .d { font-size: 0.8125rem; color: var(--ink-2); }
.badge {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 0.75rem; font-weight: 800; line-height: 1;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.na { background: var(--panel-2); color: var(--ink-3); }

/* ζ 범위 막대 (부품 조합 진단) */
.zbar { position: relative; margin: 6px 0 30px; }
.zbar-track { position: relative; display: flex; height: 26px; border-radius: 6px; overflow: hidden; }
.zbar-track span { display: flex; align-items: center; font-size: 0.75rem; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; }
.zbar .z-under { justify-content: flex-start; padding-left: 8px; }
.zbar .z-over { justify-content: flex-end; padding-right: 8px; }
.zbar .z-under { background: var(--under-bg); }
.zbar .z-crit { background: var(--crit-bg); }
.zbar .z-over { background: var(--over-bg); }
.zbar-range { position: absolute; top: -4px; height: 34px; border: 2px solid var(--ink); border-radius: 6px; pointer-events: none; }
.zbar-now { position: absolute; top: -8px; width: 2px; height: 42px; background: var(--accent); transform: translateX(-1px); }
.zbar-ticks { position: absolute; left: 0; right: 0; top: 32px; font-size: 0.6875rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.zbar-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* ---------- 표 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.9375rem; }
.table th { text-align: right; font-weight: 600; font-size: 0.8125rem; color: var(--ink-3); padding: 6px 6px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table th:first-child, .table td:first-child { text-align: left; padding-left: 0; }
.table td { text-align: right; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.lab-side .table { font-size: 0.875rem; }
.lab-side .table td:first-child { white-space: normal; }
.table tr.is-best td { background: var(--accent-soft); }
.table .lbl { display: inline-flex; align-items: center; gap: 8px; }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--bad); font-weight: 700; }

/* ---------- 실험실 배치 ---------- */
.lab-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding-block: 18px 12px; }
.lab-head h1 { font-size: 1.5rem; margin-right: auto; }
@media (max-width: 559px) {
  .lab-head .seg { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); width: 100%; }
  .lab-head .seg > :nth-child(-n+2) { grid-column: span 3; }
  .lab-head .seg > :nth-child(n+3) { grid-column: span 2; padding-inline: 4px; }
}
.alt-list { display: grid; gap: 8px; }
.alt-item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.lab-presets { padding-bottom: 14px; }
.lab-presets .chips { align-items: center; }
.lab-presets .lbl { flex: none; font-size: 0.8125rem; color: var(--ink-3); margin-right: 2px; }
.lab-tool { display: grid; gap: 18px; padding-bottom: 32px; }
.lab-main, .lab-side { display: grid; gap: 14px; align-content: start; min-width: 0; }
.lab-controls { display: grid; gap: 14px; }
@media (min-width: 760px) {
  .lab-controls { grid-template-columns: 1fr 1fr; }
  .lab-controls .span-2 { grid-column: 1 / -1; }
}
@media (min-width: 1080px) {
  .lab-tool { grid-template-columns: minmax(0, 1fr) 350px; }
}
@media (max-width: 759px) {
  .lab-scope { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); padding-top: 6px; margin-top: -6px; }
  .lab-scope .scope-screen { height: clamp(200px, 58vw, 260px); }
  .lab-scope .scope { padding: 6px; }
}
.timeline { position: relative; height: 112px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; touch-action: pan-y; cursor: pointer; }
.timeline canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.timeline-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8125rem; color: var(--ink-2); margin-top: 6px; }
.timeline-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.code-box { position: relative; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; font-family: var(--mono); font-size: 0.8125rem; white-space: pre; overflow-x: auto; }
.chart-box { position: relative; height: 300px; }
.bode-box { height: clamp(260px, 40vw, 380px); }
.chart-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 8px; font-size: 0.8125rem; line-height: 1.5;
  box-shadow: 0 6px 18px rgba(10, 30, 25, 0.14); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.875rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 알림·토스트 ---------- */
.banner {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start;
  padding: 12px 14px; border-radius: var(--r-m); border: 1px solid var(--line); background: var(--panel);
}
.banner.warn { background: var(--warn-bg); border-color: transparent; }
.banner.bad { background: var(--bad-bg); border-color: transparent; }
.banner .t { font-weight: 700; }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 80; display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--r-m);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); font-size: 0.9375rem;
}
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: var(--r-s); padding: 4px 10px; font-weight: 700; cursor: pointer; }

/* ---------- 설정 창 ---------- */
dialog.settings {
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--line-2); border-radius: var(--r-l); background: var(--panel); color: var(--ink);
}
dialog.settings::backdrop { background: rgba(6, 14, 12, 0.5); }
.dlg-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 1.125rem; margin-right: auto; }
.dlg-body { padding: 8px 18px 18px; display: grid; gap: 4px; }
.dlg-body details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.dlg-body summary { cursor: pointer; font-weight: 700; padding: 10px 0; list-style-position: inside; }
.dlg-grid { display: grid; gap: 12px; padding: 4px 0 14px; }
@media (min-width: 560px) { .dlg-grid { grid-template-columns: 1fr 1fr; } }
.dlg-grid .full { grid-column: 1 / -1; }
.dlg-field { display: grid; gap: 4px; align-content: start; }
.dlg-field > span:first-child { font-size: 0.875rem; font-weight: 600; }
.inv-list { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.inv-item button { border: 0; background: transparent; cursor: pointer; color: var(--ink-3); font-size: 1rem; line-height: 1; padding: 2px 4px; }
.inv-add { display: flex; gap: 6px; margin-top: 8px; }
.inv-add .input { width: 9rem; }

/* ---------- 본문 (홈·소개·정책) ---------- */
.section { padding-block: 40px; border-top: 1px solid var(--line); }
.section:first-of-type { border-top: 0; }
.section h2 { font-size: 1.5rem; margin-bottom: 14px; }
.prose { max-width: 68ch; display: grid; gap: 14px; }
.prose h2 { font-size: 1.375rem; margin-top: 18px; }
.prose h3 { font-size: 1.0625rem; margin-top: 8px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.prose code { font-family: var(--mono); font-size: 0.875em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.prose table { border-collapse: collapse; width: 100%; }
.page-head { padding-block: 32px 8px; }
.page-head h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); }
.page-head p { margin-top: 8px; color: var(--ink-2); max-width: 62ch; }

.faq { display: grid; gap: 0; max-width: 78ch; }
.faq details { border-top: 1px solid var(--line); }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 700; list-style: none; display: flex; gap: 10px; align-items: baseline; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; font-family: var(--mono); color: var(--accent); width: 1em; flex: none; }
.faq details[open] summary::before { content: "−"; }
.faq .a { padding: 0 0 16px 1.6em; color: var(--ink-2); display: grid; gap: 8px; }

.eq { font-family: var(--mono); font-size: 0.9375rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-s); padding: 10px 12px; overflow-x: auto; white-space: nowrap; }

/* ---------- 바닥글 ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 24px; background: var(--paper); }
.site-footer .wrap { display: grid; gap: 10px; padding-block: 24px 32px; font-size: 0.875rem; color: var(--ink-2); }
.foot-links, .foot-pages { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-links a { color: var(--ink-2); font-weight: 600; }
.foot-pages a { color: var(--ink); font-weight: 700; text-decoration: none; }
.foot-pages a:hover { text-decoration: underline; }

/* ---------- 휴대폰 아래 탭바 ---------- */
.tabbar { display: none; }
@media (max-width: 720px) {
  .site-nav { display: none; }
  .site-header .wrap { flex-wrap: nowrap; padding-block: 6px; min-height: 52px; }
  .brand { margin-right: auto; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(6, 1fr);
    background: var(--panel); border-top: 1px solid var(--line-2); box-shadow: 0 -4px 16px rgba(10, 30, 25, 0.08);
    padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
  }
  .tabbar a {
    display: grid; justify-items: center; align-content: center; gap: 1px; min-height: 56px; padding: 6px 2px 5px;
    color: var(--ink-3); text-decoration: none; font-size: 0.6875rem; font-weight: 700; line-height: 1.2; text-align: center; white-space: nowrap;
  }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .tabbar a[aria-current="page"] svg { stroke-width: 2.4; }
  body.has-tabbar { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)); }
  html { scroll-padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
  body.has-tabbar .toast { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}
@media print { .tabbar { display: none !important; } }

/* ---------- 여러 페이지에서 쓰는 작은 것들 ---------- */
.lead-s { max-width: 70ch; margin-bottom: 16px; }
.h-sm { font-size: 0.9375rem; margin-bottom: 8px; }
.grow { flex: 1 1 auto; }
.jump { margin-top: 14px; }
.jump .chip { text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; }
.ticks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ticks .toggle { align-items: flex-start; font-size: 0.9375rem; }
.ticks input { margin-top: 3px; flex: none; }
.ticks input:checked + span { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--line-2); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; white-space: nowrap; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill.must { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.maybe { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.extra { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .statusbar, .site-footer, .lab-presets, .scope-toolbar { display: none; }
}

/* ---------- 첫 방문 둘러보기 ---------- */
.tour-spot { position: fixed; z-index: 70; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(8, 16, 13, 0.55); pointer-events: none; transition: left 0.25s, top 0.25s, width 0.25s, height 0.25s; }
.tour-pop { position: fixed; z-index: 71; background: var(--panel); color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--r-m); padding: 14px 14px 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28); display: grid; gap: 6px; }
.tour-pop::before { content: ""; position: absolute; left: var(--ax, 50%); width: 12px; height: 12px; background: var(--panel); border: 1px solid var(--line-2); transform: translateX(-50%) rotate(45deg); }
.tour-pop[data-side="below"]::before { top: -7px; border-right: 0; border-bottom: 0; }
.tour-pop[data-side="above"]::before { bottom: -7px; border-left: 0; border-top: 0; }
.tour-pop[data-side="over"]::before { display: none; }
.tour-n { font-size: 0.75rem; color: var(--ink-3); font-weight: 700; }
.tour-pop strong { font-size: 1rem; }
.tour-pop p { margin: 0; font-size: 0.875rem; line-height: 1.55; color: var(--ink-2); }
.tour-acts { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
@media (prefers-reduced-motion: reduce) { .tour-spot { transition: none; } }
@media print { .tour-spot, .tour-pop { display: none !important; } }
#bode-table { font-size: 0.8125rem; }
#bode-table th, #bode-table td { padding-inline: 5px; }
#bode-table td:nth-child(n+2) { white-space: nowrap; }
@media (max-width: 400px) { #bode-table { font-size: 0.75rem; } #bode-table th, #bode-table td { padding-inline: 3px; } }
/* 휴대폰: 넓은 표는 옆으로 밀 때 첫 열(이름)을 붙잡아 둔다 */
@media (max-width: 720px) {
  .panel .table-wrap > .table th:first-child, .panel .table-wrap > .table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
  .prose .table-wrap > .table th:first-child, .prose .table-wrap > .table td:first-child { position: sticky; left: 0; z-index: 1; background: var(--paper); }
  .panel .table-wrap > .table td:first-child, .prose .table-wrap > .table td:first-child { box-shadow: 1px 0 0 var(--line); padding-right: 6px; }
}
