/* ================================================================
   VIDYA — Professional Design System
   Inspired by: Zoho, Linear, Notion — Clean Dark Theme
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Surfaces */
  --bg:          #0D0D1C;
  --surface-1:   #131327;
  --surface-2:   #1A1A35;
  --surface-3:   #21213E;
  --surface-4:   #282850;

  /* Brand */
  --brand:       #5B4FE8;
  --brand-light: #7B70F5;
  --brand-dim:   rgba(91,79,232,0.14);
  --brand-dim2:  rgba(91,79,232,0.28);

  /* Semantic */
  --gold:        #D4A843;
  --gold-dim:    rgba(212,168,67,0.14);
  --teal:        #14C9A3;
  --teal-dim:    rgba(20,201,163,0.12);
  --rose:        #E05C8E;
  --rose-dim:    rgba(224,92,142,0.14);
  --amber:       #D97B35;
  --amber-dim:   rgba(217,123,53,0.14);
  --green:       #22C55E;
  --green-dim:   rgba(34,197,94,0.12);

  /* Text */
  --text-1: #ECEAF8;
  --text-2: #8986B8;
  --text-3: #4E4C72;
  --text-accent: #A09AF5;

  /* Borders */
  --border:      rgba(255,255,255,0.065);
  --border-2:    rgba(255,255,255,0.11);
  --border-brand: rgba(91,79,232,0.38);

  /* Effects */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.35);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.40);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.50);
  --shadow-brand: 0 4px 20px rgba(91,79,232,0.28);

  /* Radius */
  --r-xs: 5px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 9999px;

  /* Easing */
  --ease: cubic-bezier(0.4,0,0.2,1);
  --spring: cubic-bezier(0.34,1.56,0.64,1);

  /* Layout */
  --nav-h: 56px;
  --btm-nav-h: 62px;
}

/* ---- Deep Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100dvh;
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-light); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: var(--r-full); }
.v-icon { flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* ---- Subtle dot grid background ---- */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background-image: radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  top: -30%; left: -10%; width: 60%; height: 60%;
  background: radial-gradient(ellipse, rgba(91,79,232,0.08) 0%, transparent 70%);
  pointer-events: none; z-index: -1;
}

/* ================================================================
   LAYOUT
   ================================================================ */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ---- Top Nav ---- */
.top-nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: rgba(13,13,28,0.88);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.nav-brand { display: flex; align-items: center; gap: 9px; }
.nav-logo { width: 30px; height: 30px; border-radius: var(--r-sm); object-fit: cover; }
.nav-title {
  font-size: 0.95rem; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text-1);
}
.nav-title span { color: var(--brand-light); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
.nav-chip {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 5px 12px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-2);
}
.nav-chip.xp { color: var(--gold); }
.nav-chip.streak { color: var(--amber); }
.nav-icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: all .18s var(--ease);
}
.nav-icon-btn:hover { border-color: var(--border-brand); color: var(--brand-light); }

/* ---- Main Content ---- */
#main-content { flex: 1; padding-bottom: calc(var(--btm-nav-h) + 12px); }

/* ---- Bottom Nav (Zoho-style solid tabs) ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--btm-nav-h);
  display: flex; align-items: center;
  background: rgba(19,19,39,0.96);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.btm-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 0 8px;
  color: var(--text-3); font-size: 0.67rem; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase;
  transition: color .18s var(--ease); position: relative;
}
.btm-btn .btm-icon { width: 22px; height: 22px; transition: transform .2s var(--spring); }
.btm-btn:hover { color: var(--text-2); }
.btm-btn.active { color: var(--brand-light); }
.btm-btn.active .btm-icon { transform: translateY(-1px); }
.btm-btn.active::after {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 36px; height: 2px;
  background: var(--brand);
  border-radius: 0 0 var(--r-full) var(--r-full);
}

/* Study CTA in bottom nav */
.btm-btn.study-cta {
  color: var(--brand-light);
}
.btm-btn.study-cta .btm-icon-wrap {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
  box-shadow: var(--shadow-brand);
  transition: all .2s var(--spring);
}
.btm-btn.study-cta:hover .btm-icon-wrap { transform: scale(1.08); }
.btm-btn.study-cta.active .btm-icon-wrap { background: var(--brand-light); }
.btm-btn.study-cta::after { display: none; }

/* Views */
.view { display: none; animation: fadeSlide .28s var(--ease); }
.view.active { display: block; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================================================================
   SHARED COMPONENTS
   ================================================================ */

/* Page wrapper */
.page-wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px; }

