/* 인재원 디자인 시스템 v0 — 학생 앱/관리자 공용
   (학습 화면에서 확정된 디자인을 토큰화. Flutter 앱 테마의 기준이 된다) */
:root {
  --bg: #f7f5ff;
  --card: #ffffff;
  --ink: #2a2740;
  --muted: #8b8aa3;
  --primary: #6d5ef2;
  --primary-soft: #edeafe;
  --good: #10b981;
  --good-soft: #e7f9f2;
  --bad: #f43f5e;
  --bad-soft: #fee8ec;
  --warn: #f59e0b;
  --warn-soft: #fff7e8;
  /* 진한 계열 — 얇은 컬러 글자는 크로마 서브샘플링 모니터에서 번져 보여서,
     작은 글자·숫자에는 아래 진한 색을 쓴다(연한 색 배경 칩 + 진한 글자 조합) */
  --ink-2: #5b5875;
  --primary-deep: #5445d8;
  --good-deep: #0b7a55;
  --bad-deep: #c31e45;
  --warn-deep: #b45309;
  --radius: 20px;
  /* 중립색도 강조색을 살짝 머금는다 — 기본은 보랏빛 회색.
     수학 관리자(body[data-subject="math"])처럼 강조색이 다른 화면은 이 토큰만 갈아끼우면 된다.
     예전엔 아래 값들이 hex로 박혀 있어 초록 화면에도 보라 잔재가 남았다 (2026-08-27 사용자 제보) */
  --surf-1: #faf9ff;            /* 아주 연한 면 — 표 줄 hover·연한 카드 */
  --primary-lite: #8f7ff7;      /* 진행바·막대 그라데이션의 밝은 쪽 */
  --shadow-rgb: 80, 70, 160;    /* 카드·띠 그림자 색조 */
  --btn-shadow-rgb: 109, 94, 242; /* 버튼 글로우 색조 */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  /* Pretendard Variable = /fonts/pretendard.css 로 직접 서빙(동적 서브셋).
     예전엔 "Pretendard"만 적어 두고 실제로 불러오지 않아, 사실상 맑은 고딕으로
     그려지면서 저PPI 모니터에서 글자가 자글자글하게 보였다. */
  font-family: "Pretendard Variable", "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, #e9e4ff 0%, transparent 60%),
    radial-gradient(900px 400px at -10% 110%, #ffeef5 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  min-height: 100%;
}

header { width: 100%; max-width: 640px; padding: 20px 20px 8px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 20px; letter-spacing: -0.4px; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 9px; }
.brand img { height: 30px; width: auto; display: block; }
.brand .key { color: var(--primary); }
.brand .sub { font-size: 13px; font-weight: 700; color: var(--muted); }
.spacer { flex: 1; }
main { width: 100%; max-width: 640px; padding: 16px 20px 110px; }
footer { padding: 14px; font-size: 11.5px; color: #a5a3bd; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(var(--shadow-rgb), .12);
  padding: 28px;
  animation: rise .4s cubic-bezier(.22,1,.36,1);
}
.card + .card { margin-top: 16px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }

.section-title { font-size: 15px; font-weight: 800; margin-bottom: 14px; display: flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin-top: 10px; }

.btn {
  border: 0; cursor: pointer;
  background: var(--primary); color: #fff;
  font-family: inherit; font-size: 16px; font-weight: 800;
  padding: 15px 34px; border-radius: 999px;
  box-shadow: 0 8px 20px rgba(var(--btn-shadow-rgb), .35);
  transition: transform .15s;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-align: center;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn.ghost { background: #f1effc; color: var(--primary); box-shadow: none; }
.btn.sm { font-size: 13.5px; padding: 10px 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { font-size: 12.5px; font-weight: 700; color: #5a5680; background: #f1effc; border-radius: 999px; padding: 7px 13px; display: inline-flex; align-items: center; gap: 6px; }
.chip.hot { color: var(--bad-deep); background: var(--bad-soft); }

/* 아이콘 (icons.js — Feather/Lucide 스타일) */
.ic { width: 1.05em; height: 1.05em; vertical-align: -0.18em; flex: none; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
.section-title [data-icon] { color: var(--primary); }
.section-title .ic { width: 17px; height: 17px; }

.stats { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.stat { background: #f6f4fe; border-radius: 16px; padding: 16px 20px; min-width: 110px; text-align: center; flex: 1; }
.stat b { display: block; font-size: 24px; font-weight: 800; color: var(--primary-deep); }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }

.progress-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.progress { height: 10px; background: #e9e6f7; border-radius: 999px; overflow: hidden; }
.progress > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--primary-lite), var(--primary));
  border-radius: 999px; transition: width .5s cubic-bezier(.22,1,.36,1);
}

.weak-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.weak-word { width: 150px; text-align: left; font-size: 14.5px; font-weight: 700; }
.weak-word small { color: var(--ink-2); font-weight: 600; }
.weak-bar { flex: 1; height: 10px; background: #f0eef9; border-radius: 999px; overflow: hidden; }
.weak-bar > div { height: 100%; background: linear-gradient(90deg, #fda4af, var(--bad)); border-radius: 999px; }
.weak-pct { width: 42px; font-size: 13px; font-weight: 800; color: var(--bad-deep); text-align: right; }

/* 하단 네비게이션 — 모바일 앱 형태 (Flutter 이식 기준) */
.bottom-nav {
  position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 420px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
  border-radius: 999px; box-shadow: 0 10px 34px rgba(var(--shadow-rgb), .22);
  display: flex; padding: 8px; z-index: 50;
}
.bottom-nav a {
  flex: 1; text-align: center; text-decoration: none;
  color: var(--muted); font-size: 12px; font-weight: 700;
  padding: 8px 0; border-radius: 999px; transition: all .2s;
}
.bottom-nav a .ico { display: flex; justify-content: center; margin-bottom: 3px; }
.bottom-nav a .ico .ic { width: 20px; height: 20px; }
.bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
/* 스크롤 반응 (사용자 요청): 내리면 라벨을 접어 작아지고, 더 내리면 숨어 화면을 넓게 쓴다.
   위로 올리거나 맨 위/맨 아래면 원래 크기로 복귀 — ijw-nav.js가 클래스를 붙인다 */
.bottom-nav { transition: transform .25s cubic-bezier(.22,1,.36,1), padding .2s, opacity .2s; }
.bottom-nav.nav-compact { padding: 5px; }
.bottom-nav.nav-compact a { padding: 7px 0; font-size: 0; }
.bottom-nav.nav-compact a .ico { margin-bottom: 0; }
.bottom-nav.nav-hidden { transform: translateX(-50%) translateY(140%); opacity: 0; pointer-events: none; }
/* 헤더도 함께: 내리면 살짝 압축해 문제 영역을 넓게 */
header { transition: padding .2s; }
body.scrolled header { padding-top: 10px; padding-bottom: 4px; }

/* 표 (관리자) */
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th { font-size: 12px; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 2px solid #eeecf9; white-space: nowrap; }
table.grid td { padding: 10px; border-bottom: 1px solid #f3f1fb; font-weight: 600; }
table.grid tr:hover td { background: var(--surf-1); }

/* 입력 */
.field {
  width: 100%; font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.6;
  color: var(--ink); background: #f4f2fd;
  border: 2px solid transparent; border-radius: 14px; padding: 12px 14px;
  outline: none; transition: all .2s;
}
.field:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
textarea.field { resize: vertical; min-height: 120px; }

.pill { font-size: 11.5px; font-weight: 800; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pill.good { color: var(--good-deep); background: var(--good-soft); }
.pill.bad { color: var(--bad-deep); background: var(--bad-soft); }
.pill.warn { color: var(--warn-deep); background: var(--warn-soft); }

/* 모달 */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(42, 39, 64, .45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(40, 35, 90, .35);
  width: 100%; max-width: 560px; max-height: 86vh;
  display: flex; flex-direction: column; animation: pop .25s;
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 20px 22px 14px; border-bottom: 1px solid #f0eef9; }
.modal-title { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.modal-title [data-icon] { color: var(--primary); }
.modal-close {
  margin-left: auto; border: 0; cursor: pointer;
  background: #f1effc; color: #5a5680; border-radius: 999px;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 18px 22px 22px; overflow-y: auto; }
.mini-btn {
  border: 0; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 700;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 999px; padding: 6px 10px;
  display: inline-flex; align-items: center; gap: 4px;
}
.mini-btn.danger { color: var(--bad); background: var(--bad-soft); }
.mini-btn.save { color: #fff; background: var(--good); }

/* ── 사용자 페이지 전용(body.user) 웹 톤 조정 — 관리자 페이지는 이 블록의 영향을 받지 않음 ── */
body.user .card {
  border-radius: 16px;
  box-shadow: 0 5px 18px rgba(var(--shadow-rgb), .08);
}
body.user .btn { box-shadow: 0 4px 12px rgba(var(--btn-shadow-rgb), .22); }
@media (min-width: 900px) {
  body.user .card { padding: 24px 26px; }
  body.user .btn { font-size: 15px; padding: 12px 26px; }
  body.user .stat { padding: 12px 14px; min-width: 90px; }
  body.user .stat b { font-size: 21px; }
  body.user .stat span { font-size: 11.5px; }
}

/* ── 데스크톱(웹) 반응형 — 파일 끝에 두어 위 기본 규칙을 확실히 덮는다 ── */
.head-nav { display: none; }
@media (min-width: 900px) {
  .head-nav { display: flex; gap: 4px; margin-left: 14px; }
  .head-nav a {
    text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 700;
    padding: 8px 16px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
    transition: all .15s;
  }
  .head-nav a:hover, .head-nav a.active { color: var(--primary); background: var(--primary-soft); }
  .head-nav .ic { width: 16px; height: 16px; }
  .bottom-nav { display: none; }
  main { padding-bottom: 48px; }
  /* 넓은 레이아웃을 쓰는 페이지(홈·통계)만 확장 */
  body.wide header, body.wide main { max-width: 1200px; }
  body.wide header { padding: 26px 28px 10px; }
  body.wide main { padding-left: 28px; padding-right: 28px; }
}

/* 모바일: 브랜드는 로고 아이콘만 (인재원 텍스트 숨김 — 사용자 결정) */
@media (max-width: 899px) {
  .brand-txt { display: none; }
}

/* ── 순위 변동(▲▼) 표시 (2026-08-20 사용자 확정) ────────────────────────────────
   칩은 "무브먼트" 시안, 내 순위 변화 카드는 "내 순위 히어로" 시안.
   홈 랭킹 카드와 전체 랭킹 페이지가 같은 부품을 쓴다 (동작은 /rank-delta.js). */
.rk-dl { flex: none; display: inline-flex; align-items: center; gap: 1px; line-height: 1.45;
  font-size: 11.5px; font-weight: 900; border-radius: 999px; padding: 2px 7px 2px 5px;
  font-variant-numeric: tabular-nums; }
.rk-dl .ar { font-size: 9.5px; transform: translateY(-0.5px); }
.rk-dl.up { color: #fff; background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 3px 8px rgba(5, 150, 105, .28); }
/* 하락은 빨강 대신 차분한 청회색 — 학생이 보는 화면이라 좌절감을 키우지 않는다 (사용자 결정) */
.rk-dl.dn { color: #44506b; background: #e6ebf5; }
.rk-dl.same { color: #9a97b3; background: #f3f2f9; }
.rk-dl.new { color: #fff; background: linear-gradient(135deg, #8b7cf6, #6d5ef2); }
/* 순위 연출(rank-gx/rank-fx) 레이어보다 위로 — gx는 z-index 8까지 쓴다 */
.gx .rk-dl, .fxc .rk-dl { position: relative; z-index: 9; }
/* 시상대 칸에서는 왼쪽 위 모서리 (오른쪽 위는 '나' 배지 자리) */
.pod .rk-dl, .pod.gx .rk-dl, .pod.fxc .rk-dl { position: absolute; top: 7px; left: 7px; z-index: 9; }
/* 연출(gx) 시상대는 메달이 왼쪽 위 모서리로 내려와 있다 → 변동 칩은 오른쪽 위로 옮겨 겹치지 않게 */
.pod.gx .rk-dl { left: auto; right: 8px; }
.pod.gx .rk-dl + .pyou { top: 36px; } /* '나' 배지도 같은 자리라 한 칸 내린다 */

/* 내 순위 변화 카드 */
.rank-hero { position: relative; overflow: hidden; color: #fff; border-radius: 18px;
  padding: 14px 16px 12px; margin-bottom: 12px;
  background: linear-gradient(135deg, #6d5ef2 0%, #8b6ef0 55%, #b06ae8 100%);
  box-shadow: 0 12px 26px rgba(93, 73, 215, .28); }
.rank-hero::after { content: ""; position: absolute; right: -40px; top: -50px; width: 170px; height: 170px;
  border-radius: 50%; background: rgba(255, 255, 255, .10); }
.rank-hero .rh-top { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; opacity: .93; }
.rank-hero .rh-top .ic { width: 14px; height: 14px; }
.rank-hero .rh-sub { font-weight: 700; opacity: .72; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-hero .rh-main { display: flex; align-items: flex-end; gap: 9px; margin: 7px 0 2px; }
.rank-hero .rh-prev { font-size: 16px; font-weight: 800; opacity: .62;
  text-decoration: line-through; text-decoration-thickness: 2px; }
.rank-hero .rh-arrow { font-size: 14px; opacity: .7; padding-bottom: 3px; }
.rank-hero .rh-now { font-size: 38px; font-weight: 900; line-height: 1; letter-spacing: -1.6px;
  font-variant-numeric: tabular-nums; }
.rank-hero .rh-now small { font-size: 17px; font-weight: 800; margin-left: 1px; }
.rank-hero .rh-move { margin-left: auto; flex: none; display: inline-flex; align-items: center; gap: 3px;
  font-size: 15px; font-weight: 900; border-radius: 999px; padding: 5px 12px 5px 9px;
  background: rgba(255, 255, 255, .22); }
.rank-hero .rh-move.dn, .rank-hero .rh-move.same { background: rgba(20, 10, 40, .20); }
.rank-hero .rh-msg { font-size: 12.5px; font-weight: 700; opacity: .95; margin-top: 6px; }
.rank-hero .rh-foot { display: flex; align-items: center; gap: 8px; margin-top: 11px; padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .22); }
.rank-hero .rh-spark { flex: 1; min-width: 0; }
.rank-hero .rh-tag { flex: none; font-size: 11.5px; font-weight: 800; white-space: nowrap;
  border-radius: 999px; padding: 4px 10px; background: rgba(255, 255, 255, .2); }
