@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;600;700;800;900&display=swap');

/* ── 리셋 & 기본 ─────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #c4597a;
  --primary-light: #e8879b;
  --primary-dark: #a3456a;
  --primary-bg: #fdf5f7;
  --primary-border: #f8bbd0;
  --gradient: linear-gradient(135deg, #e8879b 0%, #c4597a 50%, #a3456a 100%);
  --font-size-sm: 14px;
  --font-size-md: 17px;
  --font-size-lg: 22px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --shadow: 0 4px 20px rgba(196,89,122,0.1);
  --shadow-btn: 0 6px 25px rgba(196,89,122,0.3);
}

/* 다크모드 변수 */
body.dark {
  --bg: #0f0f1a;
  --bg2: #1a1a2e;
  --bg3: #16213e;
  --card-bg: #1a1a2e;
  --text: #e8e8e8;
  --text-sub: #aaa;
  --border: #2a2a4a;
  --primary-bg: #1e1028;
  --primary-border: #3a2040;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: #f5f0f0;
  color: #333;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body.dark { background: var(--bg); color: var(--text); }

/* ── 앱 컨테이너 ─────────────────────────────────────────────── */
#app {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #ede6e8;
}
body.dark #app { background: #0a0a14; }

.screen {
  width: 430px;
  min-width: 430px;
  max-width: 430px;
  min-height: 100vh;
  background: #fff;
  position: relative;
  overflow-x: hidden;
  flex-shrink: 0;
}
body.dark .screen { background: var(--bg2); }

/* 모바일: 전체 너비 */
@media (max-width: 430px) {
  .screen {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
  }
}

/* ── 로딩 ────────────────────────────────────────────────────── */
.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  flex-direction: column;
  gap: 16px;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(196,89,122,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap p { color: var(--primary); font-size: 14px; font-weight: 600; }

/* ── 헤더 그라데이션 ─────────────────────────────────────────── */
.grad-header {
  background: var(--gradient);
  padding: 44px 24px 56px;
  position: relative;
  overflow: hidden;
}
.grad-header::after {
  content: '';
  position: absolute; bottom: -1px; left: 0; right: 0;
  height: 28px; background: #fff;
  border-radius: 28px 28px 0 0;
}
body.dark .grad-header::after { background: var(--bg2); }

.grad-header::before {
  content: '';
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 60%);
  pointer-events: none;
}