/* Section header */
.sec-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.sec-title {
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3);
  display: flex; align-items: center; gap: 7px;
}
.sec-title-icon { color: var(--text-3); }
.sec-action {
  font-size: 0.78rem; font-weight: 600; color: var(--brand-light);
  border: none; background: none; cursor: pointer; padding: 4px 0;
}
.sec-action:hover { color: var(--gold); }

/* ---- Card Base ---- */
.v-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color .18s, box-shadow .18s;
}
.v-card:hover { border-color: var(--border-2); }
.v-card.interactive { cursor: pointer; }
.v-card.interactive:hover { border-color: var(--border-brand); box-shadow: var(--shadow-md); }

/* ---- Badge / Pill ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: var(--r-full); padding: 3px 10px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em;
}
.badge-outline {
  background: transparent; border: 1px solid var(--border-2); color: var(--text-2);
}
.badge-brand { background: var(--brand-dim); border: 1px solid var(--border-brand); color: var(--brand-light); }
.badge-gold  { background: var(--gold-dim); border: 1px solid rgba(212,168,67,0.28); color: var(--gold); }
.badge-teal  { background: var(--teal-dim); border: 1px solid rgba(20,201,163,0.25); color: var(--teal); }
.badge-rose  { background: var(--rose-dim); border: 1px solid rgba(224,92,142,0.28); color: var(--rose); }

/* Subject badges */
.badge-history  { background: rgba(212,168,67,0.1);  border: 1px solid rgba(212,168,67,0.22); color: var(--gold); }
.badge-science  { background: rgba(20,201,163,0.1);  border: 1px solid rgba(20,201,163,0.22); color: var(--teal); }
.badge-polity   { background: rgba(91,79,232,0.12); border: 1px solid rgba(91,79,232,0.25);  color: var(--brand-light); }
.badge-geography { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.22);  color: var(--green); }
.badge-economy  { background: rgba(217,123,53,0.1); border: 1px solid rgba(217,123,53,0.22); color: var(--amber); }
.badge-english  { background: rgba(160,154,245,0.1); border: 1px solid rgba(160,154,245,0.22); color: var(--text-accent); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: var(--r-md); font-weight: 600; font-size: 0.85rem;
  transition: all .18s var(--ease); padding: 9px 18px; white-space: nowrap;
}
.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-light); transform: translateY(-1px); }
.btn-outline {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-outline:hover { border-color: var(--border-brand); color: var(--brand-light); }
.btn-ghost { background: transparent; color: var(--text-2); padding: 8px; border-radius: var(--r-sm); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn-sm { padding: 6px 13px; font-size: 0.78rem; }

/* ---- Progress Bar ---- */
.progress-bar {
  height: 5px; border-radius: var(--r-full);
  background: var(--surface-4); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  transition: width .8s var(--ease);
}
.progress-bar.gold .progress-fill { background: linear-gradient(90deg, var(--amber), var(--gold)); }
.progress-bar.teal .progress-fill { background: linear-gradient(90deg, var(--teal), #34d9c3); }

/* ---- Divider ---- */
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ---- List Item ---- */
.list-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 16px; border-radius: var(--r-md);
  cursor: pointer; transition: background .15s;
}
.list-item:hover { background: var(--surface-2); }
.list-item + .list-item { border-top: 1px solid var(--border); margin-top: 0; }
.list-icon {
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: var(--surface-3);
  color: var(--text-2);
}
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 0.875rem; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub   { font-size: 0.75rem; color: var(--text-2); margin-top: 1px; }
.list-end   { flex-shrink: 0; color: var(--text-3); }

/* ================================================================
   DASHBOARD
   ================================================================ */
.dashboard-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.greeting-label { font-size: 0.78rem; color: var(--text-2); margin-bottom: 3px; }
.greeting-name  { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.03em; color: var(--text-1); }

/* ---- Stat Row ---- */
.stat-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 12px 12px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.stat-card.streak::before { background: var(--amber); }
.stat-card.xp::before     { background: var(--brand); }
.stat-card.due::before     { background: var(--teal); }
.stat-card.mastered::before { background: var(--gold); }
.stat-icon { color: var(--text-3); margin-bottom: 2px; }
.stat-value { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.03em; }
.stat-card.streak .stat-value { color: var(--amber); }
.stat-card.xp .stat-value     { color: var(--brand-light); }
.stat-card.due .stat-value     { color: var(--teal); }
.stat-card.mastered .stat-value { color: var(--gold); }
.stat-label { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-3); }

/* ---- Daily XP Bar ---- */
.daily-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 16px;
}
.daily-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.daily-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.daily-count { font-size: 0.78rem; font-weight: 700; color: var(--gold); }

/* ---- Due Banner ---- */
.due-banner {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
.due-banner:hover { border-color: var(--border-brand); box-shadow: var(--shadow-brand); }
.due-cnt { font-size: 2rem; font-weight: 900; letter-spacing: -0.04em; color: var(--teal); line-height: 1; }
.due-label { font-size: 0.8rem; color: var(--text-2); margin-top: 2px; }
.due-strip {
  width: 3px; height: 44px; border-radius: var(--r-full);
  background: linear-gradient(180deg, var(--teal), var(--brand));
  flex-shrink: 0;
}

/* ---- Featured Row ---- */
.featured-row {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 20px;
  cursor: pointer; transition: border-color .18s;
}
.featured-row:hover { border-color: var(--border-brand); }
.featured-img { width: 100%; height: 140px; object-fit: cover; }
.featured-body { padding: 14px 16px; }
.featured-tag { margin-bottom: 7px; }
.featured-title { font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 5px; }
.featured-sub { font-size: 0.78rem; color: var(--text-2); }

/* ---- Subject Grid ---- */
.subjects-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.subject-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 15px;
  cursor: pointer; transition: border-color .18s, transform .18s;
  display: flex; flex-direction: column; gap: 8px;
}
.subject-card:hover { border-color: var(--border-2); transform: translateY(-2px); }
.subject-icon-wrap {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}
.subject-card.history .subject-icon-wrap  { background: var(--gold-dim);  color: var(--gold); }
.subject-card.science .subject-icon-wrap  { background: var(--teal-dim);  color: var(--teal); }
.subject-card.polity .subject-icon-wrap   { background: var(--brand-dim); color: var(--brand-light); }
.subject-card.geography .subject-icon-wrap { background: var(--green-dim); color: var(--green); }
.subject-card.economy .subject-icon-wrap  { background: var(--amber-dim); color: var(--amber); }
.subject-card.english .subject-icon-wrap  { background: rgba(160,154,245,0.1); color: var(--text-accent); }
.subject-name  { font-size: 0.85rem; font-weight: 700; color: var(--text-1); }
.subject-count { font-size: 0.72rem; color: var(--text-3); margin-bottom: 4px; }

/* ---- Activity List ---- */
.activity-list { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.activity-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon-wrap {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  background: var(--surface-3); display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex-shrink: 0;
}
.activity-title { font-size: 0.84rem; font-weight: 600; }
.activity-sub   { font-size: 0.72rem; color: var(--text-3); margin-top: 1px; }
.activity-xp    { font-size: 0.78rem; font-weight: 700; color: var(--gold); }

/* ================================================================
   STUDY VIEW
   ================================================================ */
.study-wrap { max-width: 680px; margin: 0 auto; padding: 14px 14px 0; }
.study-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.study-deck-label { font-size: 0.8rem; font-weight: 600; color: var(--text-2); }
.study-counter    { font-size: 0.8rem; font-weight: 600; color: var(--text-3); }
.study-progress { margin-bottom: 20px; }
.study-progress .progress-fill { background: linear-gradient(90deg, var(--brand), var(--teal)); }

/* Card 3D Scene */
.card-scene {
  perspective: 1100px; width: 100%; min-height: 430px; margin-bottom: 18px;
}
.card-flipper {
  position: relative; width: 100%; min-height: 430px;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(0.4,0.15,0.2,1);
  cursor: pointer;
}
.card-flipper.flipped { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; width: 100%; min-height: 430px;
  backface-visibility: hidden;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px 22px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.card-face.front { justify-content: space-between; }
.card-face.back  { transform: rotateY(180deg); overflow-y: auto; }

/* Subtle accent line on card */
.card-face::before {
  content: ''; position: absolute; top: 0; left: 22px; right: 22px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-brand), transparent);
}
.card-badge-row { display: flex; align-items: center; gap: 7px; margin-bottom: 16px; flex-wrap: wrap; }
.card-img-wrap { border-radius: var(--r-md); overflow: hidden; margin-bottom: 16px; }
.card-img-wrap img { width: 100%; height: 185px; object-fit: cover; }
.card-img-caption { font-size: 0.7rem; color: var(--text-3); margin-top: 6px; text-align: center; font-style: italic; }
.card-question { font-size: 1.05rem; font-weight: 600; line-height: 1.55; color: var(--text-1); }
.card-hint {
  font-size: 0.75rem; color: var(--text-3); display: flex; align-items: center; gap: 6px;
  margin-top: auto; padding-top: 12px;
}

/* Card Back */
.answer-label {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
}
.answer-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 10px; }
.answer-body { font-size: 0.855rem; line-height: 1.72; color: var(--text-2); }
.answer-body strong { color: var(--text-1); font-weight: 600; }
.answer-body .hl { color: var(--brand-light); font-weight: 700; }

