/* 검산 디자인 시스템 「인감과 장부」 — 기준 문서: /DESIGN.md
   장부 표지(깊은 숲색) · 녹색 잉크 서식 · 금박 선 · 빨간 펜과 인주 도장.
   컴포넌트는 아래 토큰만 참조한다. 종이 서식 은유를 지키기 위해 밝은 테마 하나로 설계했다. */

/* ================= 1. Tokens ================= */
:root {
  /* 바탕 */
  --paper: #f5f4ee;
  --sheet: #fdfcf8;
  --sheet-tint: #eef3ef;
  --cover: #0f271d;
  --cover-2: #173628;
  /* 잉크 */
  --ink: #16211c;
  --ink-2: #3f4c45;
  --ink-3: #5a655f;
  --on-cover: #f1eee4;
  --on-cover-2: #b9c4bc;
  /* 서식 녹색 */
  --form: #1e5a3f;
  --form-deep: #154530;
  --form-line: #bccfc2;
  /* 금박과 인주 */
  --brass: #a5844f;
  --brass-on-cover: #d2b98a;
  --seal: #b3241b;
  --seal-tint: #f7e7e3;
  --ok: #1f6a3d;

  /* 글꼴 */
  --sans: "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  --serif: "AppleMyungjo", "Nanum Myeongjo", "NanumMyeongjo", "Noto Serif KR", "Batang", "바탕", serif;
  --fs-xs: .8125rem;
  --fs-sm: .875rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --fs-3xl: 2.5rem;
  --fs-display: clamp(1.875rem, 4.4vw, 2.875rem);

  /* 간격·크기 */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;
  --page: 1160px;
  --gutter: 32px;
  --measure: 44em;
  --control: 44px;
  --control-lg: 52px;
  --r-1: 2px;
  --r-2: 4px;
  --header-h: 72px;

  /* 깊이 */
  --lift: 0 1px 0 rgba(15, 39, 29, .06), 0 30px 60px -36px rgba(15, 39, 29, .28);

  /* 모션 */
  --t-fast: 160ms;
  --t-base: 280ms;
  --t-slow: 560ms;
  --t-draw: 700ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-press: cubic-bezier(.2, .9, .3, 1.25);

  color-scheme: light;
}

/* ================= 2. Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: var(--fs-md); line-height: 1.65;
  word-break: keep-all; overflow-wrap: break-word; font-synthesis: none;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--cover); z-index: 30; }
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; }
ul, ol { padding: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--form); }
svg { flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--form); outline-offset: 2px; }
::selection { background: #d6e5da; }
.wrap {
  width: 100%; max-width: var(--page); margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 40; background: var(--sheet); color: var(--form); padding: 10px 14px; font-weight: 700; border: 2px solid var(--form); transition: top var(--t-fast) var(--ease-out); }
.skip-link:focus { top: 12px; }

/* ================= 3. Seal (공통 도장) ================= */
.seal {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 2px solid currentColor; border-radius: var(--r-2); color: var(--seal);
  font-family: var(--serif); font-size: var(--fs-sm); font-weight: 700; line-height: 1; letter-spacing: -.04em;
  writing-mode: vertical-rl; transform: rotate(-4deg);
  box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 3px currentColor;
  transition: transform var(--t-base) var(--ease-press);
}

