/* MemoryCraftAI — styles.css v13 */

/* ── VARIABLES ─────────────────────────────────────────────────── */
:root {
  --bg:        #0e1214;
  --surface:   #141a1e;
  --surface2:  #1a2228;
  --surface3:  #1f2a32;
  --border:    rgba(65,145,161,0.28);
  --border-hi: rgba(65,145,161,0.55);
  --accent:    #4191a1;
  --accent2:   #5bb3c4;
  --accent-dim:rgba(65,145,161,0.15);
  --text:      #f0f4f6;
  --muted:     #7a9aa8;
  --danger:    #f87171;
  --gold:      #f6ad55;
  --sidebar-w: 240px;
  --radius:    14px;
  --radius-sm: 9px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Funnel Display', sans-serif;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Noise + gradient background */
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(65,145,161,0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 90% 100%, rgba(65,145,161,0.05) 0%, transparent 60%),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

/* ── SIDEBAR ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, #111820 0%, #0e1214 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.85rem 1.5rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  gap: .2rem;
  transition: width .25s ease, padding .25s ease;
  overflow: hidden;
  max-width: var(--sidebar-w);
}

.sidebar.collapsed { width: 64px; padding: 1.5rem .5rem; }
.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .user-info { display: none; }
.sidebar.collapsed #user-menu { display: none !important; }
.sidebar.collapsed .sidebar-brand { justify-content: center; gap: 0; }
.sidebar.collapsed .user-pill { padding: .5rem; justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: .65rem 0; }

.sidebar-toggle {
  position: absolute; top: 1.4rem; right: -13px;
  width: 26px; height: 26px;
  background: var(--surface2);
  border: 1px solid var(--border-hi);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 300;
  font-size: .65rem; color: var(--accent);
  transition: background .15s, transform .25s;
}
.sidebar-toggle:hover { background: var(--accent-dim); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-brand {
  display: flex; align-items: center; gap: .65rem;
  padding: .4rem .7rem;
  margin-bottom: 1.4rem;
  cursor: pointer;
  white-space: nowrap;
}
.sidebar-brand img { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.sidebar-brand span { font-weight: 800; font-size: .88rem; letter-spacing: .1em; color: var(--accent2); text-transform: uppercase; }

.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .87rem; color: var(--muted); font-weight: 500;
  transition: all .15s; border: none; background: none;
  width: 100%; text-align: left; white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: var(--accent-dim); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(65,145,161,.22), rgba(65,145,161,.1));
  color: var(--accent2);
  border: 1px solid rgba(65,145,161,.25);
}
.nav-item .icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; }
.nav-label { overflow: hidden; }

.nav-section-label {
  font-size: .62rem; font-weight: 700; letter-spacing: .14em;
  color: var(--accent); text-transform: uppercase;
  padding: 1rem .85rem .3rem; opacity: .5; white-space: nowrap;
}

.app-nav { display: none; }
.sidebar-spacer { flex: 1; }

.user-pill {
  display: flex; align-items: center; gap: .65rem;
  padding: .7rem .85rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.user-pill:hover { border-color: var(--accent); background: var(--surface3); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #2a6b78);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; flex-shrink: 0; overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-info { flex: 1; min-width: 0; overflow: hidden; }
.user-name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: .68rem; color: var(--accent); font-weight: 600; }

#user-menu {
  display: none;
  position: absolute; bottom: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface2); border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm); overflow: hidden; z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
}
#user-menu .nav-item { border-radius: 0; }
#user-menu .nav-item:last-child { border-top: 1px solid var(--border); color: var(--danger); }
#user-menu .nav-item:last-child:hover { background: rgba(248,113,113,.08); color: var(--danger); }

/* ── MOBILE ────────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.7); z-index: 150;
  backdrop-filter: blur(4px);
}
.sidebar-overlay.visible { display: block; }

.mobile-topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(135deg, #111820, #0e1214);
  border-bottom: 1px solid var(--border);
  align-items: center; justify-content: space-between;
  padding: 0 1rem; z-index: 140;
}
.mobile-topbar-brand { display: flex; align-items: center; gap: .6rem; }
.mobile-topbar-brand img { width: 28px; height: 28px; object-fit: contain; }
.mobile-topbar-brand span { font-weight: 800; font-size: .85rem; color: var(--accent2); text-transform: uppercase; letter-spacing: .1em; }
.hamburger {
  width: 38px; height: 38px; border: none; background: none;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  cursor: pointer; padding: 4px; border-radius: 8px; transition: background .15s;
}
.hamburger:hover { background: var(--accent-dim); }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--accent2); border-radius: 2px; transition: all .25s; }
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── PAGE LAYOUT ───────────────────────────────────────────────── */
.page-area {
  margin-left: var(--sidebar-w);
  flex: 1; min-height: 100vh;
  transition: margin-left .25s ease;
  display: flex; justify-content: center;
  position: relative; z-index: 1;
}
.sidebar.collapsed ~ .page-area { margin-left: 64px; }

/* ── LANDING ───────────────────────────────────────────────────── */
#landing {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 3rem 2rem;
  position: relative;
}
#landing::after {
  content: '';
  position: absolute; width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(65,145,161,.1) 0%, transparent 65%);
  top: 50%; left: 50%; transform: translate(-50%,-55%);
  pointer-events: none;
}
.hero-h1 { font-size: clamp(2.4rem, 5vw, 4.2rem); font-weight: 800; line-height: 1.05; margin-bottom: 1.2rem; }
.hero-h1 span { background: linear-gradient(135deg, var(--accent), var(--accent2), #7dd3e0); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { font-size: 1rem; color: var(--muted); max-width: 540px; line-height: 1.75; margin-bottom: 2.5rem; }

.btn {
  display: inline-flex; align-items: center; gap: .6rem;
  font-family: 'Funnel Display', sans-serif; font-size: .9rem; font-weight: 700;
  padding: .8rem 1.8rem; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: all .2s; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #2e7a8a);
  color: #fff;
  box-shadow: 0 4px 20px rgba(65,145,161,.3);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent2), var(--accent)); transform: translateY(-1px); box-shadow: 0 8px 30px rgba(65,145,161,.4); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border-hi); }
