/* ============================================================
   main.css — Global design system for Corearch Learn
   Gamified · Playful · Dark/Light Toggle
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&family=Nunito:wght@400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --primary:       #00C897;
  --primary-dark:  #00A87E;
  --primary-light: #00E5AD;
  --secondary:     #FF9600;
  --secondary-dark:#E08000;
  --accent:        #CE82FF;
  --danger:        #FF4B4B;
  --warning:       #FFD700;
  --info:          #4FC3F7;

  --xp-color:      #FF9600;
  --streak-color:  #FF6B35;
  --coin-color:    #FFD700;
  --health-green:  #22C55E;
  --health-yellow: #EAB308;
  --health-red:    #EF4444;

  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --radius-full: 9999px;

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.12);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.18);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.24);
  --shadow-glow-primary: 0 0 20px rgba(0,200,151,0.35);
  --shadow-glow-secondary: 0 0 20px rgba(255,150,0,0.35);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  --font-display: 'Baloo 2', cursive;
  --font-body:    'Nunito', sans-serif;

  --nav-height: 64px;
  --sidebar-width: 240px;
}

/* ── Dark Theme (default) ───────────────────────────────── */
[data-theme="dark"], :root {
  --bg:          #0F1923;
  --bg-2:        #162030;
  --surface:     #1A2B38;
  --surface-2:   #1F3345;
  --card:        #1E2F3E;
  --card-hover:  #243649;
  --border:      rgba(255,255,255,0.08);
  --border-2:    rgba(255,255,255,0.14);

  --text:        #F0F4F8;
  --text-2:      #A8BFCC;
  --text-3:      #6B8899;
  --text-inv:    #0F1923;

  --glass:       rgba(30, 47, 62, 0.7);
  --glass-border:rgba(255,255,255,0.1);
  --overlay:     rgba(0,0,0,0.6);

  --input-bg:    rgba(255,255,255,0.06);
  --input-border:rgba(255,255,255,0.12);
  --input-focus: rgba(0,200,151,0.3);

  --scrollbar-track: rgba(255,255,255,0.05);
  --scrollbar-thumb: rgba(255,255,255,0.15);
}

