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

:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --primary-bg: #eff6ff;
  --accent: #10b981;
  --accent-light: #6ee7b7;
  --white: #ffffff;
  --bg: #f8fafc;
  --bg-2: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --success-light: #d1fae5;
  --error: #ef4444;
  --error-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.05);
  --shadow: 0 4px 20px rgba(15,23,42,0.07);
  --shadow-lg: 0 12px 48px rgba(15,23,42,0.09);
  --shadow-xl: 0 24px 80px rgba(15,23,42,0.11);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --transition: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --nav-h: 64px;
  --bottom-nav-h: 64px;
}

/* ── DARK MODE ── */
[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #93c5fd;
  --primary-bg: #1e3a5f;
  --accent: #34d399;
  --accent-light: #6ee7b7;
  --bg: #0f172a;
  --bg-2: #1e293b;
  --card-bg: #1e293b;
  --white: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --border-light: #1e293b;
  --success: #34d399;
  --success-light: #064e3b;
  --error: #f87171;
  --error-light: #450a0a;
  --warning: #fbbf24;
  --warning-light: #451a03;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.45);
  --shadow-xl: 0 24px 80px rgba(0,0,0,0.55);
}
[data-theme="dark"] .navbar {
  background: rgba(15,23,42,0.92);
  border-bottom-color: var(--border);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text-primary); }