/* ================= 4. Masthead (sticky) ================= */
.masthead {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--cover); color: var(--on-cover);
  animation: drop-in var(--t-slow) var(--ease-out) both;
}
.masthead::after { /* 금박 선: 스크롤하면 나타남 */
  content: ""; position: absolute; inset: auto 0 0; height: 1px; background: var(--brass);
  opacity: 0; transition: opacity var(--t-base) var(--ease-out);
}
.masthead.is-scrolled { box-shadow: 0 10px 30px -18px rgba(15, 39, 29, .55); }
.masthead.is-scrolled::after { opacity: .7; }
.masthead-inner {
  display: flex; align-items: center; gap: var(--s-4) var(--s-6);
  min-height: var(--header-h); transition: min-height var(--t-base) var(--ease-out);
}
.masthead.is-scrolled .masthead-inner { min-height: 60px; }
.masthead :focus-visible { outline-color: var(--brass-on-cover); }
.brand { display: inline-flex; align-items: center; gap: var(--s-3); min-height: var(--control); color: var(--on-cover); text-decoration: none; }
.brand .seal { color: #e2584c; width: 38px; height: 38px; }
.brand:hover .seal { transform: rotate(4deg) scale(1.06); }
.brand-name { display: grid; font-family: var(--serif); font-size: var(--fs-xl); font-weight: 700; line-height: 1.1; letter-spacing: .06em; }
.brand-name small { font-family: var(--sans); font-size: .75rem; font-weight: 500; letter-spacing: .14em; color: var(--brass-on-cover); margin-top: 3px; }

.sections { display: flex; gap: var(--s-1); margin-left: auto; }
.sections a {
  position: relative; display: inline-flex; align-items: center; min-height: var(--control); padding: 0 var(--s-3);
  color: var(--on-cover-2); text-decoration: none; font-size: .9375rem; font-weight: 600;
  transition: color var(--t-fast) var(--ease-out);
}
.sections a::after {
  content: ""; position: absolute; left: var(--s-3); right: var(--s-3); bottom: 8px; height: 1.5px; background: var(--brass-on-cover);
  transform: scaleX(0); transform-origin: left; transition: transform var(--t-base) var(--ease-out);
}
.sections a:hover { color: var(--on-cover); }
.sections a:hover::after { transform: scaleX(.5); }
.sections a[aria-current="true"] { color: var(--on-cover); }
.sections a[aria-current="true"]::after { transform: scaleX(1); }
.sections a#nav-results:not([hidden]) { animation: fade-up var(--t-slow) var(--ease-out) both; }

.privacy {
  display: inline-flex; align-items: center; gap: var(--s-2); padding: 6px 12px 6px 10px;
  border: 1px solid rgba(210, 185, 138, .35); border-radius: 999px;
  font-size: var(--fs-sm); color: var(--on-cover-2); white-space: nowrap;
}
.privacy svg { width: 16px; height: 16px; color: var(--brass-on-cover); }
.progress {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 2px; z-index: 1;
  background: var(--brass-on-cover); transform-origin: left; transform: scaleX(0);
}

/* ================= 5. Buttons & fields ================= */
.button {
  position: relative; overflow: hidden; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--control); padding: 10px 20px; border-radius: var(--r-2);
  border: 1.5px solid var(--form); background: var(--sheet); color: var(--form);
  font-size: var(--fs-md); font-weight: 700; line-height: 1.2; white-space: nowrap; letter-spacing: -.005em;
  transition: background-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out), transform var(--t-fast) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
}
.button svg { width: 18px; height: 18px; }
.button:hover:not(:disabled) { background: var(--sheet-tint); }
.button:active:not(:disabled) { transform: translateY(1px) scale(.985); }
.button.primary { background: var(--form); color: var(--sheet); box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 10px 22px -14px rgba(21, 69, 48, .9); }
.button.primary:hover:not(:disabled) { background: var(--form-deep); box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 16px 28px -14px rgba(21, 69, 48, .95); }
.button.primary::after { /* 빛이 한 번 지나감 */
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .22) 48%, transparent 66%);
  transform: translateX(-120%);
}
.button.primary:hover:not(:disabled)::after { transform: translateX(120%); transition: transform 900ms var(--ease-out); }
.button.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.button.quiet:hover { background: var(--sheet-tint); color: var(--ink); }
.button.large { min-height: var(--control-lg); padding-inline: 28px; font-size: 1.0625rem; }
.button:disabled { background: transparent; border-color: var(--form-line); color: var(--ink-3); box-shadow: none; cursor: not-allowed; }
.button.is-ready { animation: ready-glow 1.4s var(--ease-out) 1; }
.link-button {
  display: inline-flex; align-items: center; min-height: var(--control); padding: 0 var(--s-2); border: 0; background: none;
  font-size: .9375rem; font-weight: 600; color: var(--form);
  text-decoration: underline; text-decoration-color: var(--form-line); text-decoration-thickness: 1.5px; text-underline-offset: 6px;
  transition: text-decoration-color var(--t-fast) var(--ease-out);
}
.link-button:hover { text-decoration-color: var(--form); }

