/* 위험성평가 판정기 화면. 시스템 글꼴만 쓰고 바깥 자원을 부르지 않는다. */
:root {
  --bg: #F2F4F6; --card: #FFFFFF; --line: #E1E5EA; --line-strong: #C5CCD4;
  --ink: #111418; --ink-2: #2A313A; --mute: #5B6470;
  --green: #0B6B4F; --green-dark: #084C39; --green-tint: #E8F3EF; --green-key: #D5EADF; --green-line: #BFDCD0;
  --warn-bg: #FFF4D6; --warn-card: #FFFAEB; --warn-line: #EBD597; --warn-ink: #4E3500;
  --gray-fill: #4B5563; --error: #B42318;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  font-size: 17px; line-height: 1.7; word-break: keep-all; overflow-wrap: anywhere;
}
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul { margin: 0; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
noscript { display: block; max-width: 720px; margin: 48px auto; padding: 0 24px; }

/* ── 질문 화면 ── */
.page {
  max-width: 1488px; margin: 0 auto; padding: 48px 24px 96px;
  display: grid; grid-template-columns: clamp(320px, 30vw, 460px) minmax(0, 1fr); gap: 24px 48px; align-items: start;
}
.intro { position: sticky; top: 32px; display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.intro h1 { font-size: 34px; line-height: 1.3; font-weight: 800; letter-spacing: -0.01em; }
.lead { font-size: 18px; color: var(--ink-2); }
.meta { font-size: 14px; color: var(--gray-fill); }
.qs { display: flex; flex-direction: column; gap: 20px; max-width: 920px; }
.q { padding: 28px 32px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.q fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.q legend, .q-title { display: block; padding: 0; font-size: 20px; font-weight: 700; line-height: 1.4; }
.q-help { margin: 6px 0 14px; font-size: 15px; line-height: 1.6; color: var(--mute); }
.opts { display: flex; flex-direction: column; gap: 8px; }
legend + .opts { margin-top: 14px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; min-height: 52px; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); cursor: pointer;
}
.opt:hover { border-color: var(--green); }
.opt:has(input:checked) { padding: 11px 13px; border: 2px solid var(--green); background: var(--green-tint); font-weight: 600; }
.opt:has(input:focus-visible) { outline: 3px solid var(--ink); outline-offset: 2px; }
.opt input { flex: none; width: 20px; height: 20px; margin: 5px 0 0; accent-color: var(--green); }
.opt input:focus-visible { outline: none; }
.opt-n {
  flex: none; width: 24px; height: 24px; margin-top: 3px; border-radius: 999px; background: #EEF1F4; color: var(--ink-2);
  font-size: 13px; font-weight: 700; line-height: 24px; text-align: center;
}
.opt:has(input:checked) .opt-n { background: var(--green); color: #FFFFFF; }
.num-row { display: flex; align-items: center; gap: 10px; }
.num-row input {
  width: 170px; height: 52px; padding: 0 16px; border: 1px solid #6B7480; border-radius: 10px; background: var(--card); color: var(--ink);
  font: inherit; font-size: 20px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums;
}
.num-row input[aria-invalid="true"] { border: 2px solid var(--error); }
.unit { font-size: 18px; }
.form-error, .q-error { color: var(--error); font-size: 15px; font-weight: 600; }
.form-error:empty, .q-error:empty { display: none; }
.form-error { padding: 12px 16px; border: 1px solid var(--error); border-radius: 10px; background: var(--card); }
.q-error { margin-top: 10px; }
.btn-go {
  min-height: 56px; padding: 0 40px; border: 0; border-radius: 12px; background: var(--green); color: #FFFFFF;
  font: inherit; font-size: 18px; font-weight: 700; cursor: pointer;
}
.btn-go:hover { background: var(--green-dark); }

/* ── 결과 화면 ── */
.bar { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 1px solid var(--line); }
.bar-inner {
  max-width: 1488px; min-height: 64px; margin: 0 auto; padding: 10px 24px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
}
.bar-title { font-size: 20px; line-height: 28px; font-weight: 800; letter-spacing: -0.01em; }
.bar-title:focus-visible { outline-offset: 4px; }
.bar-actions { display: flex; gap: 8px; }
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 10px; background: var(--card);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-edit, .btn-tier { border: 1px solid var(--green); color: var(--green); }
.btn-edit:hover, .btn-edit:focus-visible, .btn-tier:hover:enabled, .btn-tier:focus-visible { background: var(--green); color: #FFFFFF; }
.btn-reset { border: 1px solid var(--line-strong); color: var(--ink); }
.btn-reset:hover, .btn-reset:focus-visible { background: var(--gray-fill); border-color: var(--gray-fill); color: #FFFFFF; }
.btn-tier { min-height: 48px; }
.btn-tier.on { background: var(--green); color: #FFFFFF; }
.btn-tier:disabled { cursor: default; }
.btn-tier:disabled:not(.on) { opacity: 0.45; }

.layout {
  max-width: 1488px; margin: 0 auto; padding: 28px 24px 96px;
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 26vw, 420px); gap: 24px 32px; align-items: start;
}
.layout > section { grid-column: 1; }
.side {
  grid-column: 2; grid-row: 1 / span 8; position: sticky; top: 88px; max-height: calc(100vh - 112px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px; font-size: 14px; line-height: 1.6;
}
.card {
  display: flex; flex-direction: column; gap: 16px; padding: 32px 36px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
}
.card h3 { font-size: 22px; font-weight: 800; line-height: 1.35; }
.hero { gap: 10px; border-color: var(--green-line); background: var(--green-tint); }
.hero h3 { font-size: 17px; font-weight: 700; color: var(--green-dark); }
.date { font-size: 60px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; color: var(--green-dark); font-variant-numeric: tabular-nums; }
.date + p { margin-top: 6px; font-size: 18px; }
[data-t="T32"] { font-size: 18px; font-weight: 700; }
[data-t="T64"] { font-weight: 700; color: var(--ink); }
.nb { white-space: nowrap; }
.check, .note { padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.6; }
.check { background: var(--warn-bg); color: var(--warn-ink); }
.note { background: var(--bg); color: var(--ink-2); }
.hero .note { background: var(--card); }
.list { display: flex; flex-direction: column; gap: 14px; padding-left: 22px; }
.list .li-check, .list .li-note { margin-left: -20px; padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.6; list-style: none; }
.li-check { background: var(--warn-bg); color: var(--warn-ink); }
.li-note { background: var(--bg); color: var(--ink-2); }
.ref { gap: 12px; padding: 28px 36px; font-size: 15px; color: var(--ink-2); }
.ref h3 { font-size: 19px; color: var(--ink); }
.ref .list { gap: 10px; padding-left: 20px; }
.side .card { gap: 10px; padding: 18px 20px; }
.side h3 { font-size: 16px; }
.side .list { gap: 6px; padding-left: 18px; }
.warn { border-color: var(--warn-line); background: var(--warn-card); color: var(--warn-ink); }
.warn .list { gap: 10px; padding-left: 0; list-style: none; }
.warn .list li, .warn > p { margin-left: 0; padding: 10px 0 0; border-top: 1px solid var(--warn-line); border-radius: 0; background: none; font-size: inherit; line-height: inherit; }
.warn > p { font-weight: 700; }

.item { display: flex; flex-direction: column; gap: 10px; padding-top: 22px; border-top: 1px solid var(--line); }
.item h4 { font-size: 19px; font-weight: 700; line-height: 1.45; }
.basis { font-size: 13px; color: var(--mute); }
.amt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.amt thead th { padding: 10px 12px; background: var(--bg); text-align: right; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.amt thead th:first-child { width: 15%; text-align: left; border-radius: 8px 0 0 8px; }
.amt thead th:last-child { width: 26%; border-radius: 0 8px 8px 0; }
.amt thead th.key { background: var(--green-key); color: var(--green-dark); font-weight: 700; }
.amt tbody th { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; font-weight: 700; white-space: nowrap; vertical-align: top; }
.amt td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.amt td.key { background: var(--green-tint); font-size: 19px; font-weight: 800; }
.amt td.ask { text-align: left; font-size: 13px; line-height: 1.5; font-weight: 400; color: var(--warn-ink); }
.amt tbody tr:last-child th, .amt tbody tr:last-child td { border-bottom: 0; }
.fold { padding-top: 8px; border-top: 1px solid var(--line); }
.fold summary { padding: 10px 0; font-size: 15px; font-weight: 700; color: var(--green-dark); cursor: pointer; }
.fold p { padding-bottom: 10px; font-size: 14px; line-height: 1.65; color: var(--ink-2); }
.fold ~ p { font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.fold ~ p.note { font-size: 14px; }
.links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px; margin: 6px 0; padding: 0; list-style: none; }
.url { display: block; font-size: 12px; color: var(--mute); }
a.url { font-size: 13px; color: var(--green); }
.tiers { display: flex; flex-wrap: wrap; gap: 10px; }
.thanks:empty { display: none; }
.thanks { font-weight: 700; color: var(--green-dark); }

/* 결과가 처음 뜰 때와 새 질문이 나타날 때만 짧게(움직임 줄이기 설정이면 끔) */
@media (prefers-reduced-motion: no-preference) {
  .q, .go-row, .layout { animation: appear 0.2s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (max-width: 1023px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .intro { position: static; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { grid-column: 1; grid-row: auto; position: static; max-height: none; overflow: visible; }
}
@media (max-width: 640px) {
  .page { padding: 24px 12px 64px; }
  .intro h1 { font-size: 26px; }
  .q { padding: 20px 18px; }
  .btn-go { width: 100%; }
  .bar { top: -46px; }
  .bar-inner { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 16px; }
  .bar-actions .btn { flex: 1; padding: 0 10px; }
  .layout { padding: 16px 12px 64px; }
  .card, .ref { padding: 20px 18px; }
  .date { font-size: 44px; }
  .links { grid-template-columns: minmax(0, 1fr); }
  .tiers .btn { width: 100%; }
  .amt thead { display: none; }
  .amt, .amt tbody, .amt tr, .amt tbody th, .amt td { display: block; }
  .amt tr { padding: 12px 0; border-top: 1px solid var(--line); }
  .amt tbody th { padding: 0 0 6px; border-bottom: 0; }
  .amt td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; border-bottom: 0; }
  .amt td::before { content: attr(data-label); flex: none; font-size: 13px; font-weight: 600; color: var(--gray-fill); text-align: left; }
  .amt td.key { background: none; font-size: 18px; }
  .amt td.ask { flex-direction: column; align-items: flex-start; gap: 2px; }
}
