/* ================================================================
   EduNova v2 - DESIGN SYSTEM
   Mockup match: purple #5B4FE5, accent #7C3AED, cream bg #FAFAF7
   ================================================================ */

/* ---------- TOKENS ---------- */
:root {
  /* Palette */
  --c-bg: #FAFAF7;
  --c-surface: #FFFFFF;
  --c-surface-muted: #F8F9FC;
  --c-primary: #5B4FE5;
  --c-primary-50: #F4F0FF;
  --c-primary-100: #EEF0FF;
  --c-primary-light: #8B7FF0;
  --c-accent: #7C3AED;
  --c-accent-light: #C4B5FD;
  --c-cyan: #38D9F5;
  --c-purple: #8B5CF6;

  /* Text */
  --c-ink-1: #0F172A;
  --c-ink-2: #334155;
  --c-ink-3: #64748B;
  --c-ink-4: #94A3B8;

  /* Border */
  --c-border: #E5E7EB;
  --c-border-soft: #EEF0F4;

  /* Status */
  --c-ok: #10B981;
  --c-ok-bg: #ECFDF5;
  --c-warn: #F59E0B;
  --c-warn-bg: #FEF3C7;
  --c-err: #EF4444;
  --c-err-bg: #FEF2F2;

  /* Subject colors */
  --s-math: #3B82F6;        --s-math-bg: #DBEAFE;
  --s-history: #F59E0B;     --s-history-bg: #FEF3C7;
  --s-physics: #8B5CF6;     --s-physics-bg: #EDE9FE;
  --s-literature: #F87171;  --s-literature-bg: #FEE2E2;
  --s-bio: #10B981;         --s-bio-bg: #D1FAE5;
  --s-chem: #06B6D4;        --s-chem-bg: #CFFAFE;
  --s-eng: #6366F1;         --s-eng-bg: #E0E7FF;

  /* Spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  /* Radius */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.10);

  /* Sidebar width */
  --sidebar-w: 260px;
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-ink-1);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; padding: 0; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-primary {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(91, 79, 229, 0.25);
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(91, 79, 229, 0.35); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--c-surface);
  color: var(--c-ink-2);
  border-color: var(--c-border);
}
.btn-secondary:hover { background: var(--c-surface-muted); border-color: var(--c-ink-4); }
.btn-ghost { background: transparent; color: var(--c-primary); }
.btn-ghost:hover { background: var(--c-primary-50); }
.btn-danger { background: var(--c-err); color: white; }
.btn-danger:hover { background: #DC2626; }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #F4F0FF 0%, #FAFAF7 50%, #FCE7F3 100%);
  padding: 20px;
}
.login-card {
  background: var(--c-surface);
  border-radius: 20px;
  padding: 40px;
  max-width: 440px; width: 100%;
  box-shadow: 0 20px 60px rgba(91, 79, 229, 0.12);
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .logo-mark-lg {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  margin: 0;
}
.login-brand .logo-mark-lg img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-brand h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--c-ink-1);
}
.login-tagline {
  font-size: 13.5px;
  color: var(--c-ink-3);
  margin: 0;
  max-width: 320px;
  line-height: 1.4;
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  border-radius: 18px;
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 8px 24px rgba(91, 79, 229, 0.35);
}
.login-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.login-subtitle { color: var(--c-ink-3); font-size: 14px; margin-top: 4px; }
.login-tabs { display: flex; gap: 4px; background: var(--c-surface-muted); padding: 4px; border-radius: 10px; margin-bottom: 20px; }
.login-tab {
  flex: 1; padding: 8px 16px; border-radius: 7px;
  font-size: 13px; font-weight: 500; color: var(--c-ink-3);
  transition: all 0.15s;
}
.login-tab.active { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow-sm); }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form .field label { font-size: 12px; font-weight: 500; color: var(--c-ink-2); display: block; margin-bottom: 6px; }
.login-form input, .login-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--c-surface);
  transition: border-color 0.15s;
}
.login-form input:focus, .login-form select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-50); }
.login-form button[type="submit"] { margin-top: 8px; padding: 11px; justify-content: center; }
.login-error { color: var(--c-err); font-size: 12.5px; min-height: 18px; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0;
  color: var(--c-ink-4); font-size: 12px;
}
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--c-border-soft); }
.demo-btn {
  width: 100%;
  padding: 12px;
  background: var(--c-surface);
  border: 2px dashed var(--c-primary);
  color: var(--c-primary);
  border-radius: 12px;
  font-weight: 600;
  font-size: 13.5px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.demo-btn:hover { background: var(--c-primary-50); }
.demo-hint { font-size: 12px; color: var(--c-ink-3); text-align: center; margin-top: 12px; }
.demo-hint b { color: var(--c-ink-1); }

/* ---------- APP SHELL ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border-soft);
  padding: 20px 14px;
  display: flex; flex-direction: column;
  height: 100vh;
  position: sticky; top: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.sidebar-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  border-radius: 10px;
  display: grid; place-items: center;
  color: white;
  box-shadow: 0 4px 12px rgba(91, 79, 229, 0.3);
}
.sidebar-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.sidebar-tag { font-size: 10px; color: var(--c-ink-4); }

.sidebar-close { display: none; }

.sidebar-nav { flex: 1; overflow-y: auto; }
.nav-section { margin-bottom: 18px; }
.nav-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--c-ink-4); text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0 10px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px; color: var(--c-ink-2);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--c-surface-muted); }
.nav-item.active { background: var(--c-primary-50); color: var(--c-primary); font-weight: 600; }
.nav-item.active svg { stroke: var(--c-primary); }
.nav-item svg { stroke: var(--c-ink-3); flex-shrink: 0; }
.nav-item.active svg { stroke: var(--c-primary); }
.nav-badge {
  margin-left: auto;
  font-size: 9.5px; font-weight: 700;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  padding: 2px 6px; border-radius: 4px;
}

/* XP card */
.xp-card {
  background: linear-gradient(135deg, #F4F0FF 0%, #FCE7F3 100%);
  border-radius: 12px;
  padding: 12px;
  margin-top: 14px;
}
.xp-card-header { display: flex; justify-content: space-between; align-items: center; }
.xp-level { font-size: 11px; color: var(--c-primary); font-weight: 600; letter-spacing: 0.04em; }
.xp-points { font-size: 13px; font-weight: 700; color: var(--c-ink-1); }
.xp-bar { height: 6px; background: white; border-radius: 999px; margin: 8px 0 6px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--c-primary), var(--c-accent)); border-radius: 999px; transition: width 0.4s; }
.xp-card-footer { font-size: 11px; color: var(--c-ink-3); }

/* ---------- MAIN AREA ---------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}

/* TOPBAR */
.topbar {
  display: flex; align-items: center;
  padding: 12px 28px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-soft);
  gap: 16px;
}
.crumbs { font-size: 12.5px; color: var(--c-ink-3); }
.crumbs b { color: var(--c-ink-1); font-weight: 600; }
.topbar-spacer { flex: 1; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--c-surface-muted);
  border-radius: 10px;
  padding: 7px 12px;
  width: 260px;
  font-size: 12.5px;
  color: var(--c-ink-3);
}
.topbar-search input {
  border: none; background: transparent;
  font-size: 12.5px; flex: 1; outline: none;
  color: var(--c-ink-1);
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--c-ink-3);
  transition: all 0.15s;
  position: relative;
}
.icon-btn:hover { background: var(--c-surface-muted); color: var(--c-ink-1); }
.notif-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  background: var(--c-err);
  border-radius: 50%;
  border: 2px solid var(--c-surface);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: var(--c-surface-muted);
  cursor: pointer;
}
.user-chip:hover { background: var(--c-primary-50); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.user-name-block { display: flex; flex-direction: column; line-height: 1.15; }
.user-name-block b { font-size: 12.5px; }
.user-name-block span { font-size: 10.5px; color: var(--c-ink-3); }

/* ---------- VIEW & PAGE ---------- */
.view-host { padding: 28px; max-width: 1280px; margin: 0 auto; width: 100%; }
.view { display: flex; flex-direction: column; gap: var(--s-5); }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-3); flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.025em; }
.page-subtitle { color: var(--c-ink-3); font-size: 13.5px; margin-top: 4px; }