[data-theme="dark"] .question-card,
[data-theme="dark"] .wrong-card,
[data-theme="dark"] .profile-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .subject-bar,
[data-theme="dark"] .cta-card,
[data-theme="dark"] .feat-card,
[data-theme="dark"] .subject-card,
[data-theme="dark"] .ranking-table,
[data-theme="dark"] .modal-box {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text-primary);
}
[data-theme="dark"] .user-dropdown-inner {
  background: #1e293b;
  border-color: var(--border);
}
[data-theme="dark"] .stats-bar { background: #1e293b; border-color: var(--border); }
[data-theme="dark"] .page-header { background: linear-gradient(135deg, #1e293b, #0f172a); }
[data-theme="dark"] .hero { background: linear-gradient(135deg, #0f172a, #1e293b); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
  background: #0f172a;
  color: var(--text-primary);
  border-color: var(--border);
}
[data-theme="dark"] .explanation-box { background: #1e293b; border-color: var(--border); }
[data-theme="dark"] .ad-placeholder { background: #1e293b; border-color: var(--border); color: var(--text-muted); }
[data-theme="dark"] .fab-feedback { background: var(--card-bg); }
[data-theme="dark"] .score-board { background: var(--bg-2); }
[data-theme="dark"] .filter-bar { background: var(--bg-2); }
[data-theme="dark"] footer { background: #1e293b; border-top-color: var(--border); }

/* ── NAV UTILS (테마/북마크 버튼) ── */
.nav-utils {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.nav-util-btn {
  height: 34px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--bg-2);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all var(--transition);
  text-decoration: none;
  padding: 0 10px;
  gap: 5px;
  font-weight: 600;
  white-space: nowrap;
}
.nav-util-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-light); }
.nav-util-btn.active { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-light); }
/* 테마 버튼은 아이콘만 (정사각형에 가깝게) */
.nav-theme-btn { width: 34px; padding: 0; font-size: 16px; }
.nav-restore-btn { gap: 5px; }

/* ── SCROLL TO TOP ── */
#scrollToTop {
  position: fixed;
  bottom: 88px;
  left: 24px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 20px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  opacity: 0;
  pointer-events: none;
  z-index: 900;
}
#scrollToTop.visible {
  opacity: 1;
  pointer-events: all;
}
#scrollToTop:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-light);
  transform: translateY(-2px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── NAVBAR ── */
.navbar {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--nav-h);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-logo {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.nav-logo span { color: var(--primary); }

/* ── 시험 선택 드롭다운 ── */
.nav-grade-dropdown { position: relative; }
.nav-grade-btn {
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
  line-height: 1;
  min-width: 42px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-grade-btn:hover { background: var(--primary-bg); color: var(--primary); border-color: var(--primary-light); }
.nav-grade-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  min-width: 240px;
  z-index: 1000;
  padding: 6px;
  flex-direction: column;
}
.nav-grade-menu.open { display: flex; }
.grade-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.grade-menu-item:hover { background: var(--primary-bg); color: var(--primary); }
.grade-menu-item.active { background: var(--primary-bg); color: var(--primary); }
.grade-menu-group { padding: 4px 0; }
.grade-menu-label {
  padding: 8px 14px 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.grade-menu-sub {
  display: block;
  padding: 8px 14px 8px 32px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.grade-menu-sub:hover { background: var(--primary-bg); color: var(--primary); }
.grade-menu-sub.active { background: var(--primary-bg); color: var(--primary); }
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: nowrap;
  overflow: hidden;
}
.nav-links a {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background: var(--primary-bg);
}
.nav-auth { display: none; }
.btn-login {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-login:hover { background: var(--primary-dark); }
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  margin-left: auto;
  z-index: 10;
  min-width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
}

/* ── USER MENU ── */
.user-menu { position: relative; }
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.user-dropdown {
  display: none;
  position: absolute;
  right: 0; top: 100%;
  padding-top: 8px; /* 시각적 여백을 margin 대신 padding으로 → hover 끊김 방지 */
  z-index: 100;
}
.user-dropdown-inner {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 8px;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown.show { display: block; }
.user-dropdown-inner a {
  display: block;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: all var(--transition);
}
.user-dropdown-inner a:hover { background: var(--bg-2); color: var(--text-primary); }

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #1a56db 50%, #0ea5e9 100%);
  color: white;
  padding: 80px 24px 72px;
}
.hero-inner { max-width: 760px; margin: 0 auto; text-align: center; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
  backdrop-filter: blur(8px);
}
.hero h1 { font-size: clamp(28px, 5vw, 48px); font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.hero h1 .highlight { color: #bfdbfe; }
.hero p { font-size: 16px; color: rgba(255,255,255,0.85); margin-bottom: 32px; line-height: 1.7; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }
.hero-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hero-chip {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary { background: white; color: var(--primary); }
.btn-primary:hover { background: #dbeafe; transform: translateY(-1px); }
.btn-outline { background: transparent; color: white; border: 2px solid rgba(255,255,255,0.5); }
.btn-outline:hover { background: rgba(255,255,255,0.1); border-color: white; }
.btn-blue { background: var(--primary); color: white; }
.btn-blue:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-lg { padding: 15px 32px; font-size: 16px; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* ── FEATURES ── */
.features-section { padding: 72px 24px; }
.container { max-width: 1200px; margin: 0 auto; }
.section-title { text-align: center; margin-bottom: 40px; }
.section-title h2 { font-size: 28px; font-weight: 800; color: var(--text-primary); margin-bottom: 8px; }
.section-title p { font-size: 15px; color: var(--text-secondary); }

/* ── FEATURES GRID ── */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.feat-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 24px 24px 20px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: all 0.22s;
}
.feat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c, var(--primary));
  border-radius: 20px 20px 0 0;
}
.feat-card:hover {
  border-color: var(--c, var(--primary));
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0,0,0,.10);
}
.feat-icon {
  width: 56px; height: 56px;
  background: color-mix(in srgb, var(--c, var(--primary)) 13%, var(--card-bg));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.feat-body { flex: 1; }
.feat-card h3 {
  font-size: 16px; font-weight: 700;
  color: var(--text-primary); margin: 0 0 6px;
}
.feat-card p {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.65; margin: 0;
}
.feat-tag {
  display: inline-flex;
  align-items: center;
  background: color-mix(in srgb, var(--c, var(--primary)) 11%, var(--card-bg));
  color: var(--c, var(--primary));
  font-size: 11px; font-weight: 700;
  padding: 4px 11px;
  border-radius: 20px;
  align-self: flex-start;
  border: 1px solid color-mix(in srgb, var(--c, var(--primary)) 28%, transparent);
}
.badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ── SUBJECTS ── */
.subjects-section { background: var(--bg-2); padding: 64px 24px; }
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.subject-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition);
}
.subject-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.subject-icon { font-size: 28px; margin-bottom: 10px; }
.subject-card h4 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.subject-card .count { font-size: 13px; color: var(--text-muted); }

/* ── CTA ── */
/* ── 응시종목 카드 ── */
.exam-select-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px 24px;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.2s;
  position: relative;
}
.exam-select-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.1);
}
.exam-select-badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
}
.exam-select-icon { font-size: 40px; margin-bottom: 12px; }
.exam-select-card h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.exam-select-card p { font-size: 13px; color: var(--text-secondary); margin-bottom: 0; }
.exam-select-stats { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

.cta-section { padding: 72px 24px; }
.cta-card {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-radius: var(--radius-lg);
  padding: 56px 40px;
  text-align: center;
  color: white;
}
.cta-card h2 { font-size: 28px; font-weight: 800; margin-bottom: 12px; }
.cta-card p { font-size: 16px; color: rgba(255,255,255,0.85); margin-bottom: 28px; }

/* ── STATS BAR ── */
.stats-bar {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
}
.stats-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 40px;
  justify-content: center;
  flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* ── PAGE HEADER ── */
.page-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 16px 24px 14px;
}
.page-header h1 { font-size: 22px; font-weight: 800; margin-bottom: 2px; }
.page-header p { font-size: 13px; color: rgba(255,255,255,0.8); margin-bottom: 0; }

/* ── FILTER BAR ── */
.filter-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
}
.filter-bar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filter-bar-inner::-webkit-scrollbar { display: none; }
.filter-bar-inner .filter-btn { flex-shrink: 0; }
.filter-btn {
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--card-bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-btn.active, .filter-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ── QUIZ AREA ── */
.quiz-area {
  max-width: 760px;
  margin: 16px auto 0;
  padding: 0 24px;
}
.question-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 12px;
}
.question-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.meta-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--primary-bg);
  color: var(--primary);
}
.meta-chip.subject { background: #ecfdf5; color: #065f46; }
.meta-chip.session { background: #fef3c7; color: #92400e; }
.question-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.options-list { display: flex; flex-direction: column; gap: 7px; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--card-bg);
}
.option-item:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.option-item.correct { border-color: var(--success); background: var(--success-light); }
.option-item.wrong { border-color: var(--error); background: var(--error-light); }
.option-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  min-width: 22px;
}
.option-text { font-size: 14px; color: var(--text-primary); line-height: 1.5; }

