:root {
    --bg: #0B0E13;
    --bg-raised: #131820;
    --bg-panel: #10141B;
    --ink: #E7ECF3;
    --ink-soft: #8D98AC;
    --rule: #232b38;
    --steel: #5C7A99;
    --steel-bright: #7FA8CC;
    --shadow: rgba(0,0,0,0.30);
    --radius: 6px;
    --metal-grad: linear-gradient(120deg, #151B24 0%, #10141B 100%);
    --metal-line: linear-gradient(90deg, transparent, var(--steel-bright), transparent);
  }
  /* Light mode kept for parity, still cool-toned */
  html.light {
    --bg: #EEF1F5;
    --bg-raised: #FFFFFF;
    --bg-panel: #F5F7FA;
    --ink: #1B222D;
    --ink-soft: #545F70;
    --rule: #D6DCE5;
    --steel: #34506B;
    --steel-bright: #2C6E9E;
    --shadow: rgba(20,30,45,0.10);
    --metal-grad: linear-gradient(135deg, #FFFFFF 0%, #EEF1F5 45%, #E4E9EF 75%, #FFFFFF 100%);
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background-color: var(--bg);
    background-image: url("assets/bg-dark.png");
    background-repeat: no-repeat;
    background-position: bottom right;
    background-size: cover;
    background-attachment: fixed;
    color: var(--ink);
    font-family: 'Source Serif 4', Georgia, serif;
    line-height: 1.6;
    transition: background-color 0.25s ease, color 0.25s ease;
  }
  html.light body {
    background-image: url("assets/bg-light.png");
  }
  /* Fixed backgrounds can be janky/heavy on mobile browsers — let it scroll with the page instead */
  @media (max-width: 860px) {
    body { background-attachment: scroll; }
  }
  h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 600; letter-spacing: -0.01em; margin: 0; }

  header.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 28px;
    background: var(--metal-grad);
    border-bottom: 1px solid var(--rule);
    box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 2px 10px var(--shadow);
    position: relative;
  }
  header.topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
    background: var(--metal-line); opacity: 0.6;
  }
  .brand { display: flex; align-items: center; gap: 10px; }
  .brand .mark {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 12px; letter-spacing: 0.08em;
    color: var(--steel-bright); border: 1px solid var(--steel);
    padding: 2px 6px; border-radius: var(--radius);
    background: rgba(127,168,204,0.08);
  }
  .brand h1 { font-size: 18px; }

  button#toggle {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-panel); color: var(--ink);
    border: 1px solid var(--rule); border-radius: 999px;
    padding: 6px 12px; cursor: pointer;
    font-family: 'IBM Plex Mono', monospace; font-size: 12px;
  }
  button#toggle:hover { border-color: var(--steel-bright); color: var(--steel-bright); }

  main { max-width: 1180px; margin: 0 auto; padding: 48px 28px 100px; }

  .hero { padding: 10px 0 44px; border-bottom: 1px solid var(--rule); margin-bottom: 40px; }
  .hero .eyebrow {
    font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    letter-spacing: 0.1em; text-transform: uppercase; color: var(--steel-bright);
    margin-bottom: 10px;
  }
  .hero h2 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; margin-bottom: 12px; }
  .hero p { color: var(--ink-soft); max-width: 56ch; font-size: 16.5px; margin: 0; }

  /* ---------- Two-column layout: Past Lessons (left) + Subjects (right) ---------- */
  .layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
  }
  @media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
  }

  /* ---------- Past Lessons sidebar ---------- */
  .sidebar {
    position: static;
    background: var(--bg-raised);
    border: 1px solid var(--rule);
    border-radius: 10px;
    padding: 18px 16px 20px;
    box-shadow: 0 2px 10px var(--shadow);
  }

  .sidebar-head {
    display: flex; align-items: baseline; justify-content: space-between;
    margin-bottom: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--rule);
  }
  .sidebar-head h3 {
    font-size: 15px; color: var(--ink);
    font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  .sidebar-head span {
    font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--ink-soft);
  }

  .lesson-group { margin-top: 14px; }
  .lesson-group:first-of-type { margin-top: 12px; }
  .lesson-group summary {
    cursor: pointer;
    list-style: none;
    display: flex; align-items: center; justify-content: space-between;
    font-family: 'IBM Plex Mono', monospace; font-size: 12.5px;
    letter-spacing: 0.03em; text-transform: uppercase;
    color: var(--group-accent, var(--steel-bright));
    padding: 8px 10px;
    border-radius: 5px;
    background: rgba(127,168,204,0.06);
    border: 1px solid var(--rule);
  }
  .lesson-group summary::-webkit-details-marker { display: none; }
  .lesson-group summary::after {
    content: "+"; font-size: 14px; color: var(--ink-soft); transition: transform 0.15s ease;
  }
  .lesson-group[open] summary::after { content: "–"; }
  .lesson-group summary:hover { border-color: var(--group-accent, var(--steel-bright)); }

  .lesson-list { list-style: none; margin: 8px 2px 0; padding: 0; }
  .lesson-list li { margin-bottom: 2px; }
  .lesson-list a {
    display: flex; align-items: baseline; gap: 8px;
    text-decoration: none; color: var(--ink-soft);
    font-size: 13.5px; padding: 7px 10px; border-radius: 5px;
    border-left: 2px solid transparent;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  }
  .lesson-list a .n {
    font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--group-accent, var(--steel-bright));
    flex: 0 0 auto;
  }
  .lesson-list a:hover, .lesson-list a:focus-visible {
    background: var(--bg-panel); color: var(--ink);
    border-left-color: var(--group-accent, var(--steel-bright));
    outline: none;
  }
  .view-all {
    display: block; margin: 8px 2px 0; padding: 7px 10px;
    font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    color: var(--group-accent, var(--steel-bright)); text-decoration: none;
    border-top: 1px dashed var(--rule); padding-top: 10px;
  }
  .view-all:hover, .view-all:focus-visible { color: var(--ink); outline: none; }

  .sidebar-note {
    margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--rule);
    font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-soft);
    line-height: 1.5;
  }

  /* ---------- Subject cards ---------- */
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
  }
  a.card {
    display: block; text-decoration: none; color: var(--ink);
    background: var(--bg-raised);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--card-accent, var(--steel));
    border-radius: var(--radius);
    padding: 22px 22px 20px;
    box-shadow: 0 1px 2px var(--shadow);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  }
  a.card:hover, a.card:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px var(--shadow);
    border-left-color: var(--card-accent, var(--steel-bright));
  }
  a.card .tag {
    font-family: 'IBM Plex Mono', monospace; font-size: 11.5px;
    letter-spacing: 0.06em; text-transform: uppercase;
    color: var(--card-accent, var(--steel-bright));
    margin-bottom: 10px; display: block;
  }
  a.card h3 { font-size: 19px; margin-bottom: 8px; }
  a.card p { font-size: 14.5px; color: var(--ink-soft); margin: 0; }
  a.card .go {
    margin-top: 14px; font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    color: var(--card-accent, var(--steel-bright));
  }

  footer {
    text-align: center; padding: 30px; color: var(--ink-soft);
    font-family: 'IBM Plex Mono', monospace; font-size: 12px;
    border-top: 1px solid var(--rule);
  }


  .module-section {
  margin-top: 10px;
  margin-bottom: 8px;
  padding-left: 4px;
  }

  .module-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.8;
  padding: 4px 6px;
  border-left: 2px solid var(--group-accent, var(--steel-bright));
  margin-bottom: 4px;
  }

  .grid { align-content: start; }

  /* ---------------------------------------------------------------------
     THEME-AWARE ACCENT FIXES — Math (yellow) & Filipino (blue)
     Neither base brand color is changed. Each keeps its original hex in
     the mode where it already reads fine; only the OTHER mode gets an
     override so the label/border is never invisible.
     --------------------------------------------------------------------- */

  /* MATH — #FDFF00 is fine on the dark background (default), but nearly
     invisible on the light background, so light mode gets a deeper gold
     that still reads as "yellow," not a random new hue. */
  .subj-math { --group-accent: #FDFF00; --card-accent: #FDFF00; }
  html.light .subj-math { --group-accent: #8A6D00; --card-accent: #8A6D00; }

  /* FILIPINO — #0000FF is fine on the light background (default light-mode
     override below just restates it for clarity), but pure blue on the
     near-black dark background loses almost all contrast, so dark mode
     (the default, unswitched state) gets a lighter blue instead. */
  .subj-fil { --group-accent: #5B7CFA; --card-accent: #5B7CFA; }
  html.light .subj-fil { --group-accent: #0000FF; --card-accent: #0000FF; }


/* ==========================================================================
   Streak Badge Component
   ========================================================================== */

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-raised, #1e293b);
  border: 1px solid var(--rule, #334155);
  border-left: 3px solid #ff6b35; /* Orange highlight border */
  border-radius: var(--radius, 8px);
  color: var(--ink, #f8fafc);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 1px 3px var(--shadow, rgba(0, 0, 0, 0.2));
  transition: transform 0.2s ease, border-color 0.2s ease;
  user-select: none;
  margin-left: 24px;
}

.back-streak-badge{
  margin-left: 3px;
}

.streak-badge:hover {
  transform: translateY(-1px);
  border-color: #ff6b35;
}

#streak-emoji {
  font-size: 1.1rem;
  line-height: 1;
}

#streak-count {
  color: #ff6b35;
  font-weight: 700;
}

/* Responsive tweaking for smaller mobile screens */
@media (max-width: 640px) {
  .streak-badge {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
  }
  
  #streak-label {
    display: none; /* Hide 'day streak' text on tiny screens to save space */
  }
}
/* ---------------------------------------------------------------------
   WHAT'S NEW — wide standalone section below the subject grid, driven
   by assets/data/whats-new.json (manually maintained list, unrelated
   to subjects.json). Hides itself automatically when the list is empty.
   --------------------------------------------------------------------- */
.whats-new-wide {
  max-width: 1180px;
  margin: 44px auto 0;
  padding: 0 28px;
}
.whats-new-wide .whats-new-inner {
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 22px 26px 24px;
  box-shadow: 0 2px 10px var(--shadow);
}
.whats-new-wide h3 {
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--steel-bright);
  margin: 0 0 16px;
}
.whats-new-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.whats-new-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.whats-new-text {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}
a.whats-new-text:hover, a.whats-new-text:focus-visible {
  color: var(--steel-bright);
  outline: none;
}
.whats-new-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-soft);
  flex: 0 0 auto;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .whats-new-wide { padding: 0 16px; margin-top: 32px; }
  .whats-new-wide .whats-new-inner { padding: 18px 16px; }
  .whats-new-items { grid-template-columns: 1fr; }
}


