/* ========================================
   GWATOP - Global Styles v1.0.0
   ======================================== */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.min.css');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;700;800&family=Space+Grotesk:wght@500;700&display=swap');

/* ─── CSS Variables ─── */
:root {
  --bg-primary: #f0f3fb;
  --bg-secondary: #f8f9ff;
  --bg-tertiary: #ffffff;

  --glass-bg: rgba(255, 255, 255, 0.70);
  --glass-bg-hover: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-hover: rgba(0, 0, 0, 0.16);
  --pill-bg: rgba(100, 116, 139, 0.09);

  --surface: #f0f3fb;
  --surface-container: #ffffff;
  --surface-container-high: #f4f7ff;
  --surface-container-highest: #edf0fb;

  --accent: #2563eb;
  --accent-2: #6366f1;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  --accent-glow: 0 0 40px rgba(37, 99, 235, 0.2);

  --text-primary: #0d0d0d;
  --text-secondary: #374151;
  --text-muted: #6b7280;

  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.08);
  --error: #dc2626;
  --error-bg: rgba(220, 38, 38, 0.08);

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --shadow-glass: 0 1px 0 rgba(255,255,255,0.9) inset, 0 4px 20px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 20px 56px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-headline: 'Plus Jakarta Sans', var(--font);
  --font-label: 'Space Grotesk', var(--font);
  --nav-height: 68px;
}

/* ─── Icons (Lucide) ─── */
svg { vertical-align: middle; }
.icon svg, svg.icon { display: inline-block; vertical-align: -0.125em; flex-shrink: 0; }
.mbn-icon svg { font-size: 22px; }
.modal-icon svg { font-size: 48px; }

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
::selection { background: rgba(37,99,235,0.18); color: var(--text-primary); }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background ─── */
.bg-gradient {
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 65% 40% at 50% -5%, rgba(37,99,235,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 0% 60%, rgba(79,112,247,0.04) 0%, transparent 55%),
    radial-gradient(ellipse 35% 35% at 100% 70%, rgba(99,102,241,0.04) 0%, transparent 55%);
  pointer-events: none; z-index: -2;
}
.bg-noise {
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px; opacity: 0.018; pointer-events: none; z-index: -1;
}

/* ─── Glass Base ─── */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-glass);
}

/* ─── Navigation ─── */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-height); z-index: 100;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid rgba(0,0,0,0.07);
  box-shadow: 0 1px 0 rgba(255,255,255,0.9), 0 4px 20px rgba(0,0,0,0.06);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 clamp(16px,4vw,32px); height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  position: relative;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
}
.nav-logo-icon {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(37,99,235,0.3);
  border-radius: var(--radius-sm); overflow: hidden;
}
.nav-logo-text {
  font-family: var(--font-headline);
  font-size: 22px; font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1.5px;
  padding-right: 2px;
}
.nav-links { display: flex; align-items: center; gap: 8px; list-style: none; position: absolute; left: 50%; transform: translateX(-50%); }
.nav-links a {
  text-decoration: none; color: var(--text-secondary);
  font-family: var(--font-headline); font-size: 14px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius-sm);
  transition: all var(--transition); letter-spacing: -0.3px;
}
.nav-links a:hover { color: var(--text-primary); }
.nav-links a.active { color: #2563eb; border-bottom: 2px solid #2563eb; border-radius: 0; padding-bottom: 4px; }
.nav-links a.active::after { display: none; }
.nav-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-playground-btn { font-size: 16px; opacity: 0.7; color: #2563eb; transition: opacity 0.2s, transform 0.2s; text-decoration: none; line-height: 1; cursor: pointer; background: none; border: none; padding: 4px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.nav-playground-btn:hover { opacity: 1; transform: rotate(-8deg) scale(1.2); }
.nav-playground-btn.active { opacity: 0.7; }
.nav-user { display: flex; align-items: center; gap: 10px; }
.nav-avatar { width: 34px; height: 34px; border-radius: var(--radius-full); border: 2px solid var(--glass-border); object-fit: cover; background: var(--glass-bg); }
.nav-avatar:not([src]), .nav-avatar[src=""] { visibility: hidden; width: 0; border: none; }
.nav-avatar-emoji { width: 34px; height: 34px; border-radius: var(--radius-full); border: 2px solid var(--glass-border); background: var(--glass-bg); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.nav-username { font-size: 14px; font-weight: 600; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-plan-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.5px;
}
.nav-plan-badge.free { background: var(--glass-bg); border: 1px solid var(--glass-border); color: var(--text-secondary); }
.nav-plan-badge.premium { background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.25); color: #2563eb; }

/* ─── Nav Avatar Dropdown ─── */
.nav-avatar-menu { position: relative; }
.nav-dropdown {
  display: none; position: absolute; right: 0; top: 100%;
  padding-top: 6px; min-width: 190px; z-index: 300;
}
.nav-avatar-menu:hover .nav-dropdown { display: block; }
.nav-dropdown-inner {
  background: #fff; border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg); box-shadow: 0 8px 32px rgba(0,0,0,0.13);
  padding: 6px; overflow: hidden;
}
[data-theme="dark"] .nav-dropdown-inner { background: #1a2035; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.nav-dropdown-user {
  display: block; padding: 10px 12px 8px;
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  text-decoration: none; border-radius: var(--radius-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 178px;
}
.nav-dropdown-user:hover { background: var(--glass-bg); }
.nav-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-secondary);
  text-decoration: none; transition: all 0.15s;
  width: 100%; text-align: left; background: none; border: none; cursor: pointer; font-family: inherit;
}
.nav-dropdown-item:hover { background: var(--glass-bg); color: var(--text-primary); }
.nav-dropdown-sep { height: 1px; background: var(--glass-border); margin: 4px 0; }
.nav-dropdown-logout { color: #ef4444; }
.nav-dropdown-logout:hover { background: rgba(239,68,68,0.08); color: #ef4444; }

/* ─── Nav Inbox Button ─── */
.nav-inbox-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-full);
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  cursor: pointer; font-size: 18px; transition: background var(--transition);
  flex-shrink: 0;
}
.nav-inbox-btn:hover, .nav-inbox-btn.active { background: rgba(0,0,0,0.06); }
.nav-inbox-badge {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; border: 1.5px solid var(--bg-primary);
}
.nav-inbox-flyout {
  display: none; position: fixed; z-index: 2000;
  width: 320px; max-height: 420px; overflow-y: auto;
  background: var(--surface-container-high); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  flex-direction: column;
}
.nav-inbox-flyout.open { display: flex; }
.nav-inbox-head {
  padding: 14px 16px; font-size: 14px; font-weight: 700;
  border-bottom: 1px solid var(--glass-border); flex-shrink: 0;
}
.nav-inbox-footer {
  display: block; padding: 10px 16px; text-align: center;
  font-size: 12px; color: var(--text-secondary); text-decoration: none;
  border-top: 1px solid var(--glass-border); flex-shrink: 0;
  transition: color var(--transition);
}
.nav-inbox-footer:hover { color: var(--text-primary); }
.nav-inbox-item {
  padding: 12px 16px; border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
}
.nav-inbox-item:last-child { border-bottom: none; }
.nav-inbox-item-new { background: rgba(37,99,235,0.08); }
.nav-inbox-item-title {
  font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px;
}
.nav-inbox-item-body { font-size: 12px; color: var(--text-secondary); line-height: 1.4; }
.nav-inbox-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #3b82f6; flex-shrink: 0;
}
.nav-inbox-claim-btn {
  margin-top: 6px; padding: 5px 12px; border-radius: var(--radius-sm);
  background: rgba(37,99,235,0.1);
  border: 1px solid rgba(37,99,235,0.3); color: #2563eb;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.nav-inbox-claim-btn:hover { background: rgba(37,99,235,0.18); }
.nav-inbox-claim-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.nav-inbox-claimed { font-size: 12px; color: #16a34a; }
.nav-inbox-empty, .nav-inbox-loading {
  padding: 24px 16px; text-align: center; color: var(--text-secondary); font-size: 13px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--transition);
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-primary { background: var(--accent-gradient); color: #fff; font-weight: 700; box-shadow: 0 4px 24px rgba(37,99,235,0.4), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 36px rgba(37,99,235,0.55), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-glass { background: var(--glass-bg); color: var(--text-primary); border: 1px solid var(--glass-border); }
.btn-glass:hover:not(:disabled) { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--text-primary); background: var(--glass-bg); border-color: var(--glass-border); }
.btn-danger { background: var(--error-bg); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.15); }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius-md); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn-full { width: 100%; }

/* ─── Layout ─── */
.page { padding-top: var(--nav-height); min-height: 100vh; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px,4vw,32px); }
.section { padding: clamp(40px,8vw,80px) 0; }