.explanation-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 12px;
  display: none;
}
.explanation-box.show { display: block; }
.explanation-box.wrong { background: #fff1f2; border-color: #fecdd3; }
.explanation-box h4 { font-size: 12px; font-weight: 700; color: var(--success); margin-bottom: 4px; }
.explanation-box.wrong h4 { color: var(--danger); }
.explanation-box p { font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
[data-theme="dark"] .explanation-box.wrong { background: #2d1215; border-color: #7f1d1d; }

/* ── SCORE BOARD ── */
.score-board {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.score-chip {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}
.score-chip .num { color: var(--primary); }
.score-chip .num.correct { color: var(--success); }
.score-chip .num.wrong { color: var(--error); }

/* ── ACTION BUTTONS ── */
.action-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 10px 0 20px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, #f8fafc 65%, transparent);
  z-index: 10;
}
/* 모바일에선 bottom-nav 위로 */
@media (max-width: 768px) {
  .action-btns { bottom: var(--bottom-nav-h); }
}

/* ── OX QUIZ ── */
.ox-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 24px 20px;
  text-align: center;
  margin-bottom: 12px;
}
.ox-question { font-size: 16px; font-weight: 600; line-height: 1.65; margin-bottom: 20px; color: var(--text-primary); }
.ox-btns { display: flex; gap: 16px; justify-content: center; }
.ox-btn {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: none;
  font-size: 30px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.ox-btn.o { background: #dcfce7; color: #16a34a; }
.ox-btn.x { background: #fee2e2; color: #991b1b; }
.ox-btn:hover { transform: scale(1.08); box-shadow: var(--shadow-lg); }

/* ── EXAM ── */
.exam-header {
  background: var(--primary-dark);
  color: white;
  padding: 16px 24px;
  position: sticky;
  top: var(--nav-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.exam-timer { font-size: 22px; font-weight: 800; }
.exam-timer.warning { color: #fca5a5; }
.exam-progress { font-size: 14px; color: rgba(255,255,255,0.8); }
.exam-area { max-width: 900px; margin: 32px auto; padding: 0 24px; }
.exam-question-list { display: flex; flex-direction: column; gap: 24px; }
.exam-question {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}
.exam-q-num { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.exam-q-text { font-size: 16px; font-weight: 600; line-height: 1.6; margin-bottom: 18px; }
.exam-options { display: flex; flex-direction: column; gap: 8px; }
.exam-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 14px;
}
.exam-option:hover { border-color: var(--primary-light); background: var(--primary-bg); }
.exam-option.selected { border-color: var(--primary); background: var(--primary-bg); }
.exam-option.correct { border-color: var(--success); background: var(--success-light); }
.exam-option.wrong { border-color: var(--error); background: var(--error-light); }

/* ── RESULT ── */
.result-card {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 24px;
}
.result-score-circle {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  margin: 0 auto 24px;
  box-shadow: 0 8px 32px rgba(26,86,219,0.35);
}
.result-score-circle .score-num { font-size: 36px; font-weight: 800; }
.result-score-circle .score-label { font-size: 13px; font-weight: 600; opacity: 0.85; }
.result-pass { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 24px; }
.result-pass.pass { color: var(--success); }
.result-pass.fail { color: var(--error); }
.subject-scores { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; }
.subject-score-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.subject-score-row:last-child { border-bottom: none; }
.ss-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.ss-score { font-size: 16px; font-weight: 700; }
.ss-score.pass { color: var(--success); }
.ss-score.fail { color: var(--error); }

/* ── RANKING ── */
.ranking-table { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.ranking-row {
  display: grid;
  grid-template-columns: 60px 1fr 120px 100px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.ranking-row:last-child { border-bottom: none; }
.ranking-row:hover { background: var(--bg-2); }
.ranking-row.header { background: var(--bg-2); font-size: 12px; font-weight: 700; color: var(--text-muted); }
.rank-num { font-size: 16px; font-weight: 800; color: var(--text-muted); }
.rank-num.top1 { color: #f59e0b; font-size: 20px; }
.rank-num.top2 { color: #94a3b8; }
.rank-num.top3 { color: #cd7c2b; }
.rank-nick { font-size: 15px; font-weight: 600; }
.rank-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--primary-bg); color: var(--primary); margin-left: 8px; }
.rank-solved { font-size: 14px; font-weight: 700; color: var(--primary); text-align: right; }
.rank-acc { font-size: 13px; color: var(--text-muted); text-align: right; }

/* ── WRONG NOTES ── */
.wrong-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}
.wrong-meta { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.wrong-count-chip { background: var(--error-light); color: var(--error); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill); }
.wrong-q { font-size: 15px; font-weight: 600; line-height: 1.6; margin-bottom: 14px; color: var(--text-primary); }
.wrong-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.wrong-option { display: flex; gap: 10px; font-size: 13px; color: var(--text-secondary); padding: 8px 12px; border-radius: 8px; }
.wrong-option.answer { background: var(--success-light); color: #065f46; font-weight: 600; }
.wrong-exp { background: var(--bg-2); border-radius: 8px; padding: 10px 14px; font-size: 13px; color: var(--text-secondary); line-height: 1.6; }

/* ── MYPAGE ── */
.profile-card {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.profile-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 3px solid rgba(255,255,255,0.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  flex-shrink: 0;
}
.profile-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.profile-badge-text { font-size: 14px; opacity: 0.85; margin-bottom: 8px; }
.profile-stats { display: flex; gap: 16px; }
.profile-stat { text-align: center; }
.profile-stat-num { font-size: 20px; font-weight: 800; }
.profile-stat-label { font-size: 11px; opacity: 0.75; font-weight: 600; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--primary); margin-bottom: 4px; }
.stat-card .lbl { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.subject-bar { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 24px; }
.subject-bar h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.subject-row { margin-bottom: 14px; }
.subject-row-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.subject-row-name { font-weight: 600; color: var(--text-primary); }
.subject-row-pct { font-weight: 700; color: var(--primary); }
.bar-bg { background: var(--bg-2); border-radius: var(--radius-pill); height: 8px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--primary), var(--primary-light)); height: 100%; border-radius: var(--radius-pill); transition: width 0.8s ease; }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 88px;
  left: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 8px;
}
.toast {
  background: #1e293b;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideInUp 0.3s ease;
  box-shadow: var(--shadow-lg);
  max-width: 300px;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── LOADING ── */
.loading-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ── MOBILE BOTTOM NAV ── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 1000;
}
.mobile-bottom-nav-inner {
  display: flex;
  height: 100%;
}
.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  transition: color var(--transition);
  min-width: 0;
  padding: 4px 0;
}
.mobile-nav-item .nav-icon { font-size: 20px; }
.mobile-nav-item.active, .mobile-nav-item:hover { color: var(--primary); }

/* ── FOOTER ── */
footer {
  background: #0f172a;
  color: rgba(255,255,255,0.7);
  padding: 0 0 80px;
}
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 48px 24px 0; }
.footer-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 32px; flex-wrap: wrap; padding-bottom: 32px; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 24px; }
.footer-logo { font-size: 16px; font-weight: 800; color: white; margin-bottom: 8px; }
.footer-desc { font-size: 13px; line-height: 1.6; max-width: 320px; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { color: rgba(255,255,255,0.6); text-decoration: none; font-size: 14px; font-weight: 500; transition: color var(--transition); }
.footer-links a:hover { color: white; }
.footer-bottom { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.pass-info { color: rgba(255,255,255,0.5); }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 24px; }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text-muted); }

/* ── FLOATING ACTION BUTTONS (FAB) ── */
#fabGroup {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 900;
}
.fab-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fab-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.fab-label {
  background: rgba(15,23,42,0.82);
  color: white; font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: var(--radius-pill);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.fab-item:hover .fab-label { opacity: 1; pointer-events: all; }
.fab-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  transition: var(--transition);
}
.fab-btn:hover { transform: scale(1.1); }
.fab-kakaopay { background: #FEE500; }
.fab-feedback { background: var(--card-bg); color: var(--primary); border: 2px solid var(--primary); font-size: 24px; }

/* ── 플로팅 프로필 버튼 ── */
.fab-profile-btn {
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  position: relative;
}
.fab-profile-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #fff;
  color: #333;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card-bg);
  line-height: 1;
}

/* ── 플로팅 프로필 메뉴 ── */
.fab-profile-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 180px;
  padding: 6px;
  z-index: 1001;
}
.fab-profile-menu.show { display: block; }
.fab-profile-menu a {
  display: block;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s;
}
.fab-profile-menu a:hover { background: var(--bg-2); }

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,20,40,0.65);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; padding: 16px;
}
.modal-box {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text-muted); padding: 4px;
  border-radius: 50%; transition: var(--transition);
}
.modal-close:hover { background: var(--bg-2); color: var(--text-primary); }

