/* 「빨간 펜 심의」: 정부안은 검은 활자로 인쇄된 문서처럼, 시민이 손대는 것(증액·도장·내 선택)은 빨간 잉크로 보인다.
   모서리는 각지게, 괘선은 굵게 쓴다. 증액은 빨강, 감액은 파랑이다. */
:root {
  --bg: #ffffff;
  --surface: #f2f2f0;
  --fg: #111111;
  --muted: #666666;
  --line: #d6d6d6;
  --rule: #111111;
  --accent: #111111;
  --red: #e0261b;
  --up: #e0261b;
  --down: #1d4ed8;
  --stamp: #e0261b;

  /* 맨 위 합계(검은 점수판) 안의 색 */
  --board-bg: #111111;
  --board-fg: #ffffff;
  --board-muted: #a3a3a3;
  --board-up: #ff6a5c;
  --board-down: #7ea6ff;

  /* 대분류 색. 순서가 색약 구분을 보장하므로 바꾸지 않는다(validate_palette.js로 검증). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;

  --font: "Pretendard Variable", Pretendard, system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e0e;
    --surface: #1a1a1a;
    --fg: #f2f2f2;
    --muted: #9a9a9a;
    --line: #333333;
    --rule: #f2f2f2;
    --accent: #f2f2f2;
    --red: #ff5546;
    --up: #ff6a5c;
    --down: #7ea6ff;
    --stamp: #ff5546;

    --board-bg: #f2f2f2;
    --board-fg: #0e0e0e;
    --board-muted: #5c5c5c;
    --board-up: #d11f14;
    --board-down: #1d4ed8;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
  }
}

* {
  box-sizing: border-box;
}

/* 두 번 탭해 확대하지 않는다(두 손가락 확대는 dom.js와 viewport가 막는다) */
html {
  touch-action: manipulation;
}

body {
  margin: 0 auto;
  max-width: 820px;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  letter-spacing: -0.03em;
}

h1 {
  margin: 0 0 12px;
  font-size: 3.25rem;
  font-weight: 900;
  line-height: 1.1;
}

h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 800;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

a {
  color: var(--fg);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.status,
.muted {
  color: var(--muted);
}

/* 넓은 화면에서도 본문 폭을 넘어 화면 양끝까지 칠한다(그림자로 칠하고 위아래는 잘라 낸다) */
.gnb,
.summary {
  box-shadow: 0 0 0 100vmax var(--band, var(--rule));
  clip-path: inset(0 -100vmax);
}

/* GNB: 화면 폭 전체의 검은 띠. 왼쪽은 사이트 이름, 오른쪽은 메뉴. 좁은 화면에서는 메뉴가 아래 탭 바로 내려간다. */
.gnb {
  display: flex;
  align-items: stretch;
  gap: 16px;
  margin: 0 -16px;
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--rule);
  color: var(--bg);
}

.gnb-brand {
  display: flex;
  align-items: center;
  padding: 12px 0;
  color: inherit;
  font-weight: 900;
  letter-spacing: -0.03em;
  text-decoration: none;
  white-space: nowrap;
}

.gnb-brand span {
  margin-left: 4px;
  padding: 0 4px;
  border: 2px solid var(--red);
  color: var(--red);
  font-size: 0.8em;
  line-height: 1.2;
}

.gnb-menu {
  display: flex;
  margin-left: auto;
}

.gnb-menu a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 10px 8px;
  border-bottom: 4px solid transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0.7;
}

.gnb-menu a:hover {
  opacity: 1;
}

.gnb-menu a[aria-current="page"] {
  border-bottom-color: var(--red);
  opacity: 1;
}

.gnb-menu svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* GNB의 '공유' 버튼. 넓은 화면에서는 메뉴 옆에 메뉴처럼 놓인다. */
.gnb-share {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: -8px;
  padding: 12px 10px 8px;
  border: 0;
  border-bottom: 4px solid transparent;
  background: none;
  color: inherit;
  opacity: 0.7;
}

