/* ===== Chemie Quest - Light Minimal Theme (POMEPOKO UI/UX BASE) ===== */
:root {
  --bg: #F7F7F8;
  --surface: #FFFFFF;
  --surface-2: #F2F4F7;
  --text: #111827;
  --muted: #6B7280;
  --border: rgba(17,24,39,0.10);
  --primary: #2563EB;
  --primary-contrast: #FFFFFF;
  --accent: #7C3AED;
  --danger: #DC2626;
  --success: #16A34A;
  --warning: #D97706;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-1: 0 10px 25px rgba(17,24,39,0.08);
  --shadow-2: 0 20px 50px rgba(17,24,39,0.12);
  --ring: rgba(37,99,235,0.35);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== App Bar ===== */
.app-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  padding: 0 16px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.app-title { font-size: 18px; font-weight: 700; flex: 1; }
.app-bar-right { display: flex; gap: 8px; align-items: center; }
.xp-badge, .streak-badge {
  font-size: 13px; font-weight: 600;
  background: var(--surface-2);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.icon-btn {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none;
  font-size: 20px; cursor: pointer;
  color: var(--text);
  border-radius: var(--radius-sm);
  text-decoration: none;
}
.icon-btn:focus-visible { outline: 2px solid var(--ring); }

/* ===== Body Scroll ===== */
.body-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: 80px;
}

/* ===== Screen system ===== */
.screen { display: none; gap: 24px; flex-direction: column; }
.screen.active { display: flex; }
.screen-title { font-size: 20px; font-weight: 700; }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card h3 { font-size: 18px; font-weight: 700; }
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.card.mini {
  padding: 24px 16px;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: transform 0.16s ease-out, box-shadow 0.16s ease-out;
}
.card.mini:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.card-icon { font-size: 28px; margin-bottom: 8px; }
.card-list { display: flex; flex-direction: column; gap: 12px; }

/* ===== Hero Card ===== */
.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
}
.hero-icon { font-size: 48px; margin-bottom: 8px; }
.hero-card h2 { font-size: 24px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding: 0 24px;
  border: none; border-radius: var(--radius-md);
  font-size: 16px; font-weight: 600;
  cursor: pointer;
  transition: background 0.16s;
}
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.btn.primary { background: var(--primary); color: var(--primary-contrast); }
.btn.primary:hover { opacity: 0.9; }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost { background: none; color: var(--primary); }
.danger-text { color: var(--danger) !important; }
.btn-group { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

/* ===== Form ===== */
.field-label { font-size: 14px; font-weight: 600; color: var(--muted); }
.input-field {
  width: 100%; height: 48px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  background: var(--surface);
  color: var(--text);
}
.input-field:focus { outline: 2px solid var(--ring); border-color: var(--primary); }
.textarea { height: auto; padding: 12px 16px; resize: vertical; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--bg);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-2);
  transition: opacity 0.2s;
}
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }

/* ===== Bottom Nav ===== */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 0;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px;
  padding: 8px 0;
  border: none; background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
}
.nav-item.active { color: var(--primary); font-weight: 600; }
.nav-icon { font-size: 20px; }
.nav-label { font-size: 11px; }

/* ===== Quiz ===== */
.quiz-header {
  display: flex; align-items: center; gap: 12px;
}
.quiz-progress-bar {
  flex: 1; height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s;
  width: 0%;
}
.quiz-counter { font-size: 14px; font-weight: 600; white-space: nowrap; }
.quiz-timer { font-size: 14px; color: var(--warning); font-weight: 600; }
.quiz-card { position: relative; }
.quiz-ab-badge {
  position: absolute; top: 16px; right: 16px;
  font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff;
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.quiz-prompt { font-size: 18px; line-height: 1.5; font-weight: 500; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  width: 100%;
  padding: 16px;
  text-align: left;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 16px;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
}
.quiz-option:hover { border-color: var(--primary); }
.quiz-option.correct { border-color: var(--success); background: #f0fdf4; }
.quiz-option.wrong { border-color: var(--danger); background: #fef2f2; }
.quiz-option:disabled { cursor: not-allowed; opacity: 0.8; }

/* ===== Result ===== */
.result-card { text-align: center; }
.result-icon { font-size: 48px; margin-bottom: 8px; }
.result-stats { font-size: 14px; color: var(--muted); }

/* ===== Summary ===== */
.summary-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  text-align: center; margin-bottom: 16px;
}
.summary-stat { font-size: 28px; font-weight: 700; }
.summary-stat-label { font-size: 12px; color: var(--muted); }
.summary-items { display: flex; flex-direction: column; gap: 8px; }
.summary-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: var(--radius-sm);
  font-size: 14px;
}
.summary-item.correct-bg { background: #f0fdf4; }
.summary-item.wrong-bg { background: #fef2f2; }

/* ===== Progress Bars ===== */
.progress-bar-wrap {
  height: 8px; background: var(--surface-2);
  border-radius: 4px; overflow: hidden; margin-top: 4px;
}
.progress-bar-inner { height: 100%; border-radius: 4px; transition: width 0.3s; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 340px; width: 90%;
  box-shadow: var(--shadow-2);
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* ===== Formelsammlung ===== */
.formula-card { padding: 20px 24px; gap: 8px; }
.formula-name { font-size: 16px; font-weight: 700; color: var(--primary); }
.formula-latex { font-size: 18px; padding: 8px 0; overflow-x: auto; }
.formula-example { font-size: 13px; color: var(--muted); }

/* ===== Utility ===== */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.text-center { text-align: center; }

/* ===== Responsive ===== */
@media(min-width:600px) {
  .body-scroll { max-width: 560px; margin: 0 auto; }
  .card-grid { grid-template-columns: repeat(4, 1fr); }
}
@supports(padding:max(0px)) {
  .app-bar { padding-top: max(0px, env(safe-area-inset-top)); }
}