/* 피드백 타입 버튼 */
.feedback-type-btn {
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--card-bg); cursor: pointer;
  transition: var(--transition);
}
.feedback-type-btn.active, .feedback-type-btn:hover {
  border-color: var(--primary); background: var(--primary-bg); color: var(--primary);
}

/* 카카오페이 박스 */
.kakaopay-box {
  background: #FFFDE7;
  border: 2px solid #FEE500;
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.kakaopay-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 16px; color: #3C1E1E;
}
.kakaopay-btn {
  background: #FEE500 !important;
  color: #3C1E1E !important;
  font-weight: 800;
  font-size: 15px;
  border: none;
  padding: 13px 28px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 4px 16px rgba(254,229,0,.5);
  transition: var(--transition);
}
.kakaopay-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(254,229,0,.6); }

/* ── NICKNAME EDIT ── */
.nickname-edit-btn {
  background: none; border: none; cursor: pointer;
  font-size: 15px; padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: var(--transition);
}
.nickname-edit-btn:hover { background: var(--bg-2); color: var(--primary); }
.nickname-edit-form {
  margin-top: 8px;
  padding: 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.nickname-input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
}
.nickname-input:focus { border-color: var(--primary); }

/* ── AD LAYOUT ── */
.ad-layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  position: relative;
}
.ad-main {
  flex: 1;
  min-width: 0;
  max-width: 1200px;
}
.ad-side {
  width: 180px;
  flex-shrink: 0;
  padding-top: 32px;
}
.ad-left  { padding-left: 12px; }
.ad-right { padding-right: 12px; }

