:root {
  --paper: #F3F6F5;
  --card: #FFFFFF;
  --sunk: #EAF0EE;
  --ink: #15222C;
  --ink2: #3C4D57;
  --muted: #62737B;
  --line: #D3DDDA;
  --line2: #E4EBE9;
  --teal: #0B6E64;
  --teal-ink: #FFFFFF;
  --teal-soft: #DCEEEA;
  --stamp: #C4362B;
  --s1: #008F7E;
  --s2: #8A5CC8;
  --ok: #23734A;   --ok-bg: #E2F2E8;
  --warn: #8F5B0C; --warn-bg: #FBEFD6;
  --bad: #B42318;  --bad-bg: #FBE4E1;
  --focus: #1E6FD9;
  --shadow: 0 1px 2px rgba(21, 34, 44, .06), 0 4px 14px rgba(21, 34, 44, .05);
  --f-display: "Do Hyeon", "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --f-body: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0F161A; --card: #162127; --sunk: #1B2A31; --ink: #E4ECEA; --ink2: #BFCCCB; --muted: #8FA2A8;
    --line: #2B3B43; --line2: #22323A; --teal: #3FB2A2; --teal-ink: #062421; --teal-soft: #173934;
    --stamp: #E4685C; --s1: #1FA08E; --s2: #9C72DA;
    --ok: #6FCB97; --ok-bg: #173226; --warn: #E6B45A; --warn-bg: #33280F; --bad: #F08A80; --bad-bg: #3A1B18;
    --focus: #6AA8FF; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0F161A; --card: #162127; --sunk: #1B2A31; --ink: #E4ECEA; --ink2: #BFCCCB; --muted: #8FA2A8;
  --line: #2B3B43; --line2: #22323A; --teal: #3FB2A2; --teal-ink: #062421; --teal-soft: #173934;
  --stamp: #E4685C; --s1: #1FA08E; --s2: #9C72DA;
  --ok: #6FCB97; --ok-bg: #173226; --warn: #E6B45A; --warn-bg: #33280F; --bad: #F08A80; --bad-bg: #3A1B18;
  --focus: #6AA8FF; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; line-height: 1.3; }
p { margin: 0; }
a { color: var(--teal); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num, .mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── 머리 ── */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.masthead { max-width: 1120px; margin: 0 auto; padding: 12px 16px 4px; }
.top .tabs { max-width: 1120px; margin: 0 auto; padding: 0 12px; }
.brand-row { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
@media (max-width: 600px) { .brand small { display: none; } .brand b { font-size: 21px; } .store-chip { margin-left: 0; } .view-head h2 { font-size: 25px; } .kpi .v { font-size: 32px; } }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-family: var(--f-display); font-weight: 400; font-size: 24px; letter-spacing: .01em; }
.brand small { color: var(--muted); font-size: 13px; }
.seal { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 2px solid var(--stamp); color: var(--stamp); border-radius: 6px; font-family: var(--f-display); font-size: 13px; line-height: 1; transform: rotate(-6deg); flex: none; }
.store-chip { margin-left: auto; display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink2); background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px; max-width: 100%; }
.store-chip .tag { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 600; }
.store-chip .tag.mine { background: var(--teal-soft); color: var(--teal); }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; border: 0; background: none; padding: 8px 12px 10px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; font-weight: 500; white-space: nowrap; }
.tab .n { font-family: var(--f-mono); font-size: 12px; margin-right: 4px; opacity: .7; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--teal); }
.tab:hover { color: var(--ink); }

main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 64px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.view-head { display: flex; flex-direction: column; gap: 6px; max-width: 72ch; }
.view-head h2 { font-family: var(--f-display); font-weight: 400; font-size: 30px; }
.view-head p { color: var(--ink2); }
.eyebrow { font-size: 12px; letter-spacing: .08em; color: var(--muted); font-weight: 600; }

