/* 정책안 사전 점검 화면. 토스 계열의 밝은 회색 바탕 위 흰 카드, 큰 숫자와 짧은 문장.
   찬성 = 파랑, 반대 = 빨강, 모름 = 회색을 모든 화면에서 같은 뜻으로 쓴다. */
:root {
  --blue: #3182f6;
  --blue-strong: #1b64da;
  --blue-soft: #e8f3ff;
  --red: #f04452;
  --red-soft: #ffeeef;
  --orange: #e5850b;
  --orange-soft: #fff3e0;
  --green: #0a9c5e;
  --green-soft: #e5f7ee;
  --g900: #191f28;
  --g800: #333d4b;
  --g700: #4e5968;
  --g600: #6b7684;
  --g500: #8b95a1;
  --g400: #b0b8c1;
  --g300: #d1d6db;
  --g200: #e5e8eb;
  --g100: #f2f4f6;
  --g50: #f9fafb;
  --white: #ffffff;
  --pro: var(--blue);
  --con: var(--red);
  --dk: var(--g300);
  --radius-l: 24px;
  --radius-m: 16px;
  --radius-s: 10px;
  --top-h: calc(56px + env(safe-area-inset-top, 0px));    /* 위 막대 높이(구역 이동 줄이 그 밑에 붙는다) */
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--g100);
  color: var(--g900);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(49, 130, 246, 0.45); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; letter-spacing: -0.02em; }
.num, .figure-value, .stage-no { font-variant-numeric: tabular-nums; }

/* 위 막대 ------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--g200);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--g900); }
.brand-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); margin-right: 8px; vertical-align: 1px; }
.region { margin-left: auto; }

/* 쪽 ----------------------------------------------------------------------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);       /* 안의 긴 줄(구역 이동 칩 등)이 쪽 너비를 밀어내지 않게 */
  gap: 16px;
}
.hero { padding: 12px 8px 8px; display: grid; gap: 12px; }
.hero h1 { font-size: clamp(26px, 6vw, 32px); line-height: 1.35; font-weight: 700; }
.hero p { color: var(--g700); font-size: 17px; }

.card {
  background: var(--white);
  border-radius: var(--radius-l);
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);       /* 옆으로 넘기는 줄이 카드 너비를 밀어내지 않게 */
  gap: 16px;
  min-width: 0;
}
@media (max-width: 480px) { .card { padding: 20px; border-radius: 20px; } }
.card h2 { font-size: 21px; line-height: 1.4; font-weight: 700; }
.card h3 { font-size: 17px; line-height: 1.45; font-weight: 700; }
.sub { color: var(--g600); font-size: 15px; }
.caption { color: var(--g600); font-size: 14px; line-height: 1.55; }
.eyebrow { color: var(--g600); font-size: 14px; font-weight: 600; }
.section-title { padding: 20px 8px 0; font-size: 19px; font-weight: 700; }