select, input[type="number"], input[type="search"] {
  width: 100%; min-width: 0; min-height: var(--control); padding: 8px 12px;
  background: var(--sheet); color: var(--ink); border: 1px solid var(--form-line); border-radius: var(--r-1);
  border-bottom: 1.5px solid var(--form); font-size: var(--fs-md); font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-base) var(--ease-out), background-color var(--t-fast);
}
select:hover, input:hover { border-color: var(--form); }
select:focus-visible, input:focus-visible { outline: none; border-color: var(--form); box-shadow: 0 0 0 3px rgba(30, 90, 63, .28); background: #fff; }

/* ================= 6. Intro ================= */
main { display: block; }
.intro {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: end; gap: var(--s-6) var(--s-7);
  padding-block: var(--s-7) var(--s-6);
}
.intro-copy { display: grid; gap: var(--s-4); min-width: 0; }
.intro-title {
  font-family: var(--serif); font-size: var(--fs-display); font-weight: 700; line-height: 1.28; letter-spacing: -.01em;
  color: var(--ink); text-wrap: balance;
}
.intro-lede { max-width: 34em; font-size: 1.0625rem; color: var(--ink-2); }
.try-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2); }

.specimen { display: grid; border-top: 1.5px solid var(--form); border-bottom: 1.5px solid var(--form); min-width: 0; }
.specimen > div { display: grid; grid-template-columns: 9.5em 1fr; align-items: baseline; gap: var(--s-3); padding: 12px 0; }
.specimen > div + div { border-top: 1px solid var(--form-line); }
.specimen dt { font-size: var(--fs-sm); font-weight: 700; color: var(--form); }
.specimen dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; color: var(--ink-2); font-size: var(--fs-sm); }
.specimen b { font-family: var(--serif); font-size: 1.625rem; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.specimen span { flex-basis: 100%; color: var(--ink-3); }

/* ================= 7. Sheet (서식) ================= */
.stack { display: grid; gap: var(--s-5); padding-bottom: var(--s-8); }
.sheet { border: 2px solid var(--form); background: var(--sheet); box-shadow: var(--lift); border-radius: var(--r-1); }
.sheet-head { position: relative; padding: var(--s-5) var(--s-4) var(--s-4); border-bottom: 2px solid var(--form); text-align: center; }
.sheet-head::after { /* 이중 괘선 */
  content: ""; position: absolute; left: 0; right: 0; bottom: 3px; height: 1px; background: var(--form);
}
.sheet-title {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 0 .9em; color: var(--form);
  font-family: var(--serif); font-size: 1.875rem; font-weight: 700; line-height: 1.3; letter-spacing: .4em;
}
.sheet-title span:last-child { margin-right: -.4em; }
.sheet-sub { margin-top: var(--s-1); padding-bottom: var(--s-2); font-size: .9375rem; color: var(--ink-2); }

.files-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.file-card { min-width: 0; display: grid; align-content: start; padding: 0 0 var(--s-5); }
.file-card + .file-card { border-left: 1px solid var(--form); }
.file-heading { display: flex; align-items: baseline; gap: 10px; padding: 10px 24px; background: var(--sheet-tint); border-bottom: 1px solid var(--form-line); }
.file-heading h3 { font-size: 1.0625rem; font-weight: 800; color: var(--form); }
.file-heading p { font-size: .9375rem; color: var(--ink-2); }
.file-card > :not(.file-heading) { margin-inline: 24px; }

.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.drop-area {
  position: relative; display: flex; align-items: center; gap: var(--s-4); margin-top: 20px; min-height: 100px; padding: var(--s-4) 18px;
  border: 1.5px dashed var(--form-line); border-radius: var(--r-2); background: var(--sheet); cursor: pointer;
  transition: border-color var(--t-base) var(--ease-out), background-color var(--t-base) var(--ease-out), transform var(--t-base) var(--ease-out);
}
.drop-area:hover { border-color: var(--form); background: var(--sheet-tint); }
.drop-area.dragging { border-color: var(--form); border-style: solid; background: var(--sheet-tint); animation: breathe 1.2s ease-in-out infinite; }
.file-input:focus-visible + .drop-area { outline: 3px solid var(--form); outline-offset: 2px; }
.upload-symbol {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 50%;
  color: var(--form); background: var(--sheet-tint); border: 1px solid var(--form-line);
  transition: transform var(--t-base) var(--ease-press), background-color var(--t-base);
}
.upload-symbol svg { width: 24px; height: 24px; }
.drop-area:hover .upload-symbol, .drop-area.dragging .upload-symbol { transform: translateY(-4px); background: var(--sheet); }
.drop-text { display: grid; gap: 2px; min-width: 0; }
.drop-area b { font-size: var(--fs-md); font-weight: 700; overflow-wrap: anywhere; }
.drop-area small { font-size: var(--fs-sm); color: var(--ink-3); }
.file-card[data-state="loaded"] .drop-area { border-style: solid; border-color: var(--form); min-height: 72px; animation: settle var(--t-slow) var(--ease-out) both; }
.file-card[data-state="loaded"] .upload-symbol { color: var(--sheet); background: var(--ok); border-color: var(--ok); }
.file-card[data-state="loaded"] .upload-symbol path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw var(--t-draw) var(--ease-out) 120ms forwards; }
.file-card[data-state="busy"] .drop-area { cursor: progress; }
.file-card[data-state="busy"] .drop-area::after { /* 읽는 중 */
  content: ""; position: absolute; left: 0; bottom: -1.5px; height: 2px; width: 40%; background: var(--form);
  animation: scan 1.1s var(--ease-out) infinite;
}
.file-meta { margin-top: 10px; font-size: .9375rem; color: var(--ink-2); animation: fade-up var(--t-slow) var(--ease-out) 80ms both; }