/* ── 블록 ── */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); min-width: 0; }
.panel.flat { box-shadow: none; background: transparent; border-style: dashed; }
.panel h3 { font-size: 17px; font-weight: 700; }
.panel .sub { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
hr.rule { border: 0; border-top: 1px solid var(--line2); margin: 0; width: 100%; }

/* ── 폼 ── */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; color: var(--ink2); font-weight: 600; }
.field > em { font-style: normal; font-size: 12px; color: var(--muted); }
input[type="text"], input[type="url"], input[type="tel"], input[type="date"], input[type="number"], select, textarea {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; padding: 6px 0; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--teal); flex: none; }
.check .w { margin-left: auto; font-family: var(--f-mono); font-size: 12px; color: var(--muted); flex: none; padding-left: 8px; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--teal); }
.btn.primary { background: var(--teal); color: var(--teal-ink); border-color: var(--teal); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--teal); padding-inline: 6px; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 3px 11px; font-size: 13px; cursor: pointer; color: var(--ink2); }
.chip[aria-pressed="true"] { background: var(--teal-soft); border-color: var(--teal); color: var(--ink); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.neutral { background: var(--sunk); color: var(--ink2); }
.lv-핵심 { background: var(--teal); color: var(--teal-ink); }
.lv-중요 { background: var(--teal-soft); color: var(--teal); }
.lv-보조 { background: var(--sunk); color: var(--muted); }

.note { border-radius: 10px; padding: 12px 14px; font-size: 14px; background: var(--sunk); color: var(--ink2); display: flex; gap: 10px; }
.note.warn { background: var(--warn-bg); color: var(--ink); }
.note.bad { background: var(--bad-bg); color: var(--ink); }
.note b { color: var(--ink); }

/* ── 준비도 ── */
.score-wrap { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; }
@media (max-width: 560px) { .score-wrap { grid-template-columns: 1fr; } }
.score-big { font-family: var(--f-display); font-size: 64px; line-height: 1; color: var(--ink); }
.score-big small { font-size: 20px; color: var(--muted); }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 54px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 0 4px 4px 0; }
.bar-row .v { text-align: right; font-family: var(--f-mono); font-size: 12px; color: var(--ink2); }
details.area { border-top: 1px solid var(--line2); padding-top: 6px; }
details.area summary { cursor: pointer; font-weight: 600; padding: 4px 0; display: flex; gap: 8px; align-items: center; list-style: none; }
details.area summary::-webkit-details-marker { display: none; }
details.area summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.area[open] summary::before { transform: rotate(90deg); }