/* 칩 · 단추 ------------------------------------------------------------------ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--g100);
  color: var(--g700);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.chip.blue { background: var(--blue-soft); color: var(--blue-strong); }
.chip.red { background: var(--red-soft); color: #d22030; }
.chip.orange { background: var(--orange-soft); color: #b96200; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: var(--radius-m);
  font-weight: 600;
  transition: background-color 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { width: 100%; height: 56px; background: var(--blue); color: var(--white); font-size: 17px; }
.btn-primary:hover { background: var(--blue-strong); }
.btn-primary:disabled { background: var(--g300); color: var(--white); cursor: default; transform: none; }
.btn-soft { height: 48px; padding: 0 18px; background: var(--g100); color: var(--g800); font-size: 16px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-soft:hover { background: var(--g200); }
.btn-ghost { background: none; padding: 6px 2px; color: var(--blue); font-size: 15px; }
.chip-btn {
  appearance: none;
  border: 1px solid var(--g200);
  background: var(--white);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--g700);
  cursor: pointer;
}
.chip-btn:hover { border-color: var(--blue); color: var(--blue); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.actions .btn-soft { background: var(--white); }
.actions .btn-soft:hover { background: var(--g50); }
.btn-main { height: 48px; padding: 0 18px; background: var(--blue); color: var(--white); font-size: 16px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-main:hover { background: var(--blue-strong); }

/* 입력 ---------------------------------------------------------------------- */
.field { display: grid; gap: 8px; }
.label { font-size: 15px; font-weight: 600; color: var(--g800); }
textarea, .input {
  width: 100%;
  border: 1.5px solid transparent;
  background: var(--g50);
  border-radius: var(--radius-m);
  padding: 16px;
  font-size: 17px;
  line-height: 1.6;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
textarea { min-height: 168px; resize: vertical; }
textarea:focus, .input:focus { outline: none; border-color: var(--blue); background: var(--white); }
textarea::placeholder, .input::placeholder { color: var(--g400); }
.input { padding: 12px 14px; font-size: 16px; }
.counter { justify-self: end; color: var(--g500); font-size: 13px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.examples .caption { margin-right: 2px; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trio label, .duo label { display: grid; gap: 4px; font-size: 13px; color: var(--g600); font-weight: 600; }
.form-msg { color: #d22030; font-size: 15px; min-height: 0; }
.form-msg:empty { display: none; }
.notice { display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--g50); color: var(--g600); font-size: 14px; }
.notice.warn { background: var(--orange-soft); color: #8a4b00; }
.notice .fine { font-size: 13px; }

/* 펼침(details) ------------------------------------------------------------- */
details.more { border-top: 1px solid var(--g200); }
details.more > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--g700);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after,
details.engine > summary::after {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--g400);
  border-bottom: 2px solid var(--g400);
  transform: rotate(45deg);
  margin: 0 4px 4px 0;
  transition: transform 0.15s ease;
}
details[open].more > summary::after,
details[open].engine > summary::after { transform: rotate(-135deg); margin-bottom: -2px; }
details.more > .more-body { padding-bottom: 14px; display: grid; gap: 10px; color: var(--g700); font-size: 15px; }
.plain-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }

/* 예시 카드 · 목록 ----------------------------------------------------------- */
.examples-grid { display: grid; gap: 12px; }
.example-card {
  display: grid;
  gap: 12px;
  text-decoration: none;
  background: var(--white);
  border-radius: 20px;
  padding: 20px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.example-card:hover { box-shadow: 0 6px 24px rgba(0, 27, 55, 0.08); transform: translateY(-1px); }
.example-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.example-title { font-weight: 700; font-size: 17px; }
.example-verdict { font-size: 15px; font-weight: 700; }
.example-verdict.blue { color: var(--blue-strong); }
.example-verdict.red { color: #d22030; }
.example-verdict.grey { color: var(--g600); }
.go { color: var(--g400); font-size: 20px; line-height: 1; }
.row-list { display: grid; }
.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 4px;
  border-top: 1px solid var(--g100);
  text-decoration: none;
}
.row-link:first-child { border-top: 0; }
.row-title { font-weight: 600; }
.row-meta { color: var(--g500); font-size: 13px; }

/* 분포 막대 ------------------------------------------------------------------ */
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--g100); gap: 2px; }
.stack.mini { height: 8px; border-radius: 4px; }
.seg { height: 100%; }
.seg.pro { background: var(--pro); }
.seg.con { background: var(--con); }
.seg.dk { background: var(--dk); }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.figure { display: grid; gap: 2px; align-content: start; }     /* 범위 줄이 없는 '모름' 칸도 위로 붙여 찬성·반대와 높이를 맞춘다 */
.figure-name { font-size: 14px; font-weight: 600; color: var(--g600); display: flex; align-items: center; gap: 6px; }
.figure-name::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--dk); }
.figure.pro .figure-name::before { background: var(--pro); }
.figure.con .figure-name::before { background: var(--con); }
.figure-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.figure.pro .figure-value { color: var(--pro); }
.figure.con .figure-value { color: var(--con); }
.figure.dk .figure-value { color: var(--g500); }
.figure-range { color: var(--g600); font-size: 13px; }
.mini-figures { display: flex; gap: 12px; font-size: 14px; font-weight: 600; }
.pro-text { color: var(--pro); }
.con-text { color: var(--con); }
.dk-text { color: var(--g500); }