/* ─── Hero ─── */
.hero { padding: clamp(60px,12vw,120px) 0 clamp(40px,8vw,80px); text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px;
  background: rgba(37,99,235,0.1);
  border: 1px solid rgba(59,130,246,0.2);
  border-radius: var(--radius-full); font-size: 13px; font-weight: 600; color: #2563eb;
  margin-bottom: 28px; animation: fadeInDown 0.6s ease;
}
.hero-title {
  font-size: clamp(36px,7vw,72px); font-weight: 900;
  letter-spacing: -2px; line-height: 1.05; margin-bottom: 24px;
  animation: fadeInUp 0.6s ease 0.1s both;
  text-wrap: balance;
}
.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
/* 손글씨 취소선 */
.sketch-strikethrough { position: relative; display: inline-block; }
.sketch-strikethrough .sketch-strike {
  position: absolute; left: -4px;
  top: 50%; transform: translateY(-50%);
  width: calc(100% + 8px); height: 14px;
  overflow: visible; pointer-events: none;
}
.sketch-strikethrough .sketch-strike path {
  stroke: #ef4444; stroke-width: 4; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 600; stroke-dashoffset: 600;
  animation: sketch-draw 2s cubic-bezier(0.4,0,0.2,1) forwards 0.3s;
}

/* 손글씨 밑줄 */
.sketch-underline { position: relative; display: inline-block; }
.sketch-underline .sketch-line {
  position: absolute; left: 0; bottom: -6px;
  width: 100%; height: 14px; overflow: visible; pointer-events: none;
}
.sketch-underline .sketch-line path {
  stroke: #F59E0B; stroke-width: 4; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 600; stroke-dashoffset: 600;
  animation: sketch-draw 2s cubic-bezier(0.4,0,0.2,1) forwards 0.5s;
}
@keyframes sketch-draw { to { stroke-dashoffset: 0; } }
.hero-subtitle {
  font-size: clamp(15px,2.5vw,18px); color: var(--text-secondary);
  max-width: 560px; margin: 0 auto 48px; line-height: 1.7;
  animation: fadeInUp 0.6s ease 0.2s both;
  text-wrap: pretty;
}

/* ─── Upload Card ─── */
.upload-card {
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--glass-border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glass), 0 0 80px rgba(37,99,235,0.05);
  padding: clamp(24px,4vw,48px); max-width: 720px; margin: 0 auto;
  animation: fadeInUp 0.6s ease 0.3s both;
}
.upload-zone {
  border: 2px dashed var(--glass-border); border-radius: var(--radius-lg);
  padding: clamp(32px,6vw,64px) 24px; text-align: center; cursor: pointer;
  transition: all var(--transition); background: rgba(0,0,0,0.02);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: rgba(37,99,235,0.05);
  box-shadow: inset 0 0 40px rgba(37,99,235,0.04);
}
.upload-zone.has-file { border-color: var(--accent); background: rgba(37,99,235,0.06); border-style: solid; }
.upload-icon { font-size: 48px; margin-bottom: 16px; display: block; transition: transform var(--transition-bounce); }
.upload-zone:hover .upload-icon { transform: translateY(-4px) scale(1.05); }
.upload-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.upload-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.upload-file-input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; z-index: 1;
}
.file-info {
  display: none; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(37,99,235,0.08);
  border-radius: var(--radius-sm); margin-top: 16px;
  border: 1px solid rgba(37,99,235,0.20);
}
.file-info.visible { display: flex; }
.file-info-icon { font-size: 20px; }
.file-info-details { flex: 1; min-width: 0; text-align: left; }
.file-info-name { font-size: 14px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info-size { font-size: 12px; color: var(--text-secondary); }
.file-info-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; border-radius: var(--radius-xs); transition: color var(--transition); flex-shrink: 0; }
.file-info-remove:hover { color: var(--error); }

/* ─── Quiz Settings ─── */
.quiz-settings { margin-top: 28px; display: grid; gap: 18px; }
.settings-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 2px; }

/* Quiz settings — open card layout */
.quiz-settings { margin-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.settings-section { display: flex; flex-direction: column; gap: 10px; }
.settings-section-header { display: flex; align-items: center; justify-content: space-between; }
.settings-section-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

/* Pills */
.settings-pills { display: flex; gap: 8px; }
.settings-pill { position: relative; cursor: pointer; flex: 1; }
.settings-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.settings-pill span {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 11px 6px; border-radius: 12px;
  background: var(--pill-bg); border: none;
  font-size: 13.5px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; transition: background 0.15s, color 0.15s; user-select: none; white-space: nowrap;
}
/* 모든 radio/checkbox: soft tint */
.settings-pill input[type="radio"]:checked + span,
.settings-pills--soft .settings-pill input[type="radio"]:checked + span {
  background: rgba(37,99,235,0.11); color: #2563eb; font-weight: 600;
}
/* 유형 checkbox: tinted */
.settings-pill input[type="checkbox"]:checked + span {
  background: rgba(37,99,235,0.11); color: #2563eb; font-weight: 600;
}
.settings-pill span:hover { filter: brightness(0.95); }
.settings-pill input:checked + span:hover { opacity: 0.9; filter: none; }

/* Slider */
.count-slider { width: 100%; }
.slider-ticks { display: flex; justify-content: space-between; padding: 0 2px; margin-top: 4px; }
.slider-ticks span { font-size: 11px; font-weight: 600; color: var(--text-muted); transition: color 0.15s; }
.slider-ticks span.active { color: #2563eb; }
.count-credit-chip { font-size: 11px; color: #2563eb; font-weight: 700; background: rgba(37,99,235,0.09); border-radius: 999px; padding: 3px 10px; flex-shrink: 0; }

/* Segmented control (크레딧) */
.settings-segment { display: flex; background: var(--pill-bg); border-radius: 999px; padding: 3px; gap: 2px; }
.settings-segment-item { position: relative; flex: 1; cursor: pointer; }
.settings-segment-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.settings-segment-item span {
  display: flex; align-items: center; justify-content: center;
  padding: 9px 6px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; color: var(--text-muted);
  transition: all 0.15s; user-select: none; cursor: pointer;
}
.settings-segment-item input:checked + span {
  background: var(--glass-bg-hover); color: #2563eb; font-weight: 700;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

/* Advanced toggle */
.settings-advanced-toggle {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; padding: 2px 0;
}
.settings-advanced-toggle:hover { opacity: 0.7; }
.settings-advanced-toggle > span { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

/* Generate button */
.btn-generate { border-radius: 999px !important; margin-top: 4px; }

/* Free credit collapsible */
.free-credit-details { border-radius: var(--radius-md); background: var(--glass-bg); border: 1px solid var(--glass-border); margin-top: 12px; }
.free-credit-summary { display: flex; align-items: center; gap: 7px; padding: 11px 14px; font-size: 13px; font-weight: 700; color: var(--text-secondary); cursor: pointer; list-style: none; user-select: none; transition: color var(--transition); }
.free-credit-summary::-webkit-details-marker { display: none; }
.free-credit-summary::after { content: '›'; margin-left: auto; font-size: 16px; font-weight: 400; transition: transform 0.2s ease; display: inline-block; }
.free-credit-details[open] .free-credit-summary::after { transform: rotate(90deg); }
.free-credit-summary:hover { color: var(--text-primary); }
.free-credit-body { display: flex; flex-direction: column; gap: 8px; padding: 0 14px 12px; font-size: 13px; color: var(--text-secondary); }
.free-credit-item { display: flex; align-items: center; gap: 8px; }
.free-credit-item strong { color: var(--text-primary); }
.free-credit-item a { color: #3b82f6; text-decoration: none; }
.free-credit-icon { flex-shrink: 0; width: 20px; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }

/* Legacy card-style options (크레딧 사용 방식) */
.type-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.type-option { position: relative; cursor: pointer; }
.type-option input[type="radio"],
.type-option input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.type-option-label {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 10px; background: var(--glass-bg);
  border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  cursor: pointer; transition: all var(--transition);
  font-size: 13px; font-weight: 600; color: var(--text-secondary); text-align: center;
}
.type-option-label .type-icon { font-size: 22px; }
.type-option input[type="checkbox"]:checked + .type-option-label,
.type-option input[type="radio"]:checked + .type-option-label {
  background: rgba(37,99,235,0.1);
  border-color: rgba(37,99,235,0.35); color: #2563eb;
  box-shadow: 0 0 20px rgba(37,99,235,0.06);
}
.type-option-label:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); color: var(--text-primary); }

/* Count Slider */
.count-slider-wrapper { display: flex; align-items: center; gap: 16px; }
.count-slider {
  flex: 1; appearance: none; -webkit-appearance: none; height: 6px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--progress, 30%), var(--glass-border) var(--progress, 30%));
  border-radius: var(--radius-full); outline: none; cursor: pointer;
}
.count-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px;
  border-radius: var(--radius-full); background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px var(--accent);
  cursor: pointer; transition: transform var(--transition-bounce);
}
.count-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.count-slider::-moz-range-thumb {
  width: 20px; height: 20px; border: none;
  border-radius: var(--radius-full); background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), 0 0 0 3px var(--accent);
  cursor: pointer;
}
.count-display {
  min-width: 60px; text-align: center;
  font-size: 22px; font-weight: 800; color: #2563eb;
  background: rgba(37,99,235,0.07);
  border: 1px solid rgba(37,99,235,0.18); border-radius: var(--radius-sm); padding: 6px 12px;
}