.gnb-share:hover {
  border-color: transparent;
  background: none;
  color: inherit;
  opacity: 1;
}

.gnb-share svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 링크를 복사했을 때 잠깐 뜨는 알림 */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 4;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  background: var(--rule);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 700;
  transform: translateX(-50%);
  animation: fade-in 0.2s ease-out;
  overflow-wrap: anywhere;
}

/* 좁은 화면: iOS의 글래스 탭 바처럼 화면 아래에 떠 있는 캡슐. 아이콘 아래 이름, 지금 페이지는 캡슐 안의 알약으로 강조한다.
   공유 버튼은 캡슐 오른쪽에 따로 뜬 동그란 유리 버튼이다. */
@media (max-width: 640px) {
  body {
    padding-bottom: calc(64px + 80px + env(safe-area-inset-bottom));
  }

  /* 좁은 화면에서는 위쪽 띠를 없애고 아래 탭 바만 남긴다. clip-path가 탭 바까지 잘라 내지 않게 끈다. */
  .gnb {
    margin: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    clip-path: none;
  }

  .gnb-brand {
    display: none;
  }

  .eyebrow {
    margin-top: calc(24px + env(safe-area-inset-top));
  }

  .board.page {
    margin-top: calc(24px + env(safe-area-inset-top));
  }

  .gnb-menu,
  .gnb-share {
    --glass: color-mix(in srgb, var(--bg) 60%, transparent);
    --glass-edge: rgb(255 255 255 / 0.55);
    position: fixed;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 3;
    height: 62px;
    border: 1px solid var(--glass-edge);
    background: var(--glass);
    color: var(--fg);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.6),
      inset 0 -1px 0 rgb(0 0 0 / 0.04),
      0 10px 30px rgb(0 0 0 / 0.18);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    backdrop-filter: blur(24px) saturate(180%);
  }

  .gnb-menu {
    left: 12px;
    right: calc(12px + 62px + 8px);
    justify-content: space-around;
    padding: 4px;
    border-radius: 999px;
  }

  .gnb-menu a {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    color: var(--fg);
    font-size: 0.68rem;
    opacity: 1;
  }

  .gnb-menu a[aria-current="page"] {
    background: color-mix(in srgb, var(--fg) 9%, transparent);
    color: var(--red);
  }

  .gnb-menu svg {
    width: 24px;
    height: 24px;
  }

  .gnb-share {
    right: 12px;
    justify-content: center;
    width: 62px;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    opacity: 1;
  }

  .gnb-share:hover {
    border-color: var(--glass-edge);
    background: var(--glass);
    color: var(--fg);
  }

  .gnb-share svg {
    width: 24px;
    height: 24px;
  }

  .gnb-share span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

@media (max-width: 640px) and (prefers-color-scheme: dark) {
  .gnb-menu,
  .gnb-share {
    --glass: color-mix(in srgb, var(--bg) 55%, transparent);
    --glass-edge: rgb(255 255 255 / 0.14);
    box-shadow:
      inset 0 1px 0 rgb(255 255 255 / 0.12),
      0 10px 30px rgb(0 0 0 / 0.5);
  }
}