.btn-secondary:hover { border-color: var(--accent2); color: var(--accent2); background: var(--surface3); }
.btn-ghost { background: transparent; color: var(--accent); font-size: .82rem; font-weight: 600; padding: .3rem .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-family: 'Funnel Display', sans-serif; transition: all .18s; }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--accent2); }
.btn-ghost:hover { color: var(--text); }
.btn-accent-outline { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); font-size: .82rem; padding: .45rem 1rem; border-radius: var(--radius-sm); }
.btn-accent-outline:hover { background: var(--accent-dim); }

.hero-btns { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; margin-bottom: 3.5rem; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.2rem; max-width: 900px; width: 100%; }
.feat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem; text-align: left;
  transition: border-color .2s, transform .2s;
  position: relative; overflow: hidden;
}
.feat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0; transition: opacity .2s;
}
.feat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feat-card:hover::before { opacity: 1; }
.feat-icon { font-size: 1.5rem; margin-bottom: .8rem; }
.feat-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; color: var(--text); }
.feat-card p { font-size: .82rem; color: var(--muted); line-height: 1.6; }

/* ── APP SHELL ─────────────────────────────────────────────────── */
#app { display: none; }
.main { padding: 2rem 2.5rem 2rem 2rem; max-width: 1200px; width: 100%; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; }
.page-header { margin-bottom: 1.8rem; }
.page-header h2 { font-size: 1.9rem; font-weight: 800; margin-bottom: .3rem; background: linear-gradient(135deg, var(--text), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.page-header p { color: var(--muted); font-size: .92rem; }

/* ── CARDS ─────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1rem;
}
.card h3 { font-size: 1rem; font-weight: 700; margin-bottom: .4rem; }
.card p { font-size: .85rem; color: var(--muted); line-height: 1.6; }
.card-accent {
  background: linear-gradient(135deg, rgba(65,145,161,.1), rgba(65,145,161,.03));
  border-color: rgba(65,145,161,.4);
}

/* ── TWO COLUMN LAYOUT ─────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.two-col-left { display: grid; grid-template-columns: 340px 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 900px) { .two-col, .two-col-left { grid-template-columns: 1fr; } }

/* ── DASHBOARD ─────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.4rem;
  position: relative; overflow: hidden;
  transition: border-color .2s;
}
.stat-card::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: .4;
}
.stat-card:hover { border-color: var(--border-hi); }
.stat-val { font-size: 2.2rem; font-weight: 800; margin-bottom: .2rem; color: var(--accent2); }
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.dashboard-grid .card { margin-bottom: 0; }
.dashboard-wide { grid-column: 1 / -1; }

/* ── QUIZ ──────────────────────────────────────────────────────── */
.quiz-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 700px) { .quiz-layout { grid-template-columns: 1fr; } }

.quiz-mode-panel { display: flex; flex-direction: column; gap: .6rem; position: relative; z-index: 10; }
.opt-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  cursor: pointer; transition: all .2s; text-align: left;
  display: flex; align-items: center; gap: .9rem;
}
.opt-card:hover { border-color: var(--accent); background: var(--surface3); }
.opt-card.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(65,145,161,.18), rgba(65,145,161,.06));
  box-shadow: 0 0 0 1px rgba(65,145,161,.2);
}
.opt-card .opt-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: var(--accent-dim); flex-shrink: 0; }
.opt-card.selected .opt-icon { background: rgba(65,145,161,.25); }
.opt-card-text h4 { font-size: .9rem; font-weight: 700; margin-bottom: .2rem; }
.opt-card-text p { font-size: .76rem; color: var(--muted); line-height: 1.4; }