.file-settings { display: grid; grid-template-columns: minmax(0, 1fr) 112px; gap: var(--s-3); margin-top: 14px; animation: fade-up var(--t-slow) var(--ease-out) 140ms both; }
.file-settings label, .mapping-grid label { display: grid; gap: var(--s-1); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); min-width: 0; }

.mapping { margin-top: 14px; border-top: 1px solid var(--form-line); animation: fade-up var(--t-slow) var(--ease-out) 200ms both; }
.mapping summary { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; list-style: none; font-weight: 700; }
.mapping summary::-webkit-details-marker { display: none; }
.mapping summary::after {
  content: ""; width: 8px; height: 8px; margin: 0 4px 4px 2px; border: solid var(--ink-2); border-width: 0 2px 2px 0;
  transform: rotate(45deg); transition: transform var(--t-base) var(--ease-out), margin var(--t-base) var(--ease-out);
}
.mapping[open] summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.mapping[open] .mapping-grid { animation: fade-up var(--t-base) var(--ease-out) both; }
.map-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: var(--fs-xs); font-weight: 800; color: var(--sheet); background: var(--ok); flex: none; }
.mapping[data-state="todo"] .map-mark { background: var(--seal); animation: nudge 1.6s ease-in-out 2; }
.mapping[data-state="todo"] .map-label { color: var(--seal); }
.map-hint { margin-left: auto; font-size: var(--fs-sm); font-weight: 600; color: var(--ink-3); }
.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.mapping-help { margin-top: var(--s-3); font-size: var(--fs-sm); color: var(--ink-3); }

.run-row { display: flex; align-items: center; justify-content: space-between; gap: 14px var(--s-5); padding: 18px 24px; border-top: 2px solid var(--form); background: linear-gradient(var(--sheet), var(--sheet-tint)); }
.run-hint { font-size: .9375rem; color: var(--ink-2); max-width: 36em; }
.run-actions { display: flex; gap: var(--s-2); flex: none; }

.notice { font-size: .9375rem; color: var(--ink-2); min-height: 26px; margin-top: -8px; padding-left: 14px; border-left: 2px solid var(--form-line); }
.notice.is-new { animation: fade-in var(--t-slow) var(--ease-out); }
.notice.error { color: var(--seal); font-weight: 700; border-left-color: var(--seal); }

/* ================= 8. Results ================= */
.results { display: grid; gap: var(--s-5); padding-top: var(--s-5); }
.results-head { display: flex; align-items: center; gap: var(--s-3) var(--s-5); flex-wrap: wrap; padding-bottom: var(--s-4); border-bottom: 1px solid var(--form-line); }
.results-title-wrap { display: grid; gap: 2px; }
.results-head h2 { font-family: var(--serif); font-size: var(--fs-2xl); font-weight: 700; letter-spacing: .02em; }
.results-head h2:focus { outline: none; }
.results-head h2:focus-visible { outline: 3px solid var(--form); outline-offset: 4px; }
.results-sub { font-size: var(--fs-sm); color: var(--ink-3); }
.results-head .button { margin-left: auto; }

