:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #FAF8F4;
  --ink: #191C1F;
  --ink-2: #3D4247;
  --muted: #73787E;
  --line: #E8E3D9;
  --accent: #1F4E46;
  --accent-ink: #FFFFFF;
  --accent-soft: #E4EFEB;
  --ok: #2E7A57;
  --ok-soft: #E3F2EA;
  --warn: #A9690F;
  --warn-soft: #FBF0DC;
  --no: #8E4A42;
  --no-soft: #F6E7E4;
  --pin: #E0703F;
  --shadow: 0 1px 2px rgba(25, 28, 31, .04), 0 8px 28px rgba(25, 28, 31, .06);
  --radius: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413;
    --surface: #191D1C;
    --surface-2: #1E2321;
    --ink: #ECEEEB;
    --ink-2: #C9CDC9;
    --muted: #8E9590;
    --line: #2A302E;
    --accent: #7FC4B0;
    --accent-ink: #0E1A17;
    --accent-soft: #1D2E2A;
    --ok: #6FCB9C;
    --ok-soft: #17291F;
    --warn: #E5B25D;
    --warn-soft: #2D2416;
    --no: #E2958B;
    --no-soft: #2E1C1A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }

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

/* 상단 바 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand img { display: block; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.03em; }
.brand-name b { color: var(--accent); font-weight: 800; }
.beta {
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}

/* 소개 */
.hero { padding: 56px 0 36px; max-width: 640px; }
.eyebrow { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.hero h1 { margin: 0 0 16px; font-size: clamp(30px, 4.6vw, 44px); line-height: 1.22; font-weight: 800; letter-spacing: -0.035em; }
.lead { margin: 0; color: var(--muted); font-size: 16px; }

/* 2단 레이아웃 */
.layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 28px; align-items: start; padding-bottom: 48px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* 조건 입력 */
.form { position: sticky; top: 88px; padding: 28px 24px 24px; }
.panel-title { margin: 0 0 22px; font-size: 17px; font-weight: 700; }
.field { display: block; margin: 0 0 22px; padding: 0; border: 0; min-width: 0; }
.field-label { display: block; margin: 0 0 8px; padding: 0; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field-label small { margin-left: 4px; font-weight: 500; color: var(--muted); }

input[type="number"], .select select {
  width: 100%; height: 46px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
input[type="number"]::placeholder { color: var(--muted); }
input[type="number"]:focus, .select select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { position: relative; }
.select select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px; }
.select::after {
  content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -5px;
  border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segmented button, .chips button {
  border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.segmented button { height: 40px; border-radius: 10px; font-size: 13.5px; font-weight: 500; }
.segmented button:first-child { grid-column: span 3; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 34px; padding: 0 13px; border-radius: 999px; font-size: 13px; }
.segmented button:hover, .chips button:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.segmented button[aria-checked="true"], .chips button[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600;
}
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.form-error { margin: -8px 0 14px; font-size: 13px; color: var(--no); }

.primary {
  width: 100%; height: 50px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font-size: 15.5px; font-weight: 700;
  transition: transform .1s, filter .15s;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(.99); }
.primary[disabled] { opacity: .6; cursor: progress; }

/* 결과 */
.empty { padding: 64px 24px; text-align: center; }
.empty img { opacity: .9; }
.empty-title { margin: 18px 0 6px; font-size: 17px; font-weight: 700; }
.empty-desc { margin: 0; color: var(--muted); font-size: 14px; }

.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.result-summary { margin: 0; font-size: 14px; color: var(--muted); }
.result-summary b { color: var(--ink); font-weight: 600; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tabs button {
  border: 0; background: transparent; cursor: pointer; height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.tabs .count { margin-left: 4px; font-variant-numeric: tabular-nums; }

.cards { display: grid; gap: 14px; }

.card { padding: 22px 22px 18px; }
.card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.status, .cat, .dday { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-eligible { background: var(--ok-soft); color: var(--ok); }
.status-conditional { background: var(--warn-soft); color: var(--warn); }
.status-ineligible { background: var(--no-soft); color: var(--no); }
.cat { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); font-weight: 500; }
.dday { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.dday.urgent { color: var(--pin); }

.card h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.025em; }
.org { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.amount { margin: 12px 0 0; font-size: 16px; font-weight: 700; color: var(--accent); }

.checks { list-style: none; margin: 14px 0 0; padding: 14px 0 0; border-top: 1px dashed var(--line); display: grid; gap: 6px; }
.checks li { position: relative; padding-left: 24px; font-size: 13.5px; color: var(--ink-2); }
.checks li::before {
  position: absolute; left: 0; top: 2px; width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 800; line-height: 1;
}
.checks .pass::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.checks .conditional::before { content: "!"; background: var(--warn-soft); color: var(--warn); }
.checks .ineligible::before { content: "✕"; background: var(--no-soft); color: var(--no); }
.checks .info::before { content: "i"; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.checks .bonus::before { content: "★"; background: var(--accent-soft); color: var(--accent); }

.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.more {
  border: 0; background: none; padding: 4px 0; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
}
.more::after { content: ""; display: inline-block; width: 6px; height: 6px; margin: 0 0 3px 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.more[aria-expanded="true"]::after { transform: rotate(-135deg); margin-bottom: -1px; }
.source { font-size: 13px; color: var(--muted); text-decoration: none; }
.source:hover { color: var(--accent); }

.detail { margin: 14px 0 0; padding: 16px 18px; background: var(--surface-2); border-radius: 12px; display: grid; grid-template-columns: 84px 1fr; gap: 10px 14px; }
.detail dt { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.detail dd { margin: 0; font-size: 13.5px; color: var(--ink-2); }

.card.dim { opacity: .78; }
.no-results { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14px; }

/* 하단 */
.footer { padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.footer p { margin: 0 0 4px; }
.footer-sub { opacity: .8; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .form { position: static; }
}

@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 24px; }
  .result-head { flex-direction: column; align-items: stretch; }
  .tabs { overflow-x: auto; }
  .tabs button { flex: 1; }
  .card { padding: 18px 16px 16px; }
  .detail { grid-template-columns: 1fr; gap: 2px; }
  .detail dd { margin-bottom: 8px; }
}

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