.quiz-right-panel { min-width: 0; }

/* Topic grid for mode landing screens */
.topic-grid { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .8rem; }
.topic-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 999px; padding: .45rem 1rem;
  font-size: .82rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: all .18s; font-family: 'Funnel Display', sans-serif;
  display: flex; align-items: center; gap: .4rem;
}
.topic-btn:hover { border-color: var(--accent); color: var(--accent2); background: var(--accent-dim); }
.topic-btn .topic-score { font-size: .7rem; background: var(--accent-dim); color: var(--accent); padding: .1rem .4rem; border-radius: 999px; }
.topic-btn.perfect { opacity: .4; cursor: not-allowed; }

/* Quiz questions */
#quiz-display { display: none; margin-top: 0; }
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; margin-bottom: .9rem; }
.q-num { font-size: .7rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; margin-bottom: .5rem; }
.q-text { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; line-height: 1.5; }
.q-options { display: flex; flex-direction: column; gap: .4rem; }
.q-opt {
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: .7rem 1rem;
  cursor: pointer; font-size: .88rem; transition: all .15s;
  text-align: left; font-family: 'Funnel Display', sans-serif; color: var(--text);
  display: flex; align-items: center; gap: .75rem;
}
.q-opt:hover { border-color: var(--accent); background: var(--accent-dim); }
.q-opt.correct { border-color: var(--accent); background: rgba(65,145,161,.15); color: var(--accent2); }
.q-opt.wrong { border-color: var(--danger); background: rgba(248,113,113,.1); color: var(--danger); }
.q-opt-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: rgba(65,145,161,.12); border: 1.5px solid rgba(65,145,161,.3);
  font-weight: 700; font-size: .78rem; color: var(--accent); flex-shrink: 0; transition: all .15s;
}
.q-opt.correct .q-opt-letter { background: rgba(65,145,161,.25); border-color: var(--accent); }
.q-opt.wrong .q-opt-letter { background: rgba(248,113,113,.2); border-color: var(--danger); color: var(--danger); }
.q-opt-text { flex: 1; }
.q-opt-icon { width: 20px; text-align: center; font-weight: 700; flex-shrink: 0; font-size: .95rem; }
.q-opt:disabled { cursor: default; }
.q-explanation { margin-top: .7rem; padding: .75rem 1rem; background: var(--surface2); border-radius: var(--radius-sm); border-left: 3px solid var(--accent); font-size: .82rem; color: var(--muted); display: none; line-height: 1.6; }

/* ── LESSONS ───────────────────────────────────────────────────── */
.lessons-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1.4rem; align-items: start; }
@media (max-width: 700px) { .lessons-layout { grid-template-columns: 1fr; } }

.lessons-sidebar { display: flex; flex-direction: column; gap: 1rem; }

.jump-back-section h3 { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: .7rem; opacity: .8; }
.jump-back-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .9rem 1rem;
  cursor: pointer; transition: all .18s; margin-bottom: .5rem;
}
.jump-back-card:hover { border-color: var(--accent); background: var(--surface3); }
.jump-back-title { font-size: .88rem; font-weight: 600; margin-bottom: .2rem; }
.jump-back-teaser { font-size: .75rem; color: var(--accent); line-height: 1.4; }