/* 인주 도장: 화면의 유일한 과감한 요소 */
.result-badge {
  display: inline-grid; place-items: center; width: 92px; height: 92px; margin-block: -22px;
  border: 3px solid var(--seal); border-radius: 50%; color: var(--seal);
  font-family: var(--serif); font-size: 1.0625rem; font-weight: 700; line-height: 1.15; text-align: center; letter-spacing: .04em;
  padding: 0 16px; box-shadow: inset 0 0 0 3px var(--sheet), inset 0 0 0 4.5px var(--seal);
  transform: rotate(-9deg); opacity: .9; mix-blend-mode: multiply;
}
.result-badge:empty { display: none; }
.result-badge.stamped { animation: stamp .5s var(--ease-press) 120ms both; }
.result-badge.success { color: var(--ok); border-color: var(--ok); box-shadow: inset 0 0 0 3px var(--sheet), inset 0 0 0 4.5px var(--ok); }

.tally { display: grid; grid-template-columns: 1.1fr 1fr 1.25fr; border: 2px solid var(--form); background: var(--sheet); box-shadow: var(--lift); border-radius: var(--r-1); }
.tally > div { min-width: 0; display: grid; grid-template-rows: auto 1fr; }
.tally > div + div { border-left: 1px solid var(--form); }
.tally dt { padding: 9px 18px; font-size: .9375rem; font-weight: 700; color: var(--form); background: var(--sheet-tint); border-bottom: 1px solid var(--form-line); }
.tally dd { display: grid; align-content: start; gap: var(--s-1); padding: 14px 18px 16px; font-size: .9375rem; color: var(--ink-2); }
.tally strong {
  display: flex; align-items: baseline; gap: 6px; color: var(--ink);
  font-family: var(--serif); font-size: var(--fs-3xl); font-weight: 700; line-height: 1.1; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.tally strong small { font-family: var(--sans); font-size: var(--fs-md); font-weight: 600; color: var(--ink-2); }
.results[data-state="issues"] .tally-issues strong { color: var(--seal); }
.results[data-state="clean"] .tally-issues strong { color: var(--ok); }
.results.is-entering .tally > div { animation: fade-up var(--t-slow) var(--ease-out) both; }
.results.is-entering .tally > div:nth-child(2) { animation-delay: 80ms; }
.results.is-entering .tally > div:nth-child(3) { animation-delay: 160ms; }
.results.is-entering .ledger { animation: fade-up var(--t-slow) var(--ease-out) 220ms both; }

.ledger { border: 2px solid var(--form); background: var(--sheet); box-shadow: var(--lift); border-radius: var(--r-1); }
.ledger-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3) var(--s-5); flex-wrap: wrap; padding: var(--s-4) 18px; border-bottom: 2px solid var(--form); }
.ledger-tools h3 { font-size: var(--fs-lg); font-weight: 800; }
.filter-count { margin-left: 6px; font-size: .9375rem; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.filters { display: flex; flex-wrap: wrap; gap: 10px var(--s-3); }
.field { display: grid; gap: var(--s-1); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.field select { width: 230px; }
.field input { width: 200px; }

.table-scroll { position: relative; overflow-x: auto; }
table { width: 100%; min-width: 900px; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
th { padding: 10px 14px; background: var(--sheet-tint); color: var(--form); font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--form); }
th + th, td + td { border-left: 1px solid var(--form-line); }
td { padding: 13px 14px; vertical-align: top; font-size: .9375rem; color: var(--ink-2); border-bottom: 1px solid var(--form-line); transition: background-color var(--t-fast) var(--ease-out); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f3f7f4; }
tbody tr.row-in { animation: row-in 460ms var(--ease-out) var(--d, 0ms) both; }
.seq { width: 52px; color: var(--ink-3); font-family: var(--serif); }
.issue-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--seal); white-space: nowrap; }
.issue-chip::before { content: "!"; display: grid; place-items: center; width: 18px; height: 18px; border: 1.5px solid currentColor; border-radius: 50%; font-size: .6875rem; font-weight: 800; line-height: 1; }
.where { white-space: nowrap; }
.code { font-weight: 800; color: var(--ink); white-space: nowrap; letter-spacing: .02em; }
.explanation { min-width: 230px; max-width: 340px; }
.explanation b { display: block; color: var(--ink); }
.value { max-width: 170px; overflow-wrap: anywhere; color: var(--ink); }
.num { text-align: right; }

