:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.25);
  
  --secondary: #06b6d4;
  --secondary-light: #ecfeff;
  
  --accent: #f59e0b;
  --accent-light: #fffbeb;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --info: #3b82f6;

  /* Neutral tones */
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-elevated: #ffffff;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;
  
  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-float: 0 20px 30px -10px rgba(79, 70, 229, 0.2);
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.5);

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  --safe-bottom: env(safe-area-inset-bottom, 12px);
  --header-height: 62px;
  --nav-height: 64px;
}

[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-subtle: #1a233a;
  --bg-elevated: #1e293b;
  --border-color: #1e293b;
  --border-light: #182234;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  
  --primary-light: rgba(79, 70, 229, 0.2);
  --secondary-light: rgba(6, 182, 212, 0.2);
  --success-light: rgba(16, 185, 129, 0.2);
  --danger-light: rgba(239, 68, 68, 0.2);
  --accent-light: rgba(245, 158, 11, 0.2);
  
  --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
  --glass-bg: rgba(19, 27, 46, 0.94);
  --glass-border: rgba(255, 255, 255, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  background-color: #080c14;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Device Wrapper (True Mobile Layout & Fixed Viewport) */
#device-container {
  width: 100%;
  max-width: 440px;
  height: 100vh;
  max-height: 920px;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
  transition: max-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), border-radius 0.35s ease;
}

@media (min-width: 600px) {
  body {
    padding: 16px;
    background: radial-gradient(circle at top right, #1e1b4b, #090d16 70%);
  }
  #device-container {
    border-radius: 36px;
    border: 6px solid #1e293b;
    height: 94vh;
  }
  #device-container.expanded-mode {
    max-width: 1120px;
    height: 94vh;
    border-radius: 20px;
    border: 3px solid rgba(255, 255, 255, 0.12);
  }
}

@media (max-width: 599px) {
  body {
    background-color: var(--bg-app);
    padding: 0;
  }
  #device-container {
    max-width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
  }
}

/* Status Bar & Notch Mockup */
.mobile-notch-bar {
  display: none;
  flex-shrink: 0;
}
@media (min-width: 600px) {
  .mobile-notch-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 20px 2px 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-main);
    z-index: 100;
    user-select: none;
    background: var(--bg-app);
  }
  .mobile-notch-bar .notch-pill {
    width: 100px;
    height: 20px;
    background: #000;
    border-radius: 20px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .notch-pill .camera-dot {
    width: 7px;
    height: 7px;
    background: #111827;
    border-radius: 50%;
    border: 1px solid #374151;
  }
}

/* App Header */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 40;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-brand .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 10px var(--primary-glow);
}

.header-brand .brand-text h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-main);
  line-height: 1.1;
}

.header-brand .brand-text span {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  outline: none;
}

.icon-btn:hover {
  background: var(--bg-card-subtle);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(0.94);
}

.badge-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  animation: pulse 2s infinite;
}

.role-badge-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.role-badge-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* App Viewport / Main Content (Scrolls independently while header & bottom nav stay fixed) */
.app-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px calc(var(--nav-height) + 16px) 14px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.app-content::-webkit-scrollbar {
  width: 4px;
}
.app-content::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Bottom Navigation Bar (Fixed at the bottom, never scrolls away) */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 4px 8px var(--safe-bottom) 8px;
  z-index: 50;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  gap: 3px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 0;
  position: relative;
}

.nav-item i {
  font-size: 18px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active i {
  transform: translateY(-2px) scale(1.12);
  color: var(--primary);
}

.nav-item .nav-pill {
  position: absolute;
  top: 0;
  width: 18px;
  height: 3px;
  background: var(--primary);
  border-radius: 4px;
  opacity: 0;
  transform: scaleX(0);
  transition: all 0.2s ease;
}

.nav-item.active .nav-pill {
  opacity: 1;
  transform: scaleX(1);
}

.nav-badge {
  position: absolute;
  top: 0px;
  right: 18%;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  min-width: 15px;
  height: 15px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* Stories / Announcement Slider */
.slider-container {
  width: 100%;
  margin-bottom: 16px;
  position: relative;
}

.story-scroll-wrap {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px 2px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.story-scroll-wrap::-webkit-scrollbar {
  display: none;
}

.story-card {
  flex: 0 0 86%;
  max-width: 320px;
  height: 130px;
  border-radius: var(--radius-lg);
  padding: 14px;
  color: #fff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  scroll-snap-align: start;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.25s ease;
}

.story-card:hover {
  transform: translateY(-2px);
}

.story-card .card-bg-glow {
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  filter: blur(10px);
}

.story-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  align-self: flex-start;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.story-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  margin-top: 4px;
  z-index: 2;
}

.story-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  opacity: 0.9;
  z-index: 2;
}

.story-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 6px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 3px;
  background: var(--border-color);
  transition: all 0.3s ease;
}

.dot.active {
  width: 16px;
  background: var(--primary);
}

/* General Card Styles */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  position: relative;
  transition: all 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title i {
  color: var(--primary);
}

.card-link {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

/* Quick Stats Row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.stat-box:hover {
  transform: translateY(-2px);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.secondary { background: var(--secondary-light); color: var(--secondary); }
.stat-icon.warning { background: var(--accent-light); color: var(--accent); }
.stat-icon.success { background: var(--success-light); color: var(--success); }

.stat-info .stat-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-info .stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Schedule / Time Line */
.schedule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  margin-bottom: 8px;
  border-left: 4px solid var(--primary);
  transition: transform 0.15s ease;
}

.schedule-item:hover {
  transform: translateX(3px);
}

.schedule-item.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.3);
}

.schedule-time {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 64px;
  text-align: center;
}

.schedule-details {
  flex: 1;
}

.schedule-details .subject {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.schedule-details .teacher-room {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 1px;
}

.live-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  background: var(--success);
  color: #fff;
  border-radius: var(--radius-full);
  animation: pulse 1.5s infinite;
}

/* Buttons and Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 16px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.input-group {
  margin-bottom: 12px;
}

.input-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control {
  min-height: 75px;
  resize: vertical;
}

/* Modals & Bottom Sheets */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  background: var(--bg-card);
  border-radius: 26px 26px 0 0;
  padding: 18px 18px calc(var(--safe-bottom) + 16px) 18px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
}

.modal-overlay.active .bottom-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--border-color);
  border-radius: 3px;
  margin: 0 auto 14px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

/* Print Media Styles */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .app-bottom-nav, .mobile-notch-bar, .modal-overlay .icon-btn, .modal-overlay .btn {
    display: none !important;
  }
  .modal-overlay {
    position: static !important;
    background: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    display: block !important;
  }
  .bottom-sheet {
    box-shadow: none !important;
    transform: none !important;
    max-width: 100% !important;
    padding: 0 !important;
  }
  #printable-schedule-area {
    border: none !important;
    padding: 0 !important;
  }
}