/* ---------- Test Link Icon ---------- */
.test-link {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  color: var(--ink);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-left: auto;
  margin-right: 15px;
}

.test-link:hover {
  background: var(--bg-panel);
  border-color: var(--steel-bright);
}

.test-link svg {
  stroke: var(--steel-bright);
}

/* ---------- Back Link Specific Styling ---------- */
.test-link.back-link {
  gap: 4px;
}

/* Hide the "Back to Notes" text on mobile screens so only "←" shows */
@media (max-width: 640px) {
  .test-link.back-link .back-text {
    display: none;
  }

  .test-link{
    margin-left: 15px;
  }

  .test-link.back-link {
    padding: 6px 10px;
  }
}

/* ---------- Loren Signed Fix ---------- */

.quick-fix{
  margin-left: 24px;
}

@media (max-width: 640px) {
.quick-fix{
  margin-left: 5px;
}
}
/* ==========================================================================
   Header & Topbar Alignment Fixes
   ========================================================================== */

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--metal-grad);
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(255,255,255,0.03) inset, 0 2px 10px var(--shadow);
  position: relative;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Base styling for all header buttons (Tests, Install, Theme Toggle) */
.topbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: var(--bg-panel);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--radius, 6px);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  line-height: 1;
  box-sizing: border-box;
}

