:root {
  --bg: #ffffff;
  --side-bg: #f9f9f9;
  --surface: #ffffff;
  --hover: #f0f0f0;
  --active: #ececec;
  --text: #0d0d0d;
  --muted: #6b6b6b;
  --line: #e5e5e5;
  --accent: #2f6fdb;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
  --ok-bg: #e5f4ea; --ok-fg: #166534;
  --warn-bg: #fdf3dc; --warn-fg: #8a5300;
  --bad-bg: #fde8e6; --bad-fg: #a02820;
  --info-bg: #e8eefa; --info-fg: #254a99;
  --gray-bg: #efefef; --gray-fg: #484848;
  --side-w: 236px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #212121; --side-bg: #171717; --surface: #2a2a2a; --hover: #2c2c2c; --active: #303030;
    --text: #ececec; --muted: #a0a0a0; --line: #3a3a3a; --accent: #7aa7f5; --shadow: none;
    --ok-bg: #173523; --ok-fg: #9be0b2; --warn-bg: #3d2f0f; --warn-fg: #f0cd86;
    --bad-bg: #40201d; --bad-fg: #f1a8a1; --info-bg: #1d2a42; --info-fg: #a9c1f0;
    --gray-bg: #333; --gray-fg: #c4c4c4;
  }
}
:root[data-theme="dark"] {
  --bg: #212121; --side-bg: #171717; --surface: #2a2a2a; --hover: #2c2c2c; --active: #303030;
  --text: #ececec; --muted: #a0a0a0; --line: #3a3a3a; --accent: #7aa7f5; --shadow: none;
  --ok-bg: #173523; --ok-fg: #9be0b2; --warn-bg: #3d2f0f; --warn-fg: #f0cd86;
  --bad-bg: #40201d; --bad-fg: #f1a8a1; --info-bg: #1d2a42; --info-fg: #a9c1f0;
  --gray-bg: #333; --gray-fg: #c4c4c4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.sub { color: var(--muted); font-size: 0.85rem; }

/* ---------- 레이아웃 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--side-w); flex: none; height: 100vh;
  background: var(--side-bg); border-right: 1px solid var(--line);
  padding: 14px 12px; display: flex; flex-direction: column; overflow-y: auto;
}
.main { flex: 1; min-width: 0; }
.bar { display: none; }
main { max-width: 820px; margin: 0 auto; padding: 0 24px 80px; }

.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 14px; }
.brand { font-size: 1.02rem; font-weight: 650; letter-spacing: -0.01em; }
.icon-btn { background: none; border: 0; border-radius: 8px; padding: 6px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
#side-close { display: none; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: none; border: 0;
  padding: 7px 10px; border-radius: 8px; color: var(--text); font-size: 0.9rem;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--active); }
.nav-item.track { padding-left: 36px; font-size: 0.88rem; color: var(--muted); }
.nav-item.track.active { color: var(--text); }
.nav-item svg { flex: none; color: var(--muted); }
.nav-item.active svg { color: var(--text); }
.side-label { margin: 18px 10px 4px; font-size: 0.74rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.side-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px 8px 4px; border-top: 1px solid var(--line); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; flex: none; }
.foot-title { font-weight: 600; font-size: 0.9rem; }

/* ---------- 히어로 ---------- */
.hero { padding: 12vh 0 28px; text-align: center; }
.hero h1 { font-size: clamp(1.45rem, 3.4vw, 1.9rem); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 10px; }
.hero p { margin: 0 auto 26px; max-width: 560px; font-size: 0.9rem; }
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 20px; height: 58px; box-shadow: var(--shadow); color: var(--muted);
  max-width: 680px; margin: 0 auto;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 1rem; height: 100%;
}
.search input::placeholder { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; color: var(--muted); font-size: 0.9rem;
}
.chip:hover { background: var(--hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- 블록·리스트 ---------- */
.block { margin-top: 40px; scroll-margin-top: 16px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; padding: 0 4px; }
.block h2 { font-size: 1.05rem; margin: 0; font-weight: 600; }
.note { padding: 0 4px; margin-top: 10px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  transition: box-shadow .15s, border-color .15s;
}
.card:hover { box-shadow: var(--shadow); }
.card-head {
  width: 100%; text-align: left; background: none; border: 0; border-radius: var(--radius);
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 14px 18px;
}
.card-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.card-title { font-weight: 600; font-size: 1rem; }
.facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 2px; }
.fact { background: var(--gray-bg); color: var(--gray-fg); border-radius: 8px; padding: 2px 10px; font-size: 0.82rem; }
.fact b { font-weight: 600; margin-right: 4px; }
.card-right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; text-align: right; }
.chev { transition: transform .15s; }
.card.open .chev { transform: rotate(180deg); }
.detail { padding: 4px 18px 18px; border-top: 1px solid var(--line); }
.detail[hidden] { display: none; }