/* GREETING */
.greeting {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  color: white;
  position: relative;
  overflow: hidden;
}
.greeting::before, .greeting::after {
  content: ''; position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.08);
  pointer-events: none;
}
.greeting::before { width: 240px; height: 240px; top: -120px; right: -40px; }
.greeting::after { width: 160px; height: 160px; bottom: -80px; right: 120px; }
.greeting-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.greeting-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 4px; }
.greeting-subtitle { font-size: 13.5px; opacity: 0.9; }
.greeting-subtitle b { color: white; }
.wave { display: inline-block; animation: wave 2.5s ease-in-out infinite; transform-origin: 70% 70%; }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 10%,30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } }
.greeting-actions { display: flex; gap: 8px; flex-shrink: 0; }
.greeting-actions .btn-secondary { background: rgba(255,255,255,0.15); color: white; border-color: rgba(255,255,255,0.2); }
.greeting-actions .btn-secondary:hover { background: rgba(255,255,255,0.25); }
.greeting-actions .btn-primary { background: white; color: var(--c-primary); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.greeting-actions .btn-primary:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.15); }

/* ---------- KPI GRID ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
}
.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: 18px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.kpi-label { font-size: 11.5px; color: var(--c-ink-3); font-weight: 500; letter-spacing: 0.02em; }
.kpi-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--c-primary-50);
  color: var(--c-primary);
  display: grid; place-items: center;
}
.kpi-icon.ok { background: var(--c-ok-bg); color: var(--c-ok); }
.kpi-icon.warn { background: var(--c-warn-bg); color: var(--c-warn); }
.kpi-icon.violet { background: #EDE9FE; color: var(--c-purple); }
.kpi-value { font-size: 22px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.1; }
.kpi-spark { margin: 8px 0 6px; }
.kpi-delta { font-size: 11.5px; color: var(--c-ink-3); display: flex; align-items: center; gap: 4px; }
.kpi-delta .pos { color: var(--c-ok); font-weight: 700; }
.kpi-delta .neg { color: var(--c-err); font-weight: 700; }
.kpi-delta .neutral { color: var(--c-ink-4); }

/* ---------- DASHBOARD GRID ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--s-4);
}
.right-col { display: flex; flex-direction: column; gap: var(--s-4); }

/* ---------- CARD ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: 20px;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.card-meta { font-size: 12px; color: var(--c-ink-3); }

.tag {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--c-surface-muted);
  color: var(--c-ink-3);
}
.tag.violet { background: #EDE9FE; color: var(--c-purple); }
.tag.ok { background: var(--c-ok-bg); color: var(--c-ok); }

/* ---------- LEARNING PATH ---------- */
.path-tabs { display: flex; gap: 4px; background: var(--c-surface-muted); padding: 3px; border-radius: 8px; }
.path-tab { padding: 5px 10px; border-radius: 6px; font-size: 11.5px; color: var(--c-ink-3); font-weight: 500; transition: all 0.15s; }
.path-tab.active { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow-sm); }

.path-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.path-step {
  background: var(--c-surface-muted);
  border: 1px solid var(--c-border-soft);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.path-step:hover { border-color: var(--c-primary); transform: translateY(-2px); }
.path-step-num {
  width: 28px; height: 28px;
  border-radius: 8px;
  margin: 0 auto 8px;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
  background: white; color: var(--c-ink-3);
  border: 1px solid var(--c-border);
}
.path-step.done .path-step-num { background: var(--c-ok); color: white; border-color: var(--c-ok); }
.path-step.active { background: var(--c-primary-50); border-color: var(--c-primary); }
.path-step.active .path-step-num { background: var(--c-primary); color: white; border-color: var(--c-primary); }
.path-step-title { font-size: 12.5px; font-weight: 600; color: var(--c-ink-1); margin-bottom: 2px; line-height: 1.3; }
.path-step-meta { font-size: 10.5px; color: var(--c-ink-3); }

/* ---------- SUBJECT CARDS (dashboard) ---------- */
.subjects-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.subject-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 0; /* allow text-overflow */
}
.subject-card:hover {
  border-color: var(--c-primary);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(91, 79, 229, 0.12);
}
.subject-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}
.subject-name {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--c-ink-1);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.subject-percent {
  font-size: 13px;
  font-weight: 700;
  color: var(--c-ink-1);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.subject-bar {
  height: 6px;
  background: var(--c-surface-muted);
  border-radius: 999px;
  margin-bottom: 8px;
  overflow: hidden;
}
.subject-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s;
}
.subject-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--c-ink-3);
}

/* ---------- AI RECOMMENDATIONS ---------- */
.ai-rec {
  background: linear-gradient(135deg, var(--c-primary-50) 0%, #FCE7F3 100%);
  border-radius: var(--r-lg);
  padding: 18px 20px;
}
.ai-rec-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; gap: 12px; }
.ai-rec-title { display: flex; align-items: center; gap: 12px; }
.sparkle {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  border-radius: 10px;
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(91,79,229,0.3);
}
.ai-rec-heading h3 { font-size: 14px; font-weight: 600; }
.ai-rec-heading p { font-size: 12px; color: var(--c-ink-3); margin-top: 1px; }
.ai-rec-tag {
  background: rgba(255,255,255,0.6);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--c-primary);
  font-weight: 500;
  white-space: nowrap;
}
.ai-rec-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ai-rec-item {
  background: rgba(255,255,255,0.7);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.ai-rec-item:hover { background: white; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ai-rec-item-tag { font-size: 10px; color: var(--c-primary); font-weight: 600; letter-spacing: 0.04em; }
.ai-rec-item-title { font-size: 12.5px; color: var(--c-ink-1); font-weight: 500; line-height: 1.4; margin-top: 4px; }

/* ---------- DAILY GOAL RING ---------- */
.goal-card { padding: 18px; }
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.goal-title { font-size: 14px; font-weight: 600; }
.goal-percent { font-size: 13px; font-weight: 700; color: var(--c-primary); }
.ring-wrap { position: relative; display: grid; place-items: center; padding: 4px 0 12px; }
.ring-svg { width: 180px; height: 180px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--c-surface-muted); stroke-width: 12; }
.ring-fg { fill: none; stroke: url(#ringGrad); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset 0.6s; }
.ring-center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.ring-value { font-size: 32px; font-weight: 700; letter-spacing: -0.025em; }
.ring-value-suffix { font-size: 14px; color: var(--c-ink-3); margin-left: 2px; }
.ring-label { font-size: 11.5px; color: var(--c-ink-3); margin-top: 2px; }
.goal-legend { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--c-border-soft); }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--c-ink-2); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ---------- NOVA CHAT WIDGET ---------- */
.nova-card { padding: 0; display: flex; flex-direction: column; }
.nova-header { padding: 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--c-border-soft); }
.nova-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  border-radius: 50%;
  display: grid; place-items: center;
  color: white;
  position: relative;
  flex-shrink: 0;
}
.nova-avatar::after {
  content: ''; position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  background: var(--c-ok);
  border-radius: 50%;
  border: 2px solid var(--c-surface);
}
.nova-meta { flex: 1; }
.nova-name { font-size: 13px; font-weight: 600; }
.nova-sub { font-size: 11px; color: var(--c-ink-3); }
.nova-menu {
  width: 28px; height: 28px;
  border-radius: 6px;
  color: var(--c-ink-3);
  font-size: 16px;
}
.nova-menu:hover { background: var(--c-surface-muted); }
.nova-body {
  padding: 14px;
  max-height: 280px;
  min-height: 200px;
  overflow-y: auto;
  display: flex; flex-direction: column;
  gap: 10px;
}
.msg { display: flex; gap: 8px; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
  flex-shrink: 0;
}
.msg.nova .msg-avatar { background: linear-gradient(135deg, var(--c-primary), var(--c-accent)); color: white; }
.msg.user .msg-avatar { background: var(--c-surface-muted); color: var(--c-ink-1); }
.msg-bubble {
  background: var(--c-surface-muted);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 85%;
  color: var(--c-ink-1);
}
.msg.user .msg-bubble { background: var(--c-primary); color: white; }
.msg-bubble .hl { font-weight: 700; color: var(--c-primary); }
.msg.user .msg-bubble .hl { color: white; }
.msg-bubble code { background: rgba(0,0,0,0.07); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; font-family: 'SF Mono', monospace; }
.typing { display: flex; gap: 4px; padding: 4px 0; align-items: center; }
.typing span { width: 7px; height: 7px; background: var(--c-ink-4); border-radius: 50%; animation: bounce 1.4s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-6px); opacity: 1; } }
.nova-quick { padding: 0 14px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.nova-quick button {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--c-primary-50);
  color: var(--c-primary);
  font-weight: 500;
  transition: all 0.15s;
}
.nova-quick button:hover { background: var(--c-primary); color: white; }
.nova-input {
  padding: 12px 14px;
  border-top: 1px solid var(--c-border-soft);
  display: flex; gap: 6px;
}
.nova-input input {
  flex: 1;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12.5px;
  outline: none;
  background: var(--c-surface-muted);
  transition: border-color 0.15s;
}
.nova-input input:focus { border-color: var(--c-primary); background: white; }
.nova-send {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.nova-send:hover:not(:disabled) { transform: scale(1.08); }
.nova-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- SUBJECTS PAGE ---------- */
.subjects-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--s-4);
}
.subject-tile {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}
.subject-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.subject-tile-bg {
  position: absolute; top: 0; right: 0;
  width: 80px; height: 80px;
  opacity: 0.08; border-radius: 50%;
  transform: translate(30%, -30%);
}
.subject-tile-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: 12px;
}
.subject-tile-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.subject-tile-meta { font-size: 12px; color: var(--c-ink-3); margin-bottom: 12px; }
.subject-tile-stats { display: flex; justify-content: space-between; align-items: center; }
.subject-tile-progress { font-size: 14px; font-weight: 700; }