/* 빨간 펜 동그라미 */
.pen { position: relative; display: inline-block; padding: 2px 10px; color: var(--seal); font-weight: 800; }
.pen-ring { position: absolute; inset: -5px -6px -6px -8px; width: calc(100% + 14px); height: calc(100% + 11px); overflow: visible; pointer-events: none; }
.pen-ring path { fill: none; stroke: var(--seal); stroke-width: 1.6; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 0; }
tr.row-in .pen-ring path { stroke-dashoffset: 1; animation: draw var(--t-draw) var(--ease-out) calc(var(--d, 0ms) + 260ms) forwards; }

.empty { padding: 40px 20px; text-align: center; display: grid; justify-items: center; gap: var(--s-1); }
.empty-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: var(--s-2); border-radius: 50%; background: var(--ok); color: var(--sheet); }
.empty-mark svg { width: 28px; height: 28px; }
.empty:not([hidden]) .empty-mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw var(--t-draw) var(--ease-out) 200ms forwards; }
.empty:not([hidden]) { animation: fade-up var(--t-slow) var(--ease-out) both; }
.empty h3 { font-family: var(--serif); font-size: var(--fs-xl); color: var(--ok); }
.empty p { color: var(--ink-2); }
.ledger-note { padding: 12px 18px; font-size: var(--fs-sm); color: var(--ink-3); border-top: 1px solid var(--form); }

.rules { border-top: 1px solid var(--form-line); }
.rules summary {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--control); cursor: pointer; list-style: none; font-weight: 700; color: var(--form);
}
.rules summary::-webkit-details-marker { display: none; }
.rules summary::before { content: "+"; display: grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid currentColor; border-radius: 50%; font-weight: 600; line-height: 1; transition: transform var(--t-base) var(--ease-out); }
.rules[open] summary::before { transform: rotate(45deg); }
.rules[open] .rules-body { animation: fade-up var(--t-base) var(--ease-out) both; }
.rules-body { display: grid; gap: var(--s-2); max-width: var(--measure); padding-bottom: var(--s-2); font-size: .9375rem; color: var(--ink-2); }

/* ================= 9. Guide ================= */
.guide { display: grid; grid-template-columns: 12em minmax(0, 1fr); gap: var(--s-4) var(--s-6); padding-top: var(--s-6); margin-top: var(--s-4); border-top: 1.5px solid var(--form); }
.guide h2 { font-family: var(--serif); font-size: var(--fs-xl); font-weight: 700; color: var(--ink); }
.guide ol { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); counter-reset: step; }
.guide li { counter-increment: step; display: grid; gap: var(--s-1); padding-top: var(--s-3); border-top: 1px solid var(--form-line); color: var(--ink-2); font-size: .9375rem; }
.guide li::before { content: counter(step); font-family: var(--serif); font-size: var(--fs-2xl); line-height: 1; color: var(--form); }
.guide li b { color: var(--ink); font-size: var(--fs-md); }

