:root {
  --bg: #0a0a0a;
  --bg-alpha: rgba(10,10,10,.78);
  --surface: #121212;
  --surface-2: #181818;
  --fg: #ededed;
  --fg-dim: #8a8a8a;
  --border: #232323;
  --accent: oklch(0.7 0.2 25);
  --sans: 'Space Grotesk', sans-serif;
  --mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;
  --display: 'Fraunces', Georgia, serif;
}
body.theme-light {
  --bg: #f7f5f1;
  --bg-alpha: rgba(247,245,241,.78);
  --surface: #ffffff;
  --surface-2: #efece6;
  --fg: #161412;
  --fg-dim: #6a655e;
  --border: #d9d4cb;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); }
body { font-family: var(--sans); cursor: none; }
body.no-custom-cursor { cursor: auto; }
a, button, [data-cursor='hover'] { cursor: none !important; }
::selection { background: var(--accent); color: #0a0a0a; }
input, textarea, button { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--fg-dim); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.typing-dots::after { content: ' ...'; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: ' .'; } 50% { content: ' ..'; } 75% { content: ' ...'; } 100% { content: ''; } }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }

/* ─── Mobile redesign ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    cursor: auto !important;
    -webkit-text-size-adjust: 100%;
  }
  a, button, [data-cursor] { cursor: pointer !important; }

  /* Section padding (do not affect agent terminal inner layout) */
  [data-variation="F"] section,
  section { padding-left: 16px !important; padding-right: 16px !important; }
  .f-pad { padding-left: 14px !important; padding-right: 14px !important; }

  /* HERO — tighter top spacing on mobile */
  #F-home {
    padding-top: 18px !important;
    padding-bottom: 32px !important;
  }

  /* Generic multi-col grids → single col, EXCEPT inside agent terminal */
  :not(.f-agent-terminal) > [style*="grid-template-columns: repeat(2"],
  :not(.f-agent-terminal) > [style*="grid-template-columns: repeat(3"],
  :not(.f-agent-terminal) > [style*="grid-template-columns: repeat(5"],
  :not(.f-agent-terminal) > [style*="grid-template-columns: repeat(6"],
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1.05fr 0.95fr"],
  [style*="grid-template-columns: 1.2fr 0.8fr"],
  [style*="grid-template-columns: 1.5fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  /* repeat(4,...) → 2x2 (counters, agent stats stay readable) */
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0 !important;
  }

  /* Galaxy/constellation — hidden on mobile (stack-list below stays) */
  .f-galaxy { display: none !important; }

  /* Vault — equal-height project cards */
  .f-projects-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .f-projects-grid > * {
    grid-column: span 1 !important;
  }
  .f-projects-grid > * > * {
    min-height: 280px !important;
    height: auto !important;
    padding: 24px !important;
  }
  /* Hide giant decorative project numbers on mobile */
  .f-projects-grid [style*="font-size: 132"],
  .f-projects-grid [style*="font-size: 100"],
  .f-projects-grid [style*="opacity: 0.16"] {
    display: none !important;
  }
  .f-projects-grid h3 {
    font-size: 24px !important;
  }

  /* Decorative coord marks — too busy on small screen */
  .f-coord { display: none !important; }

  /* Hero headline */
  .f-h2-big, .f-headline {
    font-size: clamp(36px, 10.5vw, 54px) !important;
    line-height: 1.02 !important;
    letter-spacing: -0.035em !important;
  }
  [style*="clamp(72px"], [style*="clamp(88px"], [style*="clamp(96px"],
  [style*="clamp(120px"], [style*="clamp(140px"], [style*="clamp(184px"] {
    font-size: clamp(36px, 10.5vw, 54px) !important;
    line-height: 1.02 !important;
  }

  /* Top sticky bar — logo + toggles only */
  .f-pad {
    flex-wrap: nowrap !important;
    gap: 8px !important;
    font-size: 10px !important;
    padding: 10px 14px !important;
  }
  .f-pad > div:first-child > span:nth-child(3),
  .f-pad > div:first-child > span:nth-child(4) { display: none !important; }
  .f-nav-links a { display: none !important; }
  .f-nav-links > span { display: none !important; }
  .f-nav-links {
    gap: 4px !important;
    align-items: center !important;
  }
  .f-nav-links button {
    min-width: 38px !important;
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
    background: var(--surface-2) !important;
    font-size: 15px !important;
  }

  /* Tap targets */
  a, button { min-height: 40px; }

  /* Hide on mobile utility */
  .f-hide-mobile { display: none !important; }

  /* Hero meta strip — single scrolling line */
  .f-meta-strip {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 20px !important;
    align-items: center !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .f-meta-strip::-webkit-scrollbar { display: none; }
  .f-meta-strip > span { white-space: nowrap !important; flex-shrink: 0 !important; }

  /* Generic flex overflow → wrap (exclude marquees which use whiteSpace:nowrap) */
  [style*="display: flex"][style*="gap: 22"]:not([style*="white-space"]),
  [style*="display: flex"][style*="gap: 24"]:not([style*="white-space"]),
  [style*="display: flex"][style*="gap: 32"]:not([style*="white-space"]) {
    flex-wrap: wrap !important;
  }

  /* Sidebar-style grids */
  [style*="grid-template-columns: 78px 1fr 56px"] {
    grid-template-columns: auto 1fr auto !important;
    gap: 10px !important;
  }
  [style*="grid-template-columns: auto 1fr"] { gap: 12px !important; }

  /* Code / terminal scroll */
  pre, code, .f-agent-terminal {
    overflow-x: auto !important;
    max-width: 100% !important;
    font-size: 11px !important;
  }

  /* Footer stack */
  footer {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px !important;
  }

  /* Touch active feedback */
  a:active, button:active, [data-cursor='hover']:active {
    opacity: 0.65;
    transform: scale(0.97);
    transition: opacity .08s, transform .08s;
  }
}

@media (max-width: 480px) {
  .f-h2-big, .f-headline { font-size: clamp(30px, 9.5vw, 42px) !important; }
  .f-pad { font-size: 9px !important; }
}