/* Generate Button */
.btn-generate {
  width: 100%; padding: 16px 32px; font-size: 16px; font-weight: 700;
  background: var(--accent-gradient); color: white; border: none;
  border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition);
  box-shadow: 0 4px 24px rgba(37,99,235,0.45), inset 0 1px 0 rgba(255,255,255,0.15); letter-spacing: 0.3px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 8px; font-family: var(--font);
}
.btn-generate:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 44px rgba(37,99,235,0.6), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Loading Overlay ─── */
.loading-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(240,243,251,0.90); backdrop-filter: blur(12px);
  z-index: 1000; align-items: center; justify-content: flex-start; flex-direction: column; gap: 16px;
  padding: 40px 16px 24px; overflow-y: auto;
}
.loading-overlay.visible { display: flex; }
.loading-spinner { width: 52px; height: 52px; border: 3px solid rgba(37,99,235,0.18); border-top-color: var(--accent); border-radius: var(--radius-full); animation: spin 0.8s linear infinite; }
.loading-step-badge { font-size: 12px; font-weight: 600; color: var(--accent); background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.2); border-radius: 20px; padding: 3px 12px; letter-spacing: 0.05em; }
.loading-title { font-size: 20px; font-weight: 700; text-align: center; }
.loading-desc { font-size: 15px; color: var(--text-secondary); text-align: center; }
.loading-subtitle { font-size: 13px; color: var(--text-secondary); opacity: 0.7; text-align: center; max-width: 300px; }
.loading-dots { display: flex; gap: 8px; }
.loading-dots span { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--accent); animation: dotPulse 1.2s ease-in-out infinite; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ─── Toast ─── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--surface-container-high);
  border-radius: var(--radius-md); border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  min-width: 260px; max-width: 380px; animation: slideInRight 0.3s ease;
  backdrop-filter: blur(12px);
}
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.warning { border-color: rgba(245,158,11,0.3); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast.removing { animation: slideOutRight 0.3s ease forwards; }

/* ─── Modal ─── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.45); backdrop-filter: blur(8px); z-index: 1200; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity 0.2s ease; }
.modal-overlay.visible { display: flex; animation: overlayIn 0.2s ease forwards; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface-container); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: 40px; max-width: 460px; width: 100%; box-shadow: var(--shadow-lg); animation: scaleIn 0.3s var(--transition-bounce) backwards; text-align: center; backdrop-filter: blur(20px); }
.modal-icon { font-size: 52px; margin-bottom: 20px; }
.modal-title { font-family: var(--font-headline); font-size: 22px; font-weight: 800; margin-bottom: 10px; text-wrap: balance; letter-spacing: -0.5px; }
.modal-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: 28px; line-height: 1.7; }
.modal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ─── Section Headers ─── */
.section-header { text-align: center; margin-bottom: clamp(32px,5vw,56px); }
.section-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; }
.section-title { font-size: clamp(24px,4vw,40px); font-weight: 800; letter-spacing: -0.5px; margin-bottom: 14px; text-wrap: balance; }
.section-subtitle { font-size: 16px; color: var(--text-secondary); max-width: 480px; margin: 0 auto; line-height: 1.7; }

/* ─── Feature Cards ─── */
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.feature-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 28px 24px; transition: all var(--transition); }
.feature-card:hover { background: var(--glass-bg-hover); border-color: var(--glass-border-hover); transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-icon { width: 48px; height: 48px; border-radius: var(--radius-md); background: rgba(37,99,235,0.1); border: 1px solid rgba(59,130,246,0.15); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 16px; }
.feature-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.feature-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ─── Pricing ─── */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; max-width: 640px; margin: 0 auto; }
.pricing-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: 32px 28px; transition: all var(--transition); position: relative; }
.pricing-card.featured { background: rgba(37,99,235,0.06); border-color: rgba(59,130,246,0.22); box-shadow: 0 0 60px rgba(37,99,235,0.08); }
.pricing-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--accent-gradient); color: white; font-size: 11px; font-weight: 700; padding: 4px 14px; border-radius: var(--radius-full); white-space: nowrap; letter-spacing: 0.5px; }
.pricing-plan { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.pricing-price { font-size: 42px; font-weight: 900; letter-spacing: -2px; margin-bottom: 4px; }
.pricing-period { font-size: 14px; color: var(--text-secondary); margin-bottom: 24px; }
.pricing-features { list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.pricing-features li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-secondary); }

/* ─── Upgrade Banner ─── */
.upgrade-banner { background: rgba(37,99,235,0.07); border: 1px solid rgba(59,130,246,0.18); border-radius: var(--radius-lg); padding: 20px 24px; display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.upgrade-banner-icon { font-size: 32px; flex-shrink: 0; }
.upgrade-banner-text { flex: 1; }
.upgrade-banner-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.upgrade-banner-desc { font-size: 13px; color: var(--text-secondary); }

/* ─── Footer ─── */
.footer { border-top: 1px solid var(--glass-border); padding: 40px 0; text-align: center; color: var(--text-muted); font-size: 13px; }
.footer-links { display: flex; justify-content: center; gap: 24px; margin-bottom: 14px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); text-decoration: none; transition: color var(--transition); }
.footer-links a:hover { color: var(--text-secondary); }

/* ─── Quiz Page ─── */
.quiz-topbar {
  position: fixed; top: var(--nav-height); left: 0; right: 0; z-index: 90;
  background: rgba(255,255,255,0.90); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border); padding: 12px clamp(16px,4vw,32px);
}
.quiz-topbar-inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.quiz-progress-bar { flex: 1; height: 6px; background: rgba(0,0,0,0.10); border-radius: var(--radius-full); overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--accent-gradient); border-radius: var(--radius-full); transition: width 0.5s cubic-bezier(0.4,0,0.2,1); box-shadow: 0 0 10px rgba(37,99,235,0.5); }
.quiz-counter { font-size: 13px; font-weight: 700; color: var(--text-secondary); white-space: nowrap; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.quiz-streaming-badge {
  font-size: 14px; color: #3b82f6; animation: spin 1.2s linear infinite;
  display: inline-block; flex-shrink: 0;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.quiz-quit-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 4px; border-radius: var(--radius-xs); transition: color var(--transition); flex-shrink: 0; min-width: 44px; min-height: 44px; }
.quiz-quit-btn:hover { color: var(--error); }

.quiz-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: calc(var(--nav-height) + 86px) clamp(16px,4vw,32px) 60px; min-height: 100vh; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.quiz-main input, .quiz-main textarea { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.quiz-layout { width: 100%; max-width: 720px; display: flex; gap: 20px; align-items: flex-start; transition: max-width 0.35s cubic-bezier(0.4,0,0.2,1); }
.quiz-layout.chat-open { max-width: 100%; }
.quiz-card-container { flex: 0 0 auto; width: min(720px, 100%); }
.quiz-layout.chat-open .quiz-card-container { width: min(640px, 55%); }
.quiz-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--glass-border); border-radius: var(--radius-xl);
  padding: clamp(24px,5vw,48px); box-shadow: var(--shadow-glass);
  position: relative; /* 차폐막 absolute 기준점 */
}