/* 히어로 */
.eyebrow {
  display: inline-block;
  margin: 40px 0 16px;
  padding: 2px 8px;
  background: var(--rule);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* 제목 옆 '심의' 도장. 처음 열 때 한 번 찍힌다. */
.stamp {
  display: inline-block;
  margin-left: 6px;
  padding: 0 10px;
  border: 4px double var(--stamp);
  color: var(--stamp);
  transform: rotate(-8deg);
  animation: stamp 0.45s 0.3s cubic-bezier(0.3, 1.6, 0.5, 1) backwards;
}

@keyframes stamp {
  from {
    opacity: 0;
    transform: scale(2.2) rotate(-20deg);
  }
}

.tagline {
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.4;
}

.intro > p:not(.eyebrow):not(.tagline) {
  color: var(--muted);
}

/* 칸 그림: 칸 하나가 100억 원 */
.waffle-figure {
  margin: 28px 0 16px;
  padding: 16px 0;
  border-top: 4px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.waffle-figure figcaption {
  margin-bottom: 12px;
}

.waffle-figure figcaption strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.waffle-figure figcaption span {
  font-size: 0.85rem;
  color: var(--muted);
}

.waffle {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
  gap: 2px;
  margin-bottom: 12px;
}

.cell {
  aspect-ratio: 1;
  background: var(--group-color);
  animation: cell 0.3s calc(var(--i) * 1.2ms) ease-out backwards;
}

.cell.absent {
  background: transparent;
  outline: 2px dashed var(--group-color);
  outline-offset: -2px;
}

@keyframes cell {
  from {
    opacity: 0;
    transform: scale(0.2);
  }
}

/* 범례: 색만으로 분야를 구분하지 않도록 이름을 함께 쓴다 */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend .count {
  color: var(--fg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.legend li::before,
.group h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  background: var(--group-color);
}

.group h2::before {
  width: 14px;
  height: 14px;
  vertical-align: 1px;
}

/* 정부안에 없는 칸: 다른 네모와 같은 크기의 속이 빈 박스(테두리를 안쪽에 그린다) */
.legend li.absent::before,
.group.absent h2::before {
  box-sizing: border-box;
  background: transparent;
  border: 2px solid var(--group-color);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.start {
  display: inline-block;
  padding: 10px 20px;
  border: 2px solid var(--rule);
  background: var(--rule);
  color: var(--bg);
  font-weight: 800;
  text-decoration: none;
}

.start:hover {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.start.secondary {
  background: transparent;
  color: var(--fg);
}

.start.secondary:hover {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

/* 핵심 숫자 */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px 16px;
  margin: 32px 0 16px;
}

.fact {
  padding-top: 10px;
  border-top: 6px solid var(--fact-color, var(--rule));
}

.fact strong {
  display: block;
  font-size: 2.75rem;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.fact span {
  display: block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

/* 짚어 볼 점: 빨간 펜으로 번호를 매긴 메모. 왼쪽에 번호, 큰 숫자 하나와 한 문장. */
.points {
  margin: 40px 0 16px;
  counter-reset: point;
}

.points h2 {
  display: inline-block;
  margin-bottom: 8px;
  padding: 0 6px;
  border: 3px solid var(--red);
  color: var(--red);
  font-size: 1.1rem;
  transform: rotate(-2deg);
}

#points {
  margin: 0;
  padding: 0;
  list-style: none;
}

.point {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 14px;
  align-items: baseline;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  counter-increment: point;
}

.point::before {
  content: counter(point, decimal-leading-zero);
  grid-row: span 2;
  color: var(--red);
  font-size: 1.1rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.point-value {
  font-size: 2.25rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-decoration: underline wavy var(--red) 2px;
  text-underline-offset: 6px;
}

.point p {
  margin: 8px 0 0;
  font-size: 0.95rem;
}

/* 늘어난 돈 따라가기: 증가액이 큰 세부사업. 사업명과 증가액, 그 아래 금액 변화와 증가분 비율 */
.growth-list {
  grid-column: 2;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.growth-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.growth-name {
  font-weight: 700;
}

.growth-diff {
  color: var(--up);
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.growth-amounts,
.growth-share {
  color: var(--muted);
  font-size: 0.8rem;
}

.growth-share {
  text-align: right;
  white-space: nowrap;
}

/* 이 사이트가 다루지 않는 예산: 범위를 밝히는 상자 */
.scope {
  margin: 16px 0;
  padding: 12px 14px;
  border: 2px solid var(--line);
  font-size: 0.9rem;
}

.scope h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.scope p {
  margin: 6px 0 0;
  color: var(--muted);
}

/* 합계: 스크롤해도 위에 붙어 있는 검은 점수판 */
.summary {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 32px -16px 24px;
  padding: 12px 16px;
  background: var(--board-bg);
  color: var(--board-fg);
  --band: var(--board-bg);
  --up: var(--board-up);
  --down: var(--board-down);
}

.summary dl {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  gap: 8px 28px;
  margin: 0;
}

.summary dt {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--board-muted);
}

.summary dd {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.summary dd small {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
}

/* 정부안·내 예산 비교 막대. 같은 축척이라 합계가 늘면 막대도 길어진다. */
.bars {
  margin-top: 10px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.bar-label {
  flex: 0 0 3.5em;
  font-size: 0.75rem;
  color: var(--board-muted);
}

.track {
  flex: 1;
}

.fill {
  display: flex;
  gap: 2px;
  height: 14px;
  overflow: hidden;
  transition: width 0.25s ease-out;
}

.seg {
  flex-basis: 0;
  min-width: 2px;
  background: var(--group-color);
  transition: flex-grow 0.25s ease-out;
  cursor: default;
}

.seg.absent {
  background: repeating-linear-gradient(45deg, var(--group-color) 0 3px, transparent 3px 6px);
}

.highlights {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--board-muted);
}

.summary button {
  border-color: var(--board-fg);
  background: var(--board-fg);
  color: var(--board-bg);
}

.summary button.secondary {
  background: transparent;
  color: var(--board-fg);
}

.summary button:hover {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.share-status:empty {
  display: none;
}

.share-status {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--board-muted);
}

.share-status input {
  width: 100%;
  font: inherit;
}

@media (max-width: 480px) {
  .summary .actions {
    gap: 6px;
  }

  .summary .actions button {
    padding: 6px 10px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .summary dl {
    gap: 4px 14px;
  }

  .summary dd {
    font-size: 1.05rem;
  }

  .fact strong {
    font-size: 2.1rem;
  }

  h1 {
    font-size: 2.4rem;
  }

  .tagline {
    font-size: 1.15rem;
  }

  .waffle {
    grid-template-columns: repeat(auto-fill, minmax(7px, 1fr));
    gap: 1px;
  }

  .summary {
    padding: 8px 16px;
  }

  .bars {
    margin-top: 6px;
  }

  .bar-row {
    margin: 2px 0;
  }

  .highlights {
    margin-top: 2px;
    font-size: 0.75rem;
    line-height: 1.4;
  }

  .actions {
    margin-top: 6px;
  }

  button {
    padding: 4px 12px;
    font-size: 0.85rem;
  }
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

button {
  padding: 6px 14px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: var(--rule);
  color: var(--bg);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

button.secondary {
  background: transparent;
  color: var(--fg);
}

button.secondary:hover {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

/* 아주 좁은 화면(360px 안팎)에서도 요약 영역 버튼 셋이 한 줄에 들어가게 */
@media (max-width: 400px) {
  .summary .actions button {
    padding: 5px 7px;
    font-size: 0.82rem;
    letter-spacing: -0.02em;
  }
}

/* 글자 앞에 붙는 작은 줄 그림 아이콘 */
.button-icon {
  width: 1em;
  height: 1em;
  margin-right: 4px;
  vertical-align: -0.12em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 증감 색의 뜻 */
.color-key {
  margin: 24px 0 0;
  padding: 8px 12px;
  border: 2px solid var(--rule);
  font-size: 0.85rem;
}

/* 대분류 */
.group {
  margin: 56px 0;
}

.group-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  padding-bottom: 6px;
  border-bottom: 4px solid var(--rule);
}

.group > p {
  margin: 10px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.group > .yoy {
  margin: 0 0 8px;
}



/* 좁은 화면: 대분류마다 화면 폭 전체에 그 색을 옅게 깐 판과 위쪽 굵은 색 띠를 둬서, 스크롤하다 대분류가 바뀌면 바로 보이게 한다 */
@media (max-width: 640px) {
  .group {
    margin: 0 -16px;
    padding: 24px 16px 8px;
    border-top: 10px solid var(--group-color);
    background: color-mix(in srgb, var(--group-color) 8%, var(--bg));
  }

  .group + .group {
    margin-top: 0;
  }

  .group h2 {
    font-size: 1.75rem;
    font-weight: 900;
  }

  .group h2::before {
    display: none;
  }

  .group .category:last-child {
    border-bottom: 0;
  }

  .group .level {
    background: var(--bg);
  }

  .group .category.absent {
    margin-bottom: 16px;
    background: var(--bg);
  }
}

/* 분야 카드 */
.category {
  margin: 0;
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--line);
  border-left: 0;
}

.category-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  align-items: baseline;
}

.category-head h3 {
  font-size: 1.15rem;
}

.category-head h3::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 0.95em;
  margin-right: 8px;
  background: var(--group-color);
  vertical-align: -1px;
}

/* 정부안에 없는 칸: 시민이 채울 빈칸이라 그 대분류 색(보라) 점선으로 두른다 */
.category.absent {
  margin-top: 8px;
  padding: 18px 16px 20px;
  border: 3px dashed var(--group-color);
}

/* 분야 설명은 접지 않고 늘 보여 준다(세부사업 표만 접는다) */
.category-description,
.category .related {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

/* 전년 예산·정부안·내 예산 세 칸. 칸 위 선: 2026년 회색, 정부안 검정, 내 예산은 늘리면 빨강·줄이면 파랑·그대로면 검정 */
.yoy {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 480px;
  margin: 10px 0 0;
  font-variant-numeric: tabular-nums;
}

.yoy.only-mine {
  grid-template-columns: 1fr;
  max-width: 160px;
}

.yoy-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: 6px;
  border-top: 3px solid var(--line);
}

.yoy-cell.after,
.yoy-cell.mine {
  border-top-color: var(--fg);
}

.yoy-cell.mine.up {
  border-top-color: var(--up);
}

.yoy-cell.mine.down {
  border-top-color: var(--down);
}

.yoy-label {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.yoy-amount {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.yoy-cell.before .yoy-amount {
  color: var(--muted);
  font-weight: 600;
}

.yoy-cell.mine .yoy-label {
  color: var(--fg);
  font-weight: 800;
}

.yoy-cell.mine .yoy-amount {
  font-size: 1.1rem;
  font-weight: 900;
}

.yoy-cell.mine.up .yoy-amount,
.yoy-cell.mine.up .yoy-sub {
  color: var(--up);
}

.yoy-cell.mine.down .yoy-amount,
.yoy-cell.mine.down .yoy-sub {
  color: var(--down);
}

.yoy-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.35;
}

.yoy-sub span {
  white-space: nowrap;
}

.yoy-sub:empty {
  display: none;
}

.change {
  font-weight: 700;
}

.change.up {
  color: var(--up);
}

.change.down {
  color: var(--down);
}

/* 다섯 단계 고르기: 한 줄로 이어 붙인 굵은 버튼 묶음. 라디오 버튼을 감추고 칸 전체를 누르게 한다. */
.levels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 14px 0 8px;
  padding: 0;
  border: 2px solid var(--rule);
}

.level {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 4px 2px;
  border-left: 1px solid var(--line);
  background: var(--bg);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.level:first-child {
  border-left: 0;
}

.level input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* 이 단계를 고른 시민 예산안 수 */
.level-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  padding: 0 4px;
  background: var(--red);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.level-count:empty {
  display: none;
}

.level-note {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.level:hover {
  background: var(--surface);
}

.level:has(input:focus-visible) {
  outline: 3px solid var(--red);
  outline-offset: -3px;
}

.level:has(input:checked) {
  background: var(--rule);
  color: var(--bg);
}

.level:has(input:checked) .level-note {
  color: inherit;
  opacity: 0.8;
}

.level.up:has(input:checked) {
  background: var(--up);
  color: #ffffff;
}

.level.down:has(input:checked) {
  background: var(--down);
  color: #ffffff;
}


/* 시민 예산안들이 이 분야를 어떻게 골랐는지 */
.tally {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.tally:empty {
  display: none;
}

details {
  margin-top: 10px;
}

summary {
  cursor: pointer;
  color: var(--fg);
  font-size: 0.9rem;
  font-weight: 700;
}

details p {
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th,
td {
  padding: 6px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  border-bottom: 2px solid var(--rule);
}

th.num,
td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

td .detail {
  display: block;
  color: var(--muted);
}

.tip {
  position: fixed;
  z-index: 2;
  max-width: 240px;
  padding: 6px 10px;
  background: var(--rule);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  pointer-events: none;
}

/* 대분류·분야의 '질문·제안 남기기'와 그 바로 옆의 글 수 */
.talk-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.group-head .talk-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  margin-top: 0;
}

button.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border: 1.5px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

button.chip:hover {
  border-color: var(--red);
  background: var(--bg);
  color: var(--red);
}

.chip .icon {
  display: inline-flex;
}

.chip .num {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* 시민 심의 게시판: 질문·제안은 GitHub의 이슈, 시민 예산안은 풀 리퀘스트처럼 목록에 쌓인다 */
.board {
  margin: 72px 0 0;
  padding-top: 16px;
  border-top: 8px solid var(--rule);
}

/* 위에 붙어 있는 합계 영역에 가리지 않게 스크롤한다(--summary-height는 main.js가 잰다) */
.board,
.post,
.category {
  scroll-margin-top: calc(var(--summary-height, 0px) + 16px);
}

.board h2 {
  font-size: 2rem;
  font-weight: 900;
}

.board-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.board-list {
  margin-top: 32px;
}

.board-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--rule);
}

.board-bar h3 {
  font-size: 1.2rem;
}

.board .count {
  display: inline-block;
  min-width: 1.6em;
  margin-left: 4px;
  padding: 0 6px;
  background: var(--red);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  text-align: center;
  vertical-align: middle;
}

.board .count:empty {
  display: none;
}

.board-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.board-actions a {
  font-size: 0.9rem;
  font-weight: 700;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.filter {
  font-weight: 700;
}

.filter select {
  padding: 4px 6px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-weight: 500;
}

.board-status:empty {
  display: none;
}

.board-status {
  margin: 12px 0;
  font-size: 0.9rem;
}

.board.page {
  margin-top: 40px;
  padding-top: 0;
  border-top: 0;
}

.board.page h1 {
  font-size: 2.75rem;
}

.posts {
  margin: 0;
  padding: 0;
  list-style: none;
}

.post {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.post-icon {
  flex: 0 0 24px;
  height: 24px;
  margin-top: 1px;
  background: var(--rule);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 24px;
  text-align: center;
}

.post-icon.proposal {
  background: var(--red);
  color: #ffffff;
}

.post-icon.budget {
  background: transparent;
  color: var(--fg);
  box-shadow: inset 0 0 0 2px var(--rule);
}

.post details {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.post summary {
  color: var(--fg);
  font-weight: 400;
  list-style: none;
}

.post summary::-webkit-details-marker {
  display: none;
}

/* 질문·제안은 줄 전체가 모달을 여는 버튼이다 */
.post-open {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-weight: 400;
  text-align: left;
}

.post-open:hover {
  background: none;
  color: var(--fg);
}

.post-title {
  display: block;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.post-open:hover .post-title,
.post summary:hover .post-title {
  color: var(--red);
}

.post-meta,
.post-budget {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.post-budget {
  color: var(--fg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.post-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.post .actions {
  flex-wrap: wrap;
}

.post .actions button {
  white-space: nowrap;
}

/* 모달은 화면 아래에서 올라오는 시트로 연다 */
dialog {
  width: min(680px, 100%);
  max-width: 100%;
  max-height: 85dvh;
  margin: auto auto 0;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 6px solid var(--rule);
  background: var(--bg);
  color: var(--fg);
  overscroll-behavior: contain;
}

dialog[open] {
  animation: sheet-up 0.25s ease-out;
}

dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

dialog[open]::backdrop {
  animation: fade-in 0.25s ease-out;
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* 우상단 닫기 버튼. 내용을 내려도 따라온다. */
.dialog-close {
  position: sticky;
  top: 0;
  z-index: 1;
  float: right;
  width: 38px;
  height: 38px;
  margin: 0 0 -38px 8px; /* 첫 줄 오른쪽에만 자리를 차지한다(아래 제목 줄이 그만큼 비운다) */
  padding: 0;
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
}

dialog h2 {
  margin-bottom: 8px;
  font-size: 1.35rem;
}

dialog label {
  display: block;
  margin: 12px 0;
  font-size: 0.9rem;
  font-weight: 700;
}

dialog input:not([type="radio"]),
dialog select,
dialog textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 1rem; /* 16px보다 작으면 iOS가 입력할 때 화면을 확대한다 */
  font-weight: 400;
}

dialog input:focus,
dialog select:focus,
dialog textarea:focus {
  border-color: var(--red);
  outline: none;
}

dialog .hint,
dialog .note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

dialog .status:empty {
  display: none;
}

dialog .status {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

/* 글쓰기 창: 시민 예산안은 대상이 없고, 단계 고르기는 제안에만, 종류 고르기는 새 질문·제안에만 보인다 */
#post-form[data-kind="budget"] .category-field,
#post-form:not([data-kind="proposal"]) .level-field,
#post-form[data-fixed="true"] .kind-field {
  display: none;
}

#post-form fieldset {
  margin: 12px 0;
  padding: 0;
  border: 0;
}

#post-form legend {
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 700;
}

.kind-field {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kind-choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 6px 14px;
  border: 2px solid var(--rule);
  cursor: pointer;
}

.kind-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.kind-choice:has(input:checked) {
  background: var(--rule);
  color: var(--bg);
}

.kind-choice:has(input:focus-visible) {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

.level-field .levels {
  margin: 0;
}

.level-field .level {
  margin: 0;
}

/* 질문·제안 목록·상세 모달 */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 10px 0;
  border-bottom: 2px solid var(--rule);
}

.tabs button {
  margin-bottom: -2px;
  border: 0;
  border-bottom: 4px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tabs button:hover {
  background: transparent;
  color: var(--fg);
}

.tabs button[aria-pressed="true"] {
  border-bottom-color: var(--red);
  color: var(--fg);
  font-weight: 800;
}

.kind-badge {
  display: inline-block;
  margin: 16px 0 0;
  padding: 1px 8px;
  background: var(--rule);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 800;
}

.kind-badge.proposal {
  background: var(--red);
  color: #ffffff;
}

.proposal-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  border: 2px solid var(--red);
  font-variant-numeric: tabular-nums;
}

.viewer-bar,
#post-dialog-title {
  padding-right: 46px;
}

.viewer-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.viewer-bar button {
  white-space: nowrap;
}

.viewer-bar h2 {
  margin: 0;
  font-size: 1.2rem;
}

.talk-dialog > .post-title {
  margin: 6px 0 0;
  font-size: 1.4rem;
}

.talk-dialog .actions:empty {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

footer {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 4px solid var(--rule);
  font-size: 0.85rem;
  color: var(--muted);
}

/* 모든 페이지 맨 아래: 디스코드와 만든 사람. 홈에서는 출처(#source) 바로 아래에 온다. */
.site-footer {
  margin-top: 32px;
}

#source + .tip + .site-footer {
  margin-top: 16px;
  border-top-width: 1px;
}

.site-footer p {
  margin: 4px 0;
}

.site-footer a {
  color: var(--fg);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .fill,
  .seg {
    transition: none;
  }

  .stamp,
  .cell,
  dialog[open],
  dialog[open]::backdrop {
    animation: none;
  }
}