.teaser-section h3 { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: .7rem; opacity: .7; }
.teaser-card {
  background: linear-gradient(135deg, rgba(65,145,161,.08), rgba(65,145,161,.02));
  border: 1px solid rgba(65,145,161,.2);
  border-radius: var(--radius-sm); padding: .85rem 1rem;
  cursor: pointer; transition: all .18s; margin-bottom: .5rem;
  display: flex; align-items: center; gap: .7rem;
}
.teaser-card:hover { border-color: var(--accent); background: rgba(65,145,161,.12); }
.teaser-icon { font-size: 1.1rem; flex-shrink: 0; }
.teaser-text { font-size: .82rem; color: var(--muted); line-height: 1.4; }
.teaser-text strong { color: var(--accent2); }

/* Lesson content */
.lesson-concepts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 600px) { .lesson-concepts-grid { grid-template-columns: 1fr; } }
.lesson-concept-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .2s; overflow: hidden; }
.lesson-concept-card:hover { border-color: var(--accent); }
.lesson-concept-header { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; }
.lesson-concept-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; background: rgba(65,145,161,.2); font-size: .68rem; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.lesson-concept-term { flex: 1; font-weight: 600; font-size: .88rem; }
.lesson-concept-chevron { font-size: .75rem; color: var(--muted); transition: transform .25s; }
.lesson-concept-def { max-height: 0; overflow: hidden; transition: max-height .3s ease, padding .3s; font-size: .83rem; color: var(--muted); line-height: 1.65; padding: 0 .9rem; }
.lesson-concept-card.expanded .lesson-concept-chevron { transform: rotate(180deg); }
.lesson-concept-card.expanded .lesson-concept-def { max-height: 200px; padding: .1rem .9rem .8rem; }

.lesson-deeper-card { overflow: hidden; }
.lesson-section-toggle { display: flex; align-items: center; gap: .6rem; width: 100%; border: none; background: none; color: var(--text); font-family: 'Funnel Display', sans-serif; cursor: pointer; padding: 0; }
.lesson-chevron { font-size: .75rem; color: var(--muted); transition: transform .25s; flex-shrink: 0; }
.lesson-section-body { max-height: 0; overflow: hidden; transition: max-height .35s ease, padding .35s; font-size: .88rem; color: var(--muted); line-height: 1.75; padding: 0; }
.lesson-deeper-card.open .lesson-chevron { transform: rotate(180deg); }
.lesson-deeper-card.open .lesson-section-body { max-height: 600px; padding: .75rem 0 .25rem; }