/* 오류 샘플 정답표 (접힘) */
.answers { grid-column: 2; border-top: 1px solid var(--form-line); }
.answers summary {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--control); cursor: pointer; list-style: none; font-weight: 700; color: var(--form);
}
.answers summary::-webkit-details-marker { display: none; }
.answers summary::before { content: "+"; display: grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid currentColor; border-radius: 50%; font-weight: 600; line-height: 1; transition: transform var(--t-base) var(--ease-out); }
.answers[open] summary::before { transform: rotate(45deg); }
.answers[open] .answers-body { animation: fade-up var(--t-base) var(--ease-out) both; }
.answers-body { display: grid; gap: var(--s-6); padding: var(--s-3) 0 var(--s-2); }
.answers-body section { display: grid; gap: var(--s-2); min-width: 0; }
.answers-body h3 { font-family: var(--serif); font-size: var(--fs-lg); font-weight: 700; color: var(--ink); }
.answers-body p { max-width: var(--measure); font-size: .9375rem; color: var(--ink-2); }
.answers-body p b { color: var(--ink); }
.key-scroll { margin-top: var(--s-2); overflow-x: auto; border: 1.5px solid var(--form); border-radius: var(--r-1); background: var(--sheet); }
.key-table { min-width: 0; }
.key-table th { padding: 8px 14px; }
.key-table td { padding: 10px 14px; color: var(--ink-2); }
.key-table td:first-child { color: var(--ink); font-weight: 600; }
.key-table .code { font-weight: 800; }
.key-table tbody tr:hover td { background: #f3f7f4; }

/* ================= 10. Footer ================= */
.footer { background: var(--cover); color: var(--on-cover-2); position: relative; }
.footer::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; border-top: 1px solid var(--brass); border-bottom: 1px solid var(--brass); opacity: .55; }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, .8fr); gap: var(--s-6); padding-block: 56px var(--s-6); }
.footer-brand { display: flex; align-items: flex-start; gap: var(--s-4); }
.footer-brand .seal { color: #e2584c; width: 44px; height: 44px; font-size: .9375rem; }
.footer-brand p { display: grid; gap: var(--s-1); font-size: .9375rem; max-width: 26em; text-wrap: balance; }
.footer-brand b { font-family: var(--serif); font-size: var(--fs-xl); color: var(--on-cover); letter-spacing: .06em; font-weight: 700; }
.footer-col h2 { font-size: var(--fs-sm); font-weight: 700; color: var(--brass-on-cover); margin-bottom: var(--s-3); letter-spacing: .08em; }
.footer-col ul { list-style: none; display: grid; gap: 0; font-size: .9375rem; }
.footer-col a { display: inline-flex; align-items: center; min-height: var(--control); color: var(--on-cover); text-decoration: underline; text-decoration-color: rgba(210, 185, 138, .4); text-underline-offset: 5px; transition: text-decoration-color var(--t-fast); }
.footer-col a:hover { text-decoration-color: var(--brass-on-cover); }
.footer :focus-visible { outline-color: var(--brass-on-cover); }
.footer-base {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
  padding-block: 18px max(24px, env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(210, 185, 138, .22);
  font-size: var(--fs-sm); color: var(--on-cover-2);
}

/* ================= 11. Motion ================= */
@keyframes drop-in { from { transform: translateY(-100%); } to { transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes settle { from { transform: scale(.985); } to { transform: none; } }
@keyframes scan { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(30, 90, 63, .0); } 50% { box-shadow: 0 0 0 6px rgba(30, 90, 63, .14); } }
@keyframes nudge { 0%, 100% { transform: none; } 20% { transform: scale(1.18); } 40% { transform: none; } }
@keyframes ready-glow { 0% { box-shadow: 0 0 0 0 rgba(30, 90, 63, .5); } 100% { box-shadow: 0 0 0 14px rgba(30, 90, 63, 0); } }
@keyframes stamp {
  0% { transform: rotate(-22deg) scale(2.2); opacity: 0; }
  55% { transform: rotate(-8deg) scale(.92); opacity: 1; }
  75% { transform: rotate(-9deg) scale(1.03); }
  100% { transform: rotate(-9deg) scale(1); opacity: .9; }
}

/* 첫 화면 순차 등장 */
[data-enter] { animation: fade-up 720ms var(--ease-out) both; }
.intro-copy > [data-enter]:nth-child(1) { animation-delay: 120ms; }
.intro-copy > [data-enter]:nth-child(2) { animation-delay: 200ms; }
.intro-copy > [data-enter]:nth-child(3) { animation-delay: 280ms; }
.specimen[data-enter] { animation-delay: 360ms; }
.specimen[data-enter] > div { animation: fade-up 620ms var(--ease-out) both; }
.specimen[data-enter] > div:nth-child(1) { animation-delay: 420ms; }
.specimen[data-enter] > div:nth-child(2) { animation-delay: 500ms; }
.specimen[data-enter] > div:nth-child(3) { animation-delay: 580ms; }

/* 스크롤 등장: JS가 html에 .motion을 붙였을 때만 숨긴다 */
.motion [data-reveal] { opacity: 0; transform: translateY(24px); transition: opacity 760ms var(--ease-out), transform 760ms var(--ease-out); }
.motion [data-reveal].is-in { opacity: 1; transform: none; }

/* ================= 12. Narrow screens ================= */
@media (max-width: 1000px) {
  .sections { display: none; }
  .privacy { margin-left: auto; }
  .intro { grid-template-columns: 1fr; align-items: start; }
  .guide { grid-template-columns: 1fr; }
  .answers { grid-column: 1; }
}
@media (max-width: 760px) {
  :root { --gutter: 16px; --header-h: 60px; --fs-3xl: 2.125rem; }
  .masthead-inner { gap: var(--s-3); }
  .masthead.is-scrolled .masthead-inner { min-height: 54px; }
  .brand .seal { width: 34px; height: 34px; font-size: .8125rem; }
  .brand-name small { display: none; }
  .privacy { padding: 4px 10px 4px 8px; font-size: var(--fs-xs); }
  .intro { padding-block: var(--s-6) var(--s-5); gap: var(--s-5); }
  .intro-title { font-size: 1.75rem; }
  .intro-lede { font-size: var(--fs-md); }
  .try-actions .button { flex: 1 1 100%; }
  .try-actions .link-button { margin-inline: auto; }
  .specimen > div { grid-template-columns: 8.5em 1fr; }
  .stack { gap: var(--s-4); padding-bottom: var(--s-7); }
  .sheet-title { font-size: 1.5rem; letter-spacing: .26em; gap: 0 .55em; }
  .sheet-title span:last-child { margin-right: -.26em; }
  .files-grid { grid-template-columns: 1fr; }
  .file-card + .file-card { border-left: 0; border-top: 2px solid var(--form); }
  .file-heading { padding-inline: 16px; }
  .file-card > :not(.file-heading) { margin-inline: 16px; }
  .run-row { flex-direction: column; align-items: stretch; padding: var(--s-4); }
  .run-actions { display: grid; grid-template-columns: 1fr 2fr; }
  .results-head { align-items: flex-start; }
  .results-head .button { margin-left: 0; width: 100%; order: 3; }
  .result-badge { width: 80px; height: 80px; margin: -6px 0 -10px auto; font-size: var(--fs-md); }
  .tally { grid-template-columns: 1fr 1fr; }
  .tally-issues { grid-column: 1 / -1; border-bottom: 1px solid var(--form); }
  .tally > div + div { border-left: 0; }
  .tally > div:last-child { border-left: 1px solid var(--form); }
  .tally dd, .tally dt { padding-inline: 14px; }
  .tally > div:not(.tally-issues) strong { font-size: 1.625rem; }
  .filters, .field { width: 100%; }
  .field select, .field input { width: 100%; }

  /* 표 → 한 항목씩 세로 서식 */
  table, tbody, tr, td { display: block; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding: var(--s-4); border-bottom: 1px solid var(--form); }
  tbody tr:last-child { border-bottom: 0; }
  tbody tr:hover td { background: none; }
  td, td + td { padding: 0; border: 0; max-width: none; min-width: 0; width: auto; }
  td::before { content: attr(data-label); display: block; font-size: var(--fs-xs); font-weight: 700; color: var(--form); }
  td.seq { display: none; }
  td.type-cell, .explanation { grid-column: 1 / -1; }
  td.type-cell::before { display: none; }
  .num { text-align: left; }
  .pen { margin-left: 6px; }

  .guide ol { grid-template-columns: 1fr; gap: var(--s-4); }
  .key-table { display: table; }
  .key-table thead { position: static; width: auto; height: auto; clip-path: none; overflow: visible; display: table-header-group; }
  .key-table tbody { display: table-row-group; }
  .key-table tr, .key-table tbody tr { display: table-row; padding: 0; }
  .key-table td, .key-table td + td { display: table-cell; padding: 9px 10px; border-bottom: 1px solid var(--form-line); }
  .key-table td + td { border-left: 1px solid var(--form-line); }
  .key-table tbody tr:last-child td { border-bottom: 0; }
  .key-table td::before { content: none; }
  .key-table th { padding: 8px 10px; white-space: normal; }
  .footer-inner { grid-template-columns: 1fr 1fr; padding-block: var(--s-7) var(--s-5); gap: var(--s-5); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 400px) {
  .privacy span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .privacy { padding: 0; border: 0; width: var(--control); height: var(--control); justify-content: center; }
  .privacy svg { width: 20px; height: 20px; }
  .file-settings { grid-template-columns: minmax(0, 1fr) 92px; }
  .mapping-grid { grid-template-columns: 1fr; }
  .map-hint { display: none; }
  .footer-inner { grid-template-columns: 1fr; }
}

/* 움직임 줄이기: 모든 이동·그리기를 끄고 결과만 보여준다 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .motion [data-reveal] { opacity: 1; transform: none; }
  .pen-ring path, .upload-symbol path, .empty-mark path { stroke-dashoffset: 0 !important; }
}
