:root {
  --bg: #f6f5f3;
  --card: #ffffff;
  --ink: #1c1b19;
  --ink-soft: #4a463f;
  --muted: #8a857d;
  --faint: #a8a29a;
  --line: #e8e6e2;
  --line-soft: #f0eeea;
  --accent: #b0613c;
  --accent-soft: #f7ede7;
  --ok: #3f7d55;
  --shadow: 0 1px 2px rgba(28, 27, 25, .04), 0 8px 24px -12px rgba(28, 27, 25, .12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614;
    --card: #211f1c;
    --ink: #f0ede8;
    --ink-soft: #cfc9c0;
    --muted: #9a948b;
    --faint: #7a746c;
    --line: #33302b;
    --line-soft: #2a2724;
    --accent: #d98e68;
    --accent-soft: #2e2621;
    --ok: #6fae86;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --card: #211f1c; --ink: #f0ede8; --ink-soft: #cfc9c0;
  --muted: #9a948b; --faint: #7a746c; --line: #33302b; --line-soft: #2a2724;
  --accent: #d98e68; --accent-soft: #2e2621; --ok: #6fae86;
}

* { box-sizing: border-box; }

/* Several elements below set an explicit display (flex, grid, inline-block),
   which would otherwise beat the [hidden] attribute's own display:none. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

.wrap { max-width: 660px; margin: 0 auto; padding: 0 16px; }

/* ── masthead ─────────────────────────────────────────────── */
.masthead { padding: 68px 0 40px; }
.eyebrow {
  font-size: 12px; font-weight: 650; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint); margin-bottom: 18px;
}
.masthead h1 {
  margin: 0 0 18px; font-size: clamp(27px, 5.6vw, 38px); line-height: 1.32;
  font-weight: 680; letter-spacing: -.022em;
}
.lede { margin: 0; font-size: 16px; line-height: 1.75; color: var(--ink-soft); max-width: 52ch; }
.lede strong { font-weight: 650; color: var(--ink); }

/* ── panels ───────────────────────────────────────────────── */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 26px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.step {
  flex: none; width: 25px; height: 25px; border-radius: 50%;
  background: var(--ink); color: var(--card);
  font-size: 13px; font-weight: 680; display: grid; place-items: center;
}
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -.012em; }
h2.plain { margin: 0 0 14px; font-size: 18px; font-weight: 650; letter-spacing: -.012em; }
.count { color: var(--muted); font-weight: 500; font-size: 15px; }
.panel.quiet { background: transparent; box-shadow: none; border-style: dashed; }
.panel.quiet p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.75; color: var(--ink-soft); }
.panel.quiet p:last-child { margin-bottom: 0; }
.caveat {
  background: var(--accent-soft); border-radius: 10px; padding: 14px 16px;
  font-size: 13.5px !important; color: var(--ink-soft) !important;
}

/* ── fields ───────────────────────────────────────────────── */
.field { margin-bottom: 22px; }
.field:last-of-type { margin-bottom: 0; }
label { display: block; font-size: 14px; font-weight: 620; margin-bottom: 9px; }
.sub-inline { font-weight: 450; color: var(--muted); font-size: 13px; }
.hint { margin: 9px 0 0; font-size: 13px; line-height: 1.65; color: var(--muted); }
.hint strong { color: var(--ink-soft); font-weight: 620; }

input[type="text"], input[type="email"], input[type="number"], input[type="date"], select {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 15px;
  color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; outline: none;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238a857d' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
input:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--line-soft); }
input::placeholder { color: var(--faint); }

.row { display: flex; gap: 9px; }
.col { flex: 1; min-width: 0; }
.col .sub { display: block; margin-top: 5px; font-size: 11.5px; color: var(--faint); text-align: center; }

.check { display: flex; align-items: flex-start; gap: 9px; margin-top: 13px; font-weight: 450; font-size: 14px; }
.check input { margin: 3px 0 0; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.check em { font-style: normal; color: var(--muted); font-size: 13px; }

/* ── segmented control ────────────────────────────────────── */
.segmented { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 11px; border: 1px solid var(--line); }
.segmented.small { max-width: 320px; }
.seg {
  flex: 1; padding: 9px 10px; font: inherit; font-size: 14px; font-weight: 550;
  color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer;
  transition: background .12s, color .12s;
}
.seg.on { background: var(--card); color: var(--ink); font-weight: 640; box-shadow: 0 1px 3px rgba(0,0,0,.07); }

/* ── stacked options ──────────────────────────────────────── */
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
  padding: 13px 15px; transition: border-color .12s, background .12s;
}
.opt:hover { border-color: var(--muted); }
.opt.on { border-color: var(--ink); background: var(--card); box-shadow: 0 0 0 1px var(--ink); }
.opt-t { display: block; font-size: 14.5px; font-weight: 620; color: var(--muted); }
.opt.on .opt-t { color: var(--ink); font-weight: 650; }
.opt-d { display: block; font-size: 12.5px; line-height: 1.55; color: var(--faint); margin-top: 3px; }
.opt.on .opt-d { color: var(--muted); }