/* ── 로그인 화면 ─────────────────────────────────────────────── */
.login-hero {
  text-align: center;
  padding-bottom: 8px;
}
.login-logo {
  width: 68px; height: 68px;
  background: rgba(255,255,255,0.22);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 32px;
  backdrop-filter: blur(12px);
}
.login-hero h1 { color: #fff; font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.login-hero p { color: rgba(255,255,255,0.85); font-size: 13px; }

.login-form-wrap {
  padding: 0 24px 32px;
  margin-top: -20px;
  position: relative;
}
.login-card {
  background: #fff;
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}
body.dark .login-card { background: var(--card-bg); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: #999; letter-spacing: 0.6px;
  margin-bottom: 7px; text-transform: uppercase;
}
body.dark .form-group label { color: #777; }

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #f0e0e5;
  border-radius: 12px;
  font-size: 16px; color: #333;
  background: #fdf8f9;
  font-family: 'Noto Sans KR', sans-serif;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.form-input:focus { border-color: var(--primary); background: #fff; }
body.dark .form-input {
  background: #12121f; border-color: var(--primary-border);
  color: var(--text);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--gradient);
  color: #fff; border: none; border-radius: 14px;
  font-size: 16px; font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  padding: 14px;
  background: #fff; color: var(--primary);
  border: 2px solid var(--primary-border);
  border-radius: 14px;
  font-size: 15px; font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s;
}
.btn-secondary:active { background: var(--primary-bg); }
body.dark .btn-secondary { background: var(--bg3); color: var(--primary-light); border-color: #3a2040; }

.login-footer { text-align: center; padding: 16px; font-size: 11px; color: #bbb; }

/* ── 메인 화면 ───────────────────────────────────────────────── */
.main-header { background: var(--gradient); padding: 40px 24px 52px; position: relative; overflow: hidden; }
.main-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 26px; background: #f5f0f0; border-radius: 26px 26px 0 0;
}
body.dark .main-header::after { background: var(--bg); }

.user-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; position: relative; }
.greeting { color: rgba(255,255,255,0.85); font-size: 13px; }
.greeting strong { color: #fff; font-size: 19px; font-weight: 800; display: block; margin-top: 3px; }
.icon-btn {
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; cursor: pointer;
  backdrop-filter: blur(10px);
  border: none;
}

.stats-chips { display: flex; gap: 10px; position: relative; }
.stat-chip {
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(10px);
  padding: 10px 14px; border-radius: 14px;
  color: #fff; font-size: 12px; flex: 1; text-align: center;
}
.stat-chip .chip-num { font-size: 22px; font-weight: 800; display: block; margin-bottom: 2px; }

.main-body { padding: 8px 20px 32px; background: #f5f0f0; min-height: 60vh; }
body.dark .main-body { background: var(--bg); }

.section-title { font-size: 15px; font-weight: 700; color: #444; margin: 22px 0 12px; }
body.dark .section-title { color: #ccc; }

/* 훈련 카드 */
.training-card {
  background: linear-gradient(135deg, #fce4ec, #fdf0f4);
  border: 2px solid #f48fb1;
  border-radius: 20px;
  padding: 22px 20px;
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 16px;
}
body.dark .training-card { background: linear-gradient(135deg, #2d1428, #1e1028); border-color: #5a2040; }

.training-icon { font-size: 42px; flex-shrink: 0; }
.training-info .t-name { font-size: 18px; font-weight: 700; color: #333; }
body.dark .training-info .t-name { color: #e8e8e8; }
.training-info .t-desc { font-size: 12px; color: #999; margin-top: 3px; }
.training-info .t-count {
  display: inline-block; margin-top: 8px;
  font-size: 11px; font-weight: 700; color: var(--primary);
  background: rgba(196,89,122,0.1); padding: 4px 10px; border-radius: 8px;
}

/* 설정 토글 */
.option-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--primary-bg); padding: 14px 16px;
  border-radius: 14px; margin-bottom: 10px;
}
body.dark .option-row { background: var(--bg3); }

.opt-left { flex: 1; }
.opt-label { font-size: 13px; font-weight: 600; color: #555; }
body.dark .opt-label { color: #ccc; }
.opt-desc { font-size: 11px; color: #bbb; margin-top: 2px; }

.toggle {
  width: 50px; height: 28px; background: #ddd;
  border-radius: 14px; position: relative; cursor: pointer;
  transition: background 0.25s; flex-shrink: 0;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; width: 24px; height: 24px;
  background: #fff; border-radius: 50%;
  position: absolute; top: 2px; left: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  transition: transform 0.25s;
}
.toggle.on::after { transform: translateX(22px); }

.font-ctrl { display: flex; align-items: center; gap: 8px; }
.font-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 2px solid #e8c4cf; background: #fff;
  font-size: 15px; font-weight: 700; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
}
.font-btn:active { background: var(--primary-bg); }
body.dark .font-btn { background: var(--bg3); border-color: #3a2040; color: var(--primary-light); }
.font-label { font-size: 14px; font-weight: 700; color: var(--primary); min-width: 20px; text-align: center; }

/* ── 퀴즈 헤더 ───────────────────────────────────────────────── */
.quiz-header {
  background: var(--gradient);
  padding: 18px 20px 28px; position: relative;
}
body.dark .quiz-header { background: linear-gradient(135deg, #2d1b36 0%, #4a2040 100%); }
.quiz-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 22px; background: var(--primary-bg);
  border-radius: 22px 22px 0 0;
}
body.dark .quiz-header::after { background: var(--bg3); }

.quiz-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.quiz-nav { display: flex; gap: 6px; }
.icon-btn.nav-disabled { opacity: 0.35; cursor: default; pointer-events: none; }
.quiz-counter { color: #fff; font-size: 15px; font-weight: 700; }
.quiz-badge {
  background: rgba(255,255,255,0.22); color: #fff;
  font-size: 11px; padding: 5px 12px;
  border-radius: 20px; font-weight: 600;
}

/* 퀴즈 하단 바 (진행바 + 글자크기) */
.quiz-bottom-bar {
  display: flex; align-items: center; gap: 10px;
}
.font-ctrl-mini {
  display: flex; align-items: center; gap: 5px;
  flex-shrink: 0;
}
.font-btn-mini {
  width: 28px; height: 28px;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  border-radius: 7px;
  font-size: 11px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s;
  font-family: 'Noto Sans KR', sans-serif;
}
.font-btn-mini:active { background: rgba(255,255,255,0.35); }
.font-label-mini {
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.9);
  min-width: 16px; text-align: center;
}

.progress-track {
  background: rgba(255,255,255,0.22);
  height: 8px; border-radius: 4px; overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%; background: #fff; border-radius: 4px;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* ── 문제 바디 ───────────────────────────────────────────────── */
.quiz-body {
  background: var(--primary-bg);
  padding: 18px 20px 24px;
  min-height: calc(100vh - 120px);
  position: relative;
}
body.dark .quiz-body { background: var(--bg3); }

.indicator-badge {
  display: inline-block;
  background: var(--gradient);
  color: #fff; font-size: 11px; font-weight: 700;
  padding: 5px 14px; border-radius: 20px; margin-bottom: 10px;
}
.q-label { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 8px; }

.question-card {
  background: #fff; border-radius: 20px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
body.dark .question-card { background: var(--card-bg); box-shadow: 0 4px 20px rgba(0,0,0,0.3); }

.question-text {
  font-size: var(--font-size-md);
  font-weight: 600; color: #333;
  line-height: 1.7; word-break: keep-all;
}
body.dark .question-text { color: #e8e8e8; }

.bookmark-float {
  position: fixed; top: 100px; right: 20px;
  width: 44px; height: 44px;
  background: #fff; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  cursor: pointer; z-index: 100;
  transition: transform 0.15s;
  border: none;
}
.bookmark-float:active { transform: scale(0.9); }
body.dark .bookmark-float { background: var(--card-bg); }

.swipe-hint {
  text-align: center; padding: 14px 0;
  font-size: 11px; color: #ccc;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}

/* ── 정답 섹션 ───────────────────────────────────────────────── */
.answer-block {
  border-radius: 16px; padding: 18px; margin-bottom: 12px;
  border: 1.5px solid transparent;
}
.answer-block.ans {
  background: linear-gradient(135deg, #fce4ec, #fdf0f3);
  border-color: #f8bbd0;
}
.answer-block.exp {
  background: linear-gradient(135deg, #fff8e1, #fffde7);
  border-color: #ffe082;
}
.answer-block.mat {
  background: linear-gradient(135deg, #e8eaf6, #f0f2ff);
  border-color: #c5cae9;
}

body.dark .answer-block.ans { background: linear-gradient(135deg, #2d1b25, #3a1f30); border-color: #5a2a40; }
body.dark .answer-block.exp { background: linear-gradient(135deg, #2d2a1b, #3a3520); border-color: #5a4a2a; }
body.dark .answer-block.mat { background: linear-gradient(135deg, #1b1d2d, #202538); border-color: #2a305a; }

.answer-block-title {
  font-size: 13px; font-weight: 700; margin-bottom: 8px;
  display: flex; align-items: center; gap: 5px;
}
.answer-block.ans .answer-block-title { color: var(--primary); }
.answer-block.exp .answer-block-title { color: #f9a825; }
.answer-block.mat .answer-block-title { color: #5c6bc0; }

.answer-block p {
  font-size: 14px; line-height: 1.75; color: #555; word-break: keep-all;
}
body.dark .answer-block p { color: #ccc; }

.answer-actions { display: flex; gap: 10px; margin-top: 4px; }
.bookmark-btn {
  flex: 0 0 54px; height: 54px;
  background: #fff; border: 2px solid var(--primary-border);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer; transition: all 0.15s;
}
.bookmark-btn.active { background: #fce4ec; border-color: var(--primary); }
body.dark .bookmark-btn { background: var(--bg3); border-color: #3a2040; }

/* ── 완료 화면 ───────────────────────────────────────────────── */
.complete-header {
  background: var(--gradient);
  padding: 50px 24px 70px; text-align: center; position: relative;
}
.complete-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 32px; background: #fff; border-radius: 32px 32px 0 0;
}
body.dark .complete-header::after { background: var(--bg2); }
.complete-icon {
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 40px; backdrop-filter: blur(10px);
}
.complete-header h2 { color: #fff; font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.complete-header p { color: rgba(255,255,255,0.85); font-size: 14px; }

.complete-body { padding: 10px 20px 32px; }
body.dark .complete-body { background: var(--bg2); }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--primary-bg); border-radius: 18px;
  padding: 20px 14px; text-align: center;
}
body.dark .stat-card { background: var(--bg3); }
.stat-card .si { font-size: 28px; margin-bottom: 8px; }
.stat-card .sv { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-card .sn { font-size: 12px; color: #999; margin-top: 4px; }

/* ── 관리자 ──────────────────────────────────────────────────── */
.admin-header {
  background: linear-gradient(135deg, #4a2040 0%, #6b3a5e 100%);
  padding: 28px 22px 42px; position: relative;
}
.admin-header::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 22px; background: #f8f4f6; border-radius: 22px 22px 0 0;
}
body.dark .admin-header::after { background: var(--bg); }
.admin-header h2 { color: #fff; font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.admin-header p { color: rgba(255,255,255,0.65); font-size: 12px; }

.admin-chips { display: flex; gap: 10px; margin-top: 18px; }
.admin-chip {
  flex: 1; background: rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  border-radius: 12px; padding: 12px; text-align: center; color: #fff;
}
.admin-chip .ac-val { font-size: 22px; font-weight: 800; display: block; }
.admin-chip .ac-label { font-size: 10px; opacity: 0.75; margin-top: 2px; }

.admin-body { padding: 10px 18px 28px; background: #f8f4f6; min-height: 60vh; }
body.dark .admin-body { background: var(--bg); }

.criteria-box {
  background: #fff; border-radius: 14px;
  padding: 14px 16px; margin-bottom: 18px;
  border: 1.5px solid #e8d0d8;
}
body.dark .criteria-box { background: var(--card-bg); border-color: #3a2040; }
.criteria-title { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.criteria-item {
  font-size: 11px; color: #777; line-height: 1.75;
  padding-left: 12px; position: relative; margin-bottom: 2px;
}
.criteria-item::before { content: '·'; position: absolute; left: 2px; color: var(--primary); font-weight: 700; }
body.dark .criteria-item { color: #aaa; }

.admin-section-title {
  font-size: 14px; font-weight: 700; color: #4a2040; margin: 4px 0 12px;
}
body.dark .admin-section-title { color: #c08090; }

.emp-card {
  background: #fff; border-radius: 16px;
  padding: 16px; margin-bottom: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}
body.dark .emp-card { background: var(--card-bg); }
.emp-card.inactive { opacity: 0.6; }

.emp-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.emp-info { display: flex; align-items: center; gap: 10px; }
.emp-avatar {
  width: 38px; height: 38px;
  background: var(--gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.emp-avatar.gray { background: #ddd; color: #999; }
.emp-name { font-size: 14px; font-weight: 700; color: #333; }
body.dark .emp-name { color: #e8e8e8; }
.emp-date { font-size: 11px; color: #aaa; margin-top: 2px; }
.emp-date.warn { color: #e57373; }
.emp-sessions { font-size: 12px; color: var(--primary); font-weight: 700; background: #fdf0f3; padding: 4px 10px; border-radius: 8px; }
body.dark .emp-sessions { background: #2d1020; }
.emp-sessions.zero { background: #f5f5f5; color: #999; }

.emp-bar { height: 8px; background: #f0e6ea; border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
body.dark .emp-bar { background: #2a1a20; }
.emp-fill { height: 100%; background: var(--gradient); border-radius: 4px; transition: width 0.6s ease; }

.emp-bottom { display: flex; justify-content: space-between; font-size: 11px; color: #aaa; }
.emp-pct { color: var(--primary); font-weight: 700; }
.emp-detail { font-size: 10px; color: #bbb; margin-top: 5px; padding-top: 6px; border-top: 1px solid #f5f0f2; }
body.dark .emp-detail { border-color: #2a2a3a; }

/* ── 에러 메시지 ─────────────────────────────────────────────── */
.error-msg {
  background: #fce4ec; color: #c4597a;
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 600; margin-bottom: 14px;
  border: 1.5px solid #f8bbd0;
  display: none;
}
.error-msg.show { display: block; }

/* ── 스와이프 컨테이너 ────────────────────────────────────────── */
.swipe-wrapper {
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
}

/* ── 토스트 알림 ─────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: rgba(50,50,70,0.92); color: #fff;
  padding: 12px 22px; border-radius: 30px;
  font-size: 14px; font-weight: 600;
  z-index: 9999; transition: transform 0.3s ease;
  white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── 관리자 로그인 모달 ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: #fff; border-radius: 24px 24px 0 0;
  padding: 28px 24px 40px; width: 100%; max-width: 480px;
  transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.25,0.8,0.25,1);
}
body.dark .modal-sheet { background: var(--bg2); }
.modal-overlay.show .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px; background: #e0e0e0;
  border-radius: 2px; margin: 0 auto 20px;
}
.modal-title { font-size: 18px; font-weight: 800; color: #333; margin-bottom: 20px; text-align: center; }
body.dark .modal-title { color: #e8e8e8; }

/* ── 구분선 ──────────────────────────────────────────────────── */
.divider { height: 1px; background: #f0e8ea; margin: 8px 0; }
body.dark .divider { background: #2a2a3a; }

/* ── 스크롤바 숨김 ───────────────────────────────────────────── */
::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

/* ── 반응형 ──────────────────────────────────────────────────── */
@media (min-width: 431px) {
  .screen { box-shadow: 0 0 60px rgba(0,0,0,0.14); }
}