/* ── LEADERBOARD ───────────────────────────────────────────────── */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 1rem; margin-bottom: 1.5rem; }
.podium-place { display: flex; flex-direction: column; align-items: center; gap: .5rem; }
.podium-avatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #2a6b78); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.1rem; border: 3px solid var(--border); overflow: hidden; }
.podium-avatar img { width: 100%; height: 100%; object-fit: cover; }
.podium-place.first .podium-avatar { width: 64px; height: 64px; border-color: var(--gold); box-shadow: 0 0 20px rgba(246,173,85,.3); }
.podium-place.second .podium-avatar { border-color: #94a3b8; }
.podium-place.third .podium-avatar { border-color: #b45309; }
.podium-name { font-size: .78rem; font-weight: 600; color: var(--muted); max-width: 80px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-pts { font-size: .72rem; color: var(--accent); font-weight: 700; }
.podium-bar { border-radius: 6px 6px 0 0; width: 70px; }
.podium-place.first .podium-bar { height: 60px; background: linear-gradient(180deg, rgba(246,173,85,.3), rgba(246,173,85,.1)); border: 1px solid rgba(246,173,85,.3); }
.podium-place.second .podium-bar { height: 44px; background: linear-gradient(180deg, rgba(148,163,184,.2), rgba(148,163,184,.05)); border: 1px solid rgba(148,163,184,.2); }
.podium-place.third .podium-bar { height: 32px; background: linear-gradient(180deg, rgba(180,83,9,.2), rgba(180,83,9,.05)); border: 1px solid rgba(180,83,9,.2); }
.podium-rank { font-size: 1.2rem; }

.lb-row { display: flex; align-items: center; gap: 1rem; padding: .85rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; transition: border-color .15s; }
.lb-row:hover { border-color: var(--border-hi); }
.lb-rank { font-weight: 800; font-size: 1rem; width: 2rem; text-align: center; color: var(--muted); }
.lb-rank.gold { color: var(--gold); }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #b45309; }
.lb-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #2a6b78); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; overflow: hidden; flex-shrink: 0; }
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.lb-name { flex: 1; font-weight: 500; font-size: .9rem; }
.lb-score { font-weight: 700; color: var(--accent2); font-size: .9rem; }

/* ── ACTIVITY LOG ──────────────────────────────────────────────── */
.activity-row { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; transition: border-color .2s; }
.activity-row:hover { border-color: var(--border-hi); }
.activity-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-icon-quiz { background: rgba(65,145,161,.18); color: var(--accent2); }
.activity-icon-lesson { background: rgba(246,173,85,.14); color: var(--gold); }

/* ── SOCIAL ────────────────────────────────────────────────────── */
.social-tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.social-tab { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .45rem 1rem; font-size: .83rem; color: var(--muted); cursor: pointer; transition: all .18s; font-family: 'Funnel Display', sans-serif; font-weight: 600; }
.social-tab.active { background: linear-gradient(135deg, var(--accent), #2e7a8a); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(65,145,161,.3); }
.social-panel { display: none; }
.social-panel.active { display: block; }

.friend-row { display: flex; align-items: center; gap: 1rem; padding: .85rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; transition: border-color .15s; }
.friend-row:hover { border-color: var(--border-hi); }
.friend-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; overflow: hidden; }

/* ── SETTINGS & ACCOUNT ────────────────────────────────────────── */
.settings-group { margin-bottom: 1.8rem; }
.settings-group h3 { font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: .8rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); opacity: .8; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; }
.setting-info h4 { font-size: .88rem; font-weight: 600; margin-bottom: .15rem; }
.setting-info p { font-size: .78rem; color: var(--muted); }

.toggle { position: relative; width: 44px; height: 25px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface2); border: 1.5px solid var(--border); border-radius: 999px; cursor: pointer; transition: .2s; }
.toggle-slider::before { content:''; position:absolute; width:17px; height:17px; left:3px; top:2px; background:var(--muted); border-radius:50%; transition:.2s; }
.toggle input:checked + .toggle-slider { background: rgba(65,145,161,.25); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(19px); background: var(--accent2); }

.setting-select { background: var(--surface2); border: 1.5px solid var(--border); color: var(--text); font-family: 'Funnel Display', sans-serif; font-size: .85rem; padding: .45rem .8rem; border-radius: var(--radius-sm); outline: none; cursor: pointer; transition: border-color .2s; }
.setting-select:focus { border-color: var(--accent); }

.avatar-upload { width: 76px; height: 76px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #2a6b78); display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 800; cursor: pointer; border: 3px solid var(--border-hi); transition: border-color .2s, transform .2s; position: relative; overflow: hidden; }
.avatar-upload:hover { border-color: var(--accent2); transform: scale(1.04); }
.avatar-upload img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.profile-header { display: flex; align-items: center; gap: 1.5rem; padding: 1.4rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.5rem; background: linear-gradient(135deg, rgba(65,145,161,.06), transparent); }
.profile-header-info h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: .2rem; }
.profile-header-info p { font-size: .82rem; color: var(--muted); }

/* ── INPUTS ────────────────────────────────────────────────────── */
.input-group { display: flex; gap: .75rem; margin-top: 1.2rem; flex-wrap: wrap; }
.text-input {
  flex: 1; min-width: 200px;
  background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); font-family: 'Funnel Display', sans-serif;
  font-size: .92rem; padding: .8rem 1rem; border-radius: var(--radius-sm);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(65,145,161,.12); }
.text-input::placeholder { color: var(--muted); }

/* ── USERNAME MODAL ────────────────────────────────────────────── */
#username-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.75); z-index:9999; display:none; align-items:center; justify-content:center; backdrop-filter: blur(6px); }
#username-modal-overlay.active { display:flex; }
#username-modal { background: linear-gradient(135deg, var(--surface), var(--surface2)); border:1px solid var(--border-hi); border-radius:18px; padding:2.2rem 2rem; width:min(94vw,420px); box-shadow:0 24px 80px rgba(0,0,0,.6); }
#username-modal h2 { font-size:1.4rem; margin-bottom:.4rem; }
#username-modal p { font-size:.84rem; color:var(--muted); margin-bottom:1.2rem; line-height:1.55; }
.username-preview { font-size:.8rem; color:var(--accent); margin:.4rem 0 .9rem; min-height:1.1rem; }
#username-modal input { width:100%; }

/* ── SPINNER ───────────────────────────────────────────────────── */
.spinner { display: none; margin: 2rem auto; width: 40px; height: 40px; border: 3px solid rgba(65,145,161,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TABS ──────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .4rem; margin-bottom: 1.4rem; background: var(--surface2); border-radius: var(--radius-sm); padding: .3rem; width: fit-content; border: 1px solid var(--border); }
.tab { padding: .42rem 1rem; border-radius: 6px; cursor: pointer; font-size: .83rem; font-weight: 600; color: var(--muted); transition: all .15s; border: none; background: none; font-family: 'Funnel Display', sans-serif; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* ── TOAST ─────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 2rem; right: 2rem; background: var(--surface2); border: 1px solid var(--border-hi); border-radius: var(--radius-sm); padding: .85rem 1.3rem; font-size: .86rem; z-index: 9999; opacity: 0; transform: translateY(10px); transition: all .3s; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translateY(0); }

/* ── DANGER ────────────────────────────────────────────────────── */
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border: 1px solid rgba(248,113,113,.3); font-size: .78rem; padding: .35rem .75rem; border-radius: var(--radius-sm); cursor: pointer; transition: all .18s; font-family: 'Funnel Display', sans-serif; font-weight: 600; }
.btn-danger:hover { background: rgba(248,113,113,.22); }
.full-danger { background: rgba(248,113,113,.15); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }
.full-danger:hover { background: rgba(248,113,113,.25); }

/* ── SUBSCRIPTION ──────────────────────────────────────────────── */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 1.4rem; max-width: 900px; }
.plan-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 1.8rem 1.6rem; position: relative; transition: border-color .2s, transform .2s; }
.plan-card:hover { transform: translateY(-2px); }
.plan-card.featured { border-color: var(--accent); background: linear-gradient(135deg, rgba(65,145,161,.08), rgba(65,145,161,.02)); }
.plan-badge { position: absolute; top: -1px; right: 1.2rem; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: .25rem .75rem; border-radius: 0 0 8px 8px; }
.plan-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: .5rem; font-weight: 700; }
.plan-price { font-size: 2.2rem; font-weight: 800; margin-bottom: 1rem; }
.plan-price span { font-size: .9rem; font-weight: 400; color: var(--muted); }
.plan-features { list-style: none; padding: 0; margin: 0 0 1.5rem; display: flex; flex-direction: column; gap: .55rem; font-size: .86rem; color: var(--muted); }