.topbar-btn:hover {
  background: var(--bg-raised);
  border-color: var(--steel-bright);
  color: var(--steel-bright);
}

.topbar-btn svg {
  stroke: var(--steel-bright);
  flex-shrink: 0;
}

/* Remove old conflicting button margins */
.test-link, #toggle, .quick-fix {
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Streak badge alignment normalization */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 34px;
  padding: 0 10px;
  margin-left: 0 !important;
  background: var(--bg-raised);
  border: 1px solid var(--rule);
  border-left: 3px solid #ff6b35;
  border-radius: var(--radius, 6px);
  font-size: 0.82rem;
  box-sizing: border-box;
}

/* ==========================================================================
   Mobile Responsive Optimizations
   ========================================================================== */

@media (max-width: 680px) {
  header.topbar {
    padding: 10px 14px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-btn {
    padding: 0 8px;
  }

  /* Hide text labels on small screens to fit buttons cleanly without crowding */
  .topbar-actions .btn-text {
    display: none;
  }
}

/* Inline Comment Badge & Tooltip */
.whats-new-comment-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  cursor: help;
  position: relative;
  font-size: 0.9rem;
  user-select: none;
}

/* Floating Tooltip Box */
.whats-new-comment-badge::after {
  content: attr(data-comment);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised, #1e293b);
  color: var(--ink, #f8fafc);
  border: 1px solid var(--rule, #334155);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 14px var(--shadow, rgba(0, 0, 0, 0.4));
  z-index: 100;
}

/* Reveal Tooltip on Hover */
.whats-new-comment-badge:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-2px);
}