/* ---------- LESSON LIST (subjects detail) ---------- */
.lesson-list { display: flex; flex-direction: column; }
.lesson-item:hover .lesson-action { color: var(--c-primary); }
.lesson-item:last-child { border-bottom: none; }
.lesson-status {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--c-border);
  background: white;
  display: grid; place-items: center;
  color: white;
  flex-shrink: 0;
}
.lesson-status.done { background: var(--c-ok); border-color: var(--c-ok); }
.lesson-status.active { background: var(--c-primary-50); border-color: var(--c-primary); border-style: dashed; }
.lesson-info { flex: 1; min-width: 0; }
.lesson-title { font-size: 13.5px; font-weight: 500; margin-bottom: 2px; }
.lesson-meta { font-size: 11.5px; color: var(--c-ink-3); }
.lesson-action {
  font-size: 12.5px;
  color: var(--c-primary);
  font-weight: 600;
  flex-shrink: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--c-primary-50);
  transition: all 0.15s;
  pointer-events: none; /* click megy a parent .lesson-item-re */
}
.lesson-item:hover .lesson-action {
  background: var(--c-primary);
  color: white;
}
.lesson-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--c-border-soft);
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.12s;
  margin: 0 -12px;
}
.lesson-item:hover {
  background: #FAFAF7;
}

/* ---------- FORMS ---------- */
.field { display: flex; flex-direction: column; }
.field label { font-size: 12px; font-weight: 500; color: var(--c-ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--c-surface);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-50); }
.field textarea { min-height: 80px; resize: vertical; line-height: 1.5; }

/* ---------- QUIZ ---------- */
.quiz-card { padding: 28px; max-width: 720px; margin: 0 auto; }
.quiz-progress { display: flex; gap: 4px; margin-bottom: 24px; }
.quiz-progress-step { flex: 1; height: 4px; background: var(--c-surface-muted); border-radius: 999px; }
.quiz-progress-step.current { background: var(--c-primary); }
.quiz-progress-step.done { background: var(--c-ok); }
.quiz-question { font-size: 18px; font-weight: 600; line-height: 1.5; margin-bottom: 20px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface);
  text-align: left;
  font-size: 13.5px;
  transition: all 0.15s;
  width: 100%;
}
.quiz-opt:hover { border-color: var(--c-primary); background: var(--c-primary-50); }
.quiz-opt.correct { border-color: var(--c-ok); background: var(--c-ok-bg); color: var(--c-ok); font-weight: 600; }
.quiz-opt.wrong { border-color: var(--c-err); background: var(--c-err-bg); color: var(--c-err); }
.quiz-opt-letter {
  width: 28px; height: 28px;
  background: var(--c-surface-muted);
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12.5px;
  flex-shrink: 0;
}
.quiz-opt.correct .quiz-opt-letter { background: var(--c-ok); color: white; }
.quiz-opt.wrong .quiz-opt-letter { background: var(--c-err); color: white; }
.quiz-explain {
  background: var(--c-primary-50);
  padding: 14px;
  border-radius: 10px;
  margin-top: 16px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--c-ink-1);
  display: flex; gap: 10px; align-items: flex-start;
}
.quiz-explain svg { color: var(--c-primary); flex-shrink: 0; margin-top: 2px; }

/* ---------- STATS CHARTS ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
.chart-container { height: 240px; }

/* ---------- PROFILE ---------- */
.profile-header { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding-bottom: 24px; border-bottom: 1px solid var(--c-border-soft); }
.profile-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  display: grid; place-items: center;
  font-size: 28px; font-weight: 700;
  flex-shrink: 0;
}

/* ---------- SETTINGS ---------- */
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--c-border-soft);
}
.setting-row:last-child { border-bottom: none; }
.setting-info h4 { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; }
.setting-info p { font-size: 12.5px; color: var(--c-ink-3); }
.toggle {
  width: 40px; height: 22px;
  background: var(--c-border);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--c-primary); }
.toggle.on::after { transform: translateX(18px); }