/* ── 세분류 ── */
.seg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 10px; }
.seg-card { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.seg-card:hover { border-color: var(--teal); }
.seg-card[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.seg-card .code { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.seg-card b { font-size: 15px; }
.seg-card .ex { font-size: 12px; color: var(--muted); line-height: 1.45; }
.seg-card .flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.qlist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.qlist li::marker { color: var(--muted); font-family: var(--f-mono); font-size: 12px; }
.eng-row { display: flex; flex-wrap: wrap; gap: 6px; }
.eng-row .pill { font-weight: 600; }
.guard { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-left: 3px solid var(--bad); background: var(--bad-bg); border-radius: 0 8px 8px 0; font-size: 14px; }
.guard .law { font-size: 12px; color: var(--ink2); }
table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain th, table.plain td { padding: 7px 8px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
table.plain th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.plain td:first-child b { white-space: nowrap; }
.scroll-x { overflow-x: auto; max-width: 100%; }

/* ── 실천 ── */
.stage { display: flex; flex-direction: column; gap: 8px; }
.stage-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.stage-head h3 { font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.stage-head .prog { font-family: var(--f-mono); font-size: 13px; color: var(--muted); }
.act { background: var(--card); border: 1px solid var(--line); border-radius: 10px; position: relative; }
.act > summary { list-style: none; cursor: pointer; padding: 12px 14px; display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; }
.act > summary::-webkit-details-marker { display: none; }
.act .box { width: 20px; height: 20px; border: 2px solid var(--line); border-radius: 5px; margin-top: 2px; }
.act.done .box { background: var(--teal); border-color: var(--teal); }
.act.done .box::after { content: ""; display: block; width: 6px; height: 11px; border: solid var(--teal-ink); border-width: 0 2px 2px 0; transform: translate(5px, 1px) rotate(45deg); }
.act .t { font-weight: 600; }
.act .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; font-size: 12px; color: var(--muted); }
.act .body { padding: 0 14px 14px 46px; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
@media (max-width: 560px) { .act .body { padding-left: 14px; } }
.act .body ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.act .checkline { background: var(--sunk); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.act .checkline b { color: var(--teal); }
.stampmark { font-family: var(--f-display); color: var(--stamp); border: 2px solid var(--stamp); border-radius: 50%; width: 58px; height: 58px; display: grid; place-items: center; text-align: center; font-size: 15px; line-height: 1.05; transform: rotate(-10deg); opacity: .88; flex: none; }
.stampmark small { display: block; font-family: var(--f-mono); font-size: 9px; }
.act.forbidden { border-color: var(--bad); }

/* ── 생성기 ── */
@media (min-width: 900px) { .gen-sticky { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 60px); max-height: calc(100vh - 80px); overflow: auto; } }
.gen-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.out { background: var(--sunk); border: 1px solid var(--line2); border-radius: 10px; padding: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.65; max-height: 420px; overflow: auto; }
.out.code { font-family: var(--f-mono); font-size: 12.5px; line-height: 1.5; white-space: pre; }
.lint { display: flex; flex-wrap: wrap; gap: 6px; }
.nap-table td, .nap-table th { text-align: center; }
.nap-table td:first-child, .nap-table th:first-child { text-align: left; }
.tri { border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; background: var(--card); font-size: 12px; min-width: 52px; }
.tri[data-v="1"] { background: var(--ok-bg); color: var(--ok); border-color: transparent; font-weight: 700; }
.tri[data-v="0"] { background: var(--bad-bg); color: var(--bad); border-color: transparent; font-weight: 700; }

/* ── 측정 ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k { font-size: 13px; color: var(--ink2); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.kpi .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.kpi .v { font-family: var(--f-display); font-size: 38px; line-height: 1.05; }
.kpi .v small { font-size: 16px; color: var(--muted); }
.kpi .d { font-size: 12px; color: var(--muted); }
.kpi.hero { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; }
.verdict { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.chart-box { position: relative; width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -10px; z-index: 5; }
.chart-tip[hidden] { display: none !important; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.band { height: 10px; opacity: .25; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--stamp); }

table.ledger { border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 640px; width: 100%; }
table.ledger th, table.ledger td { border-bottom: 1px solid var(--line2); padding: 6px; vertical-align: top; }
table.ledger thead th { position: sticky; top: 0; background: var(--card); font-size: 12px; color: var(--ink2); text-align: left; border-bottom: 2px solid var(--line); }
table.ledger td.q { min-width: 220px; max-width: 320px; }
table.ledger td.q .qt { font-weight: 500; }
table.ledger td.q .qa { display: flex; gap: 2px; margin-top: 2px; }
.cell { display: flex; flex-direction: column; gap: 4px; min-width: 128px; }
.seg4 { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg4 button { border: 0; background: var(--card); font-size: 11px; padding: 3px 0; cursor: pointer; color: var(--muted); border-left: 1px solid var(--line2); }
.seg4 button:first-child { border-left: 0; }
.seg4 button[aria-pressed="true"] { background: var(--s2); color: #fff; font-weight: 700; }
.seg4 button[data-v="0"][aria-pressed="true"] { background: var(--sunk); color: var(--ink); }
.srcs { display: flex; flex-wrap: wrap; gap: 3px; }
.srcs button { border: 1px dashed var(--line); background: transparent; border-radius: 5px; font-size: 11px; padding: 1px 5px; cursor: pointer; color: var(--muted); }
.srcs button[aria-pressed="true"] { border-style: solid; border-color: var(--s1); background: var(--s1); color: #fff; font-weight: 600; }
.flags2 { display: flex; gap: 8px; font-size: 11px; color: var(--muted); }
.flags2 label { display: flex; gap: 3px; align-items: center; cursor: pointer; }
.flags2 input { accent-color: var(--bad); margin: 0; }
.cell.na .seg4, .cell.na .srcs { opacity: .35; pointer-events: none; }
.runs { display: flex; gap: 6px; flex-wrap: wrap; }
.run-chip { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; background: var(--card); cursor: pointer; font-size: 13px; display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
.run-chip .d { font-family: var(--f-mono); font-size: 12px; }
.run-chip .r { font-size: 11px; color: var(--muted); }
.run-chip[aria-pressed="true"] { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-soft); }
.run-chip.base .d::after { content: " 기준"; color: var(--warn); font-family: var(--f-body); font-weight: 700; }
.heat td.c { text-align: center; font-family: var(--f-mono); font-size: 12px; border-radius: 4px; }

/* ── 근거 ── */
.doc-card { display: flex; flex-direction: column; gap: 10px; }
.doc-card .id { font-family: var(--f-mono); color: var(--muted); font-size: 12px; }
.verdicts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.verdicts li { display: grid; grid-template-columns: 58px 1fr; gap: 8px; align-items: start; }

/* ── 바닥 ── */
.foot { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.foot .spacer { flex: 1; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--bad-bg); border-radius: 8px; padding: 8px 10px; color: var(--ink); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