.ad-slot { display: flex; flex-direction: column; align-items: center; }
.ad-skyscraper { position: fixed; top: calc(var(--nav-h) + 16px); }
.ad-left .ad-skyscraper { left: max(12px, calc((100vw - 1200px) / 2 - 192px)); }
.ad-right .ad-skyscraper { right: max(12px, calc((100vw - 1200px) / 2 - 192px)); }

/* 광고 placeholder (실제 광고 교체 전 안내용) */
.ad-placeholder {
  width: 160px; height: 600px;
  background: var(--bg-2);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px; font-weight: 500;
}
.ad-placeholder small { font-size: 11px; opacity: .7; }
.ad-placeholder-wide {
  width: 100%; height: 90px;
  flex-direction: row; gap: 12px;
}
.ad-placeholder-sticky {
  width: 100%; height: 50px;
  flex-direction: row; gap: 12px; position: relative;
}
.ad-bottom-wrap { margin-top: 8px; }
.ad-banner { width: 100%; }

/* 하단 고정 배너 */
.ad-sticky-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 800;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}
.ad-close {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--text-muted); padding: 4px;
}
body { padding-bottom: 70px; }

/* 좌우 광고 사이드: 1200px 미만에서 숨김 */
@media (max-width: 1199px) {
  .ad-side { display: none; }
}