/* ── Light Theme ────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #F0F7F4;
  --bg-2:        #E8F4EF;
  --surface:     #FFFFFF;
  --surface-2:   #F5FAF8;
  --card:        #FFFFFF;
  --card-hover:  #F8FFFE;
  --border:      rgba(0,0,0,0.08);
  --border-2:    rgba(0,0,0,0.14);

  --text:        #1A2B38;
  --text-2:      #4A6572;
  --text-3:      #8BAAB8;
  --text-inv:    #FFFFFF;

  --glass:       rgba(255,255,255,0.8);
  --glass-border:rgba(0,0,0,0.08);
  --overlay:     rgba(0,0,0,0.4);

  --input-bg:    rgba(0,0,0,0.04);
  --input-border:rgba(0,0,0,0.12);
  --input-focus: rgba(0,200,151,0.2);

  --shadow-sm:  0 2px 8px rgba(0,0,0,0.07);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.13);

  --scrollbar-track: rgba(0,0,0,0.05);
  --scrollbar-thumb: rgba(0,0,0,0.15);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(0,200,151,0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(206,130,255,0.14), transparent 26%),
    radial-gradient(circle at bottom center, rgba(255,150,0,0.10), transparent 30%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
  position: relative;
  isolation: isolate;
}

body::before,
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background:
    radial-gradient(circle at 20% 20%, rgba(0,200,151,0.18), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(206,130,255,0.16), transparent 22%),
    radial-gradient(circle at 50% 85%, rgba(255,150,0,0.10), transparent 25%);
  opacity: 0.9;
}

body::after {
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 72px 72px;
  opacity: 0.18;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.88), rgba(0,0,0,0.22));
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 99px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); font-weight: 700; line-height: 1.2; color: var(--text); }
h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.4rem); }
h4 { font-size: 1.1rem; }
p  { color: var(--text-2); }
a  { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-light); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all var(--transition-bounce);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(0,200,151,0.4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 6px 25px rgba(0,200,151,0.5);
  transform: translateY(-2px);
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,150,0,0.4);
}
.btn-secondary:hover {
  box-shadow: 0 6px 25px rgba(255,150,0,0.5);
  transform: translateY(-2px);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 2px solid var(--border-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #CC0000);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,75,75,0.35);
}

.btn-sm  { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg  { padding: 16px 36px; font-size: 1.05rem; }
.btn-full{ width: 100%; }
.btn-icon{ padding: 10px; width: 42px; height: 42px; border-radius: var(--radius-full); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: inherit;
}
.btn:hover::after { opacity: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  backdrop-filter: blur(16px);
}
.card:hover {
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,200,151,0.12), 0 20px 40px rgba(0,0,0,0.12);
  transform: translateY(-2px);
  border-color: rgba(0,200,151,0.22);
}

.card-glass {
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

/* ── Inputs ──────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 0.85rem; font-weight: 700; color: var(--text-2); letter-spacing: 0.05em; text-transform: uppercase; }

.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--input-bg);
  border: 2px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all var(--transition);
  outline: none;
}
.input:focus { border-color: var(--primary); background: var(--input-focus); box-shadow: 0 0 0 3px rgba(0,200,151,0.15); }
.input::placeholder { color: var(--text-3); }
.input-error { border-color: var(--danger) !important; }

select.input { cursor: pointer; }
select.input option { background: var(--surface); color: var(--text); }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge-primary  { background: rgba(0,200,151,0.15);  color: var(--primary); }
.badge-secondary{ background: rgba(255,150,0,0.15);  color: var(--secondary); }
.badge-accent   { background: rgba(206,130,255,0.15); color: var(--accent); }
.badge-danger   { background: rgba(255,75,75,0.15);  color: var(--danger); }
.badge-level    { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; padding: 4px 12px; }

/* ── Progress bars ───────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  animation: shimmer 2s infinite;
}

.progress-bar.xp-bar .progress-fill {
  background: linear-gradient(90deg, var(--secondary), var(--warning));
}

/* ── XP pill ─────────────────────────────────────────────── */
.xp-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(255,150,0,0.15);
  border: 1px solid rgba(255,150,0,0.3);
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--secondary);
}

/* ── Streak pill ─────────────────────────────────────────── */
.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(255,107,53,0.15);
  border: 1px solid rgba(255,107,53,0.3);
  border-radius: var(--radius-full);
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--streak-color);
}

/* ── Avatar ──────────────────────────────────────────────── */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  border: 2px solid var(--border-2);
}
.avatar > img,
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
.avatar-sm  { width: 34px; height: 34px; font-size: 1rem; }
.avatar-lg  { width: 64px; height: 64px; font-size: 1.8rem; border-width: 3px; }
.avatar-xl  { width: 88px; height: 88px; font-size: 2.4rem; border-width: 4px; }

/* ── Avatar picker ──────────────────────────────────────── */
.avatar-picker-shell {
  display: grid;
  gap: 16px;
}
.avatar-picker-note {
  color: var(--text-3);
  font-size: 0.82rem;
  line-height: 1.5;
}
.avatar-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--surface-2);
}
.avatar-preview-label {
  color: var(--text-3);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.avatar-preview-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
}
.avatar-picker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 560px) {
  .avatar-picker-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.avatar-choice {
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  border: 2px solid rgba(255,255,255,0.10);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent), var(--surface-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition-bounce);
  position: relative;
  overflow: hidden;
  color: var(--text);
}
.avatar-choice:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow-primary);
}
.avatar-choice.selected {
  border-color: var(--secondary);
  box-shadow: var(--shadow-glow-secondary);
}
.avatar-choice .emoji {
  font-size: 2rem;
  line-height: 1;
}
.avatar-choice .photo-badge {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
}
.avatar-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 480px) {
  .avatar-tools { grid-template-columns: 1fr; }
}
.avatar-file-input {
  display: none;
}

