html {
  scroll-behavior: smooth;
}

:root {
  --bg: #0c0907;
  --card: rgba(20, 15, 12, 0.75);
  --card-hover: rgba(28, 20, 15, 0.88);
  --card-backdrop: blur(16px);
  --text: #fefaf6;
  --text-muted: #d6cbbe;
  --primary: #f59e0b;
  --primary-hover: #fbbf24;
  --accent1: #d97706;
  --accent2: #b45309;
  --success: #10b981;
  --nav-height: 70px;
}

/* ============================================================
   AMBIENT GRADIENT ORB BACKGROUND
   ============================================================ */
#ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  will-change: transform;
  animation: orbFloat 30s ease-in-out infinite;
}

.orb-1 {
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(245,158,11,0.08) 0%, transparent 70%);
  top: -280px;
  left: -200px;
  animation-duration: 32s;
}

.orb-2 {
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(59,130,246,0.07) 0%, transparent 70%);
  bottom: -220px;
  right: -180px;
  animation-duration: 38s;
  animation-delay: -16s;
}

.orb-3 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(168,85,247,0.05) 0%, transparent 70%);
  top: 40%;
  left: 55%;
  animation-duration: 26s;
  animation-delay: -9s;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(60px, -50px) scale(1.07); }
  50%  { transform: translate(-40px, 80px) scale(0.95); }
  75%  { transform: translate(80px, 30px) scale(1.04); }
  100% { transform: translate(0, 0) scale(1); }
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg, #0c0907);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Transparent body rule removed to allow Ember Black solid background */

/* Navbar */

.navbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--nav-bg, var(--card));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: -1;
}
.navbar {
  height: var(--nav-height);
  /* background and blur moved to ::before to avoid trapping fixed elements */
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 2rem;
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* Container for action links */
.nav-actions-container {
  position: fixed;
  top: 0;
  right: 2rem;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 1001;
}

/* Nav action links (CGPA Calc, Platform Tour) — replaces inline styles */
.nav-action-link {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.nav-action-link.share-btn {
  background: transparent;
  border: none;
}

.nav-action-link.theme-btn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.28);
}

.nav-action-link:hover,
.nav-action-link:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary);
  outline: none;
}

.nav-action-icon {
  font-size: 1.2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
}

.brand-text .brand-title,
.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  display: block;
}

.brand-text span {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Dashboard Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 2rem;
  flex-grow: 1;
  width: 100%;
}

.hero {
  text-align: center;
  margin-bottom: 4rem;
}

.hero h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  background: linear-gradient(
    135deg,
    var(--text, #fefaf6) 0%,
    var(--primary, #f59e0b) 40%,
    #fb923c 55%,
    var(--text, #fefaf6) 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 250% auto;
  animation: heroShimmer 7s linear infinite;
}

@keyframes heroShimmer {
  0%   { background-position: 0% center; }
  100% { background-position: 250% center; }
}

.hero p {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
  transition: color 0.3s ease;
}

/* Hero Stats Row */
.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-top: 2.2rem;
  flex-wrap: wrap;
  row-gap: 1rem;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0 2.2rem;
}

.hero-stat-num {
  font-family: 'Outfit', sans-serif;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--primary, #f59e0b);
  line-height: 1;
  letter-spacing: -0.025em;
}

.hero-stat-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #d6cbbe);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  opacity: 0.8;
}

.hero-stat-divider {
  width: 1px;
  height: 38px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.15), transparent);
  flex-shrink: 0;
}

.hero-stat-live {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--success, #10b981);
  line-height: 1;
}

.live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success, #10b981);
  flex-shrink: 0;
  animation: livePulse 2.2s ease-out infinite;
}