/* 📱 MOBILE LANDSCAPE OPTIMIZATION */
@media screen and (orientation: landscape) and (max-height: 500px) {
  /* 1. Reduce top bar height to free up vertical space */
  .top-bar, .topbar {
    padding: 4px 12px !important;
  }
  .top-bar .title, .topbar .brand h1 {
    font-size: 0.9rem !important;
  }

  /* 2. Unstick sticky elements so they don't block the screen height */
  .wizard-sidebar, .top-bar {
    position: static !important;
  }

  /* 3. Reduce card padding for better visibility */
  .quiz-item, .hero {
    padding: 12px !important;
    margin-bottom: 12px !important;
  }
}

/* ==========================================================================
   Auth Modal Component
   ========================================================================== */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-raised, #131820);
  border: 1px solid var(--rule, #232b38);
  border-radius: 10px;
  padding: 28px 24px;
  box-shadow: 0 10px 30px var(--shadow, rgba(0, 0, 0, 0.5));
}

.auth-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  color: var(--ink-soft);
  font-size: 22px; cursor: pointer;
}
.auth-close:hover { color: var(--ink); }

.auth-header { margin-bottom: 20px; }
.auth-header h3 { font-size: 22px; margin: 6px 0 4px; }
.auth-header p { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

.auth-tabs {
  display: flex;
  background: var(--bg-panel, #10141B);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  padding: 8px 0;
  background: none; border: none;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12.5px; font-weight: 500;
  border-radius: 4px; cursor: pointer;
  transition: all 0.15s ease;
}

.auth-tab.active {
  background: var(--bg-raised);
  color: var(--steel-bright);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.auth-field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 16px; text-align: left;
}
.auth-field label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px; text-transform: uppercase;
  color: var(--steel-bright); letter-spacing: 0.05em;
}
.auth-field input {
  background: var(--bg-panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  font-size: 14px; outline: none;
  transition: border-color 0.15s ease;
}
.auth-field input:focus { border-color: var(--steel-bright); }

.auth-submit {
  width: 100%;
  padding: 10px;
  background: var(--steel-bright);
  border: none; border-radius: 6px;
  color: #0b0e13; font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px; cursor: pointer;
  transition: opacity 0.15s ease;
  margin-top: 4px;
}
.auth-submit:hover { opacity: 0.9; }

.auth-error {
  font-size: 12.5px; color: #ff5555;
  margin-bottom: 12px; background: rgba(255, 85, 85, 0.1);
  padding: 8px 10px; border-radius: 4px;
}
.auth-success {
  font-size: 12.5px; color: #50fa7b;
  margin-bottom: 12px; background: rgba(80, 250, 123, 0.1);
  padding: 8px 10px; border-radius: 4px;
}



/* ==========================================================================
   Sidebar Term Filter Tabs
   Three compact pill buttons (Term 1 / Term 2 / Term 3) sitting inside the
   "Past Lessons" sidebar, just below the header. The active tab highlights
   with a crisp border; the "Now" badge on Term 2 is a tiny accent pill.
   ========================================================================== */

.sidebar-term-tabs {
  display: flex;
  gap: 4px;
  margin: 12px 0 6px;
  padding: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.st-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.st-tab:hover {
  color: var(--ink);
  background: rgba(127, 168, 204, 0.07);
}

.st-tab:focus-visible {
  outline: 2px solid var(--steel-bright);
  outline-offset: 2px;
}

.st-tab.active {
  background: var(--bg-raised);
  color: var(--ink);
  border-color: var(--steel-bright);
  box-shadow: 0 1px 6px var(--shadow);
}

/* "Now" pill badge on the active term button */
.st-pill {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(127, 168, 204, 0.18);
  color: var(--steel-bright);
  border: 1px solid rgba(127, 168, 204, 0.3);
  line-height: 1.4;
  transition: background 0.15s ease, color 0.15s ease;
}

.st-tab.active .st-pill {
  background: var(--steel-bright);
  color: #0B0E13;
  border-color: transparent;
}

html.light .st-tab.active .st-pill {
  color: #fff;
}

/* Empty-state notice when a term has no lessons yet */
.sidebar-empty-term {
  text-align: center;
  padding: 20px 8px;
  font-style: italic;
  color: var(--ink-soft);
}