/* ── PERIOD TABS ── */
.period-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.period-btn {
  padding: 6px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.period-btn.active, .period-btn:hover {
  background: var(--primary); border-color: var(--primary);
  color: white;
}

/* ── SUBJECT RANKING ── */
.subject-ranking-block {
  margin-bottom: 28px;
}
.subject-ranking-title {
  font-size: 15px; font-weight: 700;
  color: var(--primary);
  padding: 10px 0 10px;
  border-bottom: 2px solid var(--primary-light);
  margin-bottom: 0;
}

/* ── ADMIN BADGE ── */
.admin-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-pill);
  margin-left: 6px;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .nav-hamburger { display: flex; margin-left: auto; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px;
    gap: 4px;
    box-shadow: var(--shadow);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 16px; }
  .nav-auth { display: none; }
  .nav-utils { display: none; }
  .mobile-bottom-nav { display: flex; }
  body { padding-bottom: var(--bottom-nav-h); }
  #scrollToTop { bottom: calc(var(--bottom-nav-h) + 16px); left: 12px; }
  #fabGroup { bottom: calc(var(--bottom-nav-h) + 12px); }
  .toast-container { bottom: calc(var(--bottom-nav-h) + 16px); left: 12px; }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-stats { justify-content: center; }
  .ranking-row { grid-template-columns: 50px 1fr 90px; }
  .rank-acc { display: none; }
  footer { padding-bottom: calc(var(--bottom-nav-h) + 24px); }
}
@media (max-width: 640px) {
  .feat-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .hero { padding: 56px 16px 52px; }
  .quiz-area, .exam-area, .result-card { padding: 0 16px; }
  .question-card, .exam-question, .wrong-card { padding: 20px 16px; }
}


/* ── 관리자 계정 광고 숨김 ─────────────────────────────────────
   body.is-admin 클래스가 붙으면 .ad-banner, .ad-item 모두 숨김.
   새 광고 슬롯 추가 시 class="ad-banner" 만 붙이면 자동 적용됨. */
body.is-admin .ad-banner,
body.is-admin .ad-item { display: none !important; }

/* ── 코드 블록 (VBA/SQL) ──────────────────────────────────────── */
pre.code-block {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px 16px;
  border-radius: 8px;
  font-family: 'Consolas', 'D2Coding', 'Nanum Gothic Coding', monospace;
  font-size: 0.82em;
  line-height: 1.7;
  overflow-x: auto;
  margin: 10px 0 4px;
  white-space: pre;
  word-break: normal;
  border: 1px solid #313244;
}