/* ── Navigation (top nav) ────────────────────────────────── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02)), var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.navbar-brand {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 8px;
}

.navbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── App menu ───────────────────────────────────────────── */
.app-menu-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  height: 42px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-2);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent), var(--surface-2);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition-bounce);
  box-shadow: var(--shadow-sm);
}
.app-menu-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-primary);
}
.app-menu-trigger .menu-icon {
  font-size: 1.1rem;
  line-height: 1;
}
.app-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(1px);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.app-menu-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
.app-menu-panel {
  position: fixed;
  top: calc(var(--nav-height) + 12px);
  right: 16px;
  width: min(320px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent), var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,200,151,0.08);
  backdrop-filter: blur(18px);
  z-index: 190;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition-bounce);
}
.app-menu-panel.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}
.app-menu-head {
  padding: 16px 18px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.app-menu-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.app-menu-subtitle {
  color: var(--text-3);
  font-size: 0.78rem;
}
.app-menu-list {
  padding: 10px;
  display: grid;
  gap: 8px;
}
.app-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  transition: all var(--transition-bounce);
  text-decoration: none;
  font-weight: 700;
}
.app-menu-item:hover,
.app-menu-item.active {
  background: rgba(0, 200, 151, 0.12);
  border-color: rgba(0, 200, 151, 0.18);
  color: var(--primary);
  transform: translateX(4px);
}
.app-menu-item .menu-item-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.app-menu-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--text-3);
  font-size: 0.78rem;
}
@media (max-width: 640px) {
  .app-menu-panel {
    left: 16px;
    right: 16px;
    width: auto;
    top: calc(var(--nav-height) + 10px);
  }
  .app-menu-trigger {
    padding: 0 12px;
  }
}

/* ── Bottom nav (mobile) ─────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 64px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)), var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.14);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 8px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-bounce);
  text-decoration: none;
  color: var(--text-3);
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 56px;
}
.bottom-nav-item span.icon { font-size: 1.4rem; transition: transform var(--transition-bounce); }
.bottom-nav-item:hover { color: var(--primary); }
.bottom-nav-item:hover span.icon { transform: translateY(-3px); }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active span.icon { transform: translateY(-3px); filter: drop-shadow(0 0 6px var(--primary)); }

/* ── Sidebar (desktop) ───────────────────────────────────── */
.sidebar {
  display: none !important;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.92rem;
}
.sidebar-item span.icon { font-size: 1.2rem; }
.sidebar-item:hover { background: var(--surface-2); color: var(--primary); }
.sidebar-item.active { background: rgba(0,200,151,0.12); color: var(--primary); }
.sidebar-item.active span.icon { filter: drop-shadow(0 0 4px var(--primary)); }

/* ── Main content layout ─────────────────────────────────── */
.page-wrapper {
  padding-top: var(--nav-height);
  min-height: 100vh;
}

.main-content {
  padding: 28px 24px 100px;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

@media (min-width: 768px) {
  .main-content { margin-left: 0; padding-bottom: 40px; }
  .bottom-nav   { display: none; }
  .main-content { max-width: none; }
}

/* ── Section header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Grid layouts ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Toast notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.4s var(--transition-bounce) forwards;
  max-width: 320px;
  font-weight: 600;
  font-size: 0.9rem;
}
.toast.success { border-left: 4px solid var(--primary); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--secondary); }
.toast.info    { border-left: 4px solid var(--info); }
.toast.xp      { border-left: 4px solid var(--xp-color); background: rgba(255,150,0,0.1); }
.toast.level   { border-left: 4px solid var(--accent); background: rgba(206,130,255,0.1); }

.toast-exit { animation: toastOut 0.3s ease forwards; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(10px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: linear-gradient(180deg, rgba(255,255,255,0.04), transparent), var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: calc(var(--radius-xl) + 4px);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0,200,151,0.08);
  animation: slideUp 0.3s var(--transition-bounce);
  position: relative;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius-full);
  width: 32px; height: 32px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; }

/* ── Theme toggle ────────────────────────────────────────── */
.theme-toggle {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-full);
  width: 44px; height: 26px;
  cursor: pointer;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.theme-toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  transition: transform var(--transition-bounce), background var(--transition);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
}
[data-theme="light"] .theme-toggle-knob { transform: translateX(18px); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.empty-state-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }

/* ── Loading spinner ─────────────────────────────────────── */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-2);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), transparent), var(--input-bg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: auto;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; }

/* ── Locked overlay ──────────────────────────────────────── */
.locked-overlay {
.input:focus { border-color: var(--primary); background: var(--input-focus); box-shadow: 0 0 0 3px rgba(0,200,151,0.15), 0 12px 24px rgba(0,0,0,0.12); }
  overflow: hidden;
}
.locked-overlay::after {
  content: '🔒';
  position: absolute;
  inset: 0;
  background: rgba(15,25,35,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  backdrop-filter: blur(4px);
  border-radius: inherit;
}
.locked-overlay::before {
  content: attr(data-locked-msg);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 28px));
  z-index: 1;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

/* ── Confetti particle ───────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 10px; height: 10px;
  top: -10px;
  animation: confettiFall 3s ease-in forwards;
  z-index: 9999;
  pointer-events: none;
  border-radius: 2px;
}

/* ── Utility classes ─────────────────────────────────────── */
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-4       { gap: 4px; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.gap-20      { gap: 20px; }
.gap-24      { gap: 24px; }
.w-full      { width: 100%; }
.text-center { text-align: center; }
.text-sm     { font-size: 0.85rem; }
.text-xs     { font-size: 0.75rem; }
.text-lg     { font-size: 1.1rem; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 800; }
.text-primary{ color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-muted  { color: var(--text-3); }
.text-2      { color: var(--text-2); }
.mb-4        { margin-bottom: 4px; }
.mb-8        { margin-bottom: 8px; }
.mb-12       { margin-bottom: 12px; }
.mb-16       { margin-bottom: 16px; }
.mb-20       { margin-bottom: 20px; }
.mb-24       { margin-bottom: 24px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.hidden      { display: none !important; }
.relative    { position: relative; }
.overflow-hidden { overflow: hidden; }

/* ── Gradient text ───────────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.gradient-text-warm {
  background: linear-gradient(135deg, var(--secondary), var(--warning));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp     { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown   { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn     { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes pulse       { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes bounce-in   { 0% { transform: scale(0); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shimmer     { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes float       { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow-pulse  { 0%,100% { box-shadow: 0 0 10px rgba(0,200,151,0.3); } 50% { box-shadow: 0 0 25px rgba(0,200,151,0.7); } }
@keyframes toastIn     { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut    { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100%); } }
@keyframes confettiFall{
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes xpFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}
@keyframes checkmark {
  0%   { stroke-dashoffset: 50; }
  100% { stroke-dashoffset: 0; }
}
@keyframes heartbeat   { 0%,100%{transform:scale(1)}50%{transform:scale(1.2)} }

.animate-fade-in  { animation: fadeIn 0.3s ease forwards; }
.animate-slide-up { animation: slideUp 0.4s var(--transition-bounce) forwards; }
.animate-scale-in { animation: scaleIn 0.3s var(--transition-bounce) forwards; }
.animate-float    { animation: float 3s ease-in-out infinite; }
.animate-pulse    { animation: pulse 2s ease-in-out infinite; }
.animate-glow     { animation: glow-pulse 2s ease-in-out infinite; }
.animate-heartbeat{ animation: heartbeat 1s ease-in-out infinite; }

/* ── Stagger animation helpers ───────────────────────────── */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }

/* ── XP float popup ──────────────────────────────────────── */
.xp-float {
  position: fixed;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--secondary);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  pointer-events: none;
  z-index: 9999;
  animation: xpFloat 1.2s ease forwards;
}

/* ── Section divider ─────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  padding: 4px;
}
.tab {
  flex: 1;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.tab.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Responsive helpers ──────────────────────────────────── */
@media (max-width: 768px) {
  .main-content  { padding: 20px 16px 80px; }
  .navbar        { padding: 0 16px; }
  .hide-mobile   { display: none !important; }
  .show-mobile   { display: block !important; }
  .sidebar       { display: none; }
}
@media (min-width: 769px) {
  .hide-desktop  { display: none !important; }
  .show-mobile   { display: none !important; }
}