:root {
  --bg: #f4f6fb;
  --bg-grad: radial-gradient(1200px 600px at 15% -10%, #e9efff 0%, rgba(233,239,255,0) 60%),
             radial-gradient(1000px 500px at 100% 0%, #eefbf4 0%, rgba(238,251,244,0) 55%);
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e8edf5;
  --border: #e2e7f0;
  --border-strong: #cfd7e6;
  --text: #131722;
  --text-dim: #5a6577;
  --text-mute: #8b94a6;
  --brand: #3355e6;
  --brand-2: #6b46f5;
  --brand-ink: #2440c4;
  --brand-grad: linear-gradient(135deg, #3355e6 0%, #6b46f5 100%);
  --ok: #0f9d58;
  --warn: #c07800;
  --danger: #e0362c;
  --shadow-sm: 0 1px 2px rgba(23, 33, 66, .06), 0 1px 3px rgba(23, 33, 66, .05);
  --shadow: 0 2px 8px rgba(23, 33, 66, .06), 0 12px 30px rgba(23, 33, 66, .07);
  --shadow-lg: 0 30px 70px rgba(15, 22, 50, .28);
  --radius: 16px;
  --radius-sm: 11px;
  /* 지원 판정 밴드 색 */
  --band-안정: #0f9d58;
  --band-적정: #2f6bff;
  --band-소신: #d9910a;
  --band-도전: #e0453b;
  --band-어려움: #97a1b3;
  --band-안정-bg: #e7f6ee;
  --band-적정-bg: #e8effe;
  --band-소신-bg: #fbf1dc;
  --band-도전-bg: #fce9e7;
  --band-어려움-bg: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d13;
    --bg-grad: radial-gradient(1200px 600px at 12% -10%, #16204a 0%, rgba(22,32,74,0) 60%),
               radial-gradient(1000px 500px at 100% 0%, #0e2c22 0%, rgba(14,44,34,0) 55%);
    --surface: #151924;
    --surface-2: #1b2130;
    --surface-3: #232b3d;
    --border: #28303f;
    --border-strong: #38424f;
    --text: #eceff6;
    --text-dim: #9aa4b6;
    --text-mute: #6b7488;
    --brand: #6d8bff;
    --brand-2: #a58bff;
    --brand-ink: #a9bcff;
    --ok: #34c77b;
    --warn: #e0a13a;
    --danger: #ff6b60;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 2px 10px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.4);
    --shadow-lg: 0 30px 80px rgba(0,0,0,.6);
    --band-안정-bg: #10281c;
    --band-적정-bg: #131f3d;
    --band-소신-bg: #2c2410;
    --band-도전-bg: #2f1614;
    --band-어려움-bg: #1c2230;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.55;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: color-mix(in srgb, var(--brand) 28%, transparent); }

/* ── App bar ── */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.appbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 13px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  font-size: 22px; width: 44px; height: 44px; flex: none;
  display: grid; place-items: center; border-radius: 13px;
  background: var(--brand-grad); box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 40%, transparent);
}
.brand h1 { font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.brand-text { display: flex; flex-direction: column; }
.brand .wordmark { font-size: 22px; font-weight: 850; letter-spacing: -.045em; line-height: 1.1; }
.brand .wordmark .accent {
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.by-badge {
  align-self: center; font-size: 10.5px; font-weight: 800; color: var(--text-mute);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 9px; white-space: nowrap; letter-spacing: 0;
}
.brand-sub { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.foot-brand { font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.foot-brand strong { color: var(--text); }
.appbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.status-chip {
  font-size: 11.5px; color: var(--text-dim); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; white-space: nowrap; font-weight: 500;
}
.status-chip b { color: var(--text); font-weight: 700; }
.status-chip.live { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.status-chip.live b { color: var(--ok); }

/* ── Buttons ── */
.btn {
  font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); border-radius: var(--radius-sm); padding: 9px 15px;
  display: inline-flex; align-items: center; gap: 7px; transition: transform .12s, background .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand-grad); border: none; color: #fff; box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 38%, transparent); }
.btn-primary:hover { filter: brightness(1.05); background: var(--brand-grad); }
.btn-lg { padding: 13px 24px; font-size: 15px; }
.btn-ico { font-size: 15px; }
.btn[disabled] { opacity: .65; cursor: progress; }
.btn.spin .btn-ico { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tabs ── */
.tabs {
  max-width: 1160px; margin: 0 auto; padding: 16px 22px 0;
  display: flex; gap: 4px;
}
.tab {
  font: inherit; font-weight: 700; font-size: 14.5px; cursor: pointer;
  border: none; background: transparent; color: var(--text-dim);
  padding: 10px 17px; border-radius: 11px 11px 0 0; border-bottom: 2.5px solid transparent;
  transition: .15s;
}
.tab:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); background: color-mix(in srgb, var(--surface) 70%, transparent); }

/* ── Layout ── */
.container { max-width: 1160px; margin: 0 auto; padding: 22px; }
.tab-panel { display: none; animation: fade .3s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow);
}
.panel-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.panel-desc { color: var(--text-dim); font-size: 13.5px; margin-top: 6px; }

/* ── Hero (성적 매칭) ── */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(600px 240px at 90% -30%, color-mix(in srgb, var(--brand-2) 16%, transparent), transparent 70%);
}
.hero-head { position: relative; max-width: 640px; }
.hero-eyebrow {
  display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: .02em;
  color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  padding: 4px 11px; border-radius: 999px; margin-bottom: 12px;
}
.hero-title { font-size: 25px; font-weight: 850; letter-spacing: -.035em; line-height: 1.25; }
.hero-desc { color: var(--text-dim); font-size: 14px; margin-top: 9px; }
.hero-desc strong { color: var(--text); }

/* ── Match form ── */
.match-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 13px; margin-top: 20px; align-items: end;
  position: relative;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--text-dim); }
.field input, .field select {
  font: inherit; padding: 11px 13px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); transition: .15s;
}
.field input::placeholder { color: var(--text-mute); }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); background: var(--surface);
}
.field-check { justify-content: center; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-dim); cursor: pointer; font-weight: 600; user-select: none; }
.check input { accent-color: var(--brand); width: 15px; height: 15px; }
.field-submit { grid-column: 1 / -1; }
.field-submit .btn { width: 100%; justify-content: center; }