.quiz-card.shake { animation: shake 0.4s ease; }
.quiz-card.correct-flash { border-color: rgba(16,185,129,0.4); animation: correctPulse 0.5s ease; }
.quiz-card.answered-correct { border-color: rgba(16,185,129,0.22); box-shadow: 0 0 0 1px rgba(16,185,129,0.1), var(--shadow-glass); transition: border-color 0.6s ease, box-shadow 0.6s ease; }
.quiz-card.answered-wrong { border-color: rgba(239,68,68,0.18); box-shadow: 0 0 0 1px rgba(239,68,68,0.08), var(--shadow-glass); transition: border-color 0.6s ease, box-shadow 0.6s ease; }

/* 다시풀기 문제 네비게이터 */
.question-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--glass-border); }
.q-nav-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.15s, border-color 0.15s, color 0.15s; flex-shrink: 0; }
.q-nav-btn:hover { background: var(--glass-bg-hover); color: var(--text-primary); }
.q-nav-btn.active { background: rgba(37,99,235,0.15); border-color: rgba(59,130,246,0.45); color: #3b82f6; }
.q-nav-btn.correct { background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.3); color: #34d399; }
.q-nav-btn.wrong { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #f87171; }
.q-nav-btn.active.correct { border-color: #34d399; box-shadow: 0 0 0 2px rgba(52,211,153,0.2); }
.q-nav-btn.active.wrong { border-color: #f87171; box-shadow: 0 0 0 2px rgba(239,68,68,0.15); }

.quiz-type-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: var(--radius-full); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 20px; background: var(--glass-bg-hover); color: var(--text-secondary); border: 1px solid var(--glass-border); }
.quiz-question { font-size: clamp(16px,2.5vw,20px); font-weight: 700; line-height: 1.6; margin-bottom: 28px; }

/* MCQ Options */
.quiz-options { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.quiz-option {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); padding: 14px 18px;
  cursor: pointer; transition: all var(--transition);
  display: flex; align-items: center; gap: 14px;
  font-size: 15px; font-weight: 500; color: var(--text-primary);
  text-align: left; width: 100%; font-family: var(--font);
}
.quiz-option:hover:not(:disabled) { background: var(--glass-bg-hover); border-color: rgba(59,130,246,0.25); transform: translateX(4px); }
.quiz-option.selected { border-color: rgba(59,130,246,0.45); background: rgba(37,99,235,0.08); }
.quiz-option.correct { border-color: rgba(16,185,129,0.5); background: var(--success-bg); color: var(--success); }
.quiz-option.wrong { border-color: rgba(239,68,68,0.4); background: var(--error-bg); color: var(--error); }
.quiz-option:disabled { cursor: default; transform: none !important; }
.option-marker { width: 32px; height: 32px; border-radius: var(--radius-full); background: rgba(37,99,235,0.07); border: 1.5px solid rgba(37,99,235,0.2); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; flex-shrink: 0; transition: all var(--transition); color: #2563eb; letter-spacing: 0; }
.quiz-option.correct .option-marker { background: var(--success); color: white; border-color: transparent; box-shadow: 0 0 12px rgba(16,185,129,0.4); }
.quiz-option.wrong .option-marker { background: var(--error); color: white; border-color: transparent; box-shadow: 0 0 12px rgba(239,68,68,0.4); }
.quiz-option.selected:not(.correct):not(.wrong) .option-marker { background: var(--accent-gradient); color: white; border-color: transparent; box-shadow: 0 0 12px rgba(37,99,235,0.45); }

/* OX */
.ox-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.ox-option { padding: 28px 16px; border-radius: var(--radius-lg); border: 2px solid var(--glass-border); background: var(--glass-bg); cursor: pointer; transition: all var(--transition); font-size: 52px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; font-family: var(--font); }
.ox-label { font-size: 13px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.ox-option:hover:not(:disabled) { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.ox-option[data-value="O"].correct { border-color: rgba(16,185,129,0.6); background: var(--success-bg); }
.ox-option[data-value="X"].correct { border-color: rgba(16,185,129,0.6); background: var(--success-bg); }
.ox-option[data-value="O"].wrong { border-color: rgba(239,68,68,0.5); background: var(--error-bg); }
.ox-option[data-value="X"].wrong { border-color: rgba(239,68,68,0.5); background: var(--error-bg); }
.ox-option.selected { box-shadow: var(--shadow-md); border-color: rgba(59,130,246,0.4); background: rgba(37,99,235,0.08); }
.ox-option:disabled { cursor: default; transform: none !important; }

/* Short Answer */
.short-answer-input {
  width: 100%; background: var(--glass-bg); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); padding: 16px 20px; font-family: var(--font);
  font-size: 15px; color: var(--text-primary); outline: none; transition: border-color var(--transition);
  resize: vertical; min-height: 100px; margin-bottom: 12px; box-sizing: border-box;
}
.short-answer-input:focus { border-color: rgba(59,130,246,0.5); box-shadow: 0 0 0 4px rgba(37,99,235,0.1); }
.short-answer-input::placeholder { color: var(--text-muted); opacity: 0.8; }

/* Explanation */
.quiz-explanation { display: none; padding: 16px 18px; background: rgba(37,99,235,0.06); border-radius: var(--radius-md); border: 1px solid rgba(59,130,246,0.14); margin-bottom: 20px; font-size: 14px; color: var(--text-secondary); line-height: 1.7; }
.quiz-explanation.visible { display: block; animation: fadeInUp 0.3s ease; }
.quiz-explanation-label { font-size: 11px; font-weight: 700; color: #2563eb; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.quiz-correct-answer { display: none; padding: 10px 14px; background: var(--success-bg); border: 1px solid rgba(16,185,129,0.2); border-radius: var(--radius-sm); margin-bottom: 10px; font-size: 14px; color: var(--success); font-weight: 600; }
.quiz-correct-answer.visible { display: block; animation: fadeInUp 0.3s ease; }
.quiz-comment { padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 12px; font-size: 14px; font-weight: 600; animation: fadeInUp 0.3s ease; }
.quiz-comment.correct { background: rgba(5,150,105,0.08); border: 1px solid rgba(5,150,105,0.25); color: var(--success); }
.quiz-comment.wrong { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); color: #ef4444; }

/* Feedback */
.feedback-overlay { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 80px; z-index: 200; pointer-events: none; animation: feedbackPop 0.7s ease forwards; }
.feedback-overlay.visible { display: block; }

/* Quiz Actions */
.quiz-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; }
.quiz-actions #prev-btn { margin-right: auto; }

/* ─── Results ─── */
.results-wrap { display: flex; align-items: center; justify-content: center; flex-direction: column; padding: calc(var(--nav-height) + 40px) clamp(16px,4vw,32px) 60px; min-height: 100vh; }
.results-card { background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--glass-border); border-radius: var(--radius-xl); padding: clamp(32px,6vw,56px) clamp(24px,5vw,48px); max-width: 620px; width: 100%; text-align: center; box-shadow: var(--shadow-glass); animation: scaleIn 0.5s var(--transition-bounce); }
.results-emoji { font-size: 64px; margin-bottom: 20px; }
.results-title { font-size: clamp(24px,4vw,36px); font-weight: 900; letter-spacing: -1px; margin-bottom: 8px; }
.results-subtitle { font-size: 15px; color: var(--text-secondary); margin-bottom: 32px; }
.results-score-ring { position: relative; width: 140px; height: 140px; margin: 0 auto 28px; }
.results-score-ring svg { transform: rotate(-90deg); }
.score-ring-bg { fill: none; stroke: rgba(0,0,0,0.10); stroke-width: 8; }
.score-ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(0.4,0,0.2,1) 0.3s; }
.results-score-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.results-score-num { font-size: 34px; font-weight: 900; background: var(--accent-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.results-score-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.results-stat { padding: 16px 12px; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md); }
.results-stat-num { font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.results-stat-label { font-size: 12px; color: var(--text-secondary); }
.results-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }

/* Wrong Answers */
.wrong-answers-section { text-align: left; }
.wrong-answers-title { font-size: 18px; font-weight: 800; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.wrong-answer-card { background: var(--glass-bg); border: 1px solid rgba(239,68,68,0.12); border-radius: var(--radius-md); padding: 16px 20px; margin-bottom: 8px; transition: border-color var(--transition); }
.wrong-answer-card:hover { border-color: rgba(239,68,68,0.25); }
.wrong-answer-card.expanded .wrong-detail { display: block !important; }
.wrong-answer-card.expanded .wrong-summary { display: none; }
.wrong-answer-num { font-size: 11px; font-weight: 700; color: var(--error); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.wrong-answer-q { font-size: 15px; font-weight: 600; margin-bottom: 12px; line-height: 1.5; }
.wrong-answer-q table, .wrong-answer-expl table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; font-weight: 400; }
.wrong-answer-q th, .wrong-answer-expl th, .wrong-answer-q td, .wrong-answer-expl td { border: 1px solid var(--glass-border); padding: 6px 10px; text-align: left; }
.wrong-answer-q th, .wrong-answer-expl th { background: rgba(37,99,235,0.1); font-weight: 700; }
.wrong-answer-q p, .wrong-answer-expl p { margin: 4px 0; }
.wrong-answer-yours { font-size: 13px; color: var(--error); margin-bottom: 6px; }
.wrong-answer-correct { font-size: 13px; color: var(--success); margin-bottom: 8px; font-weight: 600; }
.wrong-answer-expl { font-size: 13px; color: var(--text-secondary); line-height: 1.6; padding-top: 10px; border-top: 1px solid var(--glass-border); }

/* ─── Scrap Square Cards ─── */
.scrap-sq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.scrap-sq-card {
  background: var(--glass-bg);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; gap: 8px;
  overflow: hidden; position: relative;
  outline: 1px solid rgba(245,158,11,0.15);
}
.scrap-sq-card:hover {
  outline-color: rgba(245,158,11,0.4);
  background: var(--glass-bg-hover);
  transform: translateY(-2px);
}
.scrap-sq-card.selected {
  border-color: #f59e0b;
  background: rgba(245,158,11,0.07);
  outline: none;
}
.scrap-sq-badge {
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: var(--radius-full); border: 1px solid var(--glass-border);
  color: var(--text-muted); background: var(--glass-bg-hover);
  align-self: flex-start; white-space: nowrap; flex-shrink: 0;
}
.scrap-sq-q {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  line-height: 1.5; flex: 1; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
}
.scrap-sq-footer {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex-shrink: 0;
}
/* 선택됐을 때 체크마크 */
.scrap-sq-check-mark {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #f59e0b; color: white;
  font-size: 12px; font-weight: 900;
  display: none; align-items: center; justify-content: center;
}
.scrap-sq-card.selected .scrap-sq-check-mark { display: flex; }
/* 상세보기 버튼 (호버 시 표시) */
.scrap-sq-view {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,0.45); border: none; color: white;
  border-radius: var(--radius-full); width: 24px; height: 24px;
  font-size: 12px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.scrap-sq-card:not(.selected):hover .scrap-sq-view { display: flex; }
.scrap-sq-view:hover { background: rgba(37,99,235,0.6); }

/* 하단 액션 바 */
.scrap-action-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}
.pager { display:flex; justify-content:center; align-items:center; gap:4px; margin-top:16px; flex-wrap:wrap; }
.pager-btn { min-width:44px; height:44px; border-radius:var(--radius-md); border:1px solid var(--glass-border); background:var(--glass-bg); color:var(--text-secondary); font-family:var(--font); font-size:13px; font-weight:600; cursor:pointer; transition:all var(--transition); }
.pager-btn:hover { border-color:rgba(59,130,246,0.4); color:var(--text-primary); }
.pager-btn.active { background:rgba(37,99,235,0.15); border-color:rgba(59,130,246,0.5); color:var(--text-primary); }
.pager-btn:disabled { opacity:0.4; cursor:default; }
.scrap-action-bar.has-selection {
  background: rgba(245,158,11,0.06);
  border-color: rgba(245,158,11,0.25);
}
.scrap-action-info { font-size: 13px; font-weight: 700; color: var(--text-secondary); flex: 1; }
.scrap-action-bar.has-selection .scrap-action-info { color: #f59e0b; }

/* Scrap Detail Modal */
.scrap-view-modal-inner {
  max-width: 560px; max-height: 85vh;
  overflow-y: auto; text-align: left;
}
.scrap-modal-q { font-size: 16px; font-weight: 700; line-height: 1.65; margin-bottom: 16px; }
.scrap-modal-q p { margin: 4px 0; }
.scrap-modal-q table { width:100%; border-collapse:collapse; margin:8px 0; font-size:13px; }
.scrap-modal-q th, .scrap-modal-q td { border:1px solid var(--glass-border); padding:6px 10px; text-align:left; }
.scrap-modal-q th { background:rgba(37,99,235,0.1); font-weight:700; }
.scrap-modal-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.scrap-modal-option { font-size: 14px; color: var(--text-secondary); line-height: 1.5; padding: 8px 12px; background: var(--glass-bg); border-radius: var(--radius-sm); border: 1px solid var(--glass-border); }
.scrap-modal-answer { font-size: 14px; color: var(--success); font-weight: 700; margin-bottom: 14px; padding: 10px 14px; background: var(--success-bg); border-radius: var(--radius-sm); border: 1px solid rgba(16,185,129,0.2); }
.scrap-modal-expl { font-size: 13px; color: var(--text-secondary); line-height: 1.7; padding: 12px 14px; background: rgba(37,99,235,0.05); border-radius: var(--radius-sm); border: 1px solid rgba(59,130,246,0.12); }
.scrap-modal-expl p { margin: 4px 0; }

/* ─── Scrap Button ─── */
.scrap-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 600;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--glass-border);
  cursor: pointer; transition: color var(--transition), border-color var(--transition), background var(--transition);
  font-family: var(--font);
}
.report-error-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 600;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--glass-border);
  cursor: pointer; transition: color var(--transition), border-color var(--transition), background var(--transition);
  font-family: var(--font);
}
.report-error-btn:hover { color: var(--error); border-color: rgba(220,38,38,0.4); background: rgba(220,38,38,0.05); }
.scrap-btn:hover { color: #f59e0b; border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.06); }
.scrap-btn.scrapped { color: #f59e0b; border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.1); }

/* ─── Quiz Chat ─── */
.quiz-ask-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius-full);
  font-size: 13px; font-weight: 600;
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--glass-border);
  cursor: pointer; transition: color var(--transition), border-color var(--transition), background var(--transition);
  font-family: var(--font);
}
.quiz-ask-btn:hover { color: var(--accent); border-color: rgba(37,99,235,0.4); background: rgba(37,99,235,0.06); }
.quiz-ask-btn.active { color: var(--accent); border-color: rgba(37,99,235,0.5); background: rgba(37,99,235,0.1); }
/* ── 채팅 사이드 패널 ── */
.quiz-chat-panel {
  display: none;
  flex: 1;
  min-width: 280px;
  flex-direction: column;
  position: sticky;
  top: calc(var(--nav-height) + 92px);
  height: calc(100vh - var(--nav-height) - 112px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(1.5); -webkit-backdrop-filter: blur(20px) saturate(1.5);
  box-shadow: var(--shadow-glass);
  overflow: hidden;
}
.quiz-chat-panel.open { display: flex; animation: fadeInUp 0.25s ease; }

.quiz-chat-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--glass-border); background: var(--glass-bg-hover); flex-shrink: 0; }
.quiz-chat-header-title { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: var(--text-primary); }
.quiz-chat-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 16px; padding: 2px 4px; line-height: 1; border-radius: var(--radius-xs); transition: color var(--transition), background var(--transition); }
.quiz-chat-close:hover { color: var(--text-primary); background: var(--glass-border); }