.sec { padding: 12px 0; border-top: 1px solid var(--line); }
.sec:first-child { border-top: 0; }
.sec h3 { font-size: 0.92rem; margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.sec ul { margin: 4px 0; padding-left: 20px; }
.meta { font-size: 0.8rem; color: var(--muted); }
.caveat { font-size: 0.84rem; color: var(--warn-fg); background: var(--warn-bg); border-radius: 10px; padding: 5px 12px; margin: 6px 0 0; }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.b-verified_official { background: var(--ok-bg); color: var(--ok-fg); }
.b-verified_third_party { background: var(--info-bg); color: var(--info-fg); }
.b-conflict { background: var(--bad-bg); color: var(--bad-fg); }
.b-unverified_snapshot { background: var(--warn-bg); color: var(--warn-fg); }
.b-unknown { background: var(--gray-bg); color: var(--gray-fg); }
.b-stale { background: var(--bad-bg); color: var(--bad-fg); margin-left: 4px; }

.row {
  display: grid; grid-template-columns: 1.2fr 1fr 1fr 1.4fr; gap: 6px 16px; align-items: center;
  padding: 12px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.row .name { font-weight: 600; }

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 20; }
.scrim[hidden] { display: none; }

/* ---------- 모바일 ---------- */
@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.side-open .side { transform: none; }
  #side-close { display: inline-flex; }
  .bar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .bar-title { font-weight: 600; }
  main { padding: 0 16px 64px; }
  .hero { padding-top: 6vh; }
  .row { grid-template-columns: 1fr 1fr; }
  .card-head { grid-template-columns: 1fr; }
  .card-right { justify-content: space-between; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .side, .chev, .card { transition: none; }
}

/* ===== 공통 컴포넌트 ===== */
.view[hidden] { display: none; }
.page-head { padding: 36px 0 8px; }
.page-head h1 { font-size: 1.5rem; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { margin: 0; }
.btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 0.88rem; line-height: 1.4; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { color: var(--bad-fg); }
.btn.icon { padding: 3px 10px; font-size: 0.8rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-weight: 400; }
thead th { font-size: 0.78rem; color: var(--muted); font-weight: 600; background: var(--side-bg); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
ul.tight { margin: 0; padding-left: 16px; }
.toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 0.88rem; z-index: 50; }
.toast[hidden] { display: none; }

/* 비교 담기 */
.card-top { display: flex; align-items: stretch; }
.card-top .card-head { flex: 1; min-width: 0; }
.cmp { display: flex; align-items: center; gap: 6px; padding: 0 16px 0 4px; font-size: 0.82rem; color: var(--muted); cursor: pointer; white-space: nowrap; }
.cmp input { width: 16px; height: 16px; accent-color: var(--accent); }
.tray {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 25;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  padding: 8px 10px 8px 18px; display: flex; align-items: center; gap: 10px; font-size: 0.9rem;
}
.tray[hidden] { display: none; }
.cmp-table { min-width: 640px; }
.cmp-table th[scope="row"] { width: 120px; font-size: 0.8rem; color: var(--muted); background: var(--side-bg); font-weight: 600; }
.cmp-table thead th { font-size: 0.9rem; color: var(--text); }

/* 판정 배지 */
.badge.r-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.r-borderline { background: var(--warn-bg); color: var(--warn-fg); }
.badge.r-short { background: var(--bad-bg); color: var(--bad-fg); }
.badge.r-unknown, .badge.r-info { background: var(--gray-bg); color: var(--gray-fg); }

/* 타임라인 */
.tl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 6px 0 10px; }
.tl { position: relative; min-width: 760px; }
.tl-grid { position: absolute; top: 0; bottom: 0; left: 190px; right: 16px; pointer-events: none; }
.tl-month { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); opacity: .55; }
.tl-row { display: grid; grid-template-columns: 190px 1fr; align-items: center; min-height: 46px; padding-right: 16px; position: relative; }
.tl-head { min-height: 30px; }
.tl-label { padding: 4px 14px; font-size: 0.85rem; line-height: 1.3; }
.tl-name { font-weight: 600; }
.tl-track { position: relative; height: 26px; }
.tl-ml, .tl-ms { position: absolute; top: 4px; font-size: 0.72rem; color: var(--muted); transform: translateX(3px); }
.tl-ml { font-weight: 700; color: var(--text); }
.tl-bar { position: absolute; top: 5px; height: 16px; border-radius: 999px; background: var(--accent); opacity: .85; }
.tl-bar.t-statistics { background: #2f9e6e; }
.tl-bar.dashed { background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 10px); }
.tl-bar.dashed.t-statistics { background: repeating-linear-gradient(90deg, #2f9e6e 0 6px, transparent 6px 10px); }
.tl-bar.test { background: #d9892b; }
.tl-date { position: absolute; top: 5px; transform: translateX(8px); font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.tl-mark { position: absolute; top: 3px; color: var(--bad-fg); font-size: 1rem; transform: translateX(-50%); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); opacity: .7; margin-left: 190px; z-index: 1; }
.tl-section { padding: 10px 14px 2px; font-size: 0.78rem; color: var(--muted); font-weight: 600; }

/* 내 환산 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.flabel { color: var(--muted); font-size: 0.78rem; }
input[type="number"], input[type="text"], input[type="date"], select {
  font: inherit; font-size: 0.9rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-width: 0; width: 100%;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .chip:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.form-row { display: grid; grid-template-columns: 140px 160px 120px auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.course-table { min-width: 880px; }
.course-table td { padding: 6px 8px; }
.course-table td.narrow { width: 104px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.stat-v { font-size: 1.25rem; font-weight: 600; }
.card-top-line { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.rlines { display: flex; flex-direction: column; gap: 6px; }
.rline { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: center; font-size: 0.9rem; }
.rline .pbar { grid-column: 1 / -1; }
.rline .full { grid-column: 1 / -1; }
.opt-label { font-size: 0.8rem; color: var(--muted); margin-top: 6px; font-weight: 600; }
.pbar { position: relative; height: 6px; background: var(--gray-bg); border-radius: 999px; overflow: hidden; }
.pfill { position: absolute; top: 0; bottom: 0; }
.pfill.lo { left: 0; background: var(--ok-fg); opacity: .8; }
.pfill.hi { background: var(--warn-fg); opacity: .55; }

@media (max-width: 860px) {
  .form-row { grid-template-columns: 1fr 1fr; }
  .tl-grid { left: 150px; }
  .tl-row { grid-template-columns: 150px 1fr; }
  .tl-today { margin-left: 150px; }
  .cmp { padding-right: 10px; }
  .tray { width: calc(100% - 24px); justify-content: space-between; }
}
body:not([data-view="programs"]) .tray { display: none; }

/* 부족분·시뮬레이션 */
.gapbox { margin-top: 10px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 10px; padding: 8px 14px; font-size: 0.88rem; }
.gap-title { font-weight: 700; font-size: 0.78rem; margin-bottom: 2px; }
.arrow-badges { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.sim-banner { background: var(--info-bg); color: var(--info-fg); border-radius: 10px; padding: 6px 14px; font-size: 0.85rem; margin: 0 0 12px; }
input.whatif { border-style: dashed; border-color: var(--accent); }
#sim-table td { vertical-align: top; }
#sim-table .fact { display: inline-block; margin: 0 6px 6px 0; }

/* 비용 계산기 */
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; }
.res-table th, .res-table td { vertical-align: middle; }
.res-table tr.grp th { background: var(--side-bg); font-size: 0.78rem; color: var(--muted); font-weight: 600; }
td.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.sel td { background: var(--info-bg); }
input::placeholder { color: var(--muted); opacity: .65; }

/* 지원 체크리스트 */
.ck-list{list-style:none;margin:0;padding:0}
.ck-item{padding:8px 0;border-top:1px solid var(--line, rgba(128,128,128,.25))}
.ck-item:first-child{border-top:0}
.ck-label{display:flex;gap:10px;align-items:flex-start;cursor:pointer}
.ck-label input{margin-top:4px;flex:none}
.ck-label>span{display:flex;flex-direction:column;gap:2px}
.ck-title{font-weight:500}
.ck-item.done .ck-title{text-decoration:line-through;opacity:.6}
.ck-lead{opacity:.85}
.ck-required{background:rgba(200,60,60,.15)}
.ck-conditional{background:rgba(200,150,0,.18)}
.ck-optional{background:rgba(120,120,120,.18)}
.ck-block>summary{cursor:pointer;list-style:none}
.ck-rerun{margin:6px 0 0 18px;padding:0}