/* ── Band legend ── */
.band-legend {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px;
  padding-top: 16px; border-top: 1px dashed var(--border);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); font-weight: 600; }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.legend-item b { color: var(--text); font-weight: 800; }

/* ── Match result ── */
.match-result { margin-top: 24px; }
.result-summary {
  padding: 18px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 20px;
}
.summary-top { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.avg-badge { font-size: 14px; font-weight: 700; color: var(--text-dim); }
.avg-badge b { font-size: 30px; color: var(--brand-ink); font-weight: 850; letter-spacing: -.03em; display: inline-block; margin-left: 4px; }
.band-counts { display: flex; gap: 7px; flex-wrap: wrap; margin-left: auto; }
.band-pill { font-size: 12.5px; font-weight: 800; padding: 5px 12px; border-radius: 999px; color: #fff; }
/* 분포 막대 */
.dist-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; margin-top: 15px; background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }
.dist-seg { height: 100%; transition: width .5s ease; min-width: 0; }
.disclaimer { font-size: 12px; color: var(--text-mute); margin-top: 13px; line-height: 1.5; }

.result-school {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 13px; background: var(--surface); box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--edge, var(--border));
}
.result-school-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.result-school-head .rk { font-size: 11.5px; color: var(--text-mute); font-weight: 800; }
.result-school-head h3 { font-size: 16.5px; font-weight: 800; letter-spacing: -.02em; }
.dept-list { display: flex; flex-wrap: wrap; gap: 8px; }
.dept-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px;
  border: 1px solid var(--chip-border, var(--border)); border-radius: 10px; padding: 6px 11px;
  background: var(--chip-bg, var(--surface-2));
}
.dept-chip .band-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dept-chip .dept-name { font-weight: 600; color: var(--text); }
.dept-chip .pct { font-weight: 850; color: var(--text); font-variant-numeric: tabular-nums; }
.dept-chip .band-name { font-weight: 800; font-size: 11.5px; }