@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70%  { box-shadow: 0 0 0 9px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

@media (max-width: 768px) {
  .hero-stat { padding: 0 1.1rem; }
  .hero-stat-num { font-size: 1.4rem; }
  .hero-stat-divider { height: 28px; }
}

/* Light theme: gradient text fallback */
body.theme-light .hero h1 {
  background: linear-gradient(135deg, #1a1a1a 0%, var(--primary, #f59e0b) 45%, #1a1a1a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 250% auto;
}

/* Header Search Bar */
.nav-search-wrap {
  flex: 1;
  max-width: 420px;
  margin: 0 1.5rem;
  position: relative;
}

.nav-search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-search-box:focus-within {
  background: var(--card, rgba(20, 15, 12, 0.95));
  border-color: var(--primary, #f59e0b);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.nav-search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary, #f59e0b);
  margin-right: 0.55rem;
  opacity: 0.9;
  flex-shrink: 0;
}

.nav-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--text, #fefaf6);
  padding: 0.25rem 0;
  width: 100%;
}

.nav-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.nav-search-input::placeholder {
  color: var(--text-muted, #94a3b8);
  opacity: 0.65;
  font-size: 0.84rem;
}

.nav-clear-search-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--text-muted, #d6cbbe);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.72rem;
  margin-left: 0.35rem;
  margin-right: 0.35rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nav-clear-search-btn:hover {
  background: rgba(245, 158, 11, 0.3);
  color: #ffffff;
  transform: scale(1.1);
}

.nav-search-shortcut {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  pointer-events: none;
}

.nav-kbd-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  padding: 0.12rem 0.45rem;
  font-family: 'JetBrains Mono', monospace, sans-serif;
  font-size: 0.72rem;
  color: var(--text-muted, #d6cbbe);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Active Search Banner (Displayed above results when filtering) */
.search-active-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 1.5rem auto 2.5rem auto;
  padding: 0.75rem 1.2rem;
  background: var(--card, rgba(20, 15, 12, 0.85));
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 12px;
  backdrop-filter: var(--card-backdrop, blur(16px));
  -webkit-backdrop-filter: var(--card-backdrop, blur(16px));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  max-width: 900px;
}

.search-active-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.search-active-badge {
  background: rgba(245, 158, 11, 0.15);
  color: var(--primary, #f59e0b);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.search-active-text {
  font-size: 0.92rem;
  color: var(--text, #fefaf6);
  font-weight: 500;
}

.search-active-right {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.search-quick-tags {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.search-quick-label {
  color: var(--text-muted, #d6cbbe);
  font-size: 0.8rem;
  font-weight: 500;
  margin-right: 0.1rem;
}

.search-quick-tag {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted, #d6cbbe);
  padding: 0.2rem 0.55rem;
  border-radius: 14px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.search-quick-tag:hover,
.search-quick-tag.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--primary, #f59e0b);
  color: var(--primary-hover, #fbbf24);
  transform: translateY(-1px);
}

.search-active-reset {
  background: none;
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: var(--primary, #f59e0b);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.search-active-reset:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--primary, #f59e0b);
  color: var(--primary-hover, #fbbf24);
}

@media (max-width: 900px) {
  .nav-search-wrap {
    max-width: 250px;
    margin: 0 0.8rem;
  }
  .nav-search-shortcut {
    display: none;
  }
}

@media (max-width: 768px) {
  .navbar {
    height: auto;
    min-height: var(--nav-height);
    padding: 0.5rem 1rem;
    flex-wrap: nowrap;
    gap: 0.5rem;
    position: relative;
  }
  .brand-text {
    display: none;
  }
  .nav-search-wrap {
    order: 2;
    max-width: 100%;
    width: auto;
    flex: 1;
    margin: 0 0 0 1rem;
  }
}

.no-search-results {
  text-align: center;
  padding: 3.5rem 1.5rem;
  background: var(--card, rgba(20, 15, 12, 0.75));
  border: 1px dashed rgba(245, 158, 11, 0.3);
  border-radius: 20px;
  margin: 2rem auto;
  max-width: 600px;
  backdrop-filter: var(--card-backdrop, blur(16px));
  -webkit-backdrop-filter: var(--card-backdrop, blur(16px));
}

.no-search-icon {
  font-size: 2.8rem;
  margin-bottom: 0.8rem;
  opacity: 0.85;
}

.no-search-results h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  color: var(--text, #fefaf6);
  margin-bottom: 0.4rem;
}

.no-search-results p {
  color: var(--text-muted, #d6cbbe);
  font-size: 0.95rem;
  margin-bottom: 1.4rem;
  line-height: 1.5;
}

.no-search-results .clear-filter-btn {
  background: linear-gradient(135deg, var(--primary, #f59e0b), var(--accent1, #d97706));
  color: #0c0907;
  border: none;
  padding: 0.6rem 1.4rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.no-search-results .clear-filter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}

/* Photographic library background contrast enhancement */
body:not([class*="theme-"]) .hero h1,
body.theme-default .hero h1,
body.theme-glass-canva .hero h1 {
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.7);
}

body:not([class*="theme-"]) .hero p,
body.theme-default .hero p,
body.theme-glass-canva .hero p {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

#canvaBg iframe {
  width: 100vw !important;
  height: 56.25vw !important; /* 16:9 ratio */
  min-height: 100vh !important;
  min-width: 177.77vh !important; /* 16:9 ratio */
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) scale(1.15) !important;
}

/* Phase 2 Banner */
.phase2-banner {
  background: var(--card2, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
  border-radius: 12px;
  padding: 1.5rem 2rem;
  text-align: center;
  margin-bottom: 4rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.phase2-banner h3 {
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.phase2-banner p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Responsive Media Queries */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 0.9rem; }
  .container { 
    padding: 1rem 1rem 6rem 1rem; /* Extra bottom padding for app bar */
  }
  .sem-title { font-size: 1rem; }
  .subject-grid { grid-template-columns: 1fr; }
  
  /* Subject Card Optimization */
  .subject-card {
    padding: 1.25rem;
    background: rgba(20, 15, 12, 0.9);
  }

  /* Bottom App Bar Styling */
  .nav-actions-container {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    background: var(--card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 1000;
    justify-content: space-around;
    padding: 0.6rem 0.5rem;
    margin: 0;
    gap: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  }
  
  .nav-action-link {
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.65rem;
    padding: 0.3rem 0.5rem;
    border: none !important;
    background: transparent !important;
  }
  
  .nav-action-link:hover,
  .nav-action-link:focus-visible {
    background: rgba(255, 255, 255, 0.05) !important;
  }
  
  .nav-action-icon {
    font-size: 1.3rem;
  }

  /* Compact search banner */
  .search-active-banner {
    padding: 0.5rem 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .search-active-right {
    width: 100%;
    justify-content: space-between;
  }
  .search-quick-tags {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
    flex-wrap: nowrap;
    max-width: calc(100% - 80px);
  }
  .search-quick-tag {
    flex-shrink: 0;
  }
}

/* ============================================================
   SEMESTER BLOCK — PREMIUM REDESIGN
   ============================================================ */

/* Per-semester accent color palette */
.sem-block-1 { --sem-hue: 38; --sem-color: #f59e0b; --sem-glow: rgba(245,158,11,0.25); }
.sem-block-2 { --sem-hue: 217; --sem-color: #3b82f6; --sem-glow: rgba(59,130,246,0.25); }
.sem-block-3 { --sem-hue: 262; --sem-color: #a855f7; --sem-glow: rgba(168,85,247,0.25); }
.sem-block-4 { --sem-hue: 160; --sem-color: #10b981; --sem-glow: rgba(16,185,129,0.25); }
.sem-block-5 { --sem-hue: 330; --sem-color: #ec4899; --sem-glow: rgba(236,72,153,0.25); }
.sem-block-6 { --sem-hue: 14;  --sem-color: #f97316; --sem-glow: rgba(249,115,22,0.25); }

.semester-block {
  margin-bottom: 2.5rem;
  scroll-margin-top: 110px;
}

/* THE HEADER CARD */
.semester-header {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.1rem 1.5rem;
  border-radius: 16px;
  background: var(--card, rgba(20,15,12,0.7));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-left: 3px solid var(--sem-color, var(--primary));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition:
    background 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.3s ease,
    transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  user-select: none;
  margin-bottom: 0;
  position: relative;
  overflow: hidden;
}

/* Subtle gradient shimmer on the card */
.semester-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 0%,
    hsla(var(--sem-hue, 38), 80%, 55%, 0.04) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.semester-header::-webkit-details-marker { display: none; }

.semester-header:hover {
  background: var(--card-hover, rgba(28,20,15,0.88));
  border-left-color: var(--sem-color, var(--primary));
  box-shadow:
    0 0 0 1px var(--sem-glow, rgba(245,158,11,0.15)),
    0 8px 28px -6px var(--sem-glow, rgba(245,158,11,0.2)),
    0 2px 8px -2px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

/* Open / expanded state — semester accent glow */
details[open] > .semester-header {
  background: hsla(var(--sem-hue, 38), 30%, 6%, 0.92);
  border-color: var(--sem-color, var(--primary));
  box-shadow:
    0 0 0 1px var(--sem-glow, rgba(245,158,11,0.25)),
    0 6px 30px -4px var(--sem-glow, rgba(245,158,11,0.2)),
    inset 0 1px 0 rgba(255,255,255,0.05);
  transform: translateY(0);
}

/* Remove the old CSS-only chevron */
.semester-header::after { display: none !important; }
details[open] > .semester-header::after { display: none !important; }

/* ---- Big Semester Number Badge — 3D emboss ---- */
.sem-num-badge {
  font-family: 'Outfit', sans-serif;
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1;
  color: var(--sem-color, var(--primary));
  letter-spacing: -0.04em;
  min-width: 2.5rem;
  text-align: center;
  opacity: 0.92;
  flex-shrink: 0;
  position: relative;
  text-shadow:
    0 0 20px var(--sem-glow, rgba(245,158,11,0.55)),
    0 0 48px var(--sem-glow, rgba(245,158,11,0.28)),
    0 1px 0 rgba(255,255,255,0.12),
    0 -1px 0 rgba(0,0,0,0.55);
  transition: opacity 0.2s ease, transform 0.2s ease, text-shadow 0.2s ease;
}

.semester-header:hover .sem-num-badge {
  opacity: 1;
  transform: scale(1.08);
  text-shadow:
    0 0 30px var(--sem-glow, rgba(245,158,11,0.7)),
    0 0 60px var(--sem-glow, rgba(245,158,11,0.35)),
    0 1px 0 rgba(255,255,255,0.15),
    0 -1px 0 rgba(0,0,0,0.6);
}

/* ---- Header body (title + preview chips) ---- */
.sem-header-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sem-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

.semester-header:hover .sem-title {
  color: var(--sem-color, var(--primary));
}

/* Preview chips row — hidden when open */
.sem-preview-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  overflow: hidden;
  max-height: 1.8rem;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

details[open] > .semester-header .sem-preview-chips {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.sem-chip {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}

.semester-header:hover .sem-chip {
  background: hsla(var(--sem-hue,38), 80%, 55%, 0.08);
  border-color: hsla(var(--sem-hue,38), 80%, 55%, 0.2);
  color: hsla(var(--sem-hue,38), 90%, 75%, 1);
}

/* ---- Subject Count Pill ---- */
.sem-count-pill {
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--sem-color, var(--primary));
  background: hsla(var(--sem-hue,38), 80%, 55%, 0.12);
  border: 1px solid hsla(var(--sem-hue,38), 80%, 55%, 0.25);
  padding: 0.25rem 0.65rem;
  border-radius: 100px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.semester-header:hover .sem-count-pill {
  background: hsla(var(--sem-hue,38), 80%, 55%, 0.2);
  box-shadow: 0 0 10px var(--sem-glow, rgba(245,158,11,0.3));
}

/* ---- Custom Animated Chevron ---- */
.sem-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
}

.sem-chevron::after {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translate(-1px,-1px);
  transition: border-color 0.2s ease;
}

/* Rotate when open */
details[open] > .semester-header .sem-chevron {
  transform: rotate(180deg);
  background: hsla(var(--sem-hue,38), 80%, 55%, 0.12);
  border-color: hsla(var(--sem-hue,38), 80%, 55%, 0.3);
}

details[open] > .semester-header .sem-chevron::after {
  border-color: var(--sem-color, var(--primary));
}

.semester-header:hover .sem-chevron {
  background: hsla(var(--sem-hue,38), 80%, 55%, 0.1);
  border-color: var(--sem-color, var(--primary));
}
.semester-header:hover .sem-chevron::after {
  border-color: var(--sem-color, var(--primary));
}

/* ---- Smooth grid expand animation ---- */
.semester-block > .subject-grid {
  margin-top: 1.5rem;
  animation: semExpand 0.32s cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes semExpand {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Staggered card entrance (JS-triggered via .sem-opening) ---- */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.sem-opening .subject-card {
  animation: cardSlideIn 0.42s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.sem-opening .subject-card:nth-child(1)  { animation-delay: 0.03s; }
.sem-opening .subject-card:nth-child(2)  { animation-delay: 0.07s; }
.sem-opening .subject-card:nth-child(3)  { animation-delay: 0.11s; }
.sem-opening .subject-card:nth-child(4)  { animation-delay: 0.15s; }
.sem-opening .subject-card:nth-child(5)  { animation-delay: 0.19s; }
.sem-opening .subject-card:nth-child(6)  { animation-delay: 0.23s; }
.sem-opening .subject-card:nth-child(7)  { animation-delay: 0.27s; }
.sem-opening .subject-card:nth-child(8)  { animation-delay: 0.31s; }
.sem-opening .subject-card:nth-child(9)  { animation-delay: 0.35s; }
.sem-opening .subject-card:nth-child(10) { animation-delay: 0.39s; }
.sem-opening .subject-card:nth-child(n+11) { animation-delay: 0.43s; }

/* Light theme adjustments */
body.theme-light .semester-header {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
body.theme-light .semester-header:hover {
  background: #fff;
  box-shadow:
    0 0 0 1px var(--sem-glow, rgba(245,158,11,0.2)),
    0 8px 28px -6px rgba(0,0,0,0.12);
}
body.theme-light .sem-chip {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
  color: #555;
}
body.theme-light .sem-chevron {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.1);
}
body.theme-light .sem-chevron::after {
  border-color: #666;
}

/* Semester badge (kept for backwards compat) */
.semester-badge {
  background: var(--card2, rgba(255, 255, 255, 0.08));
  color: var(--primary);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
}

/* Mobile responsive */
@media (max-width: 768px) {
  .semester-header {
    padding: 0.9rem 1rem;
    gap: 0.75rem;
    border-radius: 12px;
  }
  .sem-num-badge {
    font-size: 1.4rem;
    min-width: 1.8rem;
  }
  .sem-title {
    font-size: 1rem;
  }
  .sem-preview-chips {
    display: none;
  }
  .sem-count-pill {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
  }
  .sem-chevron {
    width: 22px;
    height: 22px;
  }
}


/* Grid */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6, 2rem);
}

/* Cards */
.subject-card {
  background: var(--card);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 16px);
  padding: var(--space-5, 1.5rem);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition, 0.3s cubic-bezier(0.4, 0, 0.2, 1));
  position: relative;
  overflow: hidden;
  
  display: grid;
  grid-template-rows: auto 48px 1fr auto; /* Ensure title has 2 lines exactly */
  gap: var(--space-3, 0.75rem);
}

.subject-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--sem-color, var(--primary)),
    hsla(var(--sem-hue, 38), 85%, 65%, 0.75)
  );
  border-radius: 16px 16px 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.subject-card:hover {
  transform: translateY(-5px);
  background: var(--card-hover, var(--card2));
  border-color: var(--sem-color, var(--primary));
  box-shadow:
    0 15px 35px -8px rgba(0, 0, 0, 0.6),
    0 0 22px -5px var(--sem-glow, var(--border));
}

.subject-card:hover::before {
  opacity: 1;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: var(--card2, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.subject-card h3 {
  font-family: var(--font-sans, 'Outfit', sans-serif);
  font-size: var(--text-lg, 1.25rem);
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  align-self: start;
}

.subject-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  flex-grow: 1;
}

.card-footer {
  display: flex;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(245, 158, 11, 0.1);
  gap: 0.5rem;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--success);
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
}



.action-arrow {
  color: var(--primary);
  transition: transform 0.2s;
  margin-left: auto;
}

.subject-card:hover .action-arrow {
  transform: translateX(5px);
}

.empty-state {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
}





/* Desktop button styling for nav actions */
@media (min-width: 769px) {
  .nav-action-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
  }
  .nav-action-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
  }
}

/* Old chevron code removed — replaced by .sem-chevron in premium redesign above */
/* ============================================================
   SEMESTER FILTER PILLS (YouTube Style)
   ============================================================ */
.semester-filter-container {
  width: 100%;
  background: var(--nav-bg, var(--card));
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  position: sticky;
  top: var(--nav-height, 70px);
  z-index: 999;
  display: flex;
  align-items: center;
  padding: 0.6rem 2rem;
  backdrop-filter: var(--card-backdrop, blur(16px));
  -webkit-backdrop-filter: var(--card-backdrop, blur(16px));
  transition: all 0.3s ease;
}

.semester-filter-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
  padding-bottom: 4px; /* Room for hover effects */
}

.semester-filter-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.semester-pill {
  text-decoration: none;
  color: var(--text-muted, #94a3b8);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  padding: 0.45rem 1.1rem;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.semester-pill:hover, .semester-pill:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text, #fff);
  transform: translateY(-1px);
  outline: none;
}

.semester-pill.active, .semester-pill:active {
  background: var(--primary, #f59e0b);
  color: var(--primary-contrast, #0c0907);
  font-weight: 600;
  border-color: var(--primary, #f59e0b);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
  transform: translateY(0);
}

/* Semester-colored dots on nav pills */
.semester-pill[data-sem]::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pill-dot, var(--text-muted));
  margin-right: 5px;
  vertical-align: middle;
  opacity: 0.65;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.semester-pill[data-sem="1"] { --pill-dot: #f59e0b; }
.semester-pill[data-sem="2"] { --pill-dot: #3b82f6; }
.semester-pill[data-sem="3"] { --pill-dot: #a855f7; }
.semester-pill[data-sem="4"] { --pill-dot: #10b981; }
.semester-pill[data-sem="5"] { --pill-dot: #ec4899; }
.semester-pill[data-sem="6"] { --pill-dot: #f97316; }
.semester-pill[data-sem]:hover::before,
.semester-pill[data-sem].active::before {
  opacity: 1;
  transform: scale(1.35);
}

@media (max-width: 768px) {
  .semester-filter-container {
    padding: 0.6rem 1rem;
    position: relative; 
    top: auto; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
}

/* ============================================================
   SMART HEADER (Hide on scroll down, show on scroll up)
   ============================================================ */
#smart-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
  will-change: transform;
}

#smart-header.nav-hidden {
  transform: translateY(-100%);
}

/* Ensure the navbar and pills inside don't double-stick */
#smart-header .navbar,
#smart-header .semester-filter-container {
  position: relative;
  top: auto;
}
