:root {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-sub: #f8fbff;
  --ink: #0f172a;
  --ink-muted: #5b6b82;
  --line: #d6e3f0;
  --accent: #0ea5e9;
  --accent-dark: #0284c7;
  --pink: #ec4899;
  --pink-dark: #be185d;
  --danger: #e11d48;
  --gold: #d97706;
  --radius: 4px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  line-height: 1.5;
  padding-bottom: 112px;
  min-height: 100vh;
}

.bg-blueprint {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(14, 165, 233, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(14, 165, 233, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
}

.hidden { display: none !important; }

/* 헤더 */
.site-header {
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  padding: 26px 16px 22px;
}
.header-inner { max-width: 1060px; margin: 0 auto; }
.brand-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent-dark);
  background: #e0f2fe;
  padding: 3px 9px;
  border-left: 3px solid var(--accent);
  margin-bottom: 8px;
}
.site-title { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.site-desc { margin-top: 6px; font-size: 14px; color: var(--ink-muted); }

/* 메인 */
.container { max-width: 1060px; margin: 22px auto 0; padding: 0 16px; }
.error-banner {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-left: 4px solid var(--danger);
  color: #9f1239;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* 툴바 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.search-box { position: relative; flex: 1 1 260px; }
.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-sub);
  color: var(--ink);
  outline: none;
}
.search-box input:focus { border-color: var(--accent); background: #fff; }
.icon-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--ink-muted); font-size: 18px; cursor: pointer;
}
.toolbar-actions { display: flex; gap: 8px; align-items: center; }
select {
  height: 40px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; font-family: inherit; font-size: 13px;
}

.btn-primary, .btn-outline {
  height: 40px; padding: 0 15px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; border: 1px solid var(--accent-dark); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-primary:disabled { background: #cbd5e1; border-color: #cbd5e1; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent-dark); }

/* 학원 필터 */
.filter-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.filter-chip {
  padding: 6px 11px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-sub); color: var(--ink-muted); cursor: pointer;
}
.filter-chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 학생 그리드 */
.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 12px;
}
.student-card {
  position: relative; display: flex; flex-direction: column;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: #fff; overflow: hidden; cursor: pointer; text-align: left;
  padding: 0; font-family: inherit; transition: transform 0.12s, border-color 0.12s;
}
.student-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.student-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25); }
.avatar-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; background: #e2e8f0; overflow: hidden; }
.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-fallback {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; font-weight: 800;
}
.avatar-fallback .fb-char { font-size: 28px; line-height: 1; }
.avatar-fallback .fb-school { font-size: 10px; opacity: 0.9; margin-top: 6px; }
.select-badge {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 3px;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
  display: none; align-items: center; justify-content: center;
}
.student-card.selected .select-badge { display: flex; }
.card-info { padding: 8px 9px; }
.card-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 11px; color: var(--ink-muted); margin-top: 2px; display: flex; justify-content: space-between; }
.empty-msg { text-align: center; color: var(--ink-muted); padding: 40px 0; font-size: 14px; }

/* 하단 고정 바 + 중앙 확장 프로그레스 바 */
.sticky-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 16px; z-index: 50;
}
.sticky-inner { max-width: 1060px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.sticky-status { flex: 1; }
.sticky-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 13px; gap: 8px; }
.sticky-count strong { color: var(--accent-dark); font-size: 15px; }
.sticky-hint { font-size: 12px; color: var(--ink-muted); }
.progress-track {
  width: 100%; height: 10px; background: #e2e8f0; border-radius: 999px;
  overflow: hidden; display: flex; justify-content: center;
}
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #f472b6 0%, #38bdf8 100%);
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.btn-analyze { min-width: 128px; height: 44px; font-size: 14px; }

/* 결과 화면 */
.result-actions-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.result-export-btns { display: flex; gap: 8px; flex-wrap: wrap; }