/* ── Toolbar / filters ── */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.filters { display: flex; gap: 5px; background: var(--surface); padding: 4px; border-radius: 999px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.chip {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; color: var(--text-dim);
  background: transparent; border: none; border-radius: 999px; padding: 7px 15px; transition: .15s;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 32%, transparent); }
.search {
  font: inherit; padding: 10px 15px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); margin-left: auto; min-width: 190px; box-shadow: var(--shadow-sm);
}
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

/* ── Univ cards ── */
.univ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 15px; }
.univ-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .16s, box-shadow .16s, border-color .16s;
  position: relative; overflow: hidden;
}
.univ-card::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--edge, transparent); }
.univ-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.univ-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rank-badge {
  font-size: 12.5px; font-weight: 850; color: #fff; background: var(--brand-grad);
  border-radius: 9px; padding: 3px 10px; min-width: 30px; text-align: center; letter-spacing: -.02em;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--brand) 30%, transparent);
}
.rank-badge.medal { background: linear-gradient(135deg, #f5b301, #e88a00); box-shadow: 0 3px 8px rgba(232,138,0,.35); }
.univ-name { font-size: 17px; font-weight: 800; letter-spacing: -.025em; margin-top: 10px; }
.univ-meta { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.univ-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.tag { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); }
.tag.on { color: var(--ok); background: var(--band-안정-bg); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.tag.off { color: var(--text-mute); }
.tag.jeongsi { color: var(--brand-ink); background: color-mix(in srgb, var(--brand) 10%, transparent); border-color: color-mix(in srgb, var(--brand) 28%, var(--border)); }
.univ-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-mute); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--danger); } .dot.none { background: var(--band-어려움); }
.confidence { font-size: 11px; font-weight: 600; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(9, 13, 26, .58); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; max-width: 740px; width: 100%; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); padding: 28px; animation: pop .22s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-close { position: absolute; top: 16px; right: 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 14px; transition: .15s; }
.modal-close:hover { background: var(--surface-3); }
.m-head h2 { font-size: 23px; font-weight: 850; letter-spacing: -.03em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.m-links { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.m-links a { font-size: 13px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 7px 12px; transition: .15s; }
.m-links a:hover { background: var(--surface-3); text-decoration: none; }
.m-section { margin-top: 24px; }
.m-section h3 { font-size: 14px; font-weight: 800; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border); display: flex; align-items: center; gap: 8px; color: var(--text); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--text-dim); font-weight: 700; }
.kv dd { margin: 0; line-height: 1.5; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 9px 11px; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--text-dim); font-size: 11.5px; font-weight: 800; background: var(--surface-2); position: sticky; top: 0; }
.tbl tbody tr:hover, .tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.num { font-weight: 850; text-align: right; font-variant-numeric: tabular-nums; }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; }
.notice { font-size: 12.5px; color: var(--warn); background: var(--band-소신-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 10px; padding: 9px 12px; margin-top: 12px; }

/* ── Change log ── */
.change-log { margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.log-item { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 13.5px; box-shadow: var(--shadow-sm); }
.log-badge { font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px; color: #fff; white-space: nowrap; }
.log-badge.changed { background: var(--danger); }
.log-badge.baseline { background: var(--band-어려움); }
.log-time { color: var(--text-mute); font-size: 12px; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-name { font-weight: 800; }

/* ── Misc ── */
.empty { text-align: center; color: var(--text-dim); padding: 46px 20px; font-size: 14px; }
.foot { max-width: 1160px; margin: 14px auto 44px; padding: 0 22px; color: var(--text-mute); font-size: 12px; text-align: center; line-height: 1.6; }
.foot strong { color: var(--text-dim); }
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 13px 22px; border-radius: 13px;
  font-size: 13.5px; font-weight: 700; box-shadow: var(--shadow-lg); z-index: 60; max-width: 90vw;
  animation: pop .2s ease;
}
.toast[hidden] { display: none; }
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border-strong); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }

@media (max-width: 640px) {
  .brand h1 { font-size: 17px; }
  .appbar-actions { width: 100%; justify-content: space-between; }
  .hero-title { font-size: 21px; }
  .kv { grid-template-columns: 82px 1fr; }
  .band-counts { margin-left: 0; }
  .search { min-width: 100%; margin-left: 0; }
}