/* ---------- TOAST ---------- */
#toast-host {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background: #FFFFFF !important;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  min-width: 240px;
  max-width: 360px;
  color: #0F172A;
  border-left: 4px solid var(--c-primary);
  animation: slideIn 0.3s ease-out;
  pointer-events: auto;
}
.toast.success { border-left-color: #10B981; }
.toast.success::before { content: '✓'; color: #10B981; font-weight: 700; font-size: 15px; }
.toast.error { border-left-color: #EF4444; }
.toast.error::before { content: '✕'; color: #EF4444; font-weight: 700; font-size: 15px; }
.toast.info { border-left-color: var(--c-primary); }
.toast.info::before { content: 'ⓘ'; color: var(--c-primary); font-weight: 700; font-size: 15px; }
.toast span { color: #0F172A; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ---------- MOBILE / RESPONSIVE ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .ai-rec-items { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; place-items: center; position: absolute; top: 12px; right: 12px; }
  .sidebar-toggle { display: grid !important; place-items: center; }
  .topbar-search { display: none; }
  .view-host { padding: 16px; }
  .path-steps { grid-template-columns: repeat(2, 1fr); }
  .subjects-row { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px; }
}

#sidebar-toggle { display: none; }
@media (max-width: 768px) { #sidebar-toggle { display: grid !important; } }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: grid; place-items: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--c-surface);
  border-radius: 16px;
  max-width: 640px; width: 100%;
  max-height: 90vh;
  overflow: hidden; /* container nem scroll, csak a body */
  display: flex;
  flex-direction: column;
  animation: modalIn 0.25s ease-out;
  padding: 0; /* padding ide kerül a child-okra */
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.modal h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  padding: 24px 24px 14px;
  flex-shrink: 0;
}
.modal-body {
  font-size: 13.5px;
  color: var(--c-ink-2);
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding: 0 24px 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--c-border-soft);
  background: var(--c-surface);
  flex-shrink: 0;
}

/* ---------- UPLOAD / VISION ---------- */
.dropzone {
  border: 2px dashed var(--c-border);
  border-radius: var(--r-lg);
  padding: 60px 20px;
  text-align: center;
  background: var(--c-surface);
  cursor: pointer;
  transition: all 0.2s;
}
.dropzone:hover { border-color: var(--c-primary); background: var(--c-primary-50); }
.dropzone svg { color: var(--c-ink-4); margin-bottom: 16px; }
.dropzone h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.dropzone p { font-size: 13px; color: var(--c-ink-3); }
.uploaded-preview { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.uploaded-preview img { max-width: 100%; border-radius: var(--r-md); border: 1px solid var(--c-border-soft); }

@media (max-width: 768px) {
  .uploaded-preview { grid-template-columns: 1fr; }
}

/* ---------- PROFILE STATS ---------- */
.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s-4);
  padding-top: 20px;
  margin-top: 4px;
}
.profile-stat { text-align: center; }
.profile-stat-value { font-size: 22px; font-weight: 700; color: var(--c-primary); letter-spacing: -0.02em; }
.profile-stat-label { font-size: 11.5px; color: var(--c-ink-3); margin-top: 2px; }

@media (max-width: 600px) {
  .profile-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- MENTOR PAGE LAYOUT ---------- */
.mentor-page {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--s-4);
}
.mentor-side {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: 14px;
  height: fit-content;
  max-height: 600px;
  overflow-y: auto;
}
.mentor-side h4 { font-size: 12px; font-weight: 600; color: var(--c-ink-3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; padding: 0 8px; }
.mentor-thread {
  padding: 10px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.15s;
}
.mentor-thread:hover { background: var(--c-surface-muted); }

@media (max-width: 900px) {
  .mentor-page { grid-template-columns: 1fr; }
  .mentor-side { max-height: 200px; }
}

/* ---------- MENTOR SUGGEST CHIPS ---------- */
.mentor-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mentor-suggest button {
  font-size: 11.5px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--c-primary-50);
  color: var(--c-primary);
  font-weight: 500;
  transition: all 0.15s;
}
.mentor-suggest button:hover { background: var(--c-primary); color: white; }

.mentor-input textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  resize: none;
  outline: none;
  padding: 6px 0;
  font-family: inherit;
  color: var(--c-ink-1);
  max-height: 120px;
  line-height: 1.5;
}
.mentor-input button {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.mentor-input button:hover:not(:disabled) { transform: scale(1.08); }
.mentor-input button:disabled { opacity: 0.5; }


/* ================================================================
   MENTOR PAGE (folytatás)
   ================================================================ */
.mentor-thread.active { background: var(--c-primary-50); color: var(--c-primary); font-weight: 600; }
.mentor-thread-time { font-size: 11px; color: var(--c-ink-4); margin-top: 2px; }
.mentor-thread.active .mentor-thread-time { color: var(--c-accent-light); }

.mentor-main {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  min-height: 600px;
  overflow: hidden;
}

.mentor-chat-header { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border-soft); display: flex; align-items: center; gap: var(--s-3); }
.mentor-chat-body { flex: 1; padding: var(--s-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-4); }
.mentor-chat-body .msg { max-width: 75%; }
.mentor-chat-body .msg-bubble { font-size: 13.5px; padding: 12px 16px; }

.mentor-input-area { padding: var(--s-4); border-top: 1px solid var(--c-border-soft); }
.mentor-input {
  display: flex; gap: var(--s-2);
  background: var(--c-surface-muted);
  border-radius: 12px;
  padding: 4px 4px 4px 12px;
  align-items: flex-end;
  border: 1px solid var(--c-border-soft);
}
.mentor-input:focus-within { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(91, 79, 229, 0.08); }
.mentor-input textarea { flex: 1; resize: none; font-size: 13.5px; padding: 9px 0; max-height: 120px; font-family: inherit; }
.mentor-input button { width: 36px; height: 36px; border-radius: 9px; background: var(--c-primary); color: white; display: grid; place-items: center; flex-shrink: 0; }
.mentor-input button:disabled { opacity: 0.4; }
.mentor-input button svg { width: 16px; height: 16px; }

.mentor-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-3); }
.mentor-suggest button {
  font-size: 12px; padding: 6px 12px;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: 999px; color: var(--c-ink-2);
  transition: all 0.15s;
}
.mentor-suggest button:hover { background: var(--c-primary-50); border-color: var(--c-primary-100); color: var(--c-primary); }

/* EXAM / PLAN */
.exam-form { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 760px) { .exam-form { grid-template-columns: 1fr; } }

.exam-plan { margin-top: var(--s-5); background: var(--c-surface); border: 1px solid var(--c-border-soft); border-radius: var(--r-lg); padding: var(--s-5); }
.plan-day { display: flex; gap: var(--s-3); padding: var(--s-3); border-bottom: 1px solid var(--c-border-soft); }
.plan-day:last-child { border-bottom: none; }
.plan-day-num { width: 38px; height: 38px; border-radius: 10px; background: var(--c-primary-50); color: var(--c-primary); font-weight: 700; font-size: 13px; display: grid; place-items: center; flex-shrink: 0; }
.plan-day.done .plan-day-num { background: var(--c-success); color: white; }
.plan-day-content { flex: 1; min-width: 0; }
.plan-day-date { font-size: 11.5px; color: var(--c-ink-3); font-weight: 500; margin-bottom: 2px; }
.plan-day-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.plan-day-tasks { font-size: 12.5px; color: var(--c-ink-2); line-height: 1.55; }
.plan-day-tasks ul { padding-left: var(--s-4); margin-top: 4px; }
.plan-day-check { margin-left: auto; }

/* QUIZ */
.quiz-card { max-width: 720px; margin: 0 auto; }
.quiz-progress { display: flex; gap: 4px; margin-bottom: var(--s-5); }
.quiz-progress-step { flex: 1; height: 4px; background: var(--c-surface-muted); border-radius: 999px; transition: background 0.3s; }
.quiz-progress-step.done { background: var(--c-primary); }
.quiz-progress-step.current { background: var(--c-primary); opacity: 0.5; }

.quiz-question { font-size: 19px; font-weight: 600; line-height: 1.4; margin-bottom: var(--s-5); letter-spacing: -0.01em; }
.quiz-options { display: grid; gap: var(--s-3); }
.quiz-opt {
  padding: var(--s-4) var(--s-5);
  background: var(--c-surface);
  border: 1.5px solid var(--c-border);
  border-radius: var(--r);
  display: flex; align-items: center; gap: var(--s-3);
  font-size: 14px; font-weight: 500;
  transition: all 0.15s; cursor: pointer;
}
.quiz-opt:hover { border-color: var(--c-primary); background: var(--c-primary-50); }
.quiz-opt-letter {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--c-surface-muted);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: var(--c-ink-3);
  flex-shrink: 0; transition: all 0.15s;
}
.quiz-opt:hover .quiz-opt-letter { background: var(--c-primary); color: white; }
.quiz-opt.correct { border-color: var(--c-success); background: var(--c-success-50); }
.quiz-opt.correct .quiz-opt-letter { background: var(--c-success); color: white; }
.quiz-opt.wrong { border-color: var(--c-danger); background: var(--c-danger-50); }
.quiz-opt.wrong .quiz-opt-letter { background: var(--c-danger); color: white; }

