/* ─── Reset & base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { direction: rtl; font-size: 16px; }

body {
  font-family: 'Heebo', sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg-body);
  color: var(--text-primary);
  transition: background 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  padding-bottom: 3rem;
  overscroll-behavior-y: contain;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ─── Design tokens (spacing, typography, radius, shadows) ─────────────── */
:root {
  --space-xs:  0.25rem;  --space-sm: 0.5rem;   --space-md: 0.75rem;
  --space-lg:  1rem;     --space-xl: 1.25rem;  --space-2xl: 1.5rem;
  --space-3xl: 2rem;     --space-4xl: 2.5rem;  --space-5xl: 3rem;
  --text-xs:   0.75rem;  --text-sm:  0.875rem; --text-base: 1rem;
  --text-lg:   1.125rem; --text-xl:  1.25rem;   --text-2xl: 1.5rem;
  --text-3xl:  1.75rem;  --text-card-mobile: 1.125rem;  /* 18px */
  --text-card-desktop: 1.25rem;  /* 20px */
  --radius-sm: 10px;     --radius-md: 14px;     --radius-lg: 18px;
  --radius-xl: 22px;     --radius-2xl: 26px;   --radius-full: 9999px;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 6px 24px rgba(0,0,0,0.1), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-card-pressed: 0 1px 8px rgba(0,0,0,0.08);
  --tap-min: 44px;
  --tap-min-lg: 48px;
  --line-height-content: 1.65;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.22s ease;
}
@media (prefers-reduced-motion: reduce) {
  :root { --transition-fast: 0.05s ease; --transition-normal: 0.08s ease; }
}