/* 판정 카드 ------------------------------------------------------------------ */
.verdict { gap: 20px; }
.verdict-title { font-size: clamp(23px, 5vw, 27px); line-height: 1.4; font-weight: 700; }
.verdict-title .pro-text, .verdict-title .con-text { font-weight: 800; }
.verdict-why { color: var(--g700); font-size: 16px; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; --level: var(--g400); }
.levels.tone-blue { --level: var(--blue); }
.levels.tone-orange { --level: var(--orange); }
.level-step { display: grid; gap: 6px; }
.level-bar { height: 6px; border-radius: 3px; background: var(--g200); }
.level-step.on .level-bar { background: var(--level); }
.level-name { font-size: 12px; color: var(--g600); }
.level-step:nth-child(2) .level-name { text-align: center; }
.level-step:nth-child(3) .level-name { text-align: right; }
.level-step.now .level-name { color: var(--g800); font-weight: 700; }

/* 믿음 줄 ------------------------------------------------------------------- */
.facts { display: grid; gap: 0; }
.fact { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--g100); font-size: 15px; }
.fact:first-child { border-top: 0; padding-top: 0; }
.fact-name { color: var(--g500); font-weight: 600; }
@media (max-width: 480px) { .fact { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* 엔진 판단 ------------------------------------------------------------------ */
.stage { display: grid; gap: 10px; padding-top: 8px; }
.stage + .stage { border-top: 1px solid var(--g100); padding-top: 20px; }
.stage-head { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 12px; align-items: start; }
.stage-no {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--g100);
  color: var(--g700);
  font-weight: 700;
  font-size: 15px;
}
.stage-head h3 { padding-top: 3px; }
.engine-list { display: grid; gap: 8px; padding-left: 44px; }
@media (max-width: 480px) { .engine-list { padding-left: 0; } }
details.engine { background: var(--g50); border-radius: var(--radius-m); }
details.engine.is-key { background: var(--blue-soft); }
details.engine > summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}
details.engine > summary::-webkit-details-marker { display: none; }
.is-key .engine-title { color: var(--blue-strong); }
.engine-main { display: grid; gap: 2px; min-width: 0; }
.engine-title { font-weight: 700; font-size: 16px; }
.engine-summary { color: var(--g700); font-size: 14px; line-height: 1.5; }
.engine-body { padding: 0 16px 16px; display: grid; gap: 14px; font-size: 15px; color: var(--g700); }
@media (max-width: 480px) {
  details.engine > summary { grid-template-columns: minmax(0, 1fr) auto; }
  details.engine > summary .role { grid-column: 1; grid-row: 2; justify-self: start; }
  details.engine > summary::after { grid-row: 1; grid-column: 2; }
}
.role { padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--white); color: var(--g600); white-space: nowrap; }
.role.key { background: var(--blue); color: var(--white); }
.role.ref { background: var(--white); color: var(--g600); }
.status { font-size: 12px; font-weight: 700; color: var(--g500); }
.decisions { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.decision { display: grid; gap: 4px; padding: 12px 14px; background: var(--white); border-radius: var(--radius-s); }
.decision-what { display: flex; gap: 8px; align-items: baseline; font-weight: 700; color: var(--g800); }
.decision-why { color: var(--g600); font-size: 14px; }
.basis { flex: none; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; background: var(--g100); color: var(--g600); }
.basis.measured { background: var(--blue-soft); color: var(--blue-strong); }
.basis.assumed { background: var(--orange-soft); color: #b96200; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; color: var(--g600); }
.mini-title { font-size: 13px; font-weight: 700; color: var(--g600); }

/* 진행 화면 ------------------------------------------------------------------ */
.progress-bar { height: 8px; border-radius: 4px; background: var(--g100); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--blue); border-radius: 4px; transition: width 0.4s ease; }
.progress-meta { display: flex; justify-content: space-between; color: var(--g500); font-size: 14px; }
.track { display: grid; gap: 4px; }
.track-stage { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 14px; padding: 12px 0; }
.track-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--g100); color: var(--g400); font-weight: 700; font-size: 15px; }
.track-stage.done .track-icon { background: var(--blue); color: var(--white); }
.track-stage.running .track-icon { background: var(--blue-soft); color: var(--blue); }
.track-stage.failed .track-icon { background: var(--red-soft); color: var(--red); }
.track-body { display: grid; gap: 6px; min-width: 0; }
.track-name { font-weight: 700; }
.track-stage.pending .track-name { color: var(--g500); }
.track-lines { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.track-line { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 6px; font-size: 14px; color: var(--g600); }
.track-line.done { color: var(--g700); }
.track-line .mark { color: var(--g300); }
.track-line.done .mark { color: var(--blue); }
.track-line.running .mark { color: var(--blue); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--blue-soft); border-top-color: var(--blue); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .progress-bar > span, .example-card, .btn { transition: none; } }