.quiz-explain {
  margin-top: var(--s-4); padding: var(--s-4);
  background: var(--c-primary-50);
  border-radius: var(--r);
  font-size: 13px; color: var(--c-primary-700);
  line-height: 1.6;
  display: flex; gap: var(--s-3); align-items: flex-start;
}
.quiz-explain svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* FLASHCARD */
.flashcard-wrap { max-width: 600px; margin: 0 auto; text-align: center; }
.flashcard { perspective: 1500px; height: 320px; margin-bottom: var(--s-5); cursor: pointer; }
.flashcard-inner { position: relative; width: 100%; height: 100%; transition: transform 0.7s var(--ease); transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--r-xl);
  padding: var(--s-8);
  display: grid; place-items: center; text-align: center;
}
.flashcard-front { background: var(--c-surface); border: 2px solid var(--c-border); }
.flashcard-back {
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  color: white;
  transform: rotateY(180deg);
  box-shadow: var(--sh-primary);
}
.flashcard-q { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.4; }
.flashcard-a { font-size: 17px; line-height: 1.6; }
.flashcard-hint { position: absolute; bottom: var(--s-4); left: 50%; transform: translateX(-50%); font-size: 11.5px; color: var(--c-ink-4); font-weight: 500; }
.flashcard-back .flashcard-hint { color: rgba(255,255,255,0.7); }
.flashcard-controls { display: flex; gap: var(--s-3); justify-content: center; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 900px) { .stats-grid { grid-template-columns: 1fr; } }
.chart-container { height: 240px; position: relative; }

/* ACHIEVEMENTS */
.achievements-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s-3); }
.achievement {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-md);
  padding: var(--s-4);
  text-align: center;
  transition: all 0.2s;
}
.achievement:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.achievement.locked { opacity: 0.5; filter: grayscale(0.6); }
.achievement-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, #FBBF24, #F59E0B);
  display: grid; place-items: center;
  margin: 0 auto var(--s-3);
  font-size: 26px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.achievement.locked .achievement-icon { background: var(--c-surface-muted); box-shadow: none; }
.achievement-name { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.achievement-desc { font-size: 11px; color: var(--c-ink-3); line-height: 1.4; }

/* PROFILE */
.profile-header { display: flex; align-items: center; gap: var(--s-5); padding-bottom: var(--s-5); border-bottom: 1px solid var(--c-border-soft); margin-bottom: var(--s-5); flex-wrap: wrap; }
.profile-avatar-lg {
  width: 80px; height: 80px; border-radius: 20px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white; font-size: 28px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: var(--sh-primary);
}
.profile-name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.profile-meta { color: var(--c-ink-3); font-size: 13.5px; margin-top: 2px; }
.profile-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); margin-top: var(--s-4); }
@media (max-width: 700px) { .profile-stats { grid-template-columns: repeat(2, 1fr); } }
.profile-stat { text-align: center; padding: var(--s-3); background: var(--c-surface-muted); border-radius: var(--r-md); }
.profile-stat-value { font-size: 22px; font-weight: 700; color: var(--c-primary); letter-spacing: -0.02em; }
.profile-stat-label { font-size: 11.5px; color: var(--c-ink-3); margin-top: 2px; }

/* SETTING ROW */
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: var(--s-4) 0; border-bottom: 1px solid var(--c-border-soft); gap: var(--s-3); }
.setting-row:last-child { border-bottom: none; }
.setting-info h4 { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.setting-info p { font-size: 12px; color: var(--c-ink-3); }
.toggle { position: relative; width: 40px; height: 22px; background: var(--c-border-strong); border-radius: 999px; cursor: pointer; transition: background 0.2s; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle.on { background: var(--c-primary); }
.toggle.on::after { transform: translateX(18px); }

/* VISION */
.dropzone {
  border: 2px dashed var(--c-border-strong);
  border-radius: var(--r-lg);
  padding: var(--s-12) var(--s-6);
  text-align: center; cursor: pointer;
  transition: all 0.2s;
  background: var(--c-surface-muted);
}
.dropzone:hover { border-color: var(--c-primary); background: var(--c-primary-50); }
.dropzone svg { width: 48px; height: 48px; color: var(--c-ink-4); margin: 0 auto var(--s-3); display: block; }
.dropzone h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.dropzone p { color: var(--c-ink-3); font-size: 13px; }

.uploaded-preview { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 800px) { .uploaded-preview { grid-template-columns: 1fr; } }
.uploaded-preview img { width: 100%; border-radius: var(--r-md); border: 1px solid var(--c-border); max-height: 500px; object-fit: contain; background: var(--c-surface-muted); }

/* CHALLENGES */
.challenges-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-4); }
@media (max-width: 900px) { .challenges-grid { grid-template-columns: 1fr; } }
.challenge {
  background: var(--c-surface);
  border: 1px solid var(--c-border-soft);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex; gap: var(--s-4); align-items: flex-start;
  transition: all 0.2s;
}
.challenge:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.challenge-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  display: grid; place-items: center; color: white;
  flex-shrink: 0; font-size: 24px;
}
.challenge-info { flex: 1; min-width: 0; }
.challenge-title { font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
.challenge-desc { font-size: 12.5px; color: var(--c-ink-3); margin-bottom: var(--s-3); }
.challenge-progress { height: 6px; background: var(--c-surface-muted); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.challenge-progress-fill { height: 100%; background: linear-gradient(90deg, var(--c-primary), var(--c-accent)); border-radius: 999px; }
.challenge-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--c-ink-3); }
.challenge-meta b { color: var(--c-primary); font-weight: 600; }

/* MODAL — primary definition is earlier */

/* TOAST */
#toast-host {
  position: fixed; bottom: var(--s-5); right: var(--s-5);
  z-index: 200;
  display: flex; flex-direction: column; gap: var(--s-2);
  pointer-events: none;
}
/* (Toast styles defined earlier — duplicate block removed) */

/* RESPONSIVE */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  .view-host { padding: var(--s-5); }
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0;
    width: 280px;
    transform: translateX(-100%);
    box-shadow: var(--sh-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-toggle { display: grid; }
  .search { max-width: none; margin: 0; }
  .user-meta { display: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 var(--s-3); gap: var(--s-2); }
  .breadcrumb { display: none; }
  .view-host { padding: var(--s-3); }
  .greeting-title { font-size: 22px; }
}
@media (hover: none) {
  .kpi:hover, .subject-tile:hover, .path-step:hover { transform: none; }
  .btn-primary:hover { transform: none; }
}
:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }

/* ================================================================
   FIX: HTML class név illesztések
   ================================================================ */

/* SIDEBAR header */
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 20px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.logo-mark img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.logo-mark-lg {
  width: 72px; height: 72px;
  border-radius: 18px;
  margin-bottom: 6px;
}
.logo-text { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--c-ink-1); }
.status-dot {
  width: 8px; height: 8px;
  background: var(--c-ok);
  border-radius: 50%;
  display: inline-block;
}

/* SIDEBAR footer */
.sidebar-footer { margin-top: auto; padding-top: 14px; }

/* TOPBAR - fix layout */
.topbar { padding: 14px 28px; }

.breadcrumb { font-size: 13px; color: var(--c-ink-3); display: flex; align-items: center; gap: 6px; }
.crumb-root { font-weight: 600; color: var(--c-ink-2); }
.crumb-sep { color: var(--c-ink-4); }
.crumb-current { color: var(--c-ink-1); font-weight: 600; }

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--c-surface-muted);
  border-radius: 10px;
  padding: 7px 12px;
  width: 280px;
  font-size: 12.5px;
  color: var(--c-ink-3);
}
.search svg { stroke: var(--c-ink-4); flex-shrink: 0; }
.search input {
  border: none; background: transparent;
  font-size: 12.5px; flex: 1; outline: none;
  color: var(--c-ink-1);
}
.search kbd {
  font-family: inherit;
  font-size: 10.5px;
  padding: 2px 6px;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  color: var(--c-ink-3);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.badge-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 7px; height: 7px;
  background: var(--c-err);
  border-radius: 50%;
  border: 2px solid var(--c-surface);
}

