/* ===== 기본 설정 ===== */
:root {
  --bg:        #f4f6f9;
  --card:      #ffffff;
  --line:      #e4e8ef;
  --text:      #15181e;
  --muted:     #697487;
  --brand:     #2f6df6;
  --brand-ink: #1c4fc4;
  --brand-bg:  #eaf1ff;
  --good:      #0d9271;
  --good-bg:   #e6f7f1;
  --warn-ink:  #92600a;
  --warn-bg:   #fdf5e3;
  --warn-line: #f0dcae;
  --danger:    #d33b3b;
  --danger-bg: #fdecec;
  --radius:    16px;
  --shadow:    0 1px 2px rgba(20,25,40,.05), 0 6px 20px rgba(20,25,40,.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0f1116;
    --card:      #181b22;
    --line:      #2a2f3a;
    --text:      #e9ecf2;
    --muted:     #98a1b2;
    --brand:     #6d9bff;
    --brand-ink: #a8c4ff;
    --brand-bg:  #1c2740;
    --good:      #35c99b;
    --good-bg:   #16302a;
    --warn-ink:  #e9c377;
    --warn-bg:   #2c2417;
    --warn-line: #4a3d22;
    --danger:    #ff8080;
    --danger-bg: #331e1e;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard",
               "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 620px; margin: 0 auto; padding: 0 16px; }

.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;
}

.is-hidden { display: none !important; }

/* ===== 헤더 ===== */
.site-header { padding: 34px 0 22px; }
.eyebrow {
  margin: 0 0 6px; font-size: 13px; font-weight: 700; letter-spacing: .04em;
  color: var(--brand);
}
.site-header h1 {
  margin: 0 0 10px;
  font-size: 27px; line-height: 1.3; font-weight: 800; letter-spacing: -.02em;
}
.lede { margin: 0; color: var(--muted); font-size: 15px; }
.lede strong { color: var(--text); font-weight: 700; }
.br-pc { display: none; }

/* ===== 카드 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.q-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.q-sub   { margin: 22px 0 4px; font-size: 15px; font-weight: 700; }
.q-help  { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); }
.q-sub + .q-help { margin-bottom: 10px; }
.section-title { margin: 0 0 14px; font-size: 17px; font-weight: 700; }

/* ===== 금액 칩 ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  flex: 1 1 calc(50% - 4px);
  padding: 11px 8px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: .15s;
}
.chip:hover { border-color: var(--brand); }
.chip.is-active {
  background: var(--brand-bg); border-color: var(--brand);
  color: var(--brand-ink); font-weight: 700;
}

/* ===== 금액 입력 ===== */
.money-field { position: relative; display: flex; align-items: center; }
.money-field input {
  width: 100%;
  padding: 14px 46px 14px 14px;
  font: inherit; font-size: 19px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: .15s;
}
.money-field input::placeholder { font-weight: 500; font-size: 16px; color: var(--muted); }
.money-field input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-bg);
}
.money-field .unit {
  position: absolute; right: 14px;
  font-size: 15px; font-weight: 600; color: var(--muted); pointer-events: none;
}
.field-echo { margin: 8px 2px 0; font-size: 13px; color: var(--muted); min-height: 20px; }
.field-echo strong { color: var(--brand); font-weight: 700; }

/* ===== 세그먼트 토글 ===== */
.seg { display: flex; gap: 8px; }
.seg-item { flex: 1; position: relative; }
.seg-item input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.seg-item span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 8px 10px;
  font-size: 14.5px; font-weight: 600; color: var(--muted);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: .15s;
}
.seg-item input:checked + span {
  background: var(--brand-bg); border-color: var(--brand);
  color: var(--brand-ink); font-weight: 700;
}
.seg-item input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-bg); }

/* ===== 접이식 ===== */
.details-card { padding: 0; }
.details-card > summary {
  list-style: none; cursor: pointer;
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 2px;
  position: relative;
}
.details-card > summary::-webkit-details-marker { display: none; }
.details-card > summary::after {
  content: ""; position: absolute; right: 22px; top: 26px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg); transition: transform .2s;
}
.details-card[open] > summary::after { transform: rotate(-135deg); top: 30px; }
.sum-main { font-size: 16px; font-weight: 700; padding-right: 24px; }
.sum-sub  { font-size: 13px; color: var(--muted); padding-right: 24px; }
.details-body { padding: 0 20px 22px; border-top: 1px solid var(--line); }
.details-body .q-sub:first-child { margin-top: 18px; }
.details-body .money-field { margin-top: 12px; }

/* ===== 결과 ===== */
.result-card { }

.empty-msg { margin: 0; text-align: center; color: var(--muted); font-size: 15px; padding: 14px 0; }
.empty-msg strong { color: var(--text); }