/* 조건별 값 ------------------------------------------------------------------ */
.cond-list { display: grid; gap: 14px; }
.cond { display: grid; gap: 8px; }
.cond-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.cond-figures { display: flex; gap: 12px; align-items: baseline; font-size: 14px; font-weight: 600; }
.delta { font-size: 13px; font-weight: 700; color: var(--g600); }       /* 방향을 말하지 않은 변화는 회색 글(색은 엔진의 방향 말이 있을 때만) */
.delta.up { color: var(--blue); }
.delta.down { color: var(--red); }
.delta-dir { white-space: nowrap; }            /* 방향 말(예: 모델이 낸 변화가 1%p 안)은 한 덩어리로 줄을 바꾼다 */
.effects { display: grid; gap: 10px; }
.effect { display: grid; grid-template-columns: 120px minmax(0, 1fr) 96px; gap: 10px; align-items: center; font-size: 14px; }
.effect-name { font-weight: 600; color: var(--g700); }
.effect-value { text-align: right; font-weight: 700; }
.effect-value.up { color: var(--blue); }
.effect-value.down { color: var(--red); }
.diverge { position: relative; height: 10px; background: var(--g100); border-radius: 5px; }
.diverge::after { content: ''; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--g300); }
.diverge-bar { position: absolute; top: 0; height: 100%; border-radius: 5px; background: var(--g400); }    /* 방향을 말할 수 없으면 회색 */
.diverge-bar.up { background: var(--blue); }
.diverge-bar.down { background: var(--red); }
@media (max-width: 480px) { .effect { grid-template-columns: 96px minmax(0, 1fr) 84px; } }

/* 집단 · 이야기 · 사람 --------------------------------------------------------- */
.pairs { display: grid; gap: 8px; }
.pair { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--g50); border-radius: var(--radius-m); font-weight: 600; }
.pair .chip { margin-left: auto; }
.reasons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 600px) { .reasons { grid-template-columns: minmax(0, 1fr); } }
.reason-box { display: grid; gap: 10px; align-content: start; padding: 16px; border-radius: var(--radius-m); background: var(--g50); }
.reason-box h3 { font-size: 15px; }
.reason { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; font-size: 14px; color: var(--g700); }
.reason .count { color: var(--g500); font-size: 13px; white-space: nowrap; }
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.quote { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius-m); background: var(--g50); align-content: start; }
.quote { margin: 0; }
.quote-say { font-weight: 600; color: var(--g800); margin: 0; }
.quote-who { color: var(--g500); font-size: 13px; }
.arg-group { display: grid; gap: 8px; }
.arg { font-size: 14px; color: var(--g700); }
.arg-who { color: var(--g500); font-size: 13px; }