/* USER CHIP (re-style for HTML structure) */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--c-surface-muted);
  cursor: pointer;
  transition: background 0.15s;
}
.user-chip:hover { background: var(--c-primary-50); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: white;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--c-ink-1); }
.user-sub { font-size: 10.5px; color: var(--c-ink-3); }

/* Sidebar toggle: rejtve desktop-on, mutatva mobilon */
.sidebar-toggle, #sidebar-toggle { display: none; }
@media (max-width: 1023px) {
  .sidebar-toggle, #sidebar-toggle {
    display: grid !important;
    place-items: center;
  }
}


/* ================================================================
   FX animations
   ================================================================ */
@keyframes pop {
  0% { transform: scale(0); opacity: 0; }
  60% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); }
}

/* Streaming bubble cursor */
.msg-bubble.streaming::after {
  content: '▋';
  margin-left: 1px;
  animation: blink 0.8s infinite;
  color: var(--c-primary);
  opacity: 0.7;
}
@keyframes blink {
  0%, 50% { opacity: 0.7; }
  51%, 100% { opacity: 0; }
}

/* ================================================================
   📱 TABLET (iPad) OPTIMIZATION
   - iPad portrait:  768x1024  →  keep sidebar, 2-col dash
   - iPad landscape: 1024x768  →  desktop-like, slightly tighter
   - All touch: 44px min targets, no hover stickiness, no input zoom
   ================================================================ */

/* --- Touch targets: applies to any touch device (no hover support) --- */
@media (hover: none), (pointer: coarse) {
  .btn { min-height: 44px; padding: 12px 18px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 8px 14px; font-size: 13px; }
  .nav-item { padding: 12px 12px; font-size: 14px; }
  .icon-btn { width: 44px; height: 44px; }
  .nova-send, .mentor-input button { width: 42px; height: 42px; }
  .quiz-opt { padding: 16px 18px; min-height: 56px; font-size: 14.5px; }
  .lesson-item { padding: 16px 0; }
  .path-step { padding: 18px 12px; }
  .subject-card, .subject-tile { padding: 16px; }
  .toggle { width: 48px; height: 28px; }
  .toggle::after { width: 24px; height: 24px; }
  .toggle.on::after { transform: translateX(20px); }
  .mentor-thread { padding: 14px; }

  /* Disable :hover-only transforms (they "stick" on touch) */
  .kpi:hover, .subject-card:hover, .subject-tile:hover,
  .path-step:hover, .ai-rec-item:hover { transform: none; }

  /* Tap highlight */
  * { -webkit-tap-highlight-color: rgba(91, 79, 229, 0.12); }

  /* Input zoom on focus prevention (iOS) */
  input, select, textarea {
    font-size: 16px !important;
  }
  .field input, .field select, .field textarea,
  .login-form input, .login-form select {
    font-size: 16px;
    padding: 12px 14px;
  }
  .topbar-search input, .search input { font-size: 14px; }
  .nova-input input { font-size: 15px; padding: 10px 16px; }
  .mentor-input textarea { font-size: 15px; }
}