.quiz-chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth; }

.quiz-chat-msg { display: flex; flex-direction: column; }
.quiz-chat-msg.user { align-items: flex-end; }
.quiz-chat-msg.ai { align-items: flex-start; }
.quiz-chat-bubble { word-break: break-word; }
.quiz-chat-msg.user .quiz-chat-bubble { background: var(--accent-gradient); color: #fff; padding: 9px 14px; border-radius: 16px 16px 3px 16px; font-size: 13.5px; line-height: 1.55; max-width: 88%; box-shadow: 0 2px 8px rgba(37,99,235,0.25); }
.quiz-chat-msg.ai .quiz-chat-bubble { width: 100%; font-size: 13.5px; line-height: 1.75; color: var(--text-primary); }
.quiz-chat-msg.ai .quiz-chat-bubble.loading { color: var(--text-muted); font-style: italic; }

/* AI 응답 마크다운 */
.quiz-chat-msg.ai .quiz-chat-bubble p { margin: 0 0 9px; }
.quiz-chat-msg.ai .quiz-chat-bubble p:last-child { margin-bottom: 0; }
.quiz-chat-msg.ai .quiz-chat-bubble strong { font-weight: 700; color: var(--text-primary); }
.quiz-chat-msg.ai .quiz-chat-bubble em { font-style: italic; }
.quiz-chat-msg.ai .quiz-chat-bubble ul, .quiz-chat-msg.ai .quiz-chat-bubble ol { margin: 5px 0 9px; padding-left: 20px; }
.quiz-chat-msg.ai .quiz-chat-bubble ul { list-style: disc; }
.quiz-chat-msg.ai .quiz-chat-bubble ol { list-style: decimal; }
.quiz-chat-msg.ai .quiz-chat-bubble li { margin-bottom: 4px; line-height: 1.65; }
.quiz-chat-msg.ai .quiz-chat-bubble li:last-child { margin-bottom: 0; }
.quiz-chat-msg.ai .quiz-chat-bubble li > ul, .quiz-chat-msg.ai .quiz-chat-bubble li > ol { margin: 3px 0; }
.quiz-chat-msg.ai .quiz-chat-bubble h1, .quiz-chat-msg.ai .quiz-chat-bubble h2, .quiz-chat-msg.ai .quiz-chat-bubble h3 { font-weight: 700; line-height: 1.4; margin: 13px 0 5px; color: var(--text-primary); }
.quiz-chat-msg.ai .quiz-chat-bubble h1:first-child, .quiz-chat-msg.ai .quiz-chat-bubble h2:first-child, .quiz-chat-msg.ai .quiz-chat-bubble h3:first-child { margin-top: 0; }
.quiz-chat-msg.ai .quiz-chat-bubble h1 { font-size: 15px; }
.quiz-chat-msg.ai .quiz-chat-bubble h2 { font-size: 14px; }
.quiz-chat-msg.ai .quiz-chat-bubble h3 { font-size: 13.5px; }
.quiz-chat-msg.ai .quiz-chat-bubble code { background: rgba(37,99,235,0.08); color: var(--accent); border-radius: 4px; padding: 1px 5px; font-size: 12px; font-family: 'SF Mono','Fira Code',monospace; }
.quiz-chat-msg.ai .quiz-chat-bubble pre { background: var(--surface-container-highest); border-radius: 8px; padding: 11px 13px; overflow-x: auto; margin: 7px 0; border: 1px solid var(--glass-border); }
.quiz-chat-msg.ai .quiz-chat-bubble pre code { background: none; padding: 0; color: var(--text-primary); font-size: 12px; }
.quiz-chat-msg.ai .quiz-chat-bubble blockquote { border-left: 3px solid rgba(37,99,235,0.35); margin: 7px 0; padding: 3px 11px; color: var(--text-secondary); font-style: italic; }
.quiz-chat-msg.ai .quiz-chat-bubble hr { border: none; border-top: 1px solid var(--glass-border); margin: 10px 0; }
.quiz-chat-msg.ai .quiz-chat-bubble table { width: 100%; border-collapse: collapse; margin: 7px 0; font-size: 12.5px; }
.quiz-chat-msg.ai .quiz-chat-bubble th, .quiz-chat-msg.ai .quiz-chat-bubble td { padding: 5px 9px; border: 1px solid var(--glass-border); text-align: left; }
.quiz-chat-msg.ai .quiz-chat-bubble th { background: rgba(37,99,235,0.06); font-weight: 700; }

/* 입력창 */
.quiz-chat-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--glass-border); align-items: flex-end; background: var(--glass-bg-hover); flex-shrink: 0; }
.quiz-chat-input { flex: 1; padding: 8px 12px; font-size: 13.5px; border-radius: var(--radius-md); border: 1px solid var(--glass-border); background: var(--glass-bg); color: var(--text-primary); outline: none; resize: none; max-height: 100px; overflow-y: auto; line-height: 1.5; font-family: var(--font); transition: border-color var(--transition); }
.quiz-chat-input:focus { border-color: rgba(37,99,235,0.4); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }
.quiz-chat-send { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); border: none; background: var(--accent-gradient); color: #fff; cursor: pointer; transition: opacity var(--transition), transform var(--transition); flex-shrink: 0; }
.quiz-chat-send:hover { opacity: 0.88; transform: scale(1.04); }
.quiz-chat-send:disabled { background: var(--glass-border); cursor: not-allowed; transform: none; opacity: 1; }

