/* 통제가능한 삶의 구조 워크시트. 색·글꼴·모서리는 /design-system.css의 --hf-* 값을 쓴다.
   왼쪽은 원본 시트 순서의 입력 장부, 오른쪽은 표준 범위 막대로 읽는 측정 결과. 좁은 화면에서는 한 열. */
:root {
  --ws-line-strong: var(--hf-line-strong);
  --ws-band: #d3e6df;
  --ws-warn: #8a5a12;
  --ws-warn-soft: #fbf3e1;
  --ws-on-accent: #ffffff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--hf-background); color: var(--hf-ink); font-family: var(--hf-font); font-size: 15px; line-height: 1.55; }
.page { max-width: 1120px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 24px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.75rem; line-height: 1.25; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.125rem; line-height: 1.35; }
h3 { font-size: 0.9375rem; line-height: 1.4; }
.muted { color: var(--hf-muted); }
.small { font-size: 0.8125rem; }

.top { display: flex; flex-direction: column; gap: 8px; }
.top .kicker { font-size: 0.8125rem; color: var(--hf-accent); font-weight: 600; }
.top .lede { color: var(--hf-muted); max-width: 40em; }
.notice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; background: var(--hf-sand); border-radius: var(--hf-radius-card); padding: 12px 16px; }
.notice p { flex: 1 1 16em; min-width: 0; }
.notice .actions { display: flex; flex-wrap: wrap; gap: 8px; }