/* ── ANIMATIONS ────────────────────────────────────────────────── */
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:none; } }
.fade-up { animation: fadeUp .4s ease forwards; pointer-events: auto; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.fade-in { animation: fadeIn .3s ease both; }

/* ── MOBILE RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { left: -100%; width: var(--sidebar-w) !important; padding: 1.5rem 1rem !important; transition: left .28s ease; z-index: 160; }
  .sidebar.mobile-open { left: 0; }
  .sidebar.collapsed .sidebar-brand span,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .user-info { display: unset; }
  .sidebar.collapsed .sidebar-brand { justify-content: flex-start; gap: .65rem; }
  .sidebar.collapsed .user-pill { padding: .7rem .85rem; justify-content: flex-start; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: .6rem .85rem; }
  .sidebar-toggle { display: none; }

  .mobile-topbar { display: flex; }
  .page-area { margin-left: 0 !important; padding-top: 56px; }
  .main { padding: 1rem; max-width: 100%; }

  .hero-h1 { font-size: clamp(1.8rem, 7vw, 3rem); }
  .hero-sub { font-size: .92rem; }
  .features { grid-template-columns: 1fr; }
  .hero-btns { flex-direction: column; align-items: stretch; }
  .hero-btns .btn, .hero-btns > div { width: 100%; justify-content: center; }

  /* Force solid colors on mobile for contrast */
  .stat-val { color: #5bb3c4; }
  .nav-item.active { background: rgba(65,145,161,.25); color: #5bb3c4; }
  .social-tab.active { background: #4191a1; }

  .stats-row { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .stat-card { padding: .9rem; }
  .stat-val { font-size: 1.7rem; }

  .quiz-layout, .lessons-layout, .two-col, .two-col-left, .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-wide { grid-column: 1; }

  .opt-card { padding: .9rem 1rem; }
  .q-card { padding: 1.1rem; }
  .q-text { font-size: .95rem; }

  .input-group { flex-direction: column; gap: .6rem; }
  .input-group .btn { width: 100%; justify-content: center; }
  .text-input { min-width: unset; width: 100%; font-size: 1rem; }

  .setting-row { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .profile-header { flex-direction: column; text-align: center; align-items: center; }
  .profile-header-info { text-align: center; }

  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; font-size: .78rem; }
  .social-tabs { gap: .4rem; }
  .social-tab { font-size: .78rem; padding: .4rem .8rem; }

  .toast { bottom: 1.2rem; right: 1rem; left: 1rem; text-align: center; }
  .page-header h2 { font-size: 1.5rem; }
  .plan-grid { grid-template-columns: 1fr; }
  .podium { gap: .6rem; }
  .podium-place.first .podium-avatar { width: 54px; height: 54px; }
  .podium-avatar { width: 44px; height: 44px; }

  .username-input-row { width: 100%; }
  .username-input-row .text-input { flex: 1; }
  .lesson-concepts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .main { padding: .75rem; }
  .stats-row { gap: .5rem; }
  .stat-val { font-size: 1.5rem; }
  .card { padding: 1rem; }
  .q-opt { font-size: .84rem; padding: .6rem .85rem; }
}

/* ── HOME BUTTON ── */
.sidebar-brand {
  transition: opacity .15s, background .15s;
  border-radius: var(--radius-sm);
  padding: .5rem .7rem !important;
}
.sidebar-brand:hover {
  opacity: .85;
  background: var(--accent-dim);
}
.sidebar-brand:hover span {
  color: var(--accent2) !important;
}

/* ── SIDEBAR BALANCE WIDGET ── */
.sidebar-balance {
  margin: 0 0 .75rem;
  padding: .85rem .9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .78rem;
  transition: opacity .2s;
}
.sidebar.collapsed .sidebar-balance { display: none; }
.balance-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .35rem;
}
.balance-label { color: var(--muted); font-size: .73rem; }
.balance-count { font-weight: 700; font-size: .78rem; }
.balance-bar-track {
  background: var(--surface); border-radius: 999px; height: 4px;
  overflow: hidden; margin-bottom: .5rem;
}
.balance-bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .4s ease;
}
.balance-divider {
  border: none; border-top: 1px solid var(--border);
  margin: .5rem 0;
}
.balance-reset {
  color: var(--muted); font-size: .7rem; text-align: center;
  opacity: .7;
}

/* ── LIGHT MODE ─────────────────────────────────────────────────── */
body.light-mode {
  --bg:        #f0f4f6;
  --surface:   #ffffff;
  --surface2:  #e8eef2;
  --surface3:  #dde5eb;
  --border:    rgba(65,145,161,0.22);
  --border-hi: rgba(65,145,161,0.45);
  --text:      #0e1214;
  --muted:     #4a6a7a;
  --accent-dim:rgba(65,145,161,0.12);
}
body.light-mode .sidebar {
  background: linear-gradient(180deg, #dde5eb 0%, #e8eef2 100%);
}
body.light-mode body::before { opacity: .04; }
body.light-mode .card { box-shadow: 0 1px 4px rgba(0,0,0,.07); }
body.light-mode .opt-card { background: #f8fafc; }
body.light-mode .q-opt { background: #f8fafc; }
body.light-mode .text-input { background: #f8fafc; color: var(--text); }
body.light-mode .setting-select { background: #f8fafc; color: var(--text); }
body.light-mode #user-menu { background: #f0f4f6; }
body.light-mode .sidebar-balance { background: #e8eef2; }
body.light-mode .balance-bar-track { background: #d0dae0; }
body.light-mode .jump-back-card { background: #f0f4f6; }
body.light-mode .teaser-card { background: rgba(65,145,161,.06); }
body.light-mode .lb-row { background: #ffffff; }
body.light-mode .friend-row { background: #ffffff; }
body.light-mode .activity-row { background: #ffffff; }
body.light-mode .tabs { background: #e8eef2; }
body.light-mode .tab.active { background: #ffffff; }
body.light-mode .lesson-concept-card { background: #f0f4f6; }
body.light-mode .q-opt-letter { background: rgba(65,145,161,.1); }

/* ── HIGH CONTRAST ──────────────────────────────────────────────── */
body.high-contrast {
  --border:    rgba(65,145,161,0.6);
  --border-hi: rgba(65,145,161,0.9);
  --muted:     #a8c8d8;
}
body.high-contrast .card { border-width: 2px; }
body.high-contrast .q-opt { border-width: 2px; }
body.high-contrast .nav-item.active { border-width: 2px; }
body.light-mode.high-contrast { --muted: #2a4a5a; --text: #000000; }
body.high-contrast * { backdrop-filter: none !important; }

/* ── FONT SIZE ──────────────────────────────────────────────────── */
body.font-small {
  --fs-base: .8rem; --fs-sm: .72rem; --fs-xs: .65rem;
}
body.font-medium {
  --fs-base: .9rem; --fs-sm: .82rem; --fs-xs: .72rem;
}
body.font-large {
  --fs-base: 1.05rem; --fs-sm: .95rem; --fs-xs: .82rem;
}
body.font-small  .card p, body.font-small  .q-text, body.font-small  .q-opt,
body.font-small  .activity-row, body.font-small  .friend-row,
body.font-small  .lb-name, body.font-small  .setting-info h4,
body.font-small  .lesson-concept-def, body.font-small  .lesson-section-body { font-size: .8rem !important; }
body.font-small  .nav-label, body.font-small  .nav-section-label,
body.font-small  .user-name, body.font-small  .balance-label { font-size: .75rem !important; }

body.font-large  .card p, body.font-large  .q-text, body.font-large  .q-opt,
body.font-large  .activity-row, body.font-large  .friend-row,
body.font-large  .lb-name, body.font-large  .setting-info h4,
body.font-large  .lesson-concept-def, body.font-large  .lesson-section-body { font-size: 1.05rem !important; }
body.font-large  .q-text { font-size: 1.15rem !important; }
body.font-large  .nav-label, body.font-large  .user-name { font-size: .95rem !important; }
body.font-large  .card h3 { font-size: 1.15rem !important; }
body.font-large  .page-header h2 { font-size: 2.2rem !important; }

/* ── LINE SPACING ───────────────────────────────────────────────── */
body.spacing-normal  { --line-height: 1.6; }
body.spacing-relaxed { --line-height: 1.9; }
body.spacing-spacious{ --line-height: 2.2; }
body.spacing-relaxed  .lesson-section-body,
body.spacing-relaxed  .lesson-concept-def,
body.spacing-relaxed  .card p { line-height: 1.9; }
body.spacing-spacious .lesson-section-body,
body.spacing-spacious .lesson-concept-def,
body.spacing-spacious .card p { line-height: 2.2; }

/* ── ANSWER HIGHLIGHTING ────────────────────────────────────────── */
body.answer-shapes .q-opt.correct::before {
  content: '■ ';
  color: var(--accent2);
  font-size: .9rem;
}
body.answer-shapes .q-opt.wrong::before {
  content: '✕ ';
  color: var(--danger);
  font-size: .9rem;
}
body.answer-shapes .q-opt.correct { outline: 3px solid var(--accent); }
body.answer-shapes .q-opt.wrong   { outline: 3px solid var(--danger); }

/* ── FOCUS MODE ─────────────────────────────────────────────────── */
body.focus-mode .q-card { opacity: .35; transition: opacity .2s; }
body.focus-mode .q-card:focus-within,
body.focus-mode .q-card.answered { opacity: 1; }
body.focus-mode.quiz-active .page-header,
body.focus-mode.quiz-active .quiz-mode-panel,
body.focus-mode.quiz-active #quiz-balance-bar { opacity: .2; pointer-events: none; }

/* Ensure opt-card buttons are clickable */
button.opt-card {
  width: 100%;
  font-family: 'Funnel Display', sans-serif;
  color: var(--text);
}