/* Fact pills */
.fact-row { display: flex; flex-wrap: wrap; gap: 7px; margin: 13px 0; }
.fact-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 5px 11px; font-size: 0.78rem;
}
.fp-label { color: var(--text-3); font-weight: 500; }
.fp-val { color: var(--text-1); font-weight: 600; }

/* Cross-links */
.crosslinks-wrap { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.crosslinks-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 9px; display: flex; align-items: center; gap: 6px; }
.crosslinks-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.crosslink-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-dim); border: 1px solid rgba(91,79,232,0.28);
  border-radius: var(--r-full); padding: 5px 13px;
  font-size: 0.78rem; font-weight: 600; color: var(--brand-light);
  cursor: pointer; transition: all .15s var(--ease);
}
.crosslink-chip:hover { background: var(--brand-dim2); border-color: var(--border-brand); color: var(--text-1); }

/* Flip hint */
.flip-hint {
  text-align: center; font-size: 0.72rem; color: var(--text-3);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  margin-bottom: 14px;
}

/* Rating Row */
.rating-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rating-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 11px 6px;
  border-radius: var(--r-md); font-size: 0.78rem; font-weight: 600;
  border: 1px solid transparent;
  transition: all .18s var(--spring);
}
.rating-btn:hover { transform: translateY(-2px); }
.rating-btn .rb-emoji { font-size: 1.2rem; }
.r-again { background: var(--rose-dim);  border-color: rgba(224,92,142,0.25); color: var(--rose); }
.r-hard  { background: var(--amber-dim); border-color: rgba(217,123,53,0.22);  color: var(--amber); }
.r-good  { background: var(--teal-dim);  border-color: rgba(20,201,163,0.22);  color: var(--teal); }
.r-easy  { background: var(--brand-dim); border-color: rgba(91,79,232,0.22);   color: var(--brand-light); }
.r-again:hover { box-shadow: 0 3px 12px rgba(224,92,142,0.2); }
.r-hard:hover  { box-shadow: 0 3px 12px rgba(217,123,53,0.2); }
.r-good:hover  { box-shadow: 0 3px 12px rgba(20,201,163,0.2); }
.r-easy:hover  { box-shadow: 0 3px 12px rgba(91,79,232,0.2); }