/* --- iPad PORTRAIT specific (768-1023px wide) --- */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --sidebar-w: 220px; }
  .view-host { padding: 22px; max-width: none; }
  .topbar { padding: 12px 22px; }

  /* Hide search to save horizontal space */
  .topbar-search, .search { display: none; }

  /* Dashboard: 2-col with goal+nova narrower */
  .dash-grid { grid-template-columns: 1fr 300px; gap: 16px; }

  /* KPI: 2x2 grid not 4x1 */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 22px; }

  /* Learning path: 5 steps still fit but tighter */
  .path-steps { gap: 8px; }
  .path-step-title { font-size: 12px; }

  /* Subject row: 2x2 instead of 4x1 on dashboard */
  .subjects-row { grid-template-columns: repeat(2, 1fr); }

  /* AI rec: stack to 1 col */
  .ai-rec-items { grid-template-columns: 1fr; }

  /* Greeting */
  .greeting-title { font-size: 20px; }
  .greeting { padding: 22px; }

  /* Sidebar: tighter padding */
  .sidebar { padding: 16px 10px; }
  .nav-item { padding: 10px 10px; font-size: 13px; }
  .nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sidebar-brand .sidebar-name, .logo-text { font-size: 16px; }

  /* Mentor page side narrower */
  .mentor-page { grid-template-columns: 220px 1fr; }
  .mentor-side { padding: 12px; max-height: 480px; }

  /* Stats: 2-col still works */
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* --- iPad LANDSCAPE specific (1024-1180px) --- */
@media (min-width: 1024px) and (max-width: 1180px) {
  :root { --sidebar-w: 232px; }
  .view-host { padding: 24px; max-width: none; }

  /* Dashboard: full 1 + 320px sidebar */
  .dash-grid { grid-template-columns: 1fr 320px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

/* --- Login screen on iPad (looks lost on big screen) --- */
@media (min-width: 768px) and (max-width: 1180px) {
  .login-card {
    max-width: 480px;
    padding: 44px 40px;
  }
  .login-title { font-size: 30px; }
  .login-logo { width: 72px; height: 72px; }
  .demo-btn { padding: 16px; font-size: 14.5px; }
  .demo-btn svg { width: 20px; height: 20px; }
}

/* --- Lesson modal & achievement popup: bigger on tablet --- */
@media (min-width: 768px) {
  .modal { max-width: 540px; }
  .modal h2 { font-size: 20px; }
  .modal-body { font-size: 14.5px; }
  .achievement-popup { max-width: 420px !important; padding: 48px 40px 32px !important; }
}

/* --- Touch-friendly chat scroll, sticky input on small screens --- */
@media (hover: none) {
  .nova-body, .mentor-chat-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

/* --- Standalone PWA mode (added to home screen on iPad) --- */
@media (display-mode: standalone) {
  body { background: var(--c-bg); }
  /* Add subtle top padding for iPad notch / status bar area */
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .sidebar { padding-top: max(20px, env(safe-area-inset-top)); }
}

/* --- Bigger fonts on iPad for readability --- */
@media (min-width: 768px) and (max-width: 1180px) {
  body { font-size: 14.5px; }
  .lesson-title { font-size: 14.5px; }
  .lesson-meta { font-size: 12.5px; }
  .nav-item { font-size: 13.5px; }
  .card-title { font-size: 15.5px; }
  .subject-tile-name { font-size: 16px; }
  .quiz-question { font-size: 19px; }
}

/* --- Prevent horizontal scroll on any device --- */
html, body { overflow-x: hidden; }
.view-host { min-width: 0; }
.dash-grid, .kpi-grid, .stats-grid { min-width: 0; }

/* --- iPad pencil / fine cursor uses :hover normally --- */
@media (any-hover: hover) {
  .kpi:hover { transform: translateY(-2px); }
}

/* ================================================================
   📖 LESSON MODAL - MARKDOWN CONTENT
   ================================================================ */
.lesson-modal-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}
.modal { max-width: 600px; }
.lesson-content.markdown { font-size: 14px; line-height: 1.65; color: #1F2937; }

.md-h1 { font-size: 19px; font-weight: 700; margin: 18px 0 10px; color: #0F172A; letter-spacing: -0.01em; }
.md-h1:first-child { margin-top: 0; }
.md-h2 { font-size: 16.5px; font-weight: 700; margin: 18px 0 8px; color: #1E293B; letter-spacing: -0.01em; }
.md-h3 { font-size: 14.5px; font-weight: 700; margin: 14px 0 6px; color: #334155; }

.md-p { margin: 0 0 12px; }
.md-p:last-child { margin-bottom: 0; }

.md-ul, .md-ol { padding-left: 22px; margin: 8px 0 14px; }
.md-ul li, .md-ol li { margin: 4px 0; line-height: 1.55; }
.md-ul { list-style: disc; }
.md-ol { list-style: decimal; }

.md-quote {
  border-left: 3px solid #5B4FE5;
  padding: 8px 14px;
  margin: 12px 0;
  background: #F4F0FF;
  color: #4338CA;
  font-style: italic;
  border-radius: 0 8px 8px 0;
}

.md-code {
  background: #F1F5F9;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SF Mono, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.md-pre {
  background: #0F172A;
  color: #E2E8F0;
  padding: 14px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12.5px;
  margin: 12px 0;
  line-height: 1.5;
}
.md-pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 1em;
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.md-table th, .md-table td {
  border: 1px solid #E2E8F0;
  padding: 6px 10px;
  text-align: left;
}
.md-table th {
  background: #F8FAFC;
  font-weight: 600;
  color: #1E293B;
}
.md-table tr:nth-child(even) td { background: #FAFBFC; }

.lesson-content strong { font-weight: 700; color: #0F172A; }
.lesson-content em { font-style: italic; color: #475569; }

/* Spinner used in lesson loader */
.spinner {
  width: 28px; height: 28px;
  border: 3px solid #E2E8F0;
  border-top-color: #5B4FE5;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* iPad - bigger fonts in lesson modal */
@media (min-width: 768px) {
  .lesson-modal-body { max-height: 65vh; }
  .lesson-content.markdown { font-size: 15px; }
  .md-h1 { font-size: 21px; }
  .md-h2 { font-size: 18px; }
  .md-h3 { font-size: 15.5px; }
}

/* ================================================================
   📊 RANGE TABS (Hét/Hónap/Félév) + Rank grid
   ================================================================ */
.range-tabs {
  display: inline-flex;
  background: #F1F5F9;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.range-tab {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748B;
  border-radius: 7px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}
.range-tab:hover { color: #0F172A; }
.range-tab.active {
  background: #FFFFFF;
  color: #5B4FE5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.rank-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 720px) {
  .rank-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ================================================================
   📝 LOGIN FORM EXTRAS
   ================================================================ */
.login-form .field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.login-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2364748B' stroke-width='2' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-error {
  color: var(--c-err);
  font-size: 12.5px;
  min-height: 18px;
  margin: 0;
}
.login-footer {
  text-align: center;
  font-size: 12px;
  color: var(--c-ink-3);
  margin-top: 16px;
  line-height: 1.5;
}
.login-footer .muted { color: var(--c-ink-4); font-size: 11.5px; }
.btn-block { width: 100%; }
.btn-demo {
  border: 2px dashed var(--c-primary);
  color: var(--c-primary);
  background: var(--c-surface);
  gap: 8px;
}
.btn-demo:hover { background: var(--c-primary-50); }

/* ================================================================
   💬 MENTOR - ATTACHMENT + SVG
   ================================================================ */
.mentor-input { position: relative; }
.mentor-attach-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: #64748B;
  border-radius: 8px;
  transition: all 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mentor-attach-btn:hover { background: #F1F5F9; color: #5B4FE5; }

.mentor-attach-preview {
  padding: 8px 0 0 0;
}
.attach-thumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 6px 10px 6px 6px;
  position: relative;
}
.attach-thumb img {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.attach-name {
  font-size: 12px;
  color: #475569;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attach-remove {
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}
.attach-remove:hover { background: #FECACA; }

.msg-attached-img {
  max-width: 280px;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  margin-bottom: 8px;
}

.msg-svg {
  margin: 10px 0;
  padding: 10px;
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
}
.msg-svg svg {
  width: 100%;
  max-width: 500px;
  height: auto;
  display: block;
}

.msg-text { line-height: 1.55; }
.msg-text + .msg-svg { margin-top: 10px; }

/* ================================================================
   🔎 GLOBAL SEARCH DROPDOWN
   ================================================================ */
.search {
  position: relative;
}
.search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  max-height: 380px;
  overflow-y: auto;
  z-index: 100;
  padding: 6px;
}
.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.search-item:hover { background: var(--c-primary-50); }
.search-item-icon {
  width: 28px;
  height: 28px;
  background: #F1F5F9;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--c-primary);
  font-weight: 700;
}
.search-item-body { flex: 1; min-width: 0; }
.search-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-ink-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-item-sub {
  font-size: 11.5px;
  color: var(--c-ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.search-empty {
  padding: 16px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--c-ink-3);
}

/* ================================================================
   📱 UNIFIED RESPONSIVE STRATEGY — overrides at end (highest priority)
   Breakpoints:
     ≤480px   — mobile (telefon)
     481-767  — large mobile / small tablet
     768-1023 — iPad portrait
     1024-1279 — iPad landscape / small laptop
     ≥1280    — desktop
   ================================================================ */

/* ---------- MOBILE ≤ 767px ---------- */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 260px;
  }

  body {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
  }

  /* Off-canvas sidebar */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    z-index: 1500;
    box-shadow: 4px 0 30px rgba(0,0,0,0.15);
    background: var(--c-surface);
  }
  .sidebar.open { transform: translateX(0); }

  /* Show close button on mobile */
  .sidebar-close { display: grid !important; }
  .sidebar-toggle { display: grid !important; }

  /* Main shifts to fullwidth */
  .app-shell { grid-template-columns: 1fr; }
  .main { margin-left: 0; }

  /* Topbar */
  .topbar {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .breadcrumb { font-size: 12px; gap: 4px; }
  .crumb-root { display: none; }
  .crumb-sep { display: none; }

  /* Hide search bar on mobile */
  .search { display: none !important; }

  /* User chip — show only avatar */
  .user-meta { display: none; }
  .user-chip { padding: 4px; gap: 0; }
  .avatar { width: 32px; height: 32px; }

  .topbar-actions { gap: 6px; margin-left: auto; }

  /* Content padding */
  .view-host, .view {
    padding: 14px;
    max-width: 100%;
  }

  /* Page header — stack title and action */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .page-title { font-size: 22px; }
  .page-subtitle { font-size: 13px; }

  /* KPI cards: 2 column grid */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }
  .kpi-delta { font-size: 11px; }

  /* Dashboard grid: single column */
  .dash-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* Subject cards: 2 column */
  .subjects-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .subject-card { padding: 12px; }
  .subject-name { font-size: 12px; }

  /* Subjects PAGE grid: full width single column */
  .subjects-page-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Cards general */
  .card { padding: 16px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-title { font-size: 14.5px; }

  /* Learning path */
  .path-steps {
    flex-wrap: wrap;
    gap: 8px;
  }
  .path-step {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    padding: 12px 8px;
  }
  .path-step-title { font-size: 11px; }
  .path-step-meta { font-size: 10px; }

  /* AI recommendations - single column */
  .ai-rec-items {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .ai-rec { padding: 14px; }
  .ai-rec-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .ai-rec-tag { font-size: 10px; }

  /* Stats */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .chart-container { height: 220px !important; }
  .rank-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .range-tabs { flex: 1; }
  .range-tab { flex: 1; padding: 8px 10px; font-size: 12.5px; }

  /* Mentor — single column, side hidden */
  .mentor-page {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .mentor-side {
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
  }
  .mentor-thread { padding: 10px; font-size: 13px; }
  .mentor-thread-time { font-size: 10.5px; }
  .mentor-chat-body { padding: 12px; }
  .mentor-input-area { padding: 10px; }
  .mentor-input textarea { font-size: 16px; }
  .mentor-suggest {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .mentor-suggest button {
    flex-shrink: 0;
    font-size: 11.5px;
    padding: 6px 12px;
  }
  .msg-bubble { max-width: 85%; font-size: 14px; }
  .msg-attached-img { max-width: 220px; }
  .msg-svg svg { max-width: 100%; }

  /* Lesson items — bigger touch */
  .lesson-item {
    padding: 14px 8px;
    gap: 10px;
  }
  .lesson-title { font-size: 13.5px; }
  .lesson-meta { font-size: 11px; }
  .lesson-action {
    font-size: 11px;
    padding: 5px 8px;
  }

  /* Modal — fullscreen-like on mobile */
  .modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .modal {
    max-width: 100% !important;
    width: 100%;
    border-radius: 0;
    max-height: 100vh;
    padding: 0; /* keep flex layout — children have their own padding */
  }
  .modal h2 {
    font-size: 17px;
    padding: 16px 16px 12px;
  }
  .modal-body {
    padding: 0 16px 8px;
  }
  .modal-actions {
    padding: 12px 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .lesson-content.markdown { font-size: 14px; }
  .md-h1 { font-size: 18px; }
  .md-h2 { font-size: 16px; }
  .md-h3 { font-size: 14.5px; }
  .md-table { font-size: 11.5px; }
  .md-table th, .md-table td { padding: 5px 7px; }

  /* Forms */
  .field input, .field select, .field textarea {
    font-size: 16px;
    padding: 11px 13px;
  }
  .field-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 13.5px; min-height: 40px; }
  .btn-sm { padding: 7px 11px; font-size: 12.5px; min-height: 34px; }
  .btn-ghost.btn-sm { padding: 4px 8px; }

  /* Login screen */
  .login-screen { padding: 12px; align-items: flex-start; padding-top: 30px; }
  .login-card {
    max-width: 100%;
    padding: 22px 18px;
    border-radius: 16px;
  }
  .login-brand { margin-bottom: 18px; }
  .login-brand .logo-mark-lg { width: 56px; height: 56px; }
  .login-brand h1 { font-size: 22px; }
  .login-tagline { font-size: 12.5px; }
  .login-form { gap: 10px; }

  /* Profile */
  .profile-stats {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  /* Challenges */
  .challenges-grid {
    grid-template-columns: 1fr !important;
  }

  /* Achievement popup */
  .achievement-popup {
    width: calc(100vw - 24px) !important;
    max-width: 360px !important;
    padding: 28px 20px 24px !important;
  }

  /* Toast */
  #toast-host {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    font-size: 13px;
  }

  /* Search dropdown — fullwidth */
  .search-dropdown { left: 12px; right: 12px; }

  /* Topbar notification - hide badge dot */
  #btn-notifications .badge-dot { display: none; }

  /* Hide kbd shortcut hint */
  .search kbd { display: none; }

  /* Topbar layout fix */
  .topbar {
    display: flex;
    align-items: center;
  }

  /* Quiz */
  .quiz-card { padding: 18px; }
  .quiz-question { font-size: 16px; }
  .quiz-opt { padding: 12px 14px; font-size: 13.5px; min-height: 48px; }

  /* Exam form */
  .exam-form { grid-template-columns: 1fr; gap: 12px; }

  /* Plan day item */
  .plan-day {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  .plan-day-content { flex: 1 1 100%; }
  .plan-day-check {
    flex: 1 1 100%;
    flex-direction: row !important;
    justify-content: flex-end;
    align-items: center !important;
  }
  .plan-day-check .btn { flex: 0 0 auto; }

  /* Vision uploaded preview */
  .uploaded-preview { grid-template-columns: 1fr; }
}

/* ---------- SMALL MOBILE ≤ 380px ---------- */
@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .subjects-row { grid-template-columns: 1fr; }
  .path-step { flex: 1 1 100%; }
  .page-title { font-size: 20px; }
  .login-brand h1 { font-size: 20px; }
  .mentor-suggest { display: none; }
}

/* ---------- iPad PORTRAIT 768-1023px ---------- */
@media (min-width: 768px) and (max-width: 1023px) {
  :root { --sidebar-w: 240px; }
  .topbar { padding: 12px 20px; }
  .search { display: flex !important; }
  .search input { font-size: 13px; }
  .view-host, .view { padding: 22px; max-width: none; }
  .page-title { font-size: 26px; }

  /* Sidebar is off-canvas on portrait */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    z-index: 1500;
    box-shadow: 4px 0 30px rgba(0,0,0,0.15);
    background: var(--c-surface);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid !important; }
  .app-shell { grid-template-columns: 1fr; }
  .main { margin-left: 0; }

  /* Dashboard: single column on tablet portrait */
  .dash-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* KPI: 2x2 grid */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .subjects-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .subjects-page-grid { grid-template-columns: repeat(2, 1fr); }
  .ai-rec-items { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .mentor-page { grid-template-columns: 240px 1fr; }

  .plan-day { flex-wrap: nowrap; }
  .plan-day-check { flex-direction: column !important; }

  .msg-bubble { max-width: 75%; }
}

/* On iPad portrait, sidebar backdrop also shows */
@media (min-width: 768px) and (max-width: 1023px) {
  .sidebar-backdrop { display: block; }
}

/* ---------- iPad LANDSCAPE 1024-1279px ---------- */
@media (min-width: 1024px) and (max-width: 1279px) {
  :root { --sidebar-w: 230px; }
  .view-host { padding: 24px; max-width: none; }
  .dash-grid { grid-template-columns: 1fr 320px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .subjects-row { grid-template-columns: repeat(4, 1fr); }
  .subjects-page-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- DESKTOP ≥1280px ---------- */
@media (min-width: 1280px) {
  .view-host { max-width: 1400px; }
}

/* ---------- TOUCH DEVICES (any) ---------- */
@media (hover: none), (pointer: coarse) {
  /* No hover transforms — they stick on touch */
  .kpi:hover,
  .subject-card:hover,
  .subject-tile:hover,
  .path-step:hover,
  .ai-rec-item:hover,
  .lesson-item:hover { transform: none; }

  /* Tap highlight */
  * { -webkit-tap-highlight-color: rgba(91, 79, 229, 0.15); }

  /* 16px input prevents iOS zoom */
  input:not([type="checkbox"]):not([type="radio"]),
  select, textarea {
    font-size: 16px !important;
  }

  /* Smooth scroll on iOS */
  .modal-body,
  .mentor-chat-body,
  .nova-body,
  .lesson-modal-body {
    -webkit-overflow-scrolling: touch;
  }

  /* Bigger touch targets */
  .btn { min-height: 42px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .nav-item { min-height: 42px; }
  .toggle { width: 46px; height: 26px; }
}

/* ---------- PWA STANDALONE MODE ---------- */
@media (display-mode: standalone) {
  .topbar {
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .sidebar {
    padding-top: max(20px, env(safe-area-inset-top));
  }
  .login-screen {
    padding-top: max(20px, env(safe-area-inset-top));
  }
  #toast-host {
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* ---------- LANDSCAPE PHONES ---------- */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  .login-screen { padding-top: 10px; }
  .login-card { padding: 18px 22px; }
  .login-brand { margin-bottom: 12px; }
  .login-brand .logo-mark-lg { width: 44px; height: 44px; }
}

/* ---------- PREVENT HORIZONTAL OVERFLOW ---------- */
html, body { overflow-x: hidden; max-width: 100vw; }
.view-host, .view, .main { min-width: 0; max-width: 100%; }
.card, .kpi, .subject-card, .subject-tile { min-width: 0; }
img, svg { max-width: 100%; height: auto; }
pre, code { overflow-x: auto; }
table { display: block; overflow-x: auto; }
.md-table { display: table; min-width: 100%; }

/* ---------- TOAST ALWAYS VISIBLE ---------- */
#toast-host {
  position: fixed;
  top: auto;
  bottom: 20px;
  right: 20px;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

/* ---------- SIDEBAR BACKDROP (mobile) ---------- */
.sidebar-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1400;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-out;
  display: none;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 767px) {
  .sidebar-backdrop { display: block; }
}
