
/* === Theme variables === */
:root {
  --bg: #0b1220;
  --surface: #101827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --link: #93c5fd;
  --border: #233143;
  --card: #0f172a;
  --accent: #3b82f6;
}

:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --link: #1d4ed8;
  --border: #e2e8f0;
  --card: #ffffff;
  --accent: #2563eb;
}

/* Apply variables */
html, body { background: var(--bg); color: var(--text); }
a { color: var(--link); }
.muted { color: var(--muted); }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

.site-header, .site-footer { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-footer { border-top: 1px solid var(--border); border-bottom: none; }

.nav .nav-link, .brand { color: var(--text); text-decoration: none; }
.nav .nav-link:hover { text-decoration: underline; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 1rem; }

/* Toggle + small UI */
.theme-toggle { display:inline-flex; align-items:center; gap:.4rem; }
.theme-toggle input { inline-size: 1.2rem; block-size: 1.2rem; }

/* Simple mobile nav helper */
.nav-links { display:flex; gap: .8rem; flex-wrap:wrap; }
.menu-btn { display:none; }
@media (max-width: 720px) {
  .menu-btn { display:inline-block; }
  .nav-links { display:none; }
  .nav-links.open { display:flex; flex-direction:column; }
}
/* ---------- Layout primitives ---------- */
:root {
  --max-w: 1100px;
  --gap: 1rem;
  --radius: 16px;
  --font-scale: clamp(14px, 1.2vw, 18px);
}
html { font-size: var(--font-scale); }
.container { max-width: var(--max-w); margin-inline:auto; padding-inline: var(--gap); }
.grid { display:grid; gap: var(--gap); }
.flex { display:flex; gap: var(--gap); flex-wrap:wrap; }

/* Cards auto-fit nicely */
.cards {
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(240px,1fr));
  gap: var(--gap);
}
.card { border-radius: var(--radius); padding: 1rem; }

/* Images are fluid by default */
img, video { max-width: 100%; height: auto; }

/* Typography scales smoothly */
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem);   line-height: 1.2; }
p, li { line-height: 1.6; }

/* Nav: mobile-first */
.site-header .nav { display:flex; align-items:center; justify-content:space-between; gap:.8rem; }
.nav-links { display:none; flex-direction:column; gap:.6rem; }
.nav-links.open { display:flex; }
.menu-btn { display:inline-flex; }
@media (min-width: 720px) {
  .nav-links { display:flex; flex-direction:row; }
  .menu-btn { display:none; }
}

/* Content columns that collapse on small screens */
.columns { display:grid; gap: var(--gap); }
@media (min-width: 900px) {
  .columns { grid-template-columns: 2fr 1fr; } /* main + sidebar */
}

/* Tables: allow horizontal scroll on small viewports */
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse: collapse; }
th, td { padding:.6rem; }

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
/* Touch targets */
button, .nav-link, label, input[type="checkbox"] {
  min-height: 40px; /* comfortable tap area */
}

/* ===== Mobile menu: compact sliding sheet ===== */
@media (max-width: 720px) {
  .site-header { position: sticky; top: 0; z-index: 50; }
  .nav { position: relative; }

  /* Overlay behind the menu */
  .nav-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity .18s ease-out;
    z-index: 40;
  }
  .nav-overlay.open {
    opacity: 1; pointer-events: auto;
  }

  /* The sheet itself */
  .nav-links {
    position: absolute;
    left: var(--gap, 1rem); right: var(--gap, 1rem);
    top: calc(100% + .5rem);
    display: grid; gap: .4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .6rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    max-height: min(60vh, 22rem);
    overflow-y: auto;

    /* start collapsed */
    transform-origin: top center;
    transform: translateY(-6px) scale(.98);
    opacity: 0;
    visibility: hidden;
    transition: opacity .16s ease-out, transform .16s ease-out, visibility 0s linear .16s;
    z-index: 60;
  }
  .nav-links.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
    transition: opacity .16s ease-out, transform .16s ease-out;
  }

  /* Make links tidy, bigger tap targets */
  .nav-link, .theme-toggle, .menu-btn, .brand {
    line-height: 1.2;
  }
  .nav-link { padding: .6rem .5rem; border-radius: 8px; }
  .nav-link:focus-visible, .nav-link:hover {
    background: color-mix(in oklab, var(--surface), var(--text) 12%);
    text-decoration: none;
  }

  /* Prevent body scroll when menu is open */
  body.menu-open { overflow: hidden; }
}