.quiz-chat-limit { font-size: 11px; color: var(--text-muted); text-align: center; padding: 2px 0; }
.quiz-chat-limit-notice { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0; padding: 9px 11px; background: rgba(245,158,11,0.07); border: 1px solid rgba(245,158,11,0.22); border-radius: var(--radius-md); }
.quiz-chat-limit-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.quiz-chat-limit-body { display: flex; flex-direction: column; gap: 5px; }
.quiz-chat-limit-main { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.quiz-chat-limit-sub { font-size: 11.5px; color: var(--text-muted); }
.quiz-chat-buy-btn { align-self: flex-start; margin-top: 2px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: #fff; background: var(--accent); border: none; border-radius: var(--radius-sm); cursor: pointer; transition: opacity 0.15s; }
.quiz-chat-buy-btn:hover { opacity: 0.85; }
.quiz-chat-buy-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* 모바일: 카드 아래로 */
@media (max-width: 900px) {
  .quiz-layout { flex-direction: column; }
  .quiz-layout.chat-open { max-width: 100%; }
  .quiz-layout.chat-open .quiz-card-container { width: 100%; }
  .quiz-chat-panel { flex: none; width: 100%; position: static; height: 400px; border-radius: var(--radius-md); }
}

/* ─── Scrap Page ─── */
.scrap-header { padding: clamp(32px,5vw,56px) 0 clamp(20px,3vw,32px); }
.scrap-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.scrap-count { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.scrap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 40px; }
.scrap-card {
  background: var(--glass-bg); border: 1px solid rgba(245,158,11,0.12);
  border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 12px;
  transition: all var(--transition);
}
.scrap-card:hover { border-color: rgba(245,158,11,0.3); background: var(--glass-bg-hover); }
.scrap-card.scrap-expanded .scrap-detail { display: block !important; }
.scrap-card.scrap-expanded .scrap-summary { display: none; }
.scrap-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.scrap-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.scrap-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-full); border: 1px solid var(--glass-border); color: var(--text-secondary); background: var(--glass-bg-hover); }
.scrap-badge.amber { color: #f59e0b; border-color: rgba(245,158,11,0.3); background: rgba(245,158,11,0.08); }
.scrap-remove-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; border-radius: var(--radius-xs); transition: color var(--transition); flex-shrink: 0; }
.scrap-remove-btn:hover { color: var(--error); }
.scrap-question { font-size: 14px; font-weight: 600; line-height: 1.6; color: var(--text-primary); }
.scrap-question p { margin: 4px 0; }
.scrap-answer { font-size: 13px; color: var(--success); font-weight: 600; }
.scrap-expl-toggle { background: none; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; padding: 0; font-family: var(--font); transition: color var(--transition); text-align: left; }
.scrap-expl-toggle:hover { color: var(--text-secondary); }
.scrap-expl { font-size: 13px; color: var(--text-secondary); line-height: 1.7; padding-top: 10px; border-top: 1px solid var(--glass-border); }
.scrap-expl p { margin: 4px 0; }
.scrap-empty { text-align: center; padding: 80px 20px; }
.scrap-empty-icon { font-size: 52px; margin-bottom: 16px; }
.scrap-empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.scrap-empty-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: 28px; }