.audit-card {
  background: var(--surface); border: 1.5px solid var(--line);
  border-top: 5px solid var(--accent); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
}
.audit-card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding-bottom: 16px; border-bottom: 1px dashed var(--line);
}
.doc-code { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; color: var(--accent-dark); }
.doc-subtitle { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.audit-stamp {
  border: 2.5px solid var(--danger); color: var(--danger);
  font-size: 14px; font-weight: 900; padding: 5px 12px; letter-spacing: 0.08em;
  transform: rotate(-6deg); border-radius: 3px; background: rgba(225, 29, 72, 0.04); white-space: nowrap;
}
.title-block { margin: 18px 0 16px; }
.override-badge {
  display: inline-block; font-size: 11px; font-weight: 800; color: #fff;
  background: linear-gradient(90deg, #ec4899, #0ea5e9); padding: 2px 8px;
  border-radius: 2px; margin-bottom: 6px; letter-spacing: 0.08em;
}
.res-main-title { font-size: 26px; font-weight: 900; letter-spacing: -0.02em; }

/* 선택 학생 스트립 */
.selected-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.strip-item { width: 58px; text-align: center; position: relative; }
.strip-avatar { width: 58px; height: 58px; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.strip-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip-rank {
  position: absolute; top: 2px; left: 2px; background: rgba(15, 23, 42, 0.85); color: #fff;
  font-size: 10px; font-weight: 800; padding: 1px 4px; border-radius: 2px;
}
.strip-name { font-size: 11px; font-weight: 600; color: var(--ink-muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 핵심 요약 4칸 */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-box { background: var(--surface-sub); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat-label { display: block; font-size: 11px; font-weight: 700; color: var(--ink-muted); }
.stat-value { display: block; font-size: 16px; font-weight: 800; margin-top: 4px; }

/* 발키리 교차 경보 배너 */
.valkyrie-alert {
  padding: 13px 16px; border-radius: var(--radius); margin-bottom: 16px;
  font-size: 13px; border: 1px solid transparent;
}
.valkyrie-alert.level-ARREST {
  background: #fff1f2; border-color: #fda4af; border-left: 5px solid var(--danger); color: #881337;
}
.valkyrie-alert.level-WATCHLIST {
  background: #fffbeb; border-color: #fcd34d; border-left: 5px solid var(--gold); color: #78350f;
}
.valkyrie-alert strong { display: block; font-size: 14px; margin-bottom: 3px; }

/* =====================================================================
   신장 & 가슴 사이즈 심화 계측 카드 (리뉴얼 디자인)
   ===================================================================== */
.physical-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.bio-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}
.bio-card.bio-bust {
  border-top-color: var(--pink);
}

.bio-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.bio-code {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-dark);
  margin-bottom: 3px;
}
.bio-code.code-pink { color: var(--pink-dark); }

.bio-tier-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}
.bio-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.metric-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 3px;
  background: #e0f2fe;
  color: #0369a1;
}
.metric-chip.chip-pink {
  background: #fce7f3;
  color: #be185d;
}

.bio-hero {
  text-align: right;
  flex-shrink: 0;
}
.bio-hero-val {
  display: block;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--accent-dark);
}
.bio-hero-val.val-pink { color: var(--pink-dark); }
.bio-hero-sub {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-top: 3px;
}

/* 호칭 한 마디 스포트라이트 배너 */
.epithet-banner {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid #bae6fd;
  border-left: 4px solid var(--accent-dark);
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}
.epithet-banner.epithet-pink {
  border-color: #fbcfe8;
  border-left-color: var(--pink-dark);
  background: linear-gradient(135deg, #fdf2f8 0%, #fce7f3 100%);
}
.epithet-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--accent-dark);
  padding: 1px 6px;
  border-radius: 2px;
  margin-bottom: 5px;
}
.epithet-tag.tag-pink { background: var(--pink-dark); }
.epithet-text {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.3;
}