/* ─── Accessibility: focus states ────────────────────────────────────────── */
button:focus-visible,
.stab:focus-visible,
.tab:focus-visible,
a.link-card:focus-visible,
.btn-retry:focus-visible,
.modal-close:focus-visible,
.photo-picker-option:focus-visible {
  outline: 3px solid #3b82f6;
  outline-offset: 3px;
}
body.theme-light button:focus-visible,
body.theme-light .stab:focus-visible,
body.theme-light .tab:focus-visible { outline-color: #2563eb; }

/* ─── Type color variables (Figma Make: purple/pink/orange palette) ────── */
:root {
  --c-homework:          #8B5CF6;
  --c-homework-bg:       rgba(139, 92, 246, 0.10);
  --c-hw-not-done:       #d97706;
  --c-hw-not-done-bg:    rgba(217, 119, 6, 0.10);
  --c-missing:           #ea580c;
  --c-missing-bg:        rgba(234, 88, 12, 0.10);
  --c-late:              #b45309;
  --c-late-bg:           rgba(180, 83, 9, 0.10);
  --c-absence:           #dc2626;
  --c-absence-bg:        rgba(220, 38, 38, 0.10);
  --c-grade:             #059669;
  --c-grade-bg:          rgba(5, 150, 105, 0.10);
  --c-good-word:         #db2777;
  --c-good-word-bg:      rgba(219, 39, 119, 0.10);
  --c-general:           #475569;
  --c-general-bg:        rgba(71, 85, 105, 0.08);
  --c-done:              #059669;
  --gradient-header:     linear-gradient(to left, #7C3AED 0%, #9333ea 50%, #7C3AED 100%);
  /* ── DEFAULT THEME: Light (matches Figma Make) ── */
  --surface-1:           #ffffff;
  --surface-2:           #f8f9fa;
  --surface-3:           #f1f3f5;
  --border:              rgba(139, 92, 246, 0.12);
  --border-bright:       rgba(139, 92, 246, 0.22);
  --bg-body:             #f8f9fa;
  --text-primary:        #1a0a2e;
  --text-secondary:      #374151;
  --text-muted:          #6B7280;
}

/* Dark theme ────────────────────────────────────────────────────────────── */
body.theme-dark {
  --surface-1:           #1a0a2e;
  --surface-2:           #0F0A1E;
  --surface-3:           #2D1F4A;
  --border:              rgba(167, 139, 250, 0.2);
  --border-bright:       rgba(167, 139, 250, 0.35);
  --bg-body:             linear-gradient(180deg, #0F0A1E 0%, #1a0a2e 100%);
  --text-primary:        #F9FAFB;
  --text-secondary:      #E5E7EB;
  --text-muted:          #9CA3AF;
  --c-homework-bg:       rgba(139, 92, 246, 0.12);
  --c-hw-not-done-bg:    rgba(245, 158, 11, 0.12);
  --c-missing-bg:        rgba(249, 115, 22, 0.12);
  --c-late-bg:           rgba(251, 191, 36, 0.12);
  --c-absence-bg:        rgba(239, 68, 68, 0.12);
  --c-grade-bg:          rgba(16, 185, 129, 0.12);
  --c-general-bg:        rgba(100, 116, 139, 0.10);
}
body.theme-dark .hw-text {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.07);
}
body.theme-dark .logo-banner { background: linear-gradient(135deg, #0a0f1e 0%, #1a0a2e 100%); }
body.theme-dark .logo-banner-name { color: #60a5fa; }

/* Light theme explicit (also default) ───────────────────────────────────── */
body.theme-light {
  --surface-1:           #ffffff;
  --surface-2:           #f8f9fa;
  --surface-3:           #f1f3f5;
  --border:              rgba(139, 92, 246, 0.12);
  --border-bright:       rgba(139, 92, 246, 0.22);
  --bg-body:             #f8f9fa;
  --text-primary:        #1a0a2e;
  --text-secondary:      #374151;
  --text-muted:          #6B7280;
}
body.theme-light .hw-text {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}
body.theme-light .logo-banner { background: linear-gradient(135deg, #FFF5F7 0%, #E9D5FF 100%); }
body.theme-light .logo-banner-name { color: #8B5CF6; }

/* ─── Pull-to-refresh ──────────────────────────────────────────────────── */
.ptr {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.85rem;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
  z-index: 200;
  border-bottom: 1px solid var(--border-bright);
}
.ptr.visible { transform: translateY(0); }

.ptr-spinner {
  width: 18px; height: 18px;
  border: 2px solid #334155;
  border-top-color: #3b82f6;
  border-radius: 50%;
  flex-shrink: 0;
}
.ptr.visible .ptr-spinner,
.ptr.refreshing .ptr-spinner { animation: spin 0.8s linear infinite; }

/* ─── Loading overlay ──────────────────────────────────────────────────── */
.spinner-overlay {
  position: fixed; inset: 0;
  background: var(--bg-body);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999;
  gap: 1.25rem;
}
.spinner-overlay.hidden { display: none; }

.loading-logo {
  width: 80px; height: 80px;
  border-radius: 20px;
  object-fit: cover;
  box-shadow: 0 0 30px rgba(99,179,237,0.3);
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(99,179,237,0.2); }
  50%       { box-shadow: 0 0 40px rgba(99,179,237,0.5); }
}

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--surface-3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-overlay p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Sticky top bar — Figma: purple→pink→orange tri-color gradient ─── */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(to left, #8B5CF6 0%, #EC4899 50%, #F97316 100%);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.35);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
body.theme-dark .top-bar {
  background: linear-gradient(to left, #7C3AED 0%, #db2777 50%, #ea580c 100%);
  box-shadow: 0 4px 24px rgba(109, 40, 217, 0.4);
}

/* ─── Header ───────────────────────────────────────────────────────────── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  gap: 0.75rem;
}
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-left  { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* Figma: logo+name CENTER (large), student RIGHT (large), icons LEFT */
.header-figma {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  padding: 1.5rem 2rem;
}
.header-figma .header-icons   { order: 1; flex-shrink: 0; display: flex; align-items: center; gap: 1rem; }
.header-figma .header-center  { order: 0; flex: 1; justify-content: center; display: flex; align-items: center; gap: 1rem; min-width: 0; }
.header-figma .header-right   { order: -1; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.header-figma .header-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  flex: 1;
}
.header-figma .logo-text { display: flex; flex-direction: column; align-items: center; line-height: 1.3; gap: 0.25rem; }
.header-figma .header-logo .app-brand { font-size: 2.2rem; font-weight: 800; letter-spacing: 0.05em; }
.header-figma .header-logo .app-subtitle { font-size: 1.4rem; font-weight: 600; opacity: 1; }
.update-block-compact .last-update { font-size: 1.7rem; }

/* ─── App logo — enlarged for Figma ──────────────────────────────────────── */
.app-logo {
  width: 140px; height: 140px;
  border-radius: 20px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.30);
  border: 3px solid rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.2);
}

/* ─── Student info ─────────────────────────────────────────────────────── */
.student-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.app-brand {
  font-size: 1.1rem;
  font-weight: 800;
  color: rgba(255,255,255,0.98);
  text-transform: none;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.header-logo .app-brand { font-size: 1.15rem; }
.app-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.92);
  font-weight: 500;
}
.header-logo .app-subtitle { font-size: 0.9rem; }
.student-name {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.3;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
  max-width: 300px;
  direction: rtl;
  unicode-bidi: embed;
  color: #fff;
}
.update-block  { display: flex; flex-direction: column; align-items: flex-end; gap: 0.1rem; }
.last-update   { font-size: 1.7rem; color: #ffffff; font-weight: 700; white-space: nowrap; }

/* ─── Refresh button (primary action) ────────────────────────────────────── */
.btn-refresh {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255,255,255,0.9);
  color: #7c3aed;
  padding: 0 1.1rem;
  height: 50px; min-width: 50px;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  font-weight: 900;
  box-shadow: 0 2px 12px rgba(0,0,0,0.18);
}
.btn-refresh:hover  { background: #ffffff; box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.btn-refresh:active { transform: scale(0.94); }
.btn-refresh:focus-visible { outline: 3px solid rgba(255,255,255,0.9); outline-offset: 2px; }
.refresh-icon { line-height: 1; }
.refresh-label { font-size: 0.95rem; font-weight: 800; color: #7c3aed; letter-spacing: 0.02em; }

/* Theme toggle button */
.btn-theme {
  background: rgba(255,255,255,0.3);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  padding: 0;
  width: 50px; min-height: 50px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.btn-theme:hover  { background: rgba(255,255,255,0.35); }
.btn-theme:active { transform: scale(0.93); }
.btn-theme:focus-visible { outline: 2px solid rgba(255,255,255,0.9); outline-offset: 2px; }
.theme-icon { line-height: 1; }

/* ─── Student switcher pills ───────────────────────────────────────────── */
.student-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.15rem;
}
.student-pill {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.4);
  color: rgba(255,255,255,0.9);
  border-radius: 999px;
  padding: 0.35rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.student-pill:hover  { background: rgba(255,255,255,0.35); color: #fff; }
.student-pill.active { background: rgba(255,255,255,0.9); border-color: transparent; color: #7C3AED; }
body.theme-dark .student-pill { background: var(--surface-3); border-color: var(--border-bright); color: #94a3b8; }
body.theme-dark .student-pill:hover { background: #2d3e55; color: var(--text-primary); }
body.theme-dark .student-pill.active { background: #3b82f6; border-color: #3b82f6; color: #fff; }

/* ─── Stats bar ── Figma: horizontal scrollable tiles (5 items) ──────────── */
.stats-bar {
  display: flex;
  flex-direction: row;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow-x: hidden;
  overflow-y: hidden;
  min-height: 0;
}
.stats-bar::-webkit-scrollbar { display: none; }
.stats-bar:empty { padding: 0; border: none; }

.stat-chip {
  display: flex; align-items: center; gap: 0.25rem;
  background: var(--surface-1);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-card);
}

/* Figma stat cards — solid gradient bg, white text, SVG icon top */
.stat-card {
  flex: 1 1 0;
  min-width: 64px;
  max-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.65rem 0.4rem;
  border-radius: 1rem;
  min-height: 74px;
  cursor: pointer;
  color: #fff;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.stat-card:hover  { transform: scale(1.04); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.stat-card:active { transform: scale(0.97); }
.stat-card-icon  { font-size: 1.3rem; line-height: 1; }
.stat-card-num   { font-size: 1.75rem; font-weight: 900; line-height: 1; }
.stat-card-label { font-size: 0.7rem; font-weight: 700; opacity: 0.92; text-align: center; line-height: 1.2; }

/* Figma gradient colors per type */
.stat-card.stat-homework  { background: linear-gradient(135deg, #8B5CF6 0%, #7C3AED 100%); }
.stat-card.stat-alerts    { background: linear-gradient(135deg, #F97316 0%, #EF4444 100%); }
.stat-card.stat-grades    { background: linear-gradient(135deg, #3B82F6 0%, #06B6D4 100%); }
.stat-card.stat-messages  { background: linear-gradient(135deg, #EC4899 0%, #F43F5E 100%); }
.stat-card.stat-unread    { background: linear-gradient(135deg, #FBBF24 0%, #F59E0B 100%); }

/* ─── Section tabs — Figma: white/80 blur bg, border-purple-200, gradient active underline ── */
.section-tabs {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0;
  padding: 0.5rem 0.5rem 0;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid #e9d5ff;
  box-shadow: 0 1px 0 rgba(139, 92, 246, 0.08);
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.section-tabs::-webkit-scrollbar { display: none; }
body.theme-dark .section-tabs {
  background: rgba(30, 20, 50, 0.85);
  border-bottom-color: rgba(139, 92, 246, 0.3);
}
.stab {
  flex: 0 0 auto;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  color: #6B7280;
  padding: 0.4rem 0.75rem 0.5rem;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  min-height: var(--tap-min);
  text-align: center;
  white-space: nowrap;
  position: relative;
}
.stab .stab-icon { font-size: 1.15rem; line-height: 1; }
.stab:focus-visible { outline: 3px solid #8b5cf6; outline-offset: 2px; }
.stab:hover { color: #8B5CF6; }
/* Active: purple text + gradient bottom border (purple→pink) */
.stab.active {
  color: #7C3AED;
  font-weight: 700;
  border-bottom-color: transparent;
  background: transparent;
}
.stab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(to left, #8B5CF6, #EC4899);
  border-radius: 999px;
}
body.theme-dark .stab { color: #9CA3AF; }
body.theme-dark .stab:hover { color: #c4b5fd; }
body.theme-dark .stab.active { color: #a78bfa; }
body.theme-dark .stab.active::after { background: linear-gradient(to left, #a78bfa, #f472b6); }

/* ─── Filter tabs (inside feed section) ────────────────────────────────── */
.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.filter-tabs.hidden { display: none; }

.tab {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  min-height: var(--tap-min);
  -webkit-tap-highlight-color: transparent;
}
.tab:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
.tab:hover  { background: var(--surface-3); color: var(--text-primary); border-color: var(--border-bright); }
.tab.active { background: #3b82f6; color: #fff; border-color: #3b82f6; }

/* ─── Page sections ────────────────────────────────────────────────────── */
.page-section        { display: none; }
.page-section.active { display: block; }
.page-section.hidden { display: none; }

/* ─── Stale warning ────────────────────────────────────────────────────── */
.stale-banner {
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--c-hw-not-done);
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  text-align: center;
}

/* ─── Error / no-data banner ───────────────────────────────────────────── */
.error-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(220, 38, 38, 0.08);
  border-bottom: 1px solid rgba(220, 38, 38, 0.2);
  color: #dc2626;
  padding: 0.75rem 1rem;
  font-size: 0.83rem;
}
body.theme-dark .error-banner { background: rgba(239,68,68,0.08); color: #fca5a5; border-color: rgba(239,68,68,0.25); }
.error-banner.hidden { display: none; }
.error-icon { font-size: 1.4rem; flex-shrink: 0; }
.error-text { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }
.error-text strong { font-weight: 700; }
.error-text code { font-family: monospace; font-size: 0.8rem; color: #f87171; }
.btn-retry {
  background: rgba(220,38,38,0.10);
  border: 1px solid rgba(220,38,38,0.3);
  color: #dc2626;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-retry:hover { background: rgba(239,68,68,0.25); }

/* ─── Overview grid (2 cols) ───────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  padding: 1rem;
}
.col { display: flex; flex-direction: column; gap: 0.6rem; }

/* ─── Single-column sections ───────────────────────────────────────────── */
.single-col {
  max-width: 900px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ─── Section titles ───────────────────────────────────────────────────── */
.section-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-secondary);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.02em;
}

.card-list { display: flex; flex-direction: column; gap: var(--space-lg); }

/* ─── Cards ── Figma: rounded-2xl, border-2, colored bg tint, top accent bar ── */
.card {
  background: #ffffff;
  border-radius: 1rem;
  padding: var(--space-xl) var(--space-xl);
  border: 2px solid var(--card-border-color, rgba(0,0,0,0.1));
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
  transition: opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
/* Top gradient accent bar — Figma: absolute top-0 h-1 bg-gradient-to-r */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--card-accent-gradient, linear-gradient(to left, #8B5CF6, #EC4899));
}
.card:hover { transform: scale(1.01); box-shadow: 0 6px 24px rgba(0,0,0,0.12); }
@media (hover: none) {
  .card:active { transform: scale(0.98); box-shadow: var(--shadow-card-pressed); }
}

/* Dark mode cards */
body.theme-dark .card {
  background: var(--surface-2);
  border-color: var(--card-border-color, rgba(255,255,255,0.1));
  box-shadow: var(--shadow-card);
}
body.theme-dark .card:hover { transform: scale(1.01); box-shadow: var(--shadow-card-hover); }

/* Per-type: border color, bg tint, top accent gradient — matches NotificationCard.tsx */
.card.type-homework {
  --card-border-color: #d8b4fe;
  --card-accent-gradient: linear-gradient(to left, #8B5CF6, #7C3AED);
  --card-icon-bg: #8B5CF6;
  background: rgba(139, 92, 246, 0.05);
}
.card.type-homework_not_done {
  --card-border-color: #fed7aa;
  --card-accent-gradient: linear-gradient(to left, #F97316, #EA580C);
  --card-icon-bg: #F97316;
  background: rgba(249, 115, 22, 0.05);
}
.card.type-missing_equipment {
  --card-border-color: #fed7aa;
  --card-accent-gradient: linear-gradient(to left, #F97316, #EA580C);
  --card-icon-bg: #F97316;
  background: rgba(234, 88, 12, 0.05);
}
.card.type-late {
  --card-border-color: #fde68a;
  --card-accent-gradient: linear-gradient(to left, #F59E0B, #D97706);
  --card-icon-bg: #F59E0B;
  background: rgba(245, 158, 11, 0.05);
}
.card.type-absence {
  --card-border-color: #fca5a5;
  --card-accent-gradient: linear-gradient(to left, #EF4444, #DC2626);
  --card-icon-bg: #EF4444;
  background: rgba(220, 38, 38, 0.05);
}
.card.type-grade {
  --card-border-color: #93c5fd;
  --card-accent-gradient: linear-gradient(to left, #3B82F6, #06B6D4);
  --card-icon-bg: linear-gradient(135deg, #3B82F6, #06B6D4);
  background: rgba(59, 130, 246, 0.05);
}
.card.type-good_word {
  --card-border-color: #f9a8d4;
  --card-accent-gradient: linear-gradient(to left, #EC4899, #F43F5E);
  --card-icon-bg: linear-gradient(135deg, #EC4899, #F43F5E);
  background: rgba(236, 72, 153, 0.05);
}
.card.type-general {
  --card-border-color: #a5b4fc;
  --card-accent-gradient: linear-gradient(to left, #6366F1, #4F46E5);
  --card-icon-bg: #6366F1;
  background: rgba(99, 102, 241, 0.04);
}
.card.type-message {
  --card-border-color: #99f6e4;
  --card-accent-gradient: linear-gradient(to left, #14B8A6, #0D9488);
  --card-icon-bg: #14B8A6;
  background: rgba(20, 184, 166, 0.05);
}

/* Dark mode card type tints */
body.theme-dark .card.type-homework          { background: var(--c-homework-bg); }
body.theme-dark .card.type-homework_not_done { background: var(--c-hw-not-done-bg); }
body.theme-dark .card.type-missing_equipment { background: var(--c-missing-bg); }
body.theme-dark .card.type-late              { background: var(--c-late-bg); }
body.theme-dark .card.type-absence           { background: var(--c-absence-bg); }
body.theme-dark .card.type-grade             { background: var(--c-grade-bg); }
body.theme-dark .card.type-good_word         { background: var(--c-good-word-bg); }
body.theme-dark .card.type-general           { background: var(--c-general-bg); }

/* Figma: card with icon box on right (RTL) */
.card-inner {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  align-items: flex-start;
}
.card-icon-box {
  width: 48px; height: 48px;
  flex-shrink: 0;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  background: var(--card-icon-bg, var(--card-accent-gradient, #64748b));
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform var(--transition-fast);
}
.card:hover .card-icon-box { transform: scale(1.1); }
.card-content { flex: 1; min-width: 0; }

/* Link cards (קישורים) ── */
a.link-card {
  display: block;
  text-decoration: none;
  color: inherit;
  --card-color: #3b82f6;
  cursor: pointer;
}
a.link-card:hover { opacity: 0.9; }

.card.done-card { opacity: 0.45; }
.card.done-card:hover { transform: none; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
  flex-wrap: wrap;
}
.card-title { font-weight: 800; font-size: var(--text-card-mobile); line-height: 1.4; }
.done-card .card-title { text-decoration: line-through; color: var(--text-muted); }

.card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.card-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: var(--line-height-content);
  white-space: pre-line;
}
.hw-text {
  font-size: 0.88rem;
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  margin: 0.4rem 0 0;
  line-height: 1.55;
}

/* ─── Badges ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-homework          { background: var(--c-homework-bg);    color: var(--c-homework);    border: 1px solid var(--c-homework); }
.badge-homework_not_done { background: var(--c-hw-not-done-bg); color: var(--c-hw-not-done); border: 1px solid var(--c-hw-not-done); }
.badge-missing_equipment { background: var(--c-missing-bg);     color: var(--c-missing);     border: 1px solid var(--c-missing); }
.badge-late              { background: var(--c-late-bg);        color: var(--c-late);        border: 1px solid var(--c-late); }
.badge-absence           { background: var(--c-absence-bg);     color: var(--c-absence);     border: 1px solid var(--c-absence); }
.badge-grade             { background: var(--c-grade-bg);       color: var(--c-grade);       border: 1px solid var(--c-grade); }
.badge-good_word         { background: var(--c-good-word-bg);    color: var(--c-good-word);   border: 1px solid var(--c-good-word); }
.badge-general           { background: var(--c-general-bg);     color: var(--c-general);     border: 1px solid var(--c-general); }

/* ─── Mark-done button ─────────────────────────────────────────────────── */
.btn-done {
  background: var(--c-homework);
  border: none;
  color: #fff;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  min-height: 34px;
  -webkit-tap-highlight-color: transparent;
}
.btn-done:hover   { background: #2563eb; transform: scale(1.04); }
.btn-done.done    { background: var(--c-done); cursor: default; }
.btn-done:active  { transform: scale(0.96); }
.btn-done:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ─── Empty state ──────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--space-5xl) var(--space-2xl);
  font-size: 1.1rem;
  line-height: var(--line-height-content);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}
.empty::before {
  content: attr(data-icon);
  font-size: 4rem;
  display: block;
  opacity: 0.85;
}

/* ─── Mobile ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .main-grid {
    grid-template-columns: 1fr;
    padding: 0.75rem;
    gap: 0.85rem;
  }
  .single-col { padding: 0.8rem 0.9rem; }
  .header { padding: 0.5rem 0.8rem; }
  .stats-bar { padding: 0.4rem 0.8rem; }
  .filter-tabs { padding: 0.5rem 0.8rem; }
  .card { padding: 0.9rem 1.1rem; border-radius: var(--radius-lg); }
  .card-title { font-size: var(--text-card-mobile); }
  .card-desc { font-size: 0.9rem; }
  /* ── Mobile-only header overrides (phone vs desktop separation) ── */
  .header-figma {
    padding: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Logo: image on top, brand+subtitle stacked below */
  .header-figma .header-logo { flex-direction: column; gap: 0.3rem; }
  .header-figma .logo-text { display: flex; flex-direction: column; align-items: center; gap: 0.1rem; }
  .header-figma .header-logo .app-brand { font-size: 1.15rem; }
  .header-figma .header-logo .app-subtitle { font-size: 1.1rem; display: block; margin-top: 0; }

  /* Student area: right side — only name+avatar, NO timestamps */
  .header-figma .header-right,
  .header-figma .student-info {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end !important;
  }
  .header-figma .student-name-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.4rem;
  }
  /* Hide timestamps from student area on mobile */
  .header-figma .update-block,
  .header-figma .update-block-compact {
    display: none !important;
  }

  .last-update { font-size: 0.9rem; }
  .student-name { font-size: 1.3rem; max-width: calc(100vw - 145px); }
  .child-avatar { width: 28px; height: 28px; }
  .student-pill { font-size: 0.7rem; padding: 0.18rem 0.55rem; }
  .app-logo { display: none; }
  .app-brand { display: none; }

  /* Buttons + timestamps: left side, column layout */
  .header-figma .header-icons {
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
  }
  .header-icons-btns {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    align-items: center;
  }
  .update-block-mobile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }
  .update-block-mobile .last-update { font-size: 0.85rem; color: rgba(255,255,255,0.9); }
  .btn-refresh,
  .btn-theme {
    height: 40px;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1rem;
    padding: 0;
    border-radius: 10px;
  }
  .refresh-label { display: none; }
  .error-banner { flex-wrap: wrap; }
  .error-text code { word-break: break-all; }
  .modal-content { padding: 0.7rem 1rem 2rem; }

  .stab {
    min-width: 88px;
    font-size: 0.82rem;
    padding: var(--space-sm) var(--space-md);
    min-height: var(--tap-min);
  }
}

@media (max-width: 380px) {
  .app-brand { display: none; }
  .stab { font-size: 0.65rem; }
}

/* ─── Mobile landscape (phone rotated sideways) ────────────────────────── */
@media screen and (orientation: landscape) and (max-height: 500px) {
  /* Compact the entire sticky top bar */
  .header {
    padding: 0.3rem 0.75rem;
    gap: 0.5rem;
  }
  .app-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
  }
  .app-brand { display: none; }
  .student-name {
    font-size: 0.85rem;
    max-width: 150px;
  }
  .student-pill {
    font-size: 0.65rem;
    padding: 0.12rem 0.45rem;
  }
  .last-update { font-size: 0.65rem; }
  .btn-refresh {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
    border-radius: 10px;
  }

  /* Shrink stats bar */
  .stats-bar {
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }
  .stat-card {
    min-height: 60px;
    min-width: 52px;
    padding: 0.45rem 0.25rem;
    border-radius: 0.75rem;
  }
  .stat-card-icon { font-size: 1rem; }
  .stat-card-num { font-size: 1.2rem; }
  .stat-card-label { font-size: 0.58rem; }

  /* Compact section tabs */
  .stab {
    font-size: 0.7rem;
    padding: 0.45rem 0.25rem;
    min-height: 36px;
  }

  /* Compact filter tabs */
  .filter-tabs {
    padding: 0.35rem 0.75rem;
    gap: 0.25rem;
  }
  .tab {
    font-size: 0.72rem;
    padding: 0.25rem 0.55rem;
    min-height: 30px;
  }

  /* Compact cards */
  .card {
    padding: 0.55rem 0.75rem;
    border-radius: 9px;
  }
  .card-title { font-size: 0.88rem; }
  .card-meta  { font-size: 0.7rem; margin-bottom: 0.25rem; }
  .card-desc  { font-size: 0.78rem; }
  .hw-text    { font-size: 0.82rem; padding: 0.35rem 0.55rem; margin-top: 0.3rem; }
  .btn-done   { font-size: 0.72rem; padding: 0.25rem 0.6rem; min-height: 30px; }

  /* Grid layout in landscape: use 2 columns only if wide enough */
  .main-grid {
    grid-template-columns: 1fr 1fr;
    padding: 0.6rem 0.75rem;
    gap: 0.75rem;
  }
  .single-col { padding: 0.6rem 0.75rem; }
  .section-title { font-size: 0.82rem; padding-bottom: 0.3rem; }

  /* Less bottom padding */
  body { padding-bottom: 1.5rem; }

  /* Error banner compact */
  .error-banner { padding: 0.5rem 0.75rem; font-size: 0.78rem; }
  .error-icon   { font-size: 1.1rem; }
}

/* Very narrow landscape (e.g. older Android phones) */
@media screen and (orientation: landscape) and (max-height: 380px) {
  .stats-bar { display: none; }  /* Hide stats bar entirely on very small screens */
  .stab { font-size: 0.65rem; padding: 0.35rem 0.2rem; min-height: 32px; }
  .app-logo { width: 28px; height: 28px; }
  .student-name { font-size: 0.8rem; max-width: 120px; }
}

/* ═══════════════════════════════════════════════════════════════════
   NEW UI — Modal, clickable cards, due badges, grades, group titles
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Timestamps ────────────────────────────────────────────────── */
.sync-status { color: #7C3AED !important; }   /* purple tint for sync time */
body.theme-dark .sync-status { color: #60a5fa !important; }

/* ─── Tab: data indicator ───────────────────────────────────────── */
.stab.tab-has-data { color: #7C3AED; font-weight: 700; }
.stab.tab-has-data.active { color: #7C3AED; }
body.theme-dark .stab.tab-has-data { color: #93c5fd; }
body.theme-dark .stab.tab-has-data.active { color: #60a5fa; }

/* ─── Clickable card ────────────────────────────────────────────── */
.clickable-card {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.clickable-card:hover  { transform: translateX(-3px); box-shadow: 0 4px 18px rgba(0,0,0,0.35); }
.clickable-card:active { transform: scale(0.984); }

/* ─── Card title row (title + due badge inline) ─────────────────── */
.card-title-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

/* ─── Due-date badges ───────────────────────────────────────────── */
.due-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
  animation: pulse-badge 1.8s ease-in-out infinite;
}
.due-today {
  background: rgba(220, 38,  38,  0.12);
  color:       #dc2626;
  border:      1px solid rgba(220, 38, 38, 0.3);
}
.due-soon {
  background: rgba(234, 88,  12,  0.12);
  color:       #ea580c;
  border:      1px solid rgba(234, 88, 12, 0.3);
}
body.theme-dark .due-today {
  background: rgba(239,68,68,0.18);   color: #f87171; border-color: rgba(239,68,68,0.5);
}
body.theme-dark .due-soon {
  background: rgba(249,115,22,0.18);  color: #fb923c; border-color: rgba(249,115,22,0.45);
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* ─── Urgent card ───────────────────────────────────────────────── */
.card-urgent {
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.35);
}

/* ─── Expand hint ───────────────────────────────────────────────── */
.card-expand-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
  text-align: left;
  letter-spacing: 0.01em;
  transition: color 0.15s;
}
.clickable-card:hover .card-expand-hint { color: var(--text-secondary); }

/* ─── Group titles (alerts section) ────────────────────────────── */
.group-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.6rem 0 0.25rem;
  border-bottom: 1px solid var(--border);
  margin: 0.25rem 0 0.1rem;
  letter-spacing: 0.02em;
}
.group-title:first-child { padding-top: 0; }

/* ─── Grade number (large score badge) ─────────────────────────── */
.grade-number {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 0.1rem;
}

/* ─── Badge: large variant (used in modal) ──────────────────────── */
.badge-lg {
  font-size: 0.82rem;
  padding: 0.25rem 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════════
   DETAIL MODAL (bottom sheet)
   ═══════════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: modal-fade-in 0.18s ease;
}
.modal-overlay.hidden { display: none; }

@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-sheet {
  width: 100%;
  max-width: 840px;
  max-height: 92vh;
  background: var(--surface-2);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border-bright);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheet-slide-up 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheet-slide-up {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border-bright);
  border-radius: 2px;
  margin: 0.65rem auto 0;
  flex-shrink: 0;
}

.modal-content {
  overflow-y: auto;
  padding: var(--space-lg) var(--space-2xl) var(--space-4xl);
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* ─── Modal header row (badge + close) ─────────────────────────── */
.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
}

.modal-close {
  background: var(--surface-3);
  border: 1px solid var(--border-bright);
  color: #94a3b8;
  width: var(--tap-min);
  height: var(--tap-min);
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  font-family: inherit;
}
.modal-close:hover { background: #2d3e55; color: #e2e8f0; }
.modal-close:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }

/* ─── Modal title ───────────────────────────────────────────────── */
.modal-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: var(--space-lg);
}

/* ─── Done badge (shown when homework is completed) ─────────────── */
.modal-done-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* ─── Info rows grid ────────────────────────────────────────────── */
.modal-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  background: var(--surface-3);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
}

.modal-row {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.88rem;
  line-height: 1.45;
}

.modal-key {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
}

.modal-val {
  color: var(--text-secondary);
  word-break: break-word;
}

/* ─── Modal content boxes (homework text + description) ─────────── */
.modal-box {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
}

.modal-box-label {
  font-size: 0.73rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.4rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.modal-box-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.hw-text-lg {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-box-desc {
  background: rgba(255,255,255,0.025);
  border-color: rgba(255,255,255,0.05);
}
.modal-box-desc .modal-box-text {
  font-size: 0.83rem;
  color: #94a3b8;
}

/* ─── Mark-done button inside modal ────────────────────────────── */
.btn-done-modal {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 12px;
  min-height: 48px;
}

/* ─── Mobile adjustments for modal ─────────────────────────────── */
@media (max-width: 640px) {
  .modal-content { padding: 0.85rem 1.2rem 2.5rem; }
  .modal-title   { font-size: 1.2rem; }
  .modal-key     { min-width: 80px; }
  .modal-row     { font-size: 0.83rem; }
  .modal-box-text { font-size: 0.85rem; }
  .hw-text-lg     { font-size: 0.95rem; }
  .grade-number   { font-size: 1.1rem; }
  .card-expand-hint { font-size: 0.67rem; }
}

/* ─── Calendar section ──────────────────────────────────────────── */
.cal-day-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.cal-date-header {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 0.2rem 0.5rem;
  border-right: 3px solid var(--border-bright);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 0.1rem;
}
.cal-day-today .cal-date-header  { color: #7C3AED; border-right-color: #7C3AED; font-size: 0.83rem; }
.cal-day-past  .cal-date-header  { color: var(--text-muted); opacity: 0.6; }
body.theme-dark .cal-day-today .cal-date-header { color: #60a5fa; border-right-color: #3b82f6; }
.cal-day-past  .card             { opacity: 0.45; }
.cal-day-past  .clickable-card:hover { transform: none; }

.cal-item { padding: 0.6rem 0.85rem; }
.cal-item .card-title { font-size: 0.88rem; }
.cal-item .card-desc  { font-size: 0.78rem; margin-top: 0.2rem; }

/* ─── Special events (birthdays, parent meetings) ───────────────── */
.cal-special-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-right: 0.35rem;
  vertical-align: middle;
}
.cal-special-birthday { background: rgba(236,72,153,0.15); color: #f472b6; border: 1px solid rgba(236,72,153,0.4); }
.cal-special-meeting  { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.4); }
.cal-special-event    { background: rgba(20,184,166,0.15); color: #2dd4bf; border: 1px solid rgba(20,184,166,0.4); }

/* ─── Approvals section ─────────────────────────────────────────── */
.approval-card {
  background: rgba(99,102,241,0.07);
  border-right-color: #6366f1;
}

/* ─── Landscape modal ───────────────────────────────────────────── */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .modal-sheet  { max-height: 85vh; }
  .modal-title  { font-size: 1rem; }
  .modal-rows   { padding: 0.5rem 0.7rem; gap: 0.25rem; }
  .modal-row    { font-size: 0.8rem; }
  .modal-key    { min-width: 75px; }
  .modal-box    { padding: 0.55rem 0.7rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   SMART INSIGHTS BAR — Figma: prominent green full-width banner
   ═══════════════════════════════════════════════════════════════════ */
.insights-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  align-items: center;
}
.insights-bar:empty { display: none; }

/* Figma: main green status banner — full width, solid green bg */
.insight-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.7rem 1rem;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-radius: var(--radius-lg);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}
body.theme-dark .insight-banner {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
  box-shadow: none;
}

.insight-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.chip-overdue { background: rgba(220, 38,  38,  0.10); color: #dc2626; border: 1px solid rgba(220,38,38,0.25); }
.chip-soon    { background: rgba(234, 88,  12,  0.10); color: #ea580c; border: 1px solid rgba(234,88,12,0.25); }
.chip-alerts  { background: rgba(71,  85,  105, 0.10); color: #475569; border: 1px solid rgba(71,85,105,0.25); }
.chip-ok      { background: rgba(5,  150, 105, 0.10);  color: #059669; border: 1px solid rgba(5,150,105,0.25); }
body.theme-dark .chip-overdue { background: rgba(239,68,68,0.15);    color: #fca5a5; border-color: rgba(239,68,68,0.35); }
body.theme-dark .chip-soon    { background: rgba(249,115,22,0.15);   color: #fdba74; border-color: rgba(249,115,22,0.35); }
body.theme-dark .chip-alerts  { background: rgba(100,116,139,0.18);  color: #94a3b8; border-color: rgba(100,116,139,0.35); }
body.theme-dark .chip-ok      { background: rgba(16,185,129,0.12);   color: #6ee7b7; border-color: rgba(16,185,129,0.3); }

/* ─── Suspect-subject badge (subject not in child's curriculum) ─── */
.badge-suspect {
  background: rgba(239, 68, 68, 0.15);
  color:       #fca5a5;
  border:      1px solid rgba(239, 68, 68, 0.35);
}

/* ═══════════════════════════════════════════════════════════════════
   MESSAGES INBOX
   ═══════════════════════════════════════════════════════════════════ */

/* Card type: purple-indigo accent */
.card.type-message {
  --card-color: #7C3AED;
  background: rgba(124, 58, 237, 0.05);
}

/* Unread message: slightly brighter background + stronger border */
.msg-unread-card {
  background: rgba(124, 58, 237, 0.07) !important;
  border-right-width: 4px;
  border-right-color: #7C3AED;
}
body.theme-dark .card.type-message  { background: rgba(129,140,248,0.05); }
body.theme-dark .msg-unread-card    { background: rgba(129,140,248,0.10) !important; border-right-color: #818cf8; }

/* Unread badge (new message) */
.badge-message {
  background: rgba(129, 140, 248, 0.15);
  color:       #a5b4fc;
  border:      1px solid rgba(129, 140, 248, 0.40);
}

/* Read badge (greyed out) */
.badge-message-read {
  background: rgba(100, 116, 139, 0.12);
  color:       #64748b;
  border:      1px solid rgba(100, 116, 139, 0.25);
}
.badge-approved {
  background: rgba(16, 185, 129, 0.15);
  color:       #34d399;
  border:      1px solid rgba(16, 185, 129, 0.35);
}
.btn-approval-done {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  width: 100%;
  transition: background 0.15s;
}
.btn-approval-done:hover { background: rgba(16, 185, 129, 0.3); }

/* Approval card: checkbox, equipment, actions */
.approval-header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.approval-checkbox-wrap { display: flex; align-items: center; cursor: pointer; }
.approval-checkbox { width: 1.25rem; height: 1.25rem; accent-color: #10b981; cursor: pointer; }
.approval-checkbox:disabled { cursor: default; }
.approval-equipment { font-size: 0.85rem; color: var(--text-secondary); margin: 0.5rem 0; padding: 0.5rem; background: var(--surface-3); border-radius: 8px; }
.approval-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; align-items: center; }
.btn-open-webtop { font-size: 0.8rem; color: #7C3AED; text-decoration: none; padding: 0.35rem 0.7rem; border: 1px solid rgba(124,58,237,0.3); border-radius: 8px; }
.btn-open-webtop:hover { background: rgba(124,58,237,0.08); }
body.theme-dark .btn-open-webtop { color: #60a5fa; border-color: rgba(96,165,250,0.3); }
body.theme-dark .btn-open-webtop:hover { background: rgba(96,165,250,0.1); }
.badge-rejected { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.35); }

/* ═══════════════════════════════════════════════════════════════════
   HOMEWORK HISTORY
   ═══════════════════════════════════════════════════════════════════ */

/* History button at the bottom of the homework list */
.btn-hw-history {
  display: block;
  width: 100%;
  background: rgba(124, 58, 237, 0.06);
  border: 1px dashed rgba(124, 58, 237, 0.3);
  color: #7C3AED;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  margin-top: 0.35rem;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-hw-history:hover  { background: rgba(124,58,237,0.10); border-color: rgba(124,58,237,0.45); }
body.theme-dark .btn-hw-history { background: rgba(59,130,246,0.07); border-color: rgba(59,130,246,0.3); color: #60a5fa; }
body.theme-dark .btn-hw-history:hover { background: rgba(59,130,246,0.14); border-color: rgba(59,130,246,0.5); }
.btn-hw-history:active { transform: scale(0.98); }

/* Completed card inside history modal */
.history-done-card { opacity: 0.72; margin-bottom: 0.5rem; }
.history-done-card .card-title { text-decoration: line-through; color: #475569; }

/* "Marked at" timestamp row */
.hw-marked-at { font-size: 0.72rem; color: #334155; margin-top: 0.45rem; }

/* ═══════════════════════════════════════════════════════════════════
   CHILD SELECTOR DROPDOWN
   ═══════════════════════════════════════════════════════════════════ */
.child-select {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.22) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23ffffff' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat 0.55rem center;
  border: 1px solid rgba(255,255,255,0.45);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem 0.35rem 1.75rem;
  border-radius: 8px;
  cursor: pointer;
  direction: rtl;
  max-width: 140px;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.child-select:focus { outline: none; border-color: rgba(255,255,255,0.8); }
.child-select option { background: #1e293b; color: #e2e8f0; }

/* ═══════════════════════════════════════════════════════════════════
   CHILD AVATAR PHOTO
   ═══════════════════════════════════════════════════════════════════ */
.child-avatar-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  cursor: pointer;
}
.child-avatar-wrap:hover .avatar-upload-hint { opacity: 1; }
.child-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(96, 165, 250, 0.40);
  flex-shrink: 0;
  display: block;
}
.child-avatar.hidden { display: none !important; }

/* Camera hint shown when no photo / on hover */
.avatar-upload-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  font-size: 1rem;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
/* Always visible when avatar image is hidden (no photo set yet) */
.child-avatar.hidden ~ .avatar-upload-hint,
#child-avatar-wrap:not(:has(.child-avatar:not(.hidden))) .avatar-upload-hint {
  opacity: 0.6;
  background: rgba(59, 130, 246, 0.15);
  border: 1.5px dashed rgba(96, 165, 250, 0.5);
  width: 36px;
  height: 36px;
}

/* Student name + photo in same row */
.student-name-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  position: relative;
}

/* ─── Add-photo button ─────────────────────────────────────────────────── */
.btn-add-photo {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: #64748b;
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
  margin-inline-start: auto;
}
.btn-add-photo:hover  { background: var(--surface-3); color: #94a3b8; border-color: #4a637e; }
.btn-add-photo:active { transform: scale(0.94); }

/* ─── Photo picker popup ───────────────────────────────────────────────── */
.photo-picker-popup {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 300;
  min-width: 190px;
  overflow: hidden;
}
.photo-picker-popup.hidden { display: none; }
.photo-picker-option {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.75rem 1rem;
  text-align: start;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
}
.photo-picker-option:hover  { background: var(--surface-3); }
.photo-picker-option:active { background: #2d3e55; }
.photo-picker-option + .photo-picker-option { border-top: 1px solid var(--border); }

/* ═══════════════════════════════════════════════════════════════════
   TEACHER NAME ROW (class event cards)
   ═══════════════════════════════════════════════════════════════════ */
.card-teacher {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP BREAKPOINT (≥ 900px) — larger layout
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  .single-col {
    max-width: 960px;
    padding: 1.25rem 1.75rem;
  }
  .card {
    padding: 1.2rem 1.5rem;
    border-radius: 16px;
  }
  .card-title { font-size: 1.1rem; }
  .card-desc  { font-size: 0.9rem; }
  .modal-sheet { max-width: 900px; }
  .stab {
    font-size: 0.86rem;
    padding: 0.8rem 0.65rem;
    min-width: 88px;
  }
  .header { padding: 0.75rem 1.25rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   TREND CHIPS (insights bar)
   ═══════════════════════════════════════════════════════════════════ */
.chip-trend-up {
  background: rgba(220, 38, 38, 0.10);
  color: #dc2626;
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.chip-trend-down {
  background: rgba(5, 150, 105, 0.10);
  color: #059669;
  border: 1px solid rgba(5, 150, 105, 0.25);
}
body.theme-dark .chip-trend-up   { background: rgba(239,68,68,0.12);    color: #fca5a5; border-color: rgba(239,68,68,0.3); }
body.theme-dark .chip-trend-down { background: rgba(16,185,129,0.12);   color: #6ee7b7; border-color: rgba(16,185,129,0.3); }

/* ═══════════════════════════════════════════════════════════════════
   CLICKABLE INSIGHT CHIPS
   ═══════════════════════════════════════════════════════════════════ */
.insight-chip.chip-clickable {
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.insight-chip.chip-clickable:hover  { opacity: 0.85; transform: scale(1.05); box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.insight-chip.chip-clickable:active { transform: scale(0.95); }

/* ═══════════════════════════════════════════════════════════════════
   LOGO BANNER — prominent centered logo at top (mobile only, scrolls away)
   ═══════════════════════════════════════════════════════════════════ */
.logo-banner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  background: linear-gradient(165deg, #0a0f1e 0%, #0d1529 25%, #1e293b 60%, #1a2235 100%);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  min-height: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.logo-banner-img {
  width: 140px;
  height: 140px;
  border-radius: var(--radius-xl);
  object-fit: cover;
  box-shadow: 0 8px 36px rgba(59, 130, 246, 0.5), 0 2px 16px rgba(0,0,0,0.4);
  border: 3px solid rgba(96, 165, 250, 0.35);
  animation: pulse-glow 3s ease-in-out infinite;
  flex-shrink: 0;
}
.logo-banner-name {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: #60a5fa;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
  text-shadow: 0 0 24px rgba(96, 165, 250, 0.3);
}
/* Hide banner on desktop — header logo is enough */
@media (min-width: 641px) {
  .logo-banner { display: none; }
  .update-block-mobile { display: none; }
  .header-icons-btns { display: contents; }
}

/* ═══════════════════════════════════════════════════════════════════
   PHOTO CROP MODAL
   ═══════════════════════════════════════════════════════════════════ */
.crop-sheet {
  background: var(--surface-1);
  border-radius: 20px 20px 0 0;
  padding: 1.25rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.crop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}
.crop-title {
  font-weight: 700;
  font-size: 1rem;
  color: #e2e8f0;
}
/* The circular viewport — image moves inside this */
.crop-viewport {
  position: relative;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #3b82f6;
  box-shadow: 0 0 0 9999px rgba(10, 15, 30, 0.82);
  touch-action: none;
  cursor: grab;
  flex-shrink: 0;
  background: #0a0f1e;
}
.crop-viewport:active { cursor: grabbing; }
#crop-img {
  position: absolute;
  user-select: none;
  -webkit-user-drag: none;
  max-width: none;
  pointer-events: none;
}
.crop-hint {
  font-size: 0.8rem;
  color: #64748b;
  text-align: center;
  line-height: 1.5;
}
.crop-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.btn-crop-cancel {
  flex: 1;
  background: var(--surface-3);
  border: 1px solid var(--border-bright);
  color: #94a3b8;
  padding: 0.7rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-crop-cancel:hover { background: #2d3e55; }
.btn-crop-confirm {
  flex: 2;
  background: #3b82f6;
  border: none;
  color: #fff;
  padding: 0.7rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-crop-confirm:hover { background: #2563eb; }