/* ─── History Page ─── */
.history-header { padding: clamp(32px,5vw,56px) 0 clamp(20px,3vw,32px); }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.history-card { background: var(--surface-container); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 24px; transition: all 0.3s ease; display: flex; flex-direction: column; gap: 14px; }
.history-card:hover { transform: translateY(-4px); box-shadow: 0 12px 32px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.05), 0 0 0 1px rgba(37,99,235,0.08); }
.history-card.selected { border-color: rgba(59,130,246,0.5); background: rgba(37,99,235,0.1); }
.history-card.selected .scrap-sq-check-mark { display: flex; }
.history-card .scrap-sq-check-mark { display: none; position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; background: #3b82f6; color: #fff; font-size: 14px; font-weight: 700; align-items: center; justify-content: center; }
.history-card { position: relative; }
.history-card-icon { font-size: 32px; }
.history-card-title { font-size: 15px; font-weight: 700; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-card-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.history-meta-chip { font-size: 11px; font-weight: 600; padding: 3px 10px; background: var(--glass-bg-hover); border: 1px solid var(--glass-border); border-radius: var(--radius-full); color: var(--text-secondary); }
.history-card-score { font-size: 22px; font-weight: 800; }
.history-card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.history-empty { text-align: center; padding: 80px 20px; }
.history-empty-icon { font-size: 52px; margin-bottom: 16px; }
.history-empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.history-empty-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: 28px; }

/* ─── Animations ─── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.quiz-card.card-enter { animation: cardIn 0.25s ease both; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-4px)} 40%{transform:translateX(4px)} 60%{transform:translateX(-3px)} 80%{transform:translateX(3px)} }
@keyframes correctPulse { 0%{box-shadow:var(--shadow-glass)} 50%{box-shadow:0 0 50px rgba(16,185,129,0.2)} 100%{box-shadow:var(--shadow-glass)} }
@keyframes feedbackPop { 0%{opacity:0;transform:translate(-50%,-50%) scale(0.3)} 40%{opacity:1;transform:translate(-50%,-50%) scale(1.2)} 60%{transform:translate(-50%,-50%) scale(0.95)} 80%{opacity:1;transform:translate(-50%,-50%) scale(1.05)} 100%{opacity:0;transform:translate(-50%,-50%) scale(1)} }
@keyframes dotPulse { 0%,100%{transform:scale(1);opacity:0.5} 50%{transform:scale(1.4);opacity:1} }
@keyframes slideInRight { from{opacity:0;transform:translateX(24px)} to{opacity:1;transform:translateX(0)} }
@keyframes slideOutRight { from{opacity:1;transform:translateX(0)} to{opacity:0;transform:translateX(24px)} }

/* ─── Mobile Bottom Navigation ─── */
.mobile-bottom-nav { display: none; }

/* ─── Social Login ─── */
.social-login-btns { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-bottom: 4px; }
.btn-google { background: #fff; color: #3c4043; border: 1px solid #dadce0 !important; font-weight: 600; }
.btn-google:hover:not(:disabled) { background: #f8f9fa; box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
.btn-kakao { background: #FEE500; color: #191919; border: none !important; font-weight: 700; }
.btn-kakao:hover:not(:disabled) { background: #F0D900; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(254,229,0,0.35); }
.btn-naver { background: #03C75A; color: #fff; border: none !important; font-weight: 700; }
.btn-naver:hover:not(:disabled) { background: #02B351; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(3,199,90,0.35); }
.naver-n { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; background: white; color: #03C75A; font-size: 11px; font-weight: 900; border-radius: 2px; flex-shrink: 0; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  /* Nav */
  .nav-links { display: none; }
  .nav-username { display: none; }
  .nav-logout-btn { display: none; }
  .nav-dropdown { display: none !important; }
  .nav-inner { gap: 8px; }
  .nav-plan-badge { font-size: 11px; padding: 4px 10px; }

  /* Hero */
  .hero-title { letter-spacing: -1px; }
  .hero-subtitle { margin-bottom: 32px; }

  /* Upload */
  .upload-card { padding: 20px 16px; border-radius: var(--radius-lg); }
  .upload-zone { padding: 28px 16px; }
  .upload-icon { font-size: 36px; }
  .upload-title { font-size: 15px; }
  .type-options { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .type-option-label { padding: 10px 6px; font-size: 12px; gap: 4px; }
  .type-option-label .type-icon { font-size: 18px; }
  .settings-pill span { padding: 10px 4px; font-size: 12.5px; }
  .settings-segment-item span { font-size: 12.5px; padding: 8px 4px; }
  .count-credit-chip { font-size: 11px; }
  .count-slider::-webkit-slider-thumb { width: 26px; height: 26px; }

  /* Pricing */
  .pricing-grid { grid-template-columns: 1fr !important; max-width: 400px !important; }

  /* Features */
  .features-grid { grid-template-columns: 1fr 1fr; }

  /* Modal */
  .modal { padding: 24px 16px; max-width: calc(100vw - 32px); }
  .modal-icon { font-size: 40px; margin-bottom: 14px; }
  .modal-title { font-size: 19px; }
  .modal-desc { font-size: 14px; margin-bottom: 20px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; justify-content: center; }

  /* Quiz Topbar */
  .quiz-topbar { padding: 10px 16px; }
  .quiz-topbar-inner { gap: 12px; }

  /* Quiz */
  .quiz-main { padding-top: calc(var(--nav-height) + 74px); padding-bottom: calc(72px + 16px); }
  .quiz-card { padding: 20px 16px; }
  .quiz-question { font-size: 16px; margin-bottom: 20px; }
  .quiz-option { padding: 13px 14px; font-size: 14px; }
  .option-marker { width: 28px; height: 28px; font-size: 12px; flex-shrink: 0; }
  .ox-options { gap: 12px; }
  .ox-option { padding: 20px 12px; font-size: 40px; min-height: 44px; }
  .quiz-actions { flex-direction: column-reverse; }
  .quiz-actions .btn { width: 100%; justify-content: center; }
  .short-answer-input { min-height: 90px; font-size: 16px; /* 16px prevents iOS zoom */ }

  /* Results */
  .results-wrap { padding-top: calc(var(--nav-height) + 24px); padding-bottom: calc(72px + 20px); }
  .results-card { padding: 28px 20px; }
  .results-actions { flex-direction: column; }
  .results-actions .btn { width: 100%; justify-content: center; }
  .results-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .results-stat { padding: 12px 8px; }
  .results-stat-num { font-size: 22px; }

  /* Toast — above bottom nav + safe area */
  .toast-container { bottom: calc(72px + env(safe-area-inset-bottom, 8px) + 8px); right: 12px; left: 12px; }
  .toast { min-width: unset; max-width: 100%; width: 100%; }

  /* History */
  .history-grid { grid-template-columns: 1fr; }

  /* Upgrade Banner */
  .upgrade-banner { flex-direction: column; text-align: center; }

  /* Footer */
  .footer { padding: 28px 0 calc(72px + 20px); }
  .footer-links { gap: 16px; }

  /* Bottom nav padding for pages */
  .page { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }

  /* Mobile Bottom Nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(0,0,0,0.07);
    padding: 4px 0 env(safe-area-inset-bottom, 4px);
    justify-content: space-around;
    align-items: stretch;
    box-shadow: 0 -1px 0 rgba(0,0,0,0.07), 0 -4px 16px rgba(0,0,0,0.06);
  }
  .mbn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 8px 4px 6px; text-decoration: none;
    color: var(--text-secondary); font-family: var(--font-label); font-size: 10px; font-weight: 600;
    flex: 1; min-height: 56px;
    transition: all var(--transition);
    letter-spacing: 1px; text-transform: uppercase;
  }
  .mbn-item.active { color: #2563eb; background: rgba(37,99,235,0.08); border-radius: var(--radius-md); margin: 4px 2px; }
  .mbn-item.active .mbn-icon { filter: drop-shadow(0 0 6px rgba(37,99,235,0.4)); }
  .mbn-icon { font-size: 22px; line-height: 1; display: block; transition: filter var(--transition); }

  /* Touch targets */
  .file-info-remove { padding: 10px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
  .scrap-remove-btn { padding: 10px; min-width: 44px; min-height: 44px; display: flex; align-items: center; justify-content: center; }
}

/* ─── Game Active Badge (cross-page) ─── */
#game-active-badge {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 80px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  background: rgba(15,23,42,0.88);
  border: 1px solid rgba(52,211,153,0.5);
  border-radius: var(--radius-full);
  padding: 10px 20px;
  font-size: 13px; font-weight: 700; color: #34d399;
  text-decoration: none; cursor: pointer;
  z-index: 110;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 24px rgba(52,211,153,0.15);
  white-space: nowrap;
  animation: slideInUp 0.3s ease;
}
#game-active-badge:hover { background: rgba(15,23,42,0.95); }
#game-active-badge.game-badge-matched {
  border-color: rgba(239,68,68,0.7);
  color: #f87171;
  box-shadow: 0 4px 24px rgba(239,68,68,0.25);
  animation: slideInUp 0.3s ease, badgePulse 1s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { transform: translateX(-50%) scale(1); box-shadow: 0 4px 24px rgba(239,68,68,0.25); }
  50% { transform: translateX(-50%) scale(1.05); box-shadow: 0 4px 32px rgba(239,68,68,0.4); }
}
@media (min-width: 641px) { #game-active-badge { bottom: 24px; } }

/* ─── Very Small Screens (< 360px) ─── */
@media (max-width: 360px) {
  .modal { padding: 20px 14px; }
  .modal-icon { font-size: 32px; }
  .modal-title { font-size: 17px; }
  .hero-title { font-size: 28px; }
  .nav-plan-badge { font-size: 10px; padding: 3px 8px; }
  .nav-avatar, .nav-avatar-emoji { width: 28px; height: 28px; font-size: 16px; }
  .quiz-question { font-size: 15px; }
  .quiz-option { padding: 11px 12px; font-size: 13px; }
  .option-marker { width: 24px; height: 24px; font-size: 11px; }
  .ox-option { padding: 16px 10px; font-size: 32px; }
  .history-card { padding: 16px; gap: 10px; }
  .history-card-icon { font-size: 24px; }
  .scrap-sq-grid { grid-template-columns: 1fr !important; }
  .modal { max-width: calc(100vw - 24px) !important; padding: 18px 12px; }
  .modal-overlay { padding: 12px; }
  .nav-inner { gap: 4px; padding: 0 8px; }
  .nav-logo-text { font-size: 16px; }
}

/* ─── 저사양 기기 성능 최적화 ─── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ─── 모바일 성능 최적화 (backdrop-filter 제거) ─── */
@media (hover: none) and (pointer: coarse) {
  .glass, .nav, .upload-card, .quiz-card, .quiz-topbar, .results-card,
  .toast, .modal-overlay, .modal, .mobile-bottom-nav, #game-active-badge,
  .footer { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  .nav { background: rgba(255,255,255,0.97); }
  .quiz-topbar { background: rgba(255,255,255,0.97); }
  .mobile-bottom-nav { background: rgba(255,255,255,0.97); }
  .modal-overlay { background: rgba(15,23,42,0.45); }
  .upload-card, .quiz-card, .results-card { background: var(--surface-container); }
  .toast { background: var(--surface-container-high); }
  #game-active-badge { background: rgba(15,23,42,0.88); }
}

/* ─── 피드백 플로팅 버튼 (전 페이지 공통) ─── */
.feedback-fab {
  position: fixed; bottom: 80px; right: 16px; z-index: 90;
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: var(--radius-full);
  background: var(--accent-gradient);
  box-shadow: 0 4px 20px rgba(37,99,235,0.45), inset 0 1px 0 rgba(255,255,255,0.15);
  text-decoration: none; font-size: 13px; font-weight: 700;
  color: #fff; transition: transform 0.2s;
}
.feedback-fab:hover { transform: scale(1.05); }
.feedback-fab span { font-size: 18px; }

/* ─── Tablet (481-768px) ─── */
@media (min-width: 481px) and (max-width: 768px) {
  .features-grid { grid-template-columns: 1fr 1fr; }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-width: 420px; }
}

/* ─── Global Input Focus ─── */
input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: rgba(37,99,235,0.5) !important;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1) !important;
}

/* ─── Scrollbar & Selection ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.14); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }
::selection { background: rgba(37,99,235,0.18); color: var(--text-primary); }

/* ─── Dark Mode ─── */
[data-theme="dark"] {
  --bg-primary: #0c0f1a;
  --bg-secondary: #131728;
  --bg-tertiary: #1a1f33;

  --glass-bg: rgba(255,255,255,0.07);
  --glass-bg-hover: rgba(255,255,255,0.12);
  --glass-border: rgba(255,255,255,0.10);
  --glass-border-hover: rgba(255,255,255,0.20);
  --pill-bg: rgba(255, 255, 255, 0.09);

  --surface: #0c0f1a;
  --surface-container: #181d30;
  --surface-container-high: #1e2438;
  --surface-container-highest: #242c48;

  --text-primary: #eef2ff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --success: #10b981;
  --success-bg: rgba(16,185,129,0.12);
  --error: #ef4444;
  --error-bg: rgba(239,68,68,0.12);

  --shadow-glass: 0 1px 0 rgba(255,255,255,0.06) inset, 0 4px 20px rgba(0,0,0,0.5), 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 20px 56px rgba(0,0,0,0.6), 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] body { color-scheme: dark; }

[data-theme="dark"] .bg-gradient {
  background:
    radial-gradient(ellipse 65% 40% at 50% -5%, rgba(37,99,235,0.18) 0%, transparent 60%),
    radial-gradient(ellipse 45% 35% at 0% 60%, rgba(79,112,247,0.10) 0%, transparent 55%),
    radial-gradient(ellipse 35% 35% at 100% 70%, rgba(99,102,241,0.10) 0%, transparent 55%);
}

[data-theme="dark"] .nav {
  background: rgba(12,15,26,0.90);
  border-bottom-color: rgba(255,255,255,0.08);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 4px 20px rgba(0,0,0,0.4);
}

[data-theme="dark"] .mobile-bottom-nav {
  background: rgba(12,15,26,0.95);
  border-top-color: rgba(255,255,255,0.08);
  box-shadow: 0 -1px 0 rgba(255,255,255,0.06), 0 -4px 16px rgba(0,0,0,0.4);
}

[data-theme="dark"] .loading-overlay { background: rgba(12,15,26,0.92); }

[data-theme="dark"] .quiz-topbar {
  background: rgba(12,15,26,0.92);
  border-bottom-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .quiz-progress-bar { background: rgba(255,255,255,0.10); }
[data-theme="dark"] .score-ring-bg { stroke: rgba(255,255,255,0.12); }

[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-secondary); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

[data-theme="dark"] .btn-google { background: #1e2438; color: #eef2ff; border-color: rgba(255,255,255,0.15) !important; }
[data-theme="dark"] .btn-google:hover { background: #242c48; }

/* 다크모드 전환 애니메이션 */
html { transition: background-color 0.2s ease; }
body, .nav, .mobile-bottom-nav, .glass { transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease; }

/* KaTeX 렌더링 실패(빨간 에러 텍스트) 숨김 — 최후 방어선 */
.katex-error { display: none !important; }

/* 긴 수식 오버플로우 방지 — 카드 경계 밖으로 넘치지 않도록 */
.katex-display { overflow-x: auto; overflow-y: hidden; max-width: 100%; padding-bottom: 4px; }
.katex { max-width: 100%; }
.quiz-card, .quiz-explanation, #explanation-text,
.section-explanation, .formula-bubble-text, .ask-msg-ai,
.explanation-body, .explain-section-body { overflow-wrap: break-word; word-break: break-word; }