/* ================================================================
   TOPIC MODAL (Wikipedia-style)
   ================================================================ */
.tm-backdrop {
  display: none; position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(8px);
}
.tm-backdrop.open { display: block; }
.topic-modal {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 151;
  max-height: 90dvh;
  background: var(--surface-1);
  border-top: 1px solid var(--border-2);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform .38s cubic-bezier(0.32,0.72,0,1);
}
.topic-modal.open { transform: translateY(0); }
.tm-handle { width: 36px; height: 3px; background: var(--surface-4); border-radius: var(--r-full); margin: 14px auto 0; }
.tm-close {
  position: absolute; top: 14px; right: 16px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer; transition: background .15s;
}
.tm-close:hover { background: var(--surface-4); color: var(--text-1); }
.tm-inner { padding: 8px 18px 48px; }

/* Hero */
.tm-hero { border-radius: var(--r-lg); overflow: hidden; margin-bottom: 18px; border: 1px solid var(--border); }
.tm-hero-img { width: 100%; height: 200px; object-fit: cover; }
.tm-hero-body { padding: 18px; }
.tm-breadcrumb { font-size: 0.72rem; color: var(--text-3); margin-bottom: 6px; }
.tm-breadcrumb span { color: var(--brand-light); cursor: pointer; }
.tm-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.tm-sub { font-size: 0.82rem; color: var(--text-2); margin-bottom: 12px; }
.tm-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Layout */
.tm-layout { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 600px) {
  .tm-layout { flex-direction: row; }
  .tm-infobox { min-width: 210px; flex-shrink: 0; }
}

/* Infobox */
.tm-infobox {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 16px; align-self: start;
}
.ib-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--brand-light); margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 7px; }
.ib-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 0.82rem; }
.ib-key { color: var(--text-3); font-weight: 500; min-width: 100px; flex-shrink: 0; }
.ib-val { color: var(--text-1); font-weight: 600; }

