/* ===== 툴모음 — 디자인 시스템 ===== */
:root {
  --accent: #3182f6;        /* TDS Blue 500 (primary) */
  --accent-dark: #1b64da;   /* TDS Blue 600 (pressed) */
  --tint: #e8f3ff;          /* TDS Blue 100 (light bg) */
  --bg: #ffffff;
  --bg-soft: #f2f4f6;       /* TDS Grey 100 (box/panel) */
  --card: #ffffff;
  --ink: #191f28;           /* TDS Grey 900 (text primary) */
  --ink-2: #4e5968;         /* TDS Grey 700 (text secondary) */
  --muted: #6b7684;         /* TDS Grey 600 (text tertiary) */
  --border: #e5e8eb;        /* TDS Grey 200 */
  --input-bg: #ffffff;
  --danger: #f04452;        /* TDS Red */
  --success: #15a66b;       /* 양수·성공·diff 추가 */
  --warn: #d97706;          /* 경고·diff 변경 */
  --add-bg: #e7f6ed;        /* diff 추가 줄 배경 */
  --del-bg: #fdecec;        /* diff 삭제 줄 배경 */
  --chart-2: #c9e2ff;       /* 도넛 보조 조각 (연한 파랑, 토스 모노톤) */
  --chart-gap: #ffffff;     /* 조각 사이 구분선 색 */
  --radius: 16px;
  color-scheme: light;          /* 네이티브 위젯(체크박스·셀렉트·달력)을 테마에 맞게 */
  accent-color: var(--accent);  /* 체크박스·라디오 체크 색 */
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --accent: #4593fc;
  --accent-dark: #6aa9ff;
  --tint: #18233a;
  --bg: #14171a;
  --bg-soft: #181c20;
  --card: #1b1f24;
  --ink: #e7eaec;
  --ink-2: #c4cad1;
  --muted: #9aa2ac;
  --border: #2a3037;
  --input-bg: #14171a;
  --danger: #f1736f;
  --success: #4ec98a;
  --warn: #e0a458;
  --add-bg: #16291f;
  --del-bg: #2e1c1e;
  --chart-2: #2b4a6f;
  --chart-gap: #1b1f24;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
    "Pretendard", "Malgun Gothic", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* 레이아웃 — 메인·상세페이지 모두 동일 폭(1040px)으로 통일 */
.container { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.wide { max-width: 1040px; }
main { padding: 36px 0 64px; }

/* 헤더 (고정 sticky, 2단: 상단 로고+검색 / 하단 카테고리) */
.site-header { background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 80; }
.header-main {
  max-width: 1040px; margin: 0 auto; padding: 11px 20px;
  display: flex; align-items: center; gap: 16px;
}
.logo { font-size: 19px; font-weight: 800; color: var(--ink); letter-spacing: -.4px; flex-shrink: 0; }
.logo:hover { color: var(--ink); }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* 헤더 전역 검색 (로고와 우측 액션 사이에 중앙 정렬) */
.header-search { position: relative; flex: 0 1 580px; min-width: 0; margin: 0 auto; }
.header-search .hs-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; display: inline-flex; }
.header-search .hs-ico svg { width: 18px; height: 18px; }
.header-search input[type=text] {
  width: 100%; padding: 10px 40px 10px 42px; font-size: 14.5px; height: auto;
  border: 1px solid var(--border); border-radius: 11px; background: var(--bg-soft); color: var(--ink);
}
.header-search input[type=text]:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: 0 0 0 3px var(--tint); }
.header-search .hs-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 600 12px/1 ui-monospace, monospace; color: var(--muted);
  background: var(--card); border: 1px solid var(--border); border-radius: 6px;
  padding: 3px 7px; pointer-events: none;
}
.header-search input[type=text]:focus ~ .hs-kbd { opacity: 0; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; display: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.13); padding: 6px; max-height: 64vh; overflow-y: auto; z-index: 90;
}
.search-results.open { display: block; }
.sr-item { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; }
.sr-item:hover { background: var(--bg-soft); }
.sr-item .tool-ico { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; }
.sr-item .tool-ico svg { width: 18px; height: 18px; }
.sr-item .sr-meta { min-width: 0; }
.sr-item .sr-name { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.sr-item em { font-size: 12px; color: var(--muted); font-style: normal; }
.sr-empty { padding: 14px; text-align: center; font-size: 14px; color: var(--muted); }

/* 하단 카테고리 바 — 한 줄, 색상 점 + 이름, 넘치면 가로 스크롤 */
.cat-nav {
  max-width: 1040px; margin: 0 auto; padding: 0 20px 9px;
  display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-nav-item {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.cat-nav-item:hover { color: var(--ink); background: var(--bg-soft); }
.cat-nav-item.active { color: var(--accent); background: var(--tint); font-weight: 700; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }

/* 도구 이어쓰기 (결과 다음 단계 제안) */
.chain-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chain-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-right: 2px; }
.chain-item { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border: 1px solid var(--border); border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--ink); background: var(--card); }
.chain-item:hover { border-color: var(--accent); background: var(--bg-soft); }
.chain-item .tool-ico { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; }
.chain-item .tool-ico svg { width: 15px; height: 15px; }

/* ===== 재미·운세·게임 — 페이지 단위 컬러 테마 (더 활기차게) ===== */
body.theme-fun     { --accent: #7c3aed; --accent-dark: #6d28d9; --tint: #f3efff; }
body.theme-fortune { --accent: #db2777; --accent-dark: #be185d; --tint: #fce7f3; }
body.theme-game    { --accent: #ea580c; --accent-dark: #c2410c; --tint: #fff1e8; }
/* 다크: 카테고리 틴트만 어두운 저채도 색으로 재정의 — page-head 그라데이션·호버·포커스링이 라이트 색을 쓰지 않게.
 * 액센트는 라이트와 동일 유지(버튼 흰 글자 대비 확보) */
:root[data-theme="dark"] body.theme-fun     { --tint: #261e3d; }
:root[data-theme="dark"] body.theme-fortune { --tint: #351b29; }
:root[data-theme="dark"] body.theme-game    { --tint: #362112; }
/* 컬러풀한 히어로 헤더 */
.theme-fun .page-head, .theme-fortune .page-head, .theme-game .page-head {
  border-bottom: none; border: 1px solid var(--border); border-radius: 18px;
  padding: 26px 24px; margin-bottom: 24px;
  background: linear-gradient(135deg, var(--tint), var(--card) 78%);
}
.theme-fun .page-head h1, .theme-fortune .page-head h1, .theme-game .page-head h1 { font-size: 28px; }
.theme-fun .page-head p, .theme-fortune .page-head p, .theme-game .page-head p { color: var(--ink-2); }
/* 둥근 버튼 (재미 요소) */
.theme-fun button, .theme-fun .btn,
.theme-fortune button, .theme-fortune .btn,
.theme-game button, .theme-game .btn { border-radius: 12px; }
/* (결과 등장 애니메이션은 각 도구가 자체 구현 — 카드 플립/별점/카운트업 등.
   공통 .result 애니메이션은 도구별 플립과 충돌하므로 두지 않음) */

/* 메가패널 (카테고리 hover 시) */
.mega-panel {
  position: absolute; left: 0; right: 0; top: 100%;
  background: var(--card); border-bottom: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(0,0,0,.10);
  display: none; z-index: 79;
}
.mega-panel.open { display: block; }
.mega-inner { max-width: 1040px; margin: 0 auto; padding: 18px 20px 22px; max-height: 70vh; overflow-y: auto; }
.mega-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.mega-head strong { font-size: 15px; color: var(--ink); }
.mega-all { font-size: 13px; font-weight: 600; color: var(--accent); }
.mega-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mega-tool { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; border: 1px solid transparent; }
.mega-tool:hover { background: var(--bg-soft); border-color: var(--border); }
.mega-tool .tool-ico { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; }
.mega-tool .tool-ico svg { width: 19px; height: 19px; }
.mega-tool .mega-meta { min-width: 0; }
.mega-tool .mt-name { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.mega-tool em { display: block; font-size: 12px; color: var(--muted); font-style: normal; margin-top: 2px; }

/* 모바일 접이식 카테고리 + 햄버거 */
.icon-btn.hamburger-btn { display: none; }
.mobile-cats { display: none; border-top: 1px solid var(--border); padding: 8px; }
.mobile-cats.open { display: block; }
.mobile-cats a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; font-size: 15px; font-weight: 600; color: var(--ink); border-radius: 8px; }
.mobile-cats a .tool-ico { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px; }
.mobile-cats a .tool-ico svg { width: 17px; height: 17px; }
.mobile-cats a:hover { background: var(--bg-soft); color: var(--accent); }
.mobile-cats a.active { background: var(--tint); color: var(--accent); font-weight: 700; }

@media (max-width: 880px) {
  .cat-nav { display: none; }
  .icon-btn.hamburger-btn { display: inline-flex; }
  .mega-panel { display: none !important; }
}

/* 홈 카테고리 제목 링크 */
a.cat-title { transition: color .14s; }
a.cat-title:hover { color: var(--accent); }
.icon-btn {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }

/* 푸터 */
.site-footer {
  border-top: 1px solid var(--border); background: var(--bg-soft);
  padding: 32px 20px; margin-top: 56px; color: var(--muted); font-size: 13.5px;
}
.site-footer .inner { max-width: 1040px; margin: 0 auto; }
.site-footer a { color: var(--muted); margin-right: 18px; font-weight: 500; }
.site-footer a:hover { color: var(--ink); }
.site-footer .copy { margin-top: 12px; opacity: .85; }

/* 페이지 제목 */
.page-head { margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1.25; }
.page-head p { color: var(--ink-2); margin-top: 8px; font-size: 15.5px; }
.home-head { border: none; padding-bottom: 0; margin-bottom: 32px; }

/* 카드 */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 18px;
}

/* 폼 */
label { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13.5px; color: var(--ink); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 13px 15px; font-size: 15.5px; line-height: 1.25;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--input-bg); color: var(--ink); font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--tint);
}
.field { margin-bottom: 18px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; font-weight: 400; }
/* 금액 입력 한글 readout (입력 시 "5,000만 원" 실시간 표시) */
.amount-readout { font-size: 14px; font-weight: 600; color: var(--accent); margin-top: 7px; min-height: 18px; letter-spacing: -.2px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #f9fafb; border: none;
  padding: 13px 22px; font-size: 15.5px; font-weight: 600;
  border-radius: 11px; cursor: pointer; font-family: inherit;
  transition: background .14s, transform .06s, opacity .14s;
}
button:hover, .btn:hover { background: var(--accent-dark); color: #f9fafb; }
button:active, .btn:active { transform: scale(.98); opacity: .92; }
:root[data-theme="dark"] button:hover, :root[data-theme="dark"] .btn:hover { background: #1e6ad1; }
.btn-ghost { background: var(--bg-soft); color: var(--ink-2); border: none; font-weight: 600; }
.btn-ghost:hover { background: var(--border); color: var(--ink); }

/* 게임 공통 컨트롤 바: 캔버스 위 우측 정렬 아이콘 버튼 (일시정지·사운드 등) */
.game-ctrl { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; align-items: center; margin: 0 auto 12px; } /* 좁은 화면에서 칩·버튼이 화면 밖으로 밀리지 않게 줄바꿈 */
.game-ctrlbtn {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: color .12s, border-color .12s;
}
.game-ctrlbtn:hover { background: var(--bg-soft); color: var(--accent); border-color: var(--accent); } /* 기본 button:hover(accent-dark 배경)를 명시도로 차단 */
.game-ctrlbtn.on { background: var(--bg-soft); border-color: var(--accent); color: var(--accent); }
.game-ctrlbtn.on:hover { background: var(--bg-soft); border-color: var(--accent-dark); color: var(--accent-dark); }
.game-ctrlbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.game-ctrlbtn:disabled { opacity: .4; cursor: default; }
.game-ctrlbtn:disabled:hover { color: var(--muted); border-color: var(--border); }
.theme-game .game-ctrlbtn, .theme-fun .game-ctrlbtn { border-radius: 8px; } /* 테마별 button radius(12px) 오버라이드 차단 */
.game-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.game-chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex-shrink: 0; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 5px 12px; height: 30px; box-sizing: border-box; }
.game-chip .lbl { font-size: 12px; font-weight: 400; color: var(--muted); }
.game-chip .val { font-size: 15px; font-weight: 700; color: var(--ink); min-width: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.game-ctrlbtn.txt { width: auto; min-width: 92px; padding: 0 12px; gap: 6px; font-size: 12.5px; font-weight: 700; }
.game-ctrlbtn .cnt { font-size: 10px; font-weight: 800; margin-left: 1px; line-height: 1; } /* 되돌리기 남은 횟수 배지 (↶3) */
.game-ctrlbtn.txt .cnt { font-size: 12.5px; font-weight: 800; } /* 텍스트 버튼에선 카운트도 본문 크기 */
.game-ctrlbtn.arm { border-color: var(--danger, #f04452); color: var(--danger, #f04452); background: #fdecec; font-weight: 800; } /* 파괴적 버튼 2단계 확인 상태 */
:root[data-theme="dark"] .game-ctrlbtn.arm { background: #2e1c1e; }
.game-chip.live { border-color: var(--accent); background: var(--tint); } /* 긴박 상태 칩 (남은 수·남은 시간 등) */
.game-chip.live .lbl, .game-chip.live .val { color: var(--accent); }
.game-chip[hidden] { display: none; } /* hidden 속성이 flex에 지도록 */
.btn-full { width: 100%; }

/* 결과 */
.result {
  background: var(--bg-soft); border: none;
  border-radius: 16px; padding: 24px 22px; margin-top: 18px; position: relative;
}
.result .big { font-size: 30px; font-weight: 700; color: var(--ink); letter-spacing: -.6px; }
.result .sub { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.copy-btn {
  position: absolute; top: 14px; right: 14px;
  background: var(--card); color: var(--muted); border: 1px solid var(--border);
  width: auto; padding: 5px 11px; font-size: 12.5px; font-weight: 600; border-radius: 7px;
}
.copy-btn:hover { background: var(--card); color: var(--ink); border-color: var(--muted); }

/* 표 */
.breakdown { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14.5px; }
.breakdown th, .breakdown td { padding: 10px 4px; text-align: right; border-bottom: 1px solid var(--border); }
.breakdown th:first-child, .breakdown td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.breakdown tr.total td { font-weight: 700; color: var(--accent); border-top: 1.5px solid var(--ink); border-bottom: none; font-size: 16px; padding-top: 12px; }
/* 그룹 구분 헤더 (예: 4대보험 / 세금) */
.breakdown tr.grp th { text-align: left; color: var(--ink); font-weight: 700; font-size: 15px; padding: 16px 4px 6px; border-bottom: 1.5px solid var(--border); }
.breakdown tr.grp:first-child th { padding-top: 4px; }
/* 그룹 소계 */
.breakdown tr.subtotal th { color: var(--ink); font-weight: 700; }
.breakdown tr.subtotal td { font-weight: 700; color: var(--ink); border-bottom: 1px solid var(--border); }
/* 항목 옆 요율 (괄호) — 항목명과 같은 크기 */
.breakdown .rate { font-size: inherit; font-weight: 400; color: var(--muted); margin-left: 2px; }
/* 하위 뎁스 행 (파생 항목: 장기요양·지방소득세·농특세·교육세 등) — 들여쓰기 + 회색 */
.breakdown tr.subrow > :first-child { padding-left: 24px; color: var(--muted); font-weight: 500; position: relative; }
.breakdown tr.subrow > :first-child::before { content: "\3134"; position: absolute; left: 6px; color: var(--muted); font-size: 12px; }
.breakdown tr.subrow > td:last-child { color: var(--muted); }

/* 도구 디렉터리 */
.cat-title {
  font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: none;
  letter-spacing: .3px; margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.tool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tool-card {
  display: flex; gap: 13px; align-items: flex-start; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; transition: border-color .14s, background .14s;
}
.tool-card:hover { border-color: var(--accent); background: var(--bg-soft); }
.tool-card .tool-meta { min-width: 0; }
.tool-card h3 { font-size: 15.5px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.tool-card p { font-size: 13px; color: var(--muted); line-height: 1.45; }
/* 카테고리 색상 아이콘 (카드·페이지 공통) */
.tool-ico { width: 40px; height: 40px; border-radius: 11px; flex: 0 0 40px;
  display: inline-flex; align-items: center; justify-content: center; }
.tool-ico svg { width: 22px; height: 22px; }
.page-head h1 .tool-ico { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
  vertical-align: middle; margin-right: 11px; }
.page-head h1 .tool-ico svg { width: 21px; height: 21px; }

/* 설명 / FAQ */
.content { margin-top: 44px; }
.content h2 { font-size: 19px; font-weight: 700; margin: 30px 0 12px; letter-spacing: -.3px; }
.content h3 { font-size: 16px; font-weight: 700; margin: 20px 0 7px; }
.content p, .content li { color: var(--ink); font-size: 15px; }
.content ul { padding-left: 18px; margin: 8px 0; }
.content li { margin-bottom: 6px; }
details { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--card); }
details summary { font-weight: 600; cursor: pointer; font-size: 15px; }
details p { margin-top: 10px; color: var(--muted); }

/* 빵부스러기 */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 18px; display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { color: var(--muted); }
.breadcrumb .cur { color: var(--ink); font-weight: 600; }
.breadcrumb .fav-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: auto; padding: 5px 11px; font-size: 12.5px; font-weight: 600;
  border-radius: 7px; cursor: pointer;
}
.breadcrumb .fav-btn svg { width: 14px; height: 14px; }
.breadcrumb #fsBtn { margin-left: 6px; }
.breadcrumb .fav-btn:hover { color: var(--ink); border-color: var(--muted); background: none; }
.breadcrumb .fav-btn.on { color: #e0a32e; border-color: #e0a32e; }
.breadcrumb .fav-btn.on:hover { color: #e0a32e; }

/* 도구 검색 */
.tool-search { margin-bottom: 8px; }
.tool-search input { width: 100%; padding: 13px 15px; font-size: 15px; }
.no-tools { color: var(--muted); padding: 20px 0; }

/* 관련 도구 */
.related { margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border); }
.related h2 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }

/* 빠른 시작 프리셋 칩 (계산기 공통) — 토스풍 소프트 칩 */
.quick-presets { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; }
.preset-chip {
  font-size: 14px; font-weight: 600; color: var(--ink-2); background: var(--bg-soft);
  border: 1px solid transparent; border-radius: 999px; padding: 9px 16px; cursor: pointer;
  width: auto; transition: background .14s, color .14s, transform .06s;
}
.preset-chip:hover { background: var(--tint); color: var(--accent); }
.preset-chip:active { transform: scale(.97); }
.preset-chip.active {
  background: var(--accent); color: #f9fafb;
}

/* 숫자 스테퍼 (− 값 +) */
.stepper { display: flex; align-items: stretch; }
.stepper button {
  width: 42px; flex: 0 0 42px; padding: 0; background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--border); font-size: 18px; font-weight: 700; cursor: pointer;
}
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper button:hover { background: var(--tint); color: var(--accent); border-color: var(--accent); }
.stepper input { text-align: center; border-radius: 0; border-left: none; border-right: none; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 결과 구성 비율 도넛 차트 (계산기 공통) */
.result-chart { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.donut { width: 128px; height: 128px; border-radius: 50%; flex: 0 0 128px; position: relative; }
.donut::after { content: ""; position: absolute; inset: 21px; background: var(--bg-soft); border-radius: 50%; }
.donut-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.donut-label b { font-size: 22px; color: var(--accent); font-weight: 800; }
.donut-label span { font-size: 11px; color: var(--muted); margin-top: 2px; }
.chart-legend { font-size: 13.5px; }
.chart-legend div { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--ink); }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: 0 0 12px; }

/* 파일 업로드 드롭존 (공통) */
.dropzone-ui {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 44px 24px; border: 2px dashed var(--border); border-radius: 14px;
  background: var(--bg-soft); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone-ui:hover, .dropzone-ui.over { border-color: var(--accent); background: var(--tint); }
.dropzone-ui:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--tint); }
.dz-icon {
  width: 56px; height: 56px; border-radius: 14px; background: var(--tint);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.dropzone-ui:hover .dz-icon, .dropzone-ui.over .dz-icon { background: var(--card); }
.dz-icon svg { width: 26px; height: 26px; color: var(--accent); }
.dz-title { font-size: 16px; font-weight: 700; color: var(--ink); }
.dz-sub { font-size: 13.5px; font-weight: 600; color: var(--accent); margin-top: 8px; }
.dz-meta { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.dz-hidden { display: none !important; }

/* 광고 슬롯(인콘텐츠) — 기본 숨김, 광고/미리보기가 채워지면 .filled로 표시 */
.ad-slot { display: none; margin: 28px 0; }
.ad-slot.filled { display: block; }

/* 광고 자리 미리보기(localhost 전용) */
.ad-ph {
  min-height: 90px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; letter-spacing: .3px;
  border: 1px dashed var(--border); border-radius: 8px; background: var(--bg-soft);
}
/* 헤더 아래 가로 배너 */
.ad-leaderboard { margin: 0 0 24px; }
.ad-leaderboard .ad-ph { min-height: 90px; }
/* 데스크톱 우측 고정 광고 — 본문(1040px) 바깥에 여백이 충분할 때만(겹침 방지) */
.ad-sidebar { display: none; }
@media (min-width: 1700px) {
  .ad-sidebar {
    display: block; position: fixed; top: 90px; right: 24px; width: 300px; z-index: 70;
  }
  .ad-sidebar .ad-ph { min-height: 600px; flex-direction: column; }
}
/* 모바일 하단 고정 광고 */
.ad-anchor { display: none; }
@media (max-width: 880px) {
  .ad-anchor {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    background: var(--card); border-top: 1px solid var(--border); padding: 6px 8px; text-align: center;
  }
  .ad-anchor .ad-ph { min-height: 50px; }
  .ad-anchor-close {
    position: absolute; top: -26px; right: 8px; width: 24px; height: 24px; padding: 0;
    background: var(--card); border: 1px solid var(--border); border-radius: 6px;
    color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer;
  }
  body { padding-bottom: 70px; } /* 하단 광고에 콘텐츠 안 가리도록 */
}

/* 토스트 */
#toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 100;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 안내 박스 */
.note { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; font-size: 12.5px; color: var(--muted); margin-top: 16px; }

/* ===== 공통 UX 보강 ===== */
/* 카드(드롭존 강조 전환 부드럽게) */
.card { transition: border-color .14s, background .14s; }
/* 비활성 버튼 명확화 */
button:disabled, .btn:disabled, button[disabled] { opacity: .5; cursor: not-allowed; }
/* 컬러 피커 일관 스타일 */
input[type=color] {
  -webkit-appearance: none; appearance: none;
  width: 48px; height: 42px; padding: 2px; cursor: pointer; vertical-align: middle;
  border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg);
}
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }
input[type=color]::-moz-color-swatch { border: none; border-radius: 5px; }
/* 인라인(흐름 배치) 복사 버튼 — 결과 박스 우상단 고정형이 아닐 때 */
.copy-btn--inline { position: static; top: auto; right: auto; }
/* 드롭존 강조(파일 도구 공용) */
.card.dragover { border-color: var(--accent); background: var(--tint); }
/* 스크린리더 전용 라벨 */
.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 (max-width: 560px) {
  .page-head h1 { font-size: 22px; }
  .result .big { font-size: 24px; }
  main { padding: 24px 0 44px; }
  /* 작은 화면: 좌우 여백을 비례 축소해 콘텐츠(게임 보드 등) 폭 확보 */
  .container { padding: 0 8px; }
  .card { padding: 14px 10px; }
  /* 좁은 화면에서 입력 행을 세로로 쌓아 가독성 확보 */
  .row { flex-direction: column; gap: 12px; }
  .row > * { min-width: 0; width: 100%; }
}