button { font: inherit; color: inherit; cursor: pointer; }
.btn { min-height: 44px; padding: 0 18px; border-radius: var(--hf-radius-button); border: 1px solid var(--ws-line-strong); background: var(--hf-surface); font-weight: 600; }
.btn.primary { background: var(--hf-accent); border-color: var(--hf-accent); color: var(--ws-on-accent); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--hf-accent); padding: 0 8px; }
.btn.arming { border-color: var(--hf-error); color: var(--hf-error); background: var(--hf-error-soft); }
:is(button, input, select, textarea, a):focus-visible { outline: 2px solid var(--hf-accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 40px; align-items: start; }
.entry { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.sheet { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding-bottom: 8px; border-bottom: 2px solid var(--hf-ink); }
.sheet-head .step { color: var(--hf-accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.sheet-head .hint { color: var(--hf-muted); font-size: 0.8125rem; margin-left: auto; }
.sheet > .help { color: var(--hf-muted); font-size: 0.875rem; }

label { font-size: 0.8125rem; color: var(--hf-muted); display: block; margin-bottom: 4px; }
input[type="text"], input[type="date"], select, textarea { width: 100%; min-width: 0; height: 44px; padding: 0 12px; font: inherit; color: var(--hf-ink); background: var(--hf-surface); border: 1px solid var(--ws-line-strong); border-radius: var(--hf-radius-input); }
textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input.amt { text-align: right; font-variant-numeric: tabular-nums; }
::placeholder { color: var(--hf-muted); opacity: 0.7; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.fields > div { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 7.5rem 2.75rem; gap: 8px; align-items: center; }
.row.has-cat { grid-template-columns: 6.75rem minmax(0, 1fr) 7.5rem 2.75rem; }
.row .del { height: 44px; border: 0; background: transparent; color: var(--hf-muted); border-radius: var(--hf-radius-button); font-size: 1.125rem; line-height: 1; }
@media (hover: hover) and (pointer: fine) { .row .del:hover { background: var(--hf-sand); color: var(--hf-error); } }
.row.auto { color: var(--hf-muted); font-size: 0.875rem; }
.row.auto .auto-val { text-align: right; padding-right: 12px; font-variant-numeric: tabular-nums; color: var(--hf-ink); }
.total { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; padding-top: 10px; border-top: 1px solid var(--hf-line); font-weight: 600; }
.total .sub { font-weight: 400; color: var(--hf-muted); font-size: 0.8125rem; }
.total b { font-variant-numeric: tabular-nums; }

.group { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.group + .group { padding-top: 20px; border-top: 1px solid var(--hf-line); }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.group-head .range { color: var(--hf-muted); font-size: 0.8125rem; }

.result { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; background: var(--hf-sand); border-radius: var(--hf-radius-card); padding: 24px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.result h2 { font-size: 1rem; }
.result section { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.result section + section { padding-top: 20px; border-top: 1px solid var(--ws-line-strong); }
.net { display: flex; flex-direction: column; gap: 2px; }
.net .figure { font-size: 2rem; font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.net .parts { color: var(--hf-muted); font-size: 0.875rem; font-variant-numeric: tabular-nums; }

.zone { display: flex; flex-direction: column; gap: 6px; }
.zone-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; }
.zone-name { font-weight: 600; }
.zone-val { font-variant-numeric: tabular-nums; color: var(--hf-muted); font-size: 0.875rem; text-align: right; }
.zone-val b { color: var(--hf-ink); font-size: 1rem; }
.pill { font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--hf-accent-soft); color: var(--hf-accent); border: 1px solid transparent; }
.pill[data-lv="warn"] { background: var(--ws-warn-soft); color: var(--ws-warn); }
.pill[data-lv="crit"] { background: var(--hf-error-soft); color: var(--hf-error); }
.pill[data-lv="none"] { background: transparent; color: var(--hf-muted); border-color: var(--ws-line-strong); }
.track { position: relative; height: 18px; background: var(--hf-surface); border-radius: 4px; overflow: hidden; }
.track .band { position: absolute; top: 0; bottom: 0; background: var(--ws-band); }
/* 2026-11-30 UI/UX 검수 C-4: 폭 대신 transform으로 민다(app.mjs가 translateX를 준다). .track의 overflow: hidden이 넘친 부분을 가린다. */
.track .fill { position: absolute; left: 0; top: 5px; bottom: 5px; width: 100%; transform: translateX(-100%); background: var(--hf-accent); border-radius: 0 3px 3px 0; transition: transform 0.2s var(--hf-ease-out, ease-out); }
.track .fill[data-lv="warn"] { background: var(--ws-warn); }
.track .fill[data-lv="crit"] { background: var(--hf-error); }
.scale { position: relative; height: 16px; font-size: 0.6875rem; color: var(--hf-muted); font-variant-numeric: tabular-nums; }
.scale span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.scale span.edge { transform: none; }
.scale span.end { transform: translateX(-100%); }

dl { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.facts div { min-width: 0; }
.facts dt { font-size: 0.75rem; color: var(--hf-muted); }
.facts dd { margin: 0; font-weight: 700; font-size: 1.0625rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.todo { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; }
.handoff { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; font-size: 0.875rem; }
.handoff dt { color: var(--hf-muted); }
.handoff dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.handoff-links { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.875rem; }
.handoff-links a { color: var(--hf-accent); text-underline-offset: 4px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--ws-line-strong); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--hf-muted); font-size: 0.75rem; }
td .del { border: 0; background: transparent; color: var(--hf-muted); padding: 2px 6px; border-radius: 6px; }
.up { color: var(--hf-accent); }
.down { color: var(--hf-error); }

.finish { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#status { min-height: 1.5em; color: var(--hf-accent); font-size: 0.875rem; font-weight: 600; }
#status[data-lv="error"] { color: var(--hf-error); }
#copyFallback { font-size: 0.8125rem; min-height: 160px; }
.foot { color: var(--hf-muted); font-size: 0.8125rem; max-width: 60em; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .result { position: static; max-height: none; overflow: visible; padding: 20px 16px; }
}
@media (max-width: 480px) {
  h1 { font-size: 1.5rem; }
  .row { grid-template-columns: minmax(0, 1fr) 6.25rem 2.25rem; gap: 6px; }
  .row.has-cat { grid-template-columns: 5.5rem minmax(0, 1fr) 5.5rem 2.25rem; }
  input[type="text"], select { padding: 0 8px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sheet-head .hint { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .track .fill { transition: none; } }

/* 인쇄: 결과지를 먼저, 입력 장부를 뒤에. 버튼과 안내는 뺀다. */
@media print {
  .notice, .btn, .del, .finish, #status, #copyWrap, .handoff-links, .sheet.no-print { display: none !important; }
  .page { padding: 0; max-width: none; gap: 16px; }
  .layout { display: flex; flex-direction: column-reverse; gap: 24px; }
  .result { position: static; max-height: none; overflow: visible; background: none; padding: 0; break-inside: avoid; }
  .sheet, .group, .zone { break-inside: avoid; }
  input[type="text"], input[type="date"], select, textarea { border: 0; border-bottom: 1px solid var(--hf-line); border-radius: 0; height: 28px; padding: 0 4px; }
  textarea { height: auto; min-height: 0; }
  .row, .row.has-cat { grid-template-columns: 6rem minmax(0, 1fr) 7rem; }
  .row:not(.has-cat) { grid-template-columns: minmax(0, 1fr) 7rem; }
  .track, .track .band, .track .fill, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .track { border: 1px solid var(--hf-line); }
}

/* ── 2026-11-27 모바일·접근성 보완(레드팀 D-9). 근거: /Volumes/P7/goodnewsm-copy/design-2026-11-27/3-mobile-a11y (mobile-audit.ko.md, design-tokens.ko.md).
   값만 덧씌운다(위 규칙은 그대로). 가격·문구는 바꾸지 않는다. ── */
/* G-1: 포커스 3px 진초록 */
:is(button, input, select, textarea, a):focus-visible { outline: 3px solid var(--hf-focus, #1f5b4e); outline-offset: 2px; }
/* G-2: 입력 칸·보조 버튼 테두리 */
input[type="text"], input[type="date"], select, textarea, .btn { border-color: var(--hf-line-control, #857e80); }
.btn.primary { border-color: var(--hf-accent); }
/* W-4: 입력 글자 16px 이상 */
input, select, textarea { font-size: max(16px, 1rem); }
/* W-6: 예시 글자를 흐리게 하지 않음(7.64:1) */
::placeholder { opacity: 1; }
/* W-7: 표준 범위 띠 테두리(흰 길 위 3.66:1) */
.track .band { box-shadow: inset 0 0 0 1px #5f8f83; }
/* W-9: 눈금 숫자 12px */
.scale { font-size: 0.75rem; }
/* W-10: 기록 표의 삭제 단추 44px */
td .del { min-width: 44px; min-height: 44px; }
/* W-3·W-5: 좁은 화면에서도 행 삭제 단추 44px, 범주가 있는 행은 두 줄(윗줄 범주+이름, 아랫줄 금액+삭제) */
@media (max-width: 480px) {
  .row { grid-template-columns: minmax(0, 1fr) 6.25rem 2.75rem; gap: 8px; }
  .row.has-cat { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 2.75rem; }
  .row.has-cat > .amt { grid-column: 1 / 3; }
}
/* W-1: /coaching/worksheet 안에서 높이를 바깥 화면에 맞출 때는 결과 칸을 붙박이로 두지 않는다(frame-height.mjs) */
.in-frame .result { position: static; max-height: none; overflow: visible; }

/* ── 2026-11-27 배포 후 점검 R2 보완(M-1·L-5). 근거: /Volumes/P7/goodnewsm-copy/fix-2026-11-27/post-deploy-check-r2.ko.md ── */
/* M-1: 위 44행 `input[type="text"], … { font: inherit }`(우선순위 0,1,1)가 W-4(0,0,1)를 덮어 글자·날짜 입력이 15px이었다.
   같은 선택자로 뒤에서 다시 지정한다. 인쇄용 28px 규칙은 높이·여백만 바꾸므로 충돌하지 않는다. */
input[type="text"], input[type="date"], select, textarea { font-size: max(16px, 1rem); }
/* L-5: 결과 칸의 이어가기 링크(22px)와 인앱 안내의 링크 단추를 44×44px 이상으로 */
.handoff-links a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; }

/* ── 2026-11-30 UI/UX·접근성 검수 반영. 근거: /Volumes/P7/goodnewsm-copy/uiux-2026-11-30/fable-design-audit.md ── */
/* C-2·C-3·C-7: 버튼 눌림 표시와 호버(마우스에서만). 크기 변화 전환은 움직임 줄이기를 고르지 않은 경우에만. */
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .15s ease, border-color .15s ease, transform .16s var(--hf-ease-out, ease-out); }
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:not(.primary):not(.arming):hover { border-color: var(--hf-accent); background: var(--hf-accent-soft); }
  .btn.primary:hover { background: var(--hf-accent-strong, #1f5b4e); border-color: var(--hf-accent-strong, #1f5b4e); }
}
.row .del:active, td .del:active { background: var(--hf-sand); }
/* D-7: 항목 행 위의 보이는 머리 줄(입력에는 aria-label이 있어 화면 읽기에서는 숨긴다). 행과 같은 열을 쓴다. */
.row-head { color: var(--hf-muted); font-size: 0.8125rem; font-weight: 600; }
.row-head > span:nth-last-child(2) { text-align: right; }
@media (max-width: 480px) { .row-head { display: none; } }
@media print { .row-head { display: none; } }