/* Body */
.tm-body { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: 20px; }
.tm-section { margin-bottom: 20px; }
.tm-section:last-child { margin-bottom: 0; }
.tm-sec-title {
  font-size: 0.9rem; font-weight: 700; color: var(--text-1); margin-bottom: 9px;
  padding-bottom: 7px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 7px;
}
.topic-p { font-size: 0.855rem; line-height: 1.78; color: var(--text-2); margin-bottom: 9px; }
.topic-p strong { color: var(--text-1); font-weight: 600; }
.topic-quote {
  border-left: 2px solid var(--gold); padding: 10px 16px;
  background: var(--gold-dim); border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin: 12px 0; font-style: italic; font-size: 0.84rem; color: var(--text-2);
}
.topic-quote cite { display: block; margin-top: 5px; font-size: 0.75rem; color: var(--gold); font-style: normal; font-weight: 600; }
.wikilink {
  color: var(--brand-light); border-bottom: 1px solid rgba(91,79,232,0.3);
  cursor: pointer; font-weight: 500; transition: color .12s, border-color .12s;
}
.wikilink:hover { color: var(--gold); border-color: var(--gold); }

/* See-also */
.see-also-row { display: flex; flex-wrap: wrap; gap: 8px; }
.see-also-item {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 14px; font-size: 0.82rem;
  font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .14s;
}
.see-also-item:hover { border-color: var(--border-brand); color: var(--brand-light); }

/* ================================================================
   BROWSE VIEW
   ================================================================ */
.browse-wrap { max-width: 720px; margin: 0 auto; padding: 18px 16px; }
.browse-search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 14px;
  margin-bottom: 18px; transition: border-color .15s;
}
.browse-search-bar:focus-within { border-color: var(--border-brand); }
.browse-search-bar input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-1); font-size: 0.9rem;
}
.browse-search-bar input::placeholder { color: var(--text-3); }
.filter-bar { display: flex; gap: 7px; margin-bottom: 18px; overflow-x: auto; padding-bottom: 3px; }
.filter-chip {
  white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 6px 14px;
  font-size: 0.78rem; font-weight: 600; color: var(--text-3); cursor: pointer; transition: all .15s;
}
.filter-chip.on { background: var(--brand-dim); border-color: var(--border-brand); color: var(--brand-light); }
.filter-chip:hover:not(.on) { border-color: var(--border-2); color: var(--text-2); }

/* Deck Cards */
.deck-grid { display: flex; flex-direction: column; gap: 10px; }
.deck-row {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color .15s, box-shadow .15s; cursor: pointer;
}
.deck-row:hover { border-color: var(--border-brand); box-shadow: var(--shadow-md); }
.deck-icon {
  width: 44px; height: 44px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.deck-icon.history  { background: var(--gold-dim);  color: var(--gold); }
.deck-icon.science  { background: var(--teal-dim);  color: var(--teal); }
.deck-icon.polity   { background: var(--brand-dim); color: var(--brand-light); }
.deck-icon.geography { background: var(--green-dim); color: var(--green); }
.deck-icon.english  { background: rgba(160,154,245,0.1); color: var(--text-accent); }
.deck-info  { flex: 1; }
.deck-title { font-size: 0.92rem; font-weight: 700; margin-bottom: 3px; }
.deck-desc  { font-size: 0.78rem; color: var(--text-3); line-height: 1.5; margin-bottom: 10px; }
.deck-meta  { display: flex; gap: 12px; flex-wrap: wrap; }
.deck-meta-chip {
  display: flex; align-items: center; gap: 5px;
  font-size: 0.72rem; color: var(--text-3); font-weight: 500;
}
.deck-meta-chip strong { color: var(--text-2); font-weight: 600; }
.deck-action { align-self: center; flex-shrink: 0; }

/* ================================================================
   SESSION COMPLETE
   ================================================================ */
.session-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.72); backdrop-filter: blur(14px);
  align-items: center; justify-content: center;
}
.session-overlay.open { display: flex; }
.session-card {
  background: var(--surface-1); border: 1px solid var(--border-brand);
  border-radius: var(--r-xl); padding: 36px 30px;
  max-width: 360px; width: 90%; text-align: center;
  animation: popIn .35s var(--spring);
}
@keyframes popIn { from { opacity:0; transform: scale(0.88); } to { opacity:1; transform: scale(1); } }
.sc-trophy { font-size: 3.2rem; margin-bottom: 8px; display: block; }
.sc-title { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 5px; }
.sc-sub { font-size: 0.82rem; color: var(--text-2); margin-bottom: 22px; }
.sc-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 24px; }
.sc-stat-val { font-size: 1.5rem; font-weight: 900; letter-spacing: -0.03em; }
.sc-stat-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); margin-top: 1px; }