/* Desktop stays inline (already set above) */

/* === FINAL MOBILE MENU OVERRIDES (safe & visible) === */
@media (max-width: 720px) {
  .site-header { position: sticky; top: 0; z-index: 50; }
  .nav { position: relative; }

  .nav-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    backdrop-filter: blur(2px);
    display: none;
    z-index: 40;
  }
  .nav-overlay.open { display: block; }

  .nav-links {
    /* sheet */
    position: absolute;
    left: var(--gap, 1rem); right: var(--gap, 1rem);
    top: calc(100% + .5rem);
    display: none;                /* closed by default */
    grid-auto-rows: min-content;
    gap: .5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .7rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    max-height: min(60vh, 22rem);
    overflow-y: auto;
    z-index: 60;                  /* above overlay */
  }
  .nav-links.open {
    display: grid !important;     /* show when open */
  }

  .nav-link { padding: .6rem .5rem; border-radius: 8px; }
  .nav-link:focus-visible, .nav-link:hover {
    background: color-mix(in oklab, var(--surface), var(--text) 12%);
    text-decoration: none;
  }

  body.menu-open { overflow: hidden; }
}

/* === Sticky footer layout === */
html, body { height: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Let the main content grow to fill; footer sits at bottom */
main, .site-main, .admin-wrap { flex: 1 0 auto; }

/* Ensure footer doesn't shrink */
.site-footer { margin-top: auto; }
[?2004h[?1049h[22;0;0t[1;75r(B[m[4l[?7h[39;49m[?1h=[?1h=[?25l[39;49m(B[m[H[2J[73;56H(B[0;7m[ Reading... ](B[m[73;55H(B[0;7m[ Read 22 lines ](B[m[73;55H  (B[0;7m[ New File ](B[m[K[?12l[?25h[75;1H[?1049l[23;0;0t[?1l>[?2004l
/* === Unified Theme Toggle Style === */
.theme-toggle {
  margin-top: 1rem;
  display: flex;
  justify-content: center;
  width: 100%;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 200px; /* keeps it roughly same width as buttons */
  height: 44px;
  border-radius: 8px;
  background: var(--btn-bg, #222);
  color: var(--btn-text, #fff);
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.15);
  transition: background 0.25s, color 0.25s, transform 0.2s ease;
}
.theme-switch:hover {
  transform: translateY(-1px);
  background: var(--btn-hover-bg, #444);
}

.theme-switch input {
  display: none;
}

.theme-switch .slider {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--toggle-ball, #fff);
  margin-left: 10px;
  transition: transform 0.3s ease, background 0.3s ease;
}

.theme-switch input:checked + .slider {
  background: var(--toggle-active, #facc15); /* sun color */
  transform: rotate(180deg);
}

/* Light theme adjustments */
:root[data-theme='light'] {
  --btn-bg: #eee;
  --btn-text: #111;
  --btn-hover-bg: #ddd;
  --toggle-ball: #111;
}

/* =========================
   Theme toggle — responsive
   ========================= */

/* Base: keep markup simple */
.theme-toggle { width: 100%; }

/* Mobile (<=720px): full-width button under Sign Up */
@media (max-width: 720px) {
  .theme-toggle { margin-top: .75rem; display: flex; justify-content: center; }
  .theme-switch {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%; max-width: 200px; height: 44px;
    padding: 0 .9rem; gap: .6rem;
    border-radius: 8px; border: 1px solid var(--border);
    background: var(--btn-bg, var(--surface)); color: var(--btn-text, var(--text));
    font: inherit; line-height: 1; cursor: pointer;
    transition: background .2s ease, transform .15s ease;
  }
  .theme-switch:hover { transform: translateY(-1px); }
  .theme-switch input { display: none; }
  .theme-switch .slider {
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--toggle-ball, #fff);
    transition: transform .25s ease, background .25s ease;
  }
  .theme-switch input:checked + .slider { background: var(--toggle-active, #facc15); transform: rotate(180deg); }
}

/* Desktop (>=721px): inline pill that matches nav items */
@media (min-width: 721px) {
  /* Sit in the nav row like the other links/buttons */
  .theme-toggle { margin: 0; width: auto; display: inline-flex; }
  .theme-switch {
    display: inline-flex; align-items: center; gap: .5rem;
    height: 36px; /* match your nav button height */
    padding: 0 .75rem;
    border-radius: 8px; border: 1px solid var(--border);
    background: transparent;
    font: inherit; /* same size as nav links */
    line-height: 1; cursor: pointer;
  }
  /* Align with .nav-link visually */
  .nav .theme-toggle { align-self: center; }
  .theme-switch input { display: none; }
  .theme-switch .slider {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--toggle-ball, currentColor);
    opacity: .85;
    transition: transform .25s ease, opacity .2s ease;
  }
  .theme-switch:hover .slider { opacity: 1; }
  .theme-switch input:checked + .slider {
    background: var(--toggle-active, #facc15);
    transform: rotate(180deg);
  }
}

/* Light theme colors for the button */
:root[data-theme='light'] {
  --btn-bg: #eee; --btn-text: #111; --toggle-ball: #111;
}
/* Theme toggle behaves like a normal nav item */
.theme-toggle, .theme-switch { all: unset; } /* neutralize any previous styles */

#themeToggle.nav-link {
  display: inline-block;
  padding: .4rem .6rem;   /* adjust if your .nav-link uses different padding */
  line-height: 1;
  border-radius: 8px;
  text-decoration: none;
}
#themeToggle.nav-link:hover,
#themeToggle.nav-link:focus-visible { text-decoration: underline; }

/* ===== Theme-aware Menu Button ===== */
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  height: 36px;                    /* matches desktop nav buttons */
  padding: 0 .75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, border-color .18s ease, transform .06s ease;
}

.menu-btn:hover {
  background: color-mix(in oklab, var(--surface), var(--text) 10%);
  text-decoration: none;
}

.menu-btn:active { transform: translateY(1px); }

.menu-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent), white 50%);
}

/* Icon inherits currentColor */
.menu-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 2;
}

/* Mobile: slightly larger for touch */
@media (max-width: 720px) {
  .menu-btn { height: 44px; padding: 0 .9rem; }
  .menu-btn svg { width: 20px; height: 20px; }
}
/* ===== Header compaction + theme-matching menu button ===== */

/* Make header compact by default */
.site-header { padding-block: 8px; }

/* Desktop (inline, looks like other nav links) */
@media (min-width: 721px) {
  .nav { align-items: center; }
  /* menu button behaves like a nav link (ghost) */
  .menu-btn {
    background: transparent !important;
    border: 0 !important;
    color: var(--text) !important;
    height: 36px;
    padding: 0 .5rem;
    border-radius: 8px;
    display: inline-flex; align-items: center; gap: .45rem;
    line-height: 1;
    cursor: pointer;
  }
  .menu-btn:hover,
  .menu-btn:focus-visible {
    text-decoration: underline;
    outline: none;
    box-shadow: none;
  }
  .menu-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
}

/* Mobile (larger tap target, still compact header) */
@media (max-width: 720px) {
  .site-header { padding-block: 10px; }
  .menu-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    height: 44px;
    padding: 0 .9rem;
    border-radius: 10px;
    display: inline-flex; align-items: center; gap: .55rem;
  }
  .menu-btn svg { width: 20px; height: 20px; }
}

/* Ensure the nav sheet is NOT visible unless explicitly opened */
@media (max-width: 720px) {
  .nav-links { display: none; }          /* closed by default */
  .nav-links.open { display: grid; }     /* shown only when 'open' */
  .nav-overlay { display: none; }
  .nav-overlay.open { display: block; }
}
/* === Stable header/menu defaults === */
.site-header { padding-block: 8px; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.brand { text-decoration: none; color: var(--text); font-weight: 600; }

/* Desktop: inline nav; hide menu button */
@media (min-width: 721px) {
  .menu-btn { display: none !important; }
  .nav-links { display: flex; gap: .8rem; }
}

/* Mobile: compact header + sheet menu */
@media (max-width: 720px) {
  .menu-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    height: 44px; padding: 0 .9rem; border-radius: 10px;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); cursor: pointer;
  }
  .menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

  /* Closed by default */
  .nav-links { display: none; }

  /* Open = small floating sheet under header */
  .nav { position: relative; }
  .nav-links.open {
    display: grid;
    position: absolute; left: var(--gap,1rem); right: var(--gap,1rem); top: calc(100% + .5rem);
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: .7rem; gap: .5rem; z-index: 60; max-height: min(60vh, 22rem); overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }
  .nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); z-index: 40; }
  .nav-overlay.open { display: block; }
}

/* Nav links */
.nav-link { color: var(--text); text-decoration: none; padding: .4rem .6rem; border-radius: 8px; }
.nav-link:hover, .nav-link:focus-visible { text-decoration: underline; }
/* === FINAL MOBILE/THEME FIXES === */

/* Keep header compact */
.site-header { padding-block: 8px; }

/* Mobile: show button, ensure theme colors, keep sheet behavior */
@media (max-width: 720px) {
  .menu-btn {
    display: inline-flex !important;
    align-items: center; gap: .55rem;
    height: 44px; padding: 0 .9rem; border-radius: 10px;
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    cursor: pointer;
  }
  .menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

  /* Menu closed by default; open becomes a grid sheet */
  .nav-links { display: none !important; }
  .nav-links.open { display: grid !important; }

  .nav { position: relative; }
  .nav-links.open {
    position: absolute; left: var(--gap,1rem); right: var(--gap,1rem); top: calc(100% + .5rem);
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: .7rem; gap: .5rem; z-index: 60; max-height: min(60vh, 22rem); overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }
  .nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px); z-index: 40; }
  .nav-overlay.open { display: block; }
}

/* Desktop: inline nav; hide the menu button */
@media (min-width: 721px) {
  .menu-btn { display: none !important; }
}

/* Make theme toggle look exactly like other nav links */
#themeToggle.nav-link {
  display: inline-block; padding: .4rem .6rem; line-height: 1;
  color: var(--text); border-radius: 8px; text-decoration: none;
}
#themeToggle.nav-link:hover, #themeToggle.nav-link:focus-visible { text-decoration: underline; }
/* ==== FINAL: overlay & mobile sheet safety ==== */
@media (max-width: 720px) {
  /* Overlay: invisible & non-interactive by default */
  .nav-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.35);
    /* Disable blur to avoid "fuzzy" UI; re-enable if you want */
    /* backdrop-filter: blur(2px); */
    display: none;
    pointer-events: none;
    z-index: 40;
  }
  .nav-overlay.open {
    display: block;
    pointer-events: auto; /* only when menu is open */
  }

  /* Menu button follows theme colors */
  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    height: 44px;
    padding: 0 .9rem;
    border-radius: 10px;
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
  }
  .menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

  /* Sheet sits above overlay */
  .nav { position: relative; }
  .nav-links { display: none !important; }
  .nav-links.open {
    display: grid !important;
    position: absolute; left: var(--gap,1rem); right: var(--gap,1rem); top: calc(100% + .5rem);
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: .7rem; gap: .5rem; z-index: 60;
    max-height: min(60vh, 22rem); overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
  }
}

/* Desktop: inline nav; hide mobile button */
@media (min-width: 721px) {
  .menu-btn { display: none !important; }
}

/* Theme toggle link looks like other nav links */
#themeToggle.nav-link {
  display: inline-block; padding: .4rem .6rem; line-height: 1;
  color: var(--text); border-radius: 8px; text-decoration: none;
}
#themeToggle.nav-link:hover, #themeToggle.nav-link:focus-visible { text-decoration: underline; }
/* ==== FIX: mobile menu above overlay, clickable, correct colors ==== */
@media (max-width: 720px) {
  /* Keep header on top */
  .site-header { position: sticky; top: 0; z-index: 1000; }

  /* Overlay below header + sheet */
  .nav-overlay {
    z-index: 900;
    /* ensure no blur that makes options look foggy */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Sheet above overlay (and clickable) */
  .nav { position: relative; z-index: 1001; }
  .nav-links.open {
    z-index: 1100 !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    pointer-events: auto !important;
  }
  .nav-links.open a,
  .nav-links.open .nav-link {
    color: var(--text) !important;
    pointer-events: auto !important;
  }

  /* Button uses theme colors */
  .menu-btn {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
  }
}
/* === Mobile menu sheet: above all; clickable; theme colors === */
@media (max-width: 720px) {
  .site-header { position: sticky; top: 0; z-index: 1000; }
  .nav { position: relative; z-index: 1001; }

  .nav-links { display: none !important; }
  .nav-links.open {
    display: grid !important;
    position: absolute;
    left: var(--gap, 1rem);
    right: var(--gap, 1rem);
    top: calc(100% + .5rem);
    z-index: 2000 !important;             /* ensure above anything */
    background: var(--surface) !important; /* theme-aware */
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px;
    padding: .7rem;
    gap: .5rem;
    max-height: min(60vh, 22rem);
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    pointer-events: auto !important;       /* accept taps */
  }
  .nav-links.open a,
  .nav-links.open .nav-link {
    color: var(--text) !important;
    pointer-events: auto !important;
  }
}
/* === Theme-aware menu button === */
@media (max-width: 720px) {
  .menu-btn {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    height: 44px;
    padding: 0 .9rem;
    border-radius: 10px;
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
  }
  .menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
}
@media (min-width: 721px) { .menu-btn { display: none !important; } }
/* ===== Fix mobile menu button color (iOS/Safari, Chrome Android) ===== */
@media (max-width: 720px) {
  /* High-specificity targets to beat any older rules */
  .site-header .nav .menu-btn,
  .site-header .menu-btn,
  header .menu-btn,
  .menu-btn {
    /* Reset native button look so our colors apply */
    -webkit-appearance: none;
    appearance: none;
    background-clip: padding-box;

    /* Theme colors */
    background-color: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;

    /* Keep the sizing we already use */
    display: inline-flex; align-items: center; gap: .55rem;
    height: 44px; padding: 0 .9rem; border-radius: 10px;
  }

  .menu-btn svg { stroke: currentColor; fill: none; stroke-width: 2; }

  /* Extra nudge for WebKit-only (older iOS): */
  @supports (-webkit-touch-callout: none) {
    .menu-btn {
      background-color: var(--surface) !important;
      color: var(--text) !important;
      border-color: var(--border) !important;
    }
  }
}
/* ===== Bulletproof theme colors for the Menu button (mobile) ===== */
@media (max-width: 720px) {
  /* High specificity & reset native UA styles */
  header.site-header button.menu-btn,
  .site-header button.menu-btn,
  nav .menu-btn,
  button.menu-btn {
    -webkit-appearance: none;
    appearance: none;
    background-image: none !important;
    background: var(--surface) !important;     /* theme surface */
    background-color: var(--surface) !important;
    color: var(--text) !important;              /* theme text */
    border: 1px solid var(--border) !important; /* theme border */
    border-radius: 10px;
    height: 44px; padding: 0 .9rem;
    display: inline-flex; align-items: center; gap: .55rem;
  }
  button.menu-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }
}

/* Desktop hides the mobile menu button */
@media (min-width: 721px) { button.menu-btn { display: none !important; } }