.badge {
  display: inline-block;
  padding: 6px 13px;
  font-size: 13.5px; font-weight: 700;
  color: var(--brand-ink); background: var(--brand-bg);
  border-radius: 999px;
  margin-bottom: 16px;
}
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.badge-good   { color: var(--good);   background: var(--good-bg); }

/* 헤드라인 */
.headline-card { text-align: center; }
.headline-label { margin: 0; font-size: 14.5px; color: var(--muted); font-weight: 600; }
.headline {
  margin: 2px 0;
  font-size: 38px; line-height: 1.2; font-weight: 800; letter-spacing: -.03em;
  color: var(--good);
  font-variant-numeric: tabular-nums;
}

.metrics {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-top: 20px;
  border-top: 1px solid var(--line); padding-top: 18px;
}
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.metric-value {
  font-size: 14px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 비교표 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.cmp {
  width: 100%; min-width: 0;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.cmp th, .cmp td {
  padding: 11px 4px; text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.cmp thead th {
  font-size: 12.5px; font-weight: 700; color: var(--muted);
  white-space: normal; line-height: 1.35;
}
.cmp tbody th {
  text-align: left; font-weight: 600; color: var(--muted);
  white-space: normal; line-height: 1.35;
}
/* 아주 좁은 화면에서 표를 밀어도 행 이름은 왼쪽에 고정 */
.cmp thead th:first-child,
.cmp tbody th { position: sticky; left: 0; background: var(--card); z-index: 1; }
.cmp td { font-weight: 700; }
.cmp .is-dim { color: var(--muted); opacity: .45; font-weight: 500; }
.cmp thead th.is-dim { opacity: .45; }
.cmp .is-focus { color: var(--brand-ink); }
.cmp thead th.is-focus { color: var(--brand-ink); }
.cmp tbody tr:last-child th, .cmp tbody tr:last-child td { border-bottom: none; }

.scroll-hint {
  margin: 8px 0 0; font-size: 12px; color: var(--muted); text-align: right;
}
.table-note { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }

.loss-note {
  margin: 14px 0 0; padding: 12px 14px;
  background: var(--good-bg); color: var(--good);
  border-radius: 11px; font-size: 13.5px; font-weight: 600; line-height: 1.6;
}

/* 경고 박스 */
.warn-box { background: var(--warn-bg); border-color: var(--warn-line); }
.warn-title { margin: 0 0 6px; font-size: 15.5px; font-weight: 700; color: var(--warn-ink); }
.warn-box p { margin: 0; font-size: 13.5px; color: var(--warn-ink); line-height: 1.6; }
.warn-box strong { font-weight: 800; }

/* 액션 */
.actions-card { display: flex; flex-direction: column; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 12px 16px;
  font: inherit; font-size: 15px; font-weight: 700;
  border-radius: 12px; border: 1.5px solid transparent;
  text-decoration: none; cursor: pointer; text-align: center;
  transition: .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost {
  background: var(--bg); color: var(--muted); border-color: var(--line);
}
.is-soon { cursor: not-allowed; opacity: .65; }
.share-toast {
  margin: 0; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--good);
}

/* 가입 불가 */
.blocked-msg { margin: 0 0 10px; font-size: 15px; line-height: 1.65; }
.blocked-sub { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* ===== FAQ ===== */
.faq-card { margin-top: 28px; }
.faq { border-top: 1px solid var(--line); }
.faq:first-of-type { border-top: none; }
.faq > summary {
  list-style: none; cursor: pointer;
  padding: 15px 26px 15px 0;
  font-size: 15px; font-weight: 600;
  position: relative;
}
.faq > summary::-webkit-details-marker { display: none; }
.faq > summary::after {
  content: "+"; position: absolute; right: 4px; top: 13px;
  font-size: 19px; color: var(--muted); font-weight: 400;
}
.faq[open] > summary::after { content: "−"; }
.faq-body { padding: 0 0 16px; }
.faq-todo { margin: 0; font-size: 14px; color: var(--muted); }

/* ===== 푸터 ===== */
.site-footer { padding: 26px 0 44px; }
.disclaimer { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.note-2027 { margin-top: 12px; }

/* ===== 태블릿 이상 ===== */
@media (min-width: 560px) {
  .site-header h1 { font-size: 32px; }
  .br-pc { display: inline; }
  .card { padding: 24px; }
  .chip { flex: 1 1 0; }
  .headline { font-size: 46px; }
  .actions-card { flex-direction: row; }
  .actions-card .btn { flex: 1; }
  .share-toast { flex-basis: 100%; }
  .cmp { min-width: 0; font-size: 14px; }
  .cmp th, .cmp td { padding: 11px 8px; }
  .cmp thead th { font-size: 13px; white-space: nowrap; }
  .scroll-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