/* ================================================================
   SEARCH OVERLAY
   ================================================================ */
.search-overlay {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.68); backdrop-filter: blur(14px);
  padding: 50px 16px 20px; flex-direction: column; align-items: center;
}
.search-overlay.open { display: flex; }
.search-box {
  background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: var(--r-lg); overflow: hidden;
  max-width: 620px; width: 100%;
}
.search-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.search-input-row input {
  flex: 1; background: none; border: none; outline: none;
  font-size: 0.95rem; color: var(--text-1);
}
.search-input-row input::placeholder { color: var(--text-3); }
.search-results { padding: 8px; max-height: 58dvh; overflow-y: auto; }
.search-result {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  cursor: pointer; transition: background .12s;
}
.search-result:hover { background: var(--surface-3); }
.sr-icon { color: var(--text-3); flex-shrink: 0; }
.sr-title { font-size: 0.85rem; font-weight: 600; }
.sr-sub   { font-size: 0.72rem; color: var(--text-3); margin-top: 1px; }
.sr-type  { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-3); padding: 2px 7px; border-radius: var(--r-full); border: 1px solid var(--border); flex-shrink: 0; }

/* ================================================================
   PROFILE VIEW
   ================================================================ */
.profile-wrap { max-width: 500px; margin: 0 auto; padding: 20px 16px; }
.profile-hero {
  text-align: center; padding: 24px 0 20px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-xl); margin-bottom: 16px;
}
.avatar-ring {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  display: flex; align-items: center; justify-content: center;
  color: white; box-shadow: 0 0 0 3px var(--surface-1), 0 0 0 5px var(--brand);
}
.profile-name  { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; }
.profile-level { font-size: 0.78rem; color: var(--gold); font-weight: 600; margin-top: 2px; }
.profile-stats-row { display: flex; justify-content: center; gap: 24px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.ps-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.ps-val { font-size: 1.1rem; font-weight: 800; }
.ps-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); }

/* Achievements */
.achiev-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 14px 0; }
.achiev-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 10px; text-align: center;
}
.achiev-card.unlocked { border-color: rgba(212,168,67,0.3); background: var(--gold-dim); }
.achiev-icon { height: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; color: var(--text-3); }
.achiev-card.unlocked .achiev-icon { color: var(--gold); }
.achiev-name { font-size: 0.7rem; font-weight: 600; color: var(--text-2); }

/* Leaderboard */
.lb-list { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.lb-header { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 0.78rem; font-weight: 700; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-row.you { background: var(--brand-dim); }
.lb-rank { width: 22px; font-size: 0.85rem; font-weight: 800; color: var(--text-3); text-align: center; }
.lb-rank.gold   { color: var(--gold); }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }
.lb-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 0.85rem; }
.lb-name { flex: 1; font-size: 0.85rem; font-weight: 600; }
.lb-xp   { font-size: 0.82rem; font-weight: 700; color: var(--brand-light); display: flex; align-items: center; gap: 4px; }

/* ================================================================
   UTILITY & ANIMATION
   ================================================================ */
.hidden { display: none !important; }
.mt-4  { margin-top: 4px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }

/* XP Pop */
.xp-pop {
  position: fixed; z-index: 300; pointer-events: none;
  font-size: 1rem; font-weight: 800; color: var(--gold);
  display: flex; align-items: center; gap: 4px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
  animation: xpPop 1.1s var(--ease) forwards;
}
@keyframes xpPop {
  0%   { opacity:1; transform: translateY(0) scale(1); }
  80%  { opacity:1; transform: translateY(-52px) scale(1.08); }
  100% { opacity:0; transform: translateY(-70px) scale(0.95); }
}

/* Confetti */
.confetti {
  position: fixed; z-index: 400; pointer-events: none;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { opacity:1; transform: translateY(-10px) rotate(0deg); }
  100% { opacity:0; transform: translateY(100vh) rotate(720deg); }
}

/* Responsive */
@media (min-width: 560px) {
  .subjects-grid { grid-template-columns: repeat(3,1fr); }
  .stat-row { grid-template-columns: repeat(4,1fr); }
}