/* 눈금자 포인터 게이지 */
.ruler-wrap { padding-top: 2px; }
.ruler-track {
  position: relative;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
}
.ruler-mid-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: #64748b;
  z-index: 1;
}
.ruler-mid-mark.mark-pink { background: #db2777; }
.ruler-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}
.ruler-fill-sky { background: linear-gradient(90deg, #7dd3fc 0%, #0284c7 100%); }
.ruler-fill-pink { background: linear-gradient(90deg, #f9a8d4 0%, #db2777 100%); }
.ruler-pointer {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3.5px solid var(--accent-dark);
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
  z-index: 2;
  transition: left 0.35s ease;
}
.ruler-pointer.pointer-pink {
  border-color: var(--pink-dark);
  box-shadow: 0 2px 6px rgba(190, 24, 93, 0.35);
}
.ruler-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-top: 6px;
}

.bio-comment {
  font-size: 13px;
  color: #334155;
  line-height: 1.5;
}

.bio-extremes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.extreme-pill {
  background: var(--surface-sub);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.extreme-pill span { color: var(--ink-muted); font-weight: 700; }
.extreme-pill strong { color: var(--ink); font-weight: 800; }

.bio-dist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  font-size: 11px;
}
.dist-chip {
  background: #f1f5f9;
  color: #334155;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
}

/* 6축 레이더 & 헤어 도넛 2단 */
.charts-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; margin-bottom: 20px; }
.chart-panel {
  background: var(--surface-sub); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
#radarCanvas { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.donut-wrap {
  display: flex; align-items: center; justify-content: center; gap: 20px;
  min-height: 260px; flex-wrap: wrap;
}
.hair-legend { display: flex; flex-direction: column; gap: 7px; min-width: 140px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }
.legend-left { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.legend-dot { width: 12px; height: 12px; border-radius: 2px; border: 1px solid rgba(15, 23, 42, 0.2); flex-shrink: 0; }
.legend-val { font-size: 12px; color: var(--ink-muted); font-weight: 700; }

/* 섹션 라벨, 태그 & 시너지 */
.section-label {
  font-size: 12px; font-weight: 800; letter-spacing: 0.04em; color: var(--accent-dark);
  margin-bottom: 10px; padding-left: 8px; border-left: 3px solid var(--accent);
}
.tags-synergy-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 20px; margin-bottom: 22px; }
.top-tags-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  font-size: 13px; font-weight: 700; padding: 6px 11px; border-radius: var(--radius);
  background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd;
}
.tag-pill span { font-size: 11px; opacity: 0.75; margin-left: 4px; }

.synergy-list { display: flex; flex-direction: column; gap: 8px; }
.synergy-card { padding: 10px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-sub); }
.synergy-card.tier-HIDDEN { background: #fffbeb; border-color: #fcd34d; border-left: 4px solid var(--gold); }
.synergy-card.tier-RARE { background: #fdf2f8; border-color: #fbcfe8; border-left: 4px solid #db2777; }
.synergy-card.tier-NORMAL { background: #f0f9ff; border-color: #bae6fd; border-left: 4px solid var(--accent); }
.synergy-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.synergy-tier { font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 2px; background: var(--ink); color: #fff; }
.tier-HIDDEN .synergy-tier { background: var(--gold); }
.tier-RARE .synergy-tier { background: #db2777; }
.tier-NORMAL .synergy-tier { background: var(--accent-dark); }
.synergy-name { font-size: 14px; font-weight: 800; }
.synergy-desc { font-size: 12px; color: var(--ink-muted); }

/* 유우카 소견서 */
.yuuka-box {
  background: #0f172a; color: #f8fafc; border-radius: var(--radius);
  padding: 20px; border-left: 4px solid #f472b6;
}
.yuuka-box-head { font-size: 12px; font-weight: 800; color: #38bdf8; letter-spacing: 0.08em; margin-bottom: 10px; }
.audit-opening { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.audit-body-list { margin: 0 0 12px 18px; font-size: 14px; color: #cbd5e1; }
.audit-body-list li { margin-bottom: 6px; }
.audit-closing { font-size: 13px; color: #f9a8d4; font-weight: 600; border-top: 1px solid rgba(255,255,255,0.12); padding-top: 10px; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(16px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 닉네임 입력 바 & 결과 대상자 배지 */
.nickname-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--surface-sub);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}

.nickname-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-dark);
  white-space: nowrap;
}

.nickname-bar input {
  flex: 1;
  max-width: 300px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  outline: none;
}

.nickname-bar input:focus {
  border-color: var(--accent);
}

.teacher-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-dark);
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  border-radius: 3px;
}

@media (max-width: 520px) {
  .nickname-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .nickname-bar input {
    max-width: 100%;
  }
}

@media (max-width: 860px) {
  .physical-grid, .charts-grid, .tags-synergy-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .audit-card { padding: 18px; }
  .res-main-title { font-size: 21px; }
}
@media (max-width: 520px) {
  .student-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .bio-extremes { grid-template-columns: 1fr; }
  .btn-analyze { min-width: 102px; padding: 0 12px; }
}