/* 결과 화면의 구역 이동 줄 ------------------------------------------------------ */
.section-nav {
  position: sticky;
  top: var(--top-h);
  z-index: 9;
  min-width: 0;
  margin-top: -28px;                          /* 쪽 위 여백만큼 올려 위 막대 바로 밑에 붙인다 */
  background: var(--white);
  box-shadow: 0 0 0 100vmax var(--white);     /* 양옆 끝까지 흰 띠. 그림자라 가로 스크롤이 생기지 않는다 */
  clip-path: inset(0 -100vmax);
}
.section-nav::after {                         /* 아래 가는 줄도 양옆 끝까지 */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--g200);
  box-shadow: 0 0 0 100vmax var(--g200);
  clip-path: inset(0 -100vmax);
}
.section-nav-row {
  position: relative;
  display: flex;
  gap: 4px;
  margin: 0 -16px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.section-nav-row::-webkit-scrollbar { display: none; }
.nav-chip {
  flex: none;
  appearance: none;
  border: 0;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--g500);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-chip:hover { background: var(--g50); color: var(--g800); }
.nav-chip[aria-current='true'] { background: var(--g100); color: var(--g900); }
.page > [data-nav] { scroll-margin-top: calc(var(--top-h) + 68px); }
.page > [data-nav]:focus { outline: none; }
.page:focus { outline: none; }               /* 결과로 넘어갈 때 쪽 전체에 옮기는 초점은 테두리 없이 */

/* 가상 시민의 답 ---------------------------------------------------------------- */
.soft-note { display: grid; padding: 16px 16px 4px; border-radius: var(--radius-m); background: var(--g50); color: var(--g700); font-size: 15px; }
.soft-note > p { padding-bottom: 12px; }
.soft-note details.more > summary { padding: 12px 0; font-size: 14px; }
.soft-note details.more > .more-body { font-size: 14px; color: var(--g600); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  appearance: none;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--g100);
  color: var(--g700);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.filter-chip:hover { background: var(--g200); }
.filter-chip[aria-pressed='true'] { background: var(--g800); color: var(--white); }
.filter-n { font-variant-numeric: tabular-nums; opacity: 0.7; }
.person-list { display: grid; }
.person-list > li + li { border-top: 1px solid var(--g100); }
.person-row {
  appearance: none;
  width: 100%;
  min-height: 64px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border: 0;
  border-radius: 12px;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.person-row:hover { background: var(--g50); }
.person-row:active { background: var(--g100); }
.person-stance { min-width: 48px; justify-content: center; }
.person-main { display: grid; gap: 2px; min-width: 0; }
.person-title { color: var(--g900); font-size: 16px; font-weight: 600; line-height: 1.45; }
.person-reason { color: var(--g500); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-own { color: var(--g600); font-size: 13px; }
.person-empty { padding: 16px 6px; }
.person-more:empty { display: none; }
.person-more-btn { width: 100%; gap: 8px; }
.person-more-n { color: var(--g500); font-size: 14px; }

/* 가상 시민 한 명의 장(휴대폰: 아래에서 올라오는 판, 넓은 화면: 가운데 카드) ------------------- */
html:has(dialog.sheet[open]) { overflow: hidden; scrollbar-gutter: stable; }
dialog.sheet {
  width: min(560px, calc(100% - 32px));
  max-width: none;
  max-height: min(88vh, 860px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--white);
  color: var(--g900);
  box-shadow: 0 24px 64px rgba(0, 27, 55, 0.24);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-pop 0.2s ease-out; }
dialog.sheet:focus { outline: none; }        /* 안의 글을 눌러 장 자체가 초점을 받을 때(←/→ 가 이어지게) 테두리는 그리지 않는다 */
dialog.sheet::backdrop { background: rgba(0, 12, 30, 0.48); animation: fade-in 0.2s ease-out; }
.sheet-grab { display: none; }
.sheet-head { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 22px 18px 14px 24px; border-bottom: 1px solid var(--g100); }
.sheet-title { font-size: 21px; font-weight: 700; line-height: 1.4; }
.sheet-sub { color: var(--g600); font-size: 15px; }
.sheet-close {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -8px -4px 0 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--g500);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.sheet-close:hover { background: var(--g100); color: var(--g800); }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-content: start; padding: 20px 24px 24px; }
.sheet-foot { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--g100); }
.sheet-step { height: 44px; padding: 0 16px; border: 0; border-radius: var(--radius-s); background: var(--g100); color: var(--g800); font-size: 15px; font-weight: 600; cursor: pointer; }
.sheet-step:first-child { justify-self: start; }
.sheet-step:last-child { justify-self: end; }
.sheet-step:hover { background: var(--g200); }
.sheet-step[aria-disabled='true'] { opacity: 0.4; cursor: default; background: var(--g100); }
.sheet-pos { color: var(--g500); font-size: 14px; font-variant-numeric: tabular-nums; }
.sheet-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 56px 0; color: var(--g500); font-size: 15px; }
.sheet-sec { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.sheet-sec h3 { font-size: 17px; font-weight: 700; line-height: 1.45; }
.sheet-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin: 0; padding: 16px; border-radius: var(--radius-m); background: var(--g50); }
.sheet-fact dt { color: var(--g500); font-size: 13px; font-weight: 600; }
.sheet-fact dd { margin: 0; color: var(--g800); font-size: 15px; font-weight: 600; }
.sheet-traits { display: grid; margin: 0; }
.sheet-trait { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--g100); font-size: 15px; }
.sheet-trait:first-child { border-top: 0; padding-top: 0; }
.sheet-trait dt { color: var(--g500); font-weight: 600; }
.sheet-trait dd { margin: 0; color: var(--g800); }
.sheet-line { color: var(--g700); font-size: 15px; }
.sheet-note { padding: 14px 16px; border-radius: var(--radius-m); background: var(--g50); color: var(--g600); font-size: 15px; }
.sheet-ask { margin-top: 4px; }
.chip.big { justify-self: start; padding: 6px 16px; font-size: 16px; }
.lean { display: grid; gap: 8px; padding: 16px; border-radius: var(--radius-m); background: var(--g50); }
.lean-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; color: var(--g700); font-size: 14px; font-weight: 600; }
.lean-value { color: var(--g700); font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.lean-value.pro { color: var(--pro); }
.lean-value.con { color: var(--con); }
.lean-max { color: var(--g500); font-size: 13px; font-weight: 600; }
.lean-track { position: relative; height: 10px; margin: 6px 9px; border-radius: 5px; background: var(--g200); }
.lean-track::after { content: ''; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--g400); }
.lean-fill { position: absolute; top: 0; height: 100%; border-radius: 5px; }
.lean-fill.pro { background: var(--pro); }
.lean-fill.con { background: var(--con); }
.lean-dot { position: absolute; top: 50%; z-index: 1; width: 18px; height: 18px; border: 3px solid var(--g500); border-radius: 50%; background: var(--white); transform: translate(-50%, -50%); }
.lean-dot.pro { border-color: var(--pro); }
.lean-dot.con { border-color: var(--con); }
.lean-ends { display: flex; justify-content: space-between; color: var(--g500); font-size: 12px; }
.say { margin: 0; display: grid; gap: 6px; padding: 14px 16px; border-radius: var(--radius-m); background: var(--g50); }
.say-text { margin: 0; color: var(--g800); font-size: 16px; font-weight: 600; }
.say-ref { color: var(--g500); font-size: 13px; line-height: 1.55; }
.say-ref-name { font-weight: 700; }
.story-intro { color: var(--g800); font-size: 16px; }
.story-part { display: grid; gap: 4px; }
.story-part p { color: var(--g700); font-size: 15px; }
.caption.fine { color: var(--g600); font-size: 12px; }
@media (max-width: 600px) {
  dialog.sheet {
    width: 100%;
    max-height: 88vh;
    max-height: 88dvh;
    margin: auto 0 0;
    border-radius: 24px 24px 0 0;
  }
  dialog.sheet[open] { animation-name: sheet-up; animation-duration: 0.24s; }
  .sheet-grab { display: block; flex: none; width: 40px; height: 4px; margin: 10px auto 0; border-radius: 2px; background: var(--g300); }
  .sheet-head { padding: 12px 12px 12px 20px; }
  .sheet-body { padding: 16px 20px 24px; }
  .sheet-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .sheet-trait { grid-template-columns: 96px minmax(0, 1fr); }
}
@keyframes sheet-up { from { transform: translateY(48px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@keyframes sheet-pop { from { transform: translateY(8px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* AI에게 물어보기 ------------------------------------------------------------------ */
.chat-log { display: grid; gap: 12px; }
.chat-log:not(:empty) + .chat-suggest:not(:empty) { margin-top: 16px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.chat-suggest:empty { display: none; }
@media (max-width: 600px) {                   /* 대화가 시작되면 휴대폰에서는 물음 칩을 한 줄로 접어 옆으로 넘긴다 */
  .chat-log:not(:empty) + .chat-suggest { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -20px; padding-inline: 20px; }
  .chat-log:not(:empty) + .chat-suggest::-webkit-scrollbar { display: none; }
  .chat-log:not(:empty) + .chat-suggest .chip-btn { flex: none; white-space: nowrap; }
}
.chip-btn:disabled { opacity: 0.5; cursor: default; border-color: var(--g200); color: var(--g700); }
.msg { display: grid; gap: 6px; max-width: min(88%, 600px); }
.msg.me { justify-self: end; justify-items: end; }
.msg.ai { justify-self: start; justify-items: start; }
.bubble { padding: 12px 16px; border-radius: 20px; font-size: 16px; line-height: 1.6; }
.bubble-text { white-space: pre-wrap; }
.msg.me .bubble { background: var(--blue); color: var(--white); border-bottom-right-radius: 6px; }
.msg.ai .bubble { background: var(--g100); color: var(--g900); border-bottom-left-radius: 6px; }
.msg.err .bubble { background: var(--red-soft); color: #c4202e; }
.msg.wait .bubble { display: inline-flex; align-items: center; gap: 10px; color: var(--g600); font-size: 15px; }
.msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 6px; color: var(--g500); font-size: 13px; }
.chip.mock { padding: 2px 8px; font-size: 12px; background: var(--orange-soft); color: #b96200; }
.msg-action { appearance: none; border: 0; background: none; padding: 6px; color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; }
.msg .chat-code { width: min(100%, 360px); padding: 14px; border: 1px solid var(--g200); border-radius: var(--radius-m); background: var(--white); }
.typing { display: inline-flex; gap: 4px; }
.typing > span { width: 6px; height: 6px; border-radius: 50%; background: var(--g400); animation: typing 1.2s ease-in-out infinite; }
.typing > span:nth-child(2) { animation-delay: 0.15s; }
.typing > span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.35; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-code { display: grid; gap: 8px; }
.chat-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.chat-code-row .btn-soft { height: auto; min-height: 48px; }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.chat-context-slot:empty { display: none; }
.chat-context { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-strong); font-size: 13px; font-weight: 600; }
.chat-context-x { width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.chat-context-x:hover { background: rgba(49, 130, 246, 0.12); }
.chat-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border: 1.5px solid var(--g200);
  border-radius: 20px;
  background: var(--white);
  transition: border-color 0.15s ease;
  scroll-margin: calc(var(--top-h) + 68px) 0 24px;
}
.chat-input:focus-within { border-color: var(--blue); }
.chat-input textarea.chat-text { min-height: 0; max-height: 112px; padding: 8px 0; border: 0; border-radius: 0; background: transparent; resize: none; font-size: 16px; line-height: 1.5; overflow-y: auto; }
.chat-input textarea.chat-text:focus { border: 0; background: transparent; }
.chat-send { height: 40px; padding: 0 16px; border-radius: 14px; background: var(--blue); color: var(--white); font-size: 15px; }
.chat-send:hover { background: var(--blue-strong); }
.chat-send:disabled { background: var(--g300); cursor: default; transform: none; }
.chat-count { justify-self: end; color: var(--g500); font-size: 13px; font-variant-numeric: tabular-nums; }
.chat-count:empty { display: none; }
.chat-count.full { color: #d22030; }

/* 끝 단추 --------------------------------------------------------------------- */
.end-actions { display: grid; gap: 4px; }
.end-actions .btn-main { height: 56px; font-size: 17px; }
.text-link { justify-self: center; padding: 10px 12px; color: var(--g600); font-size: 14px; text-decoration: underline; text-decoration-color: var(--g300); text-underline-offset: 3px; }
.text-link:hover { color: var(--g800); text-decoration-color: currentColor; }

.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; }
@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open], dialog.sheet::backdrop { animation: none; }
  .typing > span { animation: none; opacity: 0.6; }
  .nav-chip, .filter-chip, .person-row, .chat-input { transition: none; }
}

/* 빈 화면 · 오류 ------------------------------------------------------------- */
.state-card { text-align: center; justify-items: center; padding: 40px 24px; }
.state-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.state-card .spinner { width: 28px; height: 28px; border-width: 3px; }

/* 간격·초기화 도우미 --------------------------------------------------------- */
.stack-2 { display: grid; gap: 2px; min-width: 0; }
.stack-6 { display: grid; gap: 6px; min-width: 0; }
.stack-10 { display: grid; gap: 10px; min-width: 0; }
.stack-12 { display: grid; gap: 12px; min-width: 0; }
.stack-14 { display: grid; gap: 14px; min-width: 0; }
.gap-top { margin-top: 8px; }
.bare { border: 0; padding: 0; margin: 0; min-width: 0; list-style: none; }
.chip.start { justify-self: start; }