.caution {
  margin: 10px 0 0; padding: 12px 14px; border-radius: 9px;
  background: var(--accent-soft); color: var(--ink-soft);
  font-size: 12.5px; line-height: 1.7;
}
.caution strong { color: var(--accent); font-weight: 650; }

/* ── chips ────────────────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { margin: 0; font-weight: 450; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 8px 14px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  color: var(--muted); background: var(--bg); transition: all .12s; user-select: none;
}
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--card); font-weight: 600; }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--line-soft); }

/* ── readout ──────────────────────────────────────────────── */
.readout {
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px;
  padding: 16px 18px; margin-bottom: 22px; font-size: 14.5px; line-height: 1.7;
}
.readout .big { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.readout .warn { margin-top: 12px; color: var(--accent); font-size: 13.5px; }
.readout .foot { margin-top: 10px; font-size: 12px; color: var(--faint); }

/* Ten upcoming years. One column when narrow; where there is room, two columns
   filled top-to-bottom — years 1-5 on the left, 6-10 on the right — rather than
   the row-first order a plain grid would give. */
.years-grid {
  margin-top: 12px; display: grid; gap: 1px 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 560px) {
  .years-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(5, auto);
    grid-auto-flow: column;
  }
  /* the 6th entry starts the second column, so it is a top row too */
  .years-grid .yr:nth-child(6) { border-top: 0; }
}
.yr {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0; font-size: 14px; font-variant-numeric: tabular-nums;
  border-top: 1px solid var(--line-soft);
}
.yr .y { color: var(--faint); font-size: 12.5px; min-width: 2.6em; }
.yr .d { font-weight: 560; color: var(--ink-soft); }
.yr .w { color: var(--faint); font-size: 12.5px; }
.yr em { font-style: normal; color: var(--accent); font-size: 12px; font-weight: 600; margin-left: auto; }
.yr i { font-style: normal; color: var(--accent); font-size: 11.5px; margin-left: auto; }
.yr.first { border-top: 0; }
.yr.first .d { color: var(--ink); font-weight: 650; }
.yr.est .y::after { content: "*"; color: var(--accent); }

/* ── advanced ─────────────────────────────────────────────── */
.advanced { margin: 22px 0; border-top: 1px solid var(--line-soft); padding-top: 16px; }
.advanced summary {
  cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-soft);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "＋"; color: var(--faint); font-weight: 400; }
.advanced[open] summary::before { content: "−"; }
.adv-body { padding-top: 18px; }

/* ── buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-block; font: inherit; font-size: 15px; font-weight: 640;
  padding: 12px 24px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); cursor: pointer; transition: opacity .12s;
}
.btn.primary { background: var(--ink); color: var(--card); border-color: var(--ink); width: 100%; margin-top: 22px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:not(:disabled):hover { opacity: .85; }

.err, .ok { margin: 13px 0 0; font-size: 14px; line-height: 1.6; }
.err { color: var(--accent); }
.ok { color: var(--ok); }

/* ── list ─────────────────────────────────────────────────── */
.item {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 10px;
  background: var(--bg);
}
.item:last-child { margin-bottom: 0; }
.item-top { display: flex; align-items: flex-start; gap: 12px; }
.item-name { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.item-date { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.item-when { font-size: 13px; color: var(--muted); margin-top: 7px; }
.item-next { font-size: 13px; color: var(--muted); margin-top: 7px; }
.item-actions { margin-left: auto; display: flex; gap: 6px; flex: none; }
.mini {
  font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 11px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--card);
  color: var(--muted); cursor: pointer;
}
.mini:hover { color: var(--ink); }

/* ── modal ────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(28,27,25,.5); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 84vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px -20px rgba(0,0,0,.4);
}
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.close {
  margin-left: auto; background: none; border: 0; font-size: 26px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 0 4px;
}
.modal-body { overflow-y: auto; padding: 8px 22px 22px; }
table.years { width: 100%; border-collapse: collapse; font-size: 14px; }
table.years th {
  text-align: left; font-size: 11.5px; font-weight: 640; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint); padding: 10px 6px 8px;
  position: sticky; top: 0; background: var(--card);
}
table.years td { padding: 7px 6px; border-top: 1px solid var(--line-soft); }
table.years td.y, table.years td.w { color: var(--muted); font-variant-numeric: tabular-nums; }
table.years td.s { font-weight: 560; font-variant-numeric: tabular-nums; }
table.years td.n { color: var(--accent); font-size: 12.5px; }
table.years tr.est td.y::after { content: " *"; color: var(--accent); }
.modal-note { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

footer { padding: 26px 0 60px; }
footer p { margin: 0; font-size: 13px; color: var(--faint); text-align: center; }

@media (max-width: 480px) {
  .masthead { padding: 44px 0 28px; }
  .panel { padding: 22px 18px; }
  .row { flex-wrap: wrap; }
  .col { flex: 1 1 30%; }
}
