/* ─── CSS Variables ───────────────────────────────────────── */
    :root {
      --bg:           #f8f9fc;
      --bg-card:      #ffffff;
      --bg-muted:     #eef1f7;
      --border:       #d0d8e8;
      --text:         #0d1520;
      --text-muted:   #4a5568;
      --text-faint:   #8898aa;
      --accent:       #1a4fa0;
      --accent-mid:   #2e6fd4;
      --accent-light: #6aaee8;
      --accent-pale:  #dceeff;
      --tag-bg:       #e8f0fd;
      --tag-text:     #1a4fa0;
      --nav-bg:       rgba(248,249,252,0.88);
      --shadow-sm:    0 1px 4px rgba(26,79,160,0.07);
      --shadow-md:    0 4px 20px rgba(26,79,160,0.10);
      --radius:       10px;
      --radius-lg:    18px;
      --transition:   0.25s ease;
      --logo-url: url('../assets/alecs_logo_light.svg');
      --cross-url: url(../assets/alecs_cross_light.svg);
    }

    [data-theme="dark"] {
      --bg:           #090e1a;
      --bg-card:      #111827;
      --bg-muted:     #161f31;
      --border:       #1e2d45;
      --text:         #e8edf5;
      --text-muted:   #93aac6;
      --text-faint:   #4a6282;
      --accent:       #5b9cf5;
      --accent-mid:   #84b9ff;
      --accent-light: #b3d4ff;
      --accent-pale:  #1a2d4a;
      --tag-bg:       #1a2d4a;
      --tag-text:     #84b9ff;
      --nav-bg:       rgba(9,14,26,0.88);
      --shadow-sm:    0 1px 4px rgba(0,0,0,0.30);
      --shadow-md:    0 4px 20px rgba(0,0,0,0.40);
      --logo-url: url('../assets/alecs_logo_dark.svg');
      --cross-url: url(../assets/alecs_cross_dark.svg);
    }

    /* ─── Reset & Base ────────────────────────────────────────── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

    html { scroll-behavior: smooth; font-size: 16px; }

    body {
      font-family: 'Outfit', sans-serif;
      background: var(--bg);
      color: var(--text);
      transition: background var(--transition), color var(--transition);
      line-height: 1.7;
      overflow-x: hidden;
    }

    /* ─── Scrollbar ───────────────────────────────────────────── */
    ::-webkit-scrollbar { width: 6px; }
    ::-webkit-scrollbar-track { background: var(--bg); }
    ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
    ::-webkit-scrollbar-thumb:hover { background: var(--accent-light); }

    /* ─── Typography ──────────────────────────────────────────── */
    h1, h2, h3, h4 {
      font-family: 'Cormorant Garamond', serif;
      line-height: 1.15;
      letter-spacing: -0.01em;
    }

    .mono {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.82em;
    }

    a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
    a:hover { color: var(--accent-mid); }

    /* ─── Nav ─────────────────────────────────────────────────── */
    nav {
      position: fixed; top: 0; left: 0; right: 0; z-index: 100;
      display: flex; align-items: center; justify-content: space-between;
      padding: 0 2.5rem;
      height: 60px;
      background: var(--nav-bg);
      backdrop-filter: blur(14px) saturate(160%);
      -webkit-backdrop-filter: blur(14px) saturate(160%);
      border-bottom: 1px solid var(--border);
      transition: background var(--transition), border-color var(--transition);
    }

    .nav-logo {
      font-family: 'JetBrains Mono', monospace;
      font-size: 1rem;
      font-weight: 400;
      color: var(--accent);
      letter-spacing: 0.04em;
    }

    .nav-logo span { color: var(--text-muted); }

    .nav-links {
      display: flex; align-items: center; gap: 2rem;
      list-style: none;
    }

    .nav-links a {
      font-size: 0.82rem;
      font-weight: 500;
      letter-spacing: 0.06em;
      text-transform: uppercase;
      color: var(--text-muted);
      transition: color var(--transition);
    }

    .nav-links a:hover { color: var(--accent); }

    .theme-toggle {
      width: 36px; height: 36px;
      border: 1px solid var(--border);
      border-radius: 50%;
      background: var(--bg-card);
      cursor: pointer;
      display: flex; align-items: center; justify-content: center;
      transition: all var(--transition);
      color: var(--text-muted);
      font-size: 0.95rem;
    }

    .theme-toggle:hover {
      border-color: var(--accent);
      color: var(--accent);
      box-shadow: var(--shadow-sm);
    }

    /* ─── Sections ────────────────────────────────────────────── */
    section { padding: 5.5rem 2.5rem; }

    .container {
      max-width: 1060px;
      margin: 0 auto;
    }

    .section-label {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.72rem;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--accent);
      margin-bottom: 0.8rem;
      display: flex; align-items: center; gap: 0.6rem;
    }

    .section-label::before {
      content: '';
      display: inline-block;
      width: 22px; height: 1px;
      background: var(--accent);
    }

    .section-title {
      font-size: clamp(2.2rem, 4vw, 3.4rem);
      font-weight: 300;
      color: var(--text);
      margin-bottom: 1.2rem;
    }

    .section-lead {
      font-size: 1.07rem;
      color: var(--text-muted);
      max-width: 640px;
      line-height: 1.75;
    }
    .section-lead.full {
      max-width: 100%;
    }

    /* ─── Hero ────────────────────────────────────────────────── */
    #hero {
      min-height: 100vh;
      display: flex;
      align-items: center;
      padding-top: 60px;
      position: relative;
      overflow: hidden;
    }

    .hero-bg {
      position: absolute; inset: 0;
      pointer-events: none;
      z-index: 0;
    }

    /* Subtle grid */
    .hero-bg::before {
      content: '';
      position: absolute; inset: 0;
      background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
      background-size: 52px 52px;
      opacity: 0.35;
    }

    /* Orb glows */
    .hero-bg::after {
      content: '';
      position: absolute;
      width: 700px; height: 700px;
      border-radius: 50%;
      background: radial-gradient(circle, var(--accent-pale) 0%, transparent 70%);
      top: -200px; right: -200px;
      opacity: 0.55;
    }

    .hero-inner {
      position: relative; z-index: 1;
      max-width: 1060px; margin: 0 auto;
      width: 100%;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4rem;
      align-items: center;
    }

    .hero-eyebrow {
      display: flex; align-items: center; gap: 0.5rem;
      margin-bottom: 1.5rem;
    }

    .badge {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.68rem;
      letter-spacing: 0.1em;
      text-transform: uppercase;
      padding: 0.28rem 0.7rem;
      border-radius: 100px;
      background: var(--tag-bg);
      color: var(--tag-text);
      border: 1px solid var(--border);
    }

    .hero-title {
      font-size: clamp(2.8rem, 5.5vw, 4.8rem);
      font-weight: 300;
      color: var(--text);
      margin-bottom: 1.2rem;
      line-height: 1.08;
    }

    .hero-title em {
      font-style: italic;
      color: var(--accent);
    }

    .hero-name-logo {
      display: inline-block;
      background-image: var(--logo-url);
      background-size: contain;
      background-repeat: no-repeat;
      background-position: left center;

      height: 0.75em; 
      aspect-ratio: 4 / 1; 
      vertical-align: bottom;
      transform: translateY(-0.2em); 
      margin-left: -0.1em;
    }

    .hero-subtitle {
      font-size: 1.08rem;
      color: var(--text-muted);
      line-height: 1.75;
      margin-bottom: 2.4rem;
      max-width: 480px;
    }

    .hero-actions {
      display: flex; gap: 0.9rem; flex-wrap: wrap;
    }

    .btn-primary {
      display: inline-flex; align-items: center; gap: 0.5rem;
      padding: 0.7rem 1.6rem;
      background: var(--accent);
      color: #fff;
      border-radius: 6px;
      font-size: 0.87rem;
      font-weight: 500;
      letter-spacing: 0.03em;
      transition: all var(--transition);
      border: none; cursor: pointer;
    }

    .btn-primary:hover {
      background: var(--accent-mid);
      color: #fff;
      box-shadow: 0 4px 18px rgba(26,79,160,0.3);
      transform: translateY(-1px);
    }

    .btn-secondary {
      display: inline-flex; align-items: center; gap: 0.5rem;
      padding: 0.7rem 1.6rem;
      background: transparent;
      color: var(--text-muted);
      border-radius: 6px;
      font-size: 0.87rem;
      font-weight: 500;
      letter-spacing: 0.03em;
      transition: all var(--transition);
      border: 1px solid var(--border);
      cursor: pointer;
    }

    .btn-secondary:hover {
      border-color: var(--accent);
      color: var(--accent);
      transform: translateY(-1px);
    }

    /* Molecule SVG diagram on hero right */
    .hero-diagram {
      display: flex;
      align-items: center;
      justify-content: center;
      
      width: 100%;
      max-width: 580px; /* Increased to fill space */
      margin: 0 auto;

      opacity: 0;
      animation: fadeIn 1.2s 0.4s forwards;
    }

    #dynamicPlot {
      width: 100%;
      height: auto;
      display: block;
      object-fit: contain;
      
      /* Prevents a "flash" of the old image during the swap */
      transition: opacity 0.2s ease; 
    }

    .hero-stats {
      display: flex; gap: 2.2rem; margin-top: 2.8rem;
      padding-top: 2rem;
      border-top: 1px solid var(--border);
    }

    .stat-item {}
    .stat-value {
      font-family: 'Cormorant Garamond', serif;
      font-size: 2.2rem;
      font-weight: 600;
      color: var(--accent);
      line-height: 1;
      display: block;
    }
    .stat-label {
      font-size: 0.78rem;
      color: var(--text-faint);
      letter-spacing: 0.06em;
      text-transform: uppercase;
      margin-top: 0.25rem;
    }

    /* ─── About / Contents ────────────────────────────────────── */
    #about { background: var(--bg); }

    .about-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4rem;
      align-items: start;
      margin-top: 3rem;
    }

    .about-cards {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 1rem;
      margin-top: 3rem;
    }

    .about-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 1.4rem 1.6rem;
      display: flex;
      align-items: flex-start;
      gap: 1rem;
      transition: box-shadow var(--transition), border-color var(--transition);
    }

    .about-card:hover {
      box-shadow: var(--shadow-md);
      border-color: var(--accent-light);
    }

    .card-icon {
      width: 40px; height: 40px;
      border-radius: 8px;
      background: var(--accent-pale);
      color: var(--accent);
      display: flex; align-items: center; justify-content: center;
      font-size: 1.1rem;
      flex-shrink: 0;
    }

    .card-title {
      font-family: 'Outfit', sans-serif;
      font-size: 0.92rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.3rem;
    }

    .card-desc {
      font-size: 0.85rem;
      color: var(--text-muted);
      line-height: 1.6;
    }

    .tag-list {
      display: flex; flex-wrap: wrap; gap: 0.5rem;
      margin-top: 0.6rem;
    }

    .tag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.68rem;
      padding: 0.2rem 0.55rem;
      border-radius: 4px;
      background: var(--tag-bg);
      color: var(--tag-text);
    }

    /* ─── Access ──────────────────────────────────────────────── */
    #access { background: var(--bg-muted); }

    .access-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1.2rem;
      margin-top: 3rem;
    }

    .access-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 2rem 1.6rem;
      transition: all var(--transition);
      position: relative;
      overflow: hidden;
    }

    .access-card::before {
      content: '';
      position: absolute;
      top: 0; left: 0; right: 0;
      height: 3px;
      background: linear-gradient(90deg, var(--accent), var(--accent-light));
      opacity: 0;
      transition: opacity var(--transition);
    }

    .access-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
    .access-card:hover::before { opacity: 1; }

    .access-num {
      font-family: 'Cormorant Garamond', serif;
      font-size: 3rem;
      font-weight: 300;
      color: var(--border);
      line-height: 1;
      margin-bottom: 1rem;
    }

    .access-title {
      font-size: 1.05rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.6rem;
    }

    .access-desc {
      font-size: 0.87rem;
      color: var(--text-muted);
      line-height: 1.65;
    }

    .code-block {
      margin-top: 1rem;
      background: var(--bg-muted);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 0.6rem 0.9rem;
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.74rem;
      color: var(--accent-mid);
      white-space: pre-wrap;
      word-break: break-all;
      overflow-x: auto;
    max-height: 220px;
    overflow-y: auto;
    }

    /* ─── App / Streamlit ─────────────────────────────────────── */
    #app { background: var(--bg); }

    .app-frame-wrap {
      margin-top: 2.8rem;
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      overflow: hidden;
      box-shadow: var(--shadow-md);
    }

    .app-frame-header {
      background: var(--bg-muted);
      border-bottom: 1px solid var(--border);
      padding: 0.75rem 1.2rem;
      display: flex;
      align-items: center;
      gap: 0.6rem;
    }

    .dot { width: 10px; height: 10px; border-radius: 50%; }
    .dot-r { background: #f87171; }
    .dot-y { background: #fbbf24; }
    .dot-g { background: #34d399; }

    .frame-url {
      margin-left: 0.5rem;
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.72rem;
      color: var(--text-faint);
      flex: 1;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .app-iframe {
      width: 100%;
      height: 640px;
      border: none;
      display: block;
      background: var(--bg-muted);
    }

    /* ─── Board ───────────────────────────────────────────────── */
    #board { background: var(--bg-muted); }

    .board-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
      gap: 1.2rem;
      margin-top: 3rem;
    }

    .board-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 1.6rem 1.4rem;
      transition: all var(--transition);
    }

    .board-card:hover {
      box-shadow: var(--shadow-md);
      border-color: var(--accent-light);
      transform: translateY(-2px);
    }

    .board-avatar {
      width: 54px; height: 54px;
      border-radius: 50%;
      background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
      display: flex; align-items: center; justify-content: center;
      object-fit: cover;
      object-position: center top;  /* crops toward the face, not the chin */
      overflow: hidden;
      margin-bottom: 1rem;
    }

    .board-name {
      font-size: 0.97rem;
      font-weight: 600;
      color: var(--text);
      margin-bottom: 0.2rem;
    }

    .board-role {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.7rem;
      color: var(--accent);
      margin-bottom: 0.4rem;
    }

    .board-affil {
      font-size: 0.8rem;
      color: var(--text-faint);
      line-height: 1.5;
    }

    .board-job {
      font-size: 0.8rem;
      font-weight:600;
      color: var(--text-faint);
      line-height: 1.5;
    }

    /* ─── Supporters ──────────────────────────────────────────── */
    #supporters { background: var(--bg); }

    .supporters-logos {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 2.5rem;
      margin-top: 3rem;
    }

    .supporter-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      padding: 1.2rem 2rem;
      display: flex;
      align-items: center;
      gap: 1rem;
      transition: all var(--transition);
      min-width: 200px;
    }

    .supporter-card:hover {
      box-shadow: var(--shadow-md);
      border-color: var(--accent-light);
    }

    .supporter-icon {
      font-size: 1.8rem;
      line-height: 1;
    }

    .supporter-name {
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text);
    }

    .supporter-type {
      font-size: 0.75rem;
      color: var(--text-faint);
    }

    /* ─── Collaborate ─────────────────────────────────────────── */
    #collaborate { background: var(--bg-muted); }

    .collab-inner {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4rem;
      align-items: center;
    }

    .collab-feature-list {
      list-style: none;
      margin-top: 1.8rem;
      display: flex; flex-direction: column; gap: 1rem;
    }

    .collab-feature-list li {
      display: flex; align-items: flex-start; gap: 0.8rem;
      font-size: 0.95rem;
      color: var(--text-muted);
    }

    .collab-check {
      width: 20px; height: 20px; flex-shrink: 0;
      border-radius: 50%;
      background: var(--accent-pale);
      color: var(--accent);
      display: flex; align-items: center; justify-content: center;
      font-size: 0.7rem;
      margin-top: 2px;
    }

    .collab-cta {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: var(--radius-lg);
      padding: 2.4rem;
    }

    .collab-cta h3 {
      font-size: 1.8rem;
      font-weight: 300;
      margin-bottom: 0.8rem;
      color: var(--text);
    }

    .collab-cta p {
      font-size: 0.9rem;
      color: var(--text-muted);
      line-height: 1.7;
      margin-bottom: 1.6rem;
    }

    .collab-divider {
      height: 1px;
      background: var(--border);
      margin: 1.4rem 0;
    }

    .form-field {
      display: flex;
      flex-direction: column;
      gap: 0.35rem;
      margin-bottom: 0.9rem;
    }

    .form-field label {
      font-size: 0.8rem;
      font-weight: 500;
      color: var(--text-muted);
      letter-spacing: 0.04em;
    }

    .form-field input,
    .form-field textarea {
      background: var(--bg-muted);
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 0.6rem 0.85rem;
      font-family: 'Outfit', sans-serif;
      font-size: 0.9rem;
      color: var(--text);
      transition: border-color 0.2s ease, box-shadow 0.2s ease;
      resize: vertical;
    }

    .form-field input:focus,
    .form-field textarea:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px var(--accent-pale);
    }

    .form-field input::placeholder,
    .form-field textarea::placeholder {
      color: var(--text-faint);
    }

    /* ─── Footer ──────────────────────────────────────────────── */
    footer {
      background: var(--bg);
      border-top: 1px solid var(--border);
      padding: 3rem 2.5rem;
    }

    .footer-inner {
      max-width: 1060px; margin: 0 auto;
      display: grid;
      grid-template-columns: 2fr 1fr;
      gap: 3rem;
    }

    .footer-brand {
      font-family: 'JetBrains Mono', monospace;
      font-size: 1rem;
      color: var(--accent);
      margin-bottom: 0.7rem;
    }

    .footer-desc {
      font-size: 0.85rem;
      color: var(--text-faint);
      line-height: 1.65;
      max-width: 300px;
    }

    .footer-heading {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.68rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: var(--text-faint);
      margin-bottom: 1rem;
    }

    .footer-links {
      list-style: none;
      display: flex; flex-direction: column; gap: 0.5rem;
    }

    .footer-links a {
      font-size: 0.85rem;
      color: var(--text-muted);
      transition: color var(--transition);
    }

    .footer-links a:hover { color: var(--accent); }

    .footer-bottom {
      padding: 1.5rem 2.5rem;  /* matches footer's side padding */
      margin-top: 1rem;
      border-top: 1px solid var(--border);  /* now spans full width */
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 0.78rem;
      color: var(--text-faint);
    }

    .github-link {
      display: inline-flex; align-items: center; gap: 0.4rem;
      color: var(--text-muted);
      transition: color var(--transition);
      font-size: 0.82rem;
    }

    .github-link:hover { color: var(--accent); }

    .code-block-wrap {
        position: relative;
        }

    .copy-btn {
        position: absolute;
        top: 0.45rem;
        right: 0.45rem;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.68rem;
        padding: 0.2rem 0.55rem;
        border-radius: 4px;
        border: 1px solid var(--border);
        background: var(--bg-card);
        color: var(--text-faint);
        cursor: pointer;
        transition: all var(--transition);
        z-index: 1;
    }

    .copy-btn:hover {
        border-color: var(--accent);
        color: var(--accent);
    }

    .copy-btn.copied {
        color: #16a34a;
        border-color: #16a34a;
    }

    /* ─── Animations ──────────────────────────────────────────── */
    @keyframes fadeIn {
      from { opacity: 0; transform: translateY(20px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    @keyframes rotSlow {
      from { transform: rotate(0deg); }
      to   { transform: rotate(360deg); }
    }

    .hero-left > * {
      opacity: 0;
      animation: fadeIn 0.85s forwards;
    }

    .hero-eyebrow { animation-delay: 0.05s !important; }
    .hero-title   { animation-delay: 0.15s !important; }
    .hero-subtitle{ animation-delay: 0.25s !important; }
    .hero-actions { animation-delay: 0.35s !important; }
    .hero-stats   { animation-delay: 0.5s  !important; }

    .reveal {
      opacity: 0;
      transform: translateY(24px);
      transition: opacity 0.7s ease, transform 0.7s ease;
    }

    .reveal.visible {
      opacity: 1;
      transform: translateY(0);
    }

    /* ─── Mobile ──────────────────────────────────────────────── */
    @media (max-width: 820px) {
      nav { padding: 0 1.2rem; }
      .nav-links { display: none; }
      section { padding: 4rem 1.2rem; }

      .hero-inner { grid-template-columns: 1fr; gap: 2.5rem; }
      .hero-diagram { display: none; }
      .about-grid, .collab-inner { grid-template-columns: 1fr; gap: 2rem; }
      .access-grid { grid-template-columns: 1fr; }
      .footer-inner { grid-template-columns: 1fr; gap: 2rem; }
      .footer-bottom { flex-direction: column; gap: 0.8rem; text-align: center; }
      .hero-stats { flex-wrap: wrap; gap: 1.5rem; }
    }