:root {
    --bg: #fbfbfd;
    --surface: #ffffff;
    --surface-hover: #f5f5f7;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --border: rgba(0,0,0,0.08);
    --accent: #0066cc;
    --accent-soft: rgba(0,102,204,0.08);
    --status: #2fb350;
    --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 12px 28px rgba(0,0,0,0.06);
    --radius: 20px;
    --radius-sm: 12px;
    --chrome-bg: #000000;
    --chrome-text: #f5f5f7;
    --chrome-text-dim: rgba(245,245,247,0.68);
    --chrome-border: rgba(255,255,255,0.14);
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #000000;
      --surface: #1c1c1e;
      --surface-hover: #2c2c2e;
      --text: #f5f5f7;
      --text-secondary: #a1a1a6;
      --border: rgba(255,255,255,0.12);
      --accent: #409cff;
      --accent-soft: rgba(64,156,255,0.14);
      --status: #32d74b;
      --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.45);
    }
  }
  :root[data-theme="dark"] {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-hover: #2c2c2e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --border: rgba(255,255,255,0.12);
    --accent: #409cff;
    --accent-soft: rgba(64,156,255,0.14);
    --status: #32d74b;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.45);
  }

  * { margin: 0; padding: 0; box-sizing: border-box; }
  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background .2s ease, color .2s ease;
  }

  a { color: inherit; text-decoration: none; }
  a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
  .nav a:focus-visible, .hero-banner a:focus-visible { outline-color: #ffffff; }

  .wrap { max-width: 880px; margin: 0 auto; padding: 0 24px; }

  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  /* Scoped to the hero's entrance animations, which is all this ever needed
     to do: those elements start at opacity 0 and are revealed by `rise`, so
     without this they'd stay invisible when the animation is suppressed.
     It used to be a blanket `*` rule. That also set `transform: none
     !important` on every element, and WebKit treats `transform: none` as
     clearing the whole composed transform — including the independent
     `translate` property — so it silently froze the ticker. */
  @media (prefers-reduced-motion: reduce) {
    .hero-banner .avatar,
    .eyebrow-line,
    .hero-banner h1,
    .hero-banner .btn {
      animation: none !important;
      opacity: 1 !important;
      transform: none !important;
    }
  }

  /* Nav — fixed dark chrome, like Apple's own top bar */
  .nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(0,0,0,0.82);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--chrome-border);
  }
  .nav-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  /* Logo is light-on-transparent, so it only works on the permanently dark
     nav chrome — not on the themed body below it. */
  .nav-name { display: flex; align-items: center; gap: 10px; color: var(--chrome-text); font-weight: 600; font-size: 0.98rem; transition: opacity .15s ease; }
  .nav-name:hover { opacity: 0.82; }
  .nav-logo { display: block; height: 22px; width: auto; }
  .nav-wordmark { display: flex; align-items: baseline; gap: 6px; }
  .nav-name .suffix { font-size: 0.72rem; font-weight: 500; color: var(--chrome-text-dim); }
  .nav-links { display: flex; gap: 26px; list-style: none; font-size: 0.9rem; color: var(--chrome-text-dim); }
  .nav-links a:hover { color: var(--chrome-text); }

  /* Hero banner — dark, textured, like an Apple promo module */
  .hero-banner {
    background-image:
      radial-gradient(circle at 1px 1px, rgba(255,255,255,0.08) 1px, transparent 0),
      linear-gradient(180deg, #0a0a0c 0%, #000000 100%);
    background-size: 22px 22px, auto;
    color: var(--chrome-text);
    text-align: center;
    padding: 84px 24px 92px;
  }
  .hero-banner .avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.18);
    box-shadow: 0 10px 26px rgba(0,0,0,0.5);
    opacity: 0;
    animation: rise .6s ease forwards;
  }
  .eyebrow-line {
    margin: 22px auto 18px;
    max-width: 460px;
    font-size: 0.98rem;
    color: var(--chrome-text-dim);
    opacity: 0;
    animation: rise .6s ease .1s forwards;
  }
  .eyebrow-line strong { color: var(--chrome-text); font-weight: 600; }
  .hero-banner h1 {
    font-size: clamp(2rem, 5vw, 3.1rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    max-width: 640px;
    margin: 0 auto 32px;
    opacity: 0;
    animation: rise .6s ease .2s forwards;
  }
  .hero-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; }
  .hero-banner .btn { opacity: 0; animation: rise .6s ease .3s forwards; }
  .hero-actions .btn:nth-child(2) { animation-delay: .38s; }
  .btn-light { background: #ffffff; color: #000000; }
  .btn-light:hover { opacity: 0.88; }
  /* Sits on the always-dark hero, so it can't use the themed --border/--text */
  .btn-ghost { border: 1px solid rgba(255,255,255,0.28); color: var(--chrome-text); }
  .btn-ghost:hover { background: rgba(255,255,255,0.10); }

  /* Other projects — compact text sub-section under the slides. The label
     echoes the CV page's section labels, so it reads as subordinate to the
     big "Projects" heading rather than competing with it. */
  .other-projects { margin-top: 56px; }
  .other-projects > h3 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  .other-list { list-style: none; }
  .other-list li { padding: 20px 0; border-bottom: 1px solid var(--border); }
  .other-list li:last-child { border-bottom: none; padding-bottom: 0; }
  .other-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 18px; flex-wrap: wrap; }
  .other-head h4 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
  .other-cat {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
  }
  .other-desc { margin-top: 4px; font-size: 0.92rem; color: var(--text-secondary); max-width: 68ch; }
  /* Neutral, not accent: a row of blue terms with dot separators reads as a
     row of links, and none of these are clickable. Weight carries it instead. */
  .other-tech { margin-top: 7px; font-size: 0.8rem; font-weight: 500; color: var(--text); opacity: 0.72; }

  /* Status ticker — full-bleed one-line ribbon, news-ribbon style.
     The marquee animates `translate`, not `transform`, on purpose: the global
     reduced-motion rule above sets `transform: none !important`, and important
     declarations outrank keyframes, so a transform marquee would sit frozen.
     `translate` is a separate property and is untouched by that rule. */
  .ticker {
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    overflow: hidden;
  }
  .ticker-viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    /* soften the edges so items don't pop in and out */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent);
  }
  .ticker-track {
    display: flex;
    flex: 0 0 auto;          /* never let the flex parent squeeze the run */
    width: max-content;
    will-change: translate;
  }
  .ticker-set { display: flex; flex: 0 0 auto; list-style: none; }
  /* cycle marker; scrolls with the run so nothing blocks either corner */
  .ticker-lead {
    color: var(--text);
    font-weight: 600;
    font-size: 0.76rem !important;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .ticker-lead .status-dot {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 2px;
  }
  .ticker-set li {
    white-space: nowrap;
    padding: 13px 0;
    margin-right: 46px;
    font-size: 0.88rem;
    color: var(--text-secondary);
  }
  /* separator between items */
  .ticker-set li::after {
    content: "";
    display: inline-block;
    vertical-align: middle;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--border);
    margin-left: 46px;
    margin-bottom: 2px;
  }
  /* No CSS animation and no keyframes here on purpose. script.js drives the
     `translate` property on rAF instead: the offset wraps with an exact
     modulo, so the loop cannot land short whatever the engine makes of
     `max-content`, and neither `animation: none !important` nor
     `transform: none !important` from the blanket reduced-motion rule can
     reach it. Hover/focus pausing lives in the script too. */

  .status-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--status) 18%, transparent);
  }

  /* Section shell */
  section { padding: 64px 0; }
  section[id] { scroll-margin-top: 72px; }   /* clears the sticky nav */
  .section-head { margin-bottom: 36px; }
  .section-head h2 {
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
  }
  .section-head p { color: var(--text-secondary); font-size: 1rem; max-width: 46ch; }

  /* Projects — full-bleed 16:9 slide carousel. Slides are centred with the
     neighbours peeking, and script.js clones the set on both sides so it
     loops endlessly in either direction. */
  .projects-carousel { position: relative; }

  .projects-track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    /* No scroll-behavior here: script.js runs its own eased glide, and a
       native smooth scroll would fight it. */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .projects-track::-webkit-scrollbar { display: none; }

  .project-slide {
    position: relative;
    flex: 0 0 auto;
    width: min(1060px, 84vw);
    aspect-ratio: 16 / 9;
    scroll-snap-align: center;
    /* Neutral dark stand-in until the artwork lands, so the overlay reads */
    background: #16161a;
    border-radius: var(--radius);
    overflow: hidden;
  }
  .project-slide picture { display: block; width: 100%; height: 100%; }
  .project-slide img { display: block; width: 100%; height: 100%; object-fit: cover; }

  /* Scrim, so the overlay stays legible over any artwork */
  .project-slide::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    /* Full height with a soft ramp: the caption is ~78% of a 184px mobile
       slide but only ~37% of a 596px desktop one, so a fixed % would miss. */
    top: 0;
    background: linear-gradient(to top,
      rgba(0,0,0,0.86) 0%,
      rgba(0,0,0,0.58) 28%,
      rgba(0,0,0,0.18) 58%,
      rgba(0,0,0,0) 85%);
    pointer-events: none;
    z-index: 0;
  }

  /* Caption, pinned bottom-left over the artwork */
  .slide-text {
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 1;
    /* A 16:9 slide is only ~184px tall at 390px wide, so the caption has to
       stay compact there or it overflows the top of its own slide. */
    padding: clamp(12px, 2.6vw, 36px);
    max-width: min(100%, 54ch);
    text-align: left;
    color: #ffffff;
  }
  .slide-text h3 {
    font-size: clamp(1.05rem, 2.1vw, 1.9rem);
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin-bottom: clamp(4px, 0.6vw, 8px);
  }
  .slide-sub {
    font-size: clamp(0.78rem, 1vw, 1rem);
    line-height: 1.42;
    color: rgba(255,255,255,0.78);
  }
  .slide-text .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: clamp(6px, 1.2vw, 16px);
  }
  .slide-text .tag {
    background: rgba(255,255,255,0.16);
    color: #ffffff;
    font-size: clamp(0.62rem, 0.78vw, 0.78rem);
    /* Clamps land on the old 4px/10px above ~1100px, so desktop is unchanged */
    padding: clamp(3px, 0.35vw, 4px) clamp(8px, 0.9vw, 10px);
    border-radius: 999px;
    white-space: nowrap;
  }

  /* Controls sit centred beneath the slides, so they never cover artwork */
  .carousel-nav { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }
  .carousel-btn, .carousel-play {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease, opacity .15s ease;
  }
  .carousel-btn:hover, .carousel-play:hover { background: var(--surface-hover); }
  .carousel-btn:active, .carousel-play:active { transform: scale(0.94); }
  .carousel-btn svg { width: 18px; height: 18px; }

  /* Pause control for the 3s auto-advance (WCAG 2.2.2) */
  .carousel-play { color: var(--text-secondary); }
  .carousel-play:hover { color: var(--text); }
  .carousel-play svg { width: 13px; height: 13px; }
  /* The UA rule for [hidden] is namespaced to HTML, so it never reaches SVG */
  .carousel-play svg[hidden] { display: none; }

  /* Certifications — compact two-column list */
  .cert-list {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 32px;
  }
  .cert-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .cert-item:nth-last-child(-n+2) { border-bottom: none; }
  .cert-check { flex-shrink: 0; width: 20px; height: 20px; color: var(--accent); margin-top: 2px; }
  .cert-name { font-weight: 600; font-size: 0.96rem; margin-bottom: 2px; }
  .cert-issuer { font-size: 0.85rem; color: var(--text-secondary); }
  .cert-more { margin-top: 22px; font-size: 0.88rem; color: var(--text-secondary); }

  /* Contact */
  .contact { text-align: center; }
  .contact h2 { font-size: clamp(1.6rem, 3vw, 2rem); font-weight: 700; letter-spacing: -0.01em; margin-bottom: 10px; }
  .contact p { color: var(--text-secondary); margin-bottom: 28px; }
  .btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: transform .15s ease, opacity .15s ease, background .15s ease;
  }
  .btn:hover { transform: translateY(-1px); }
  .btn-primary { background: var(--accent); color: #ffffff; }
  .btn-primary:hover { opacity: 0.9; }
  .btn-secondary { border: 1px solid var(--border); color: var(--text); }
  .btn-secondary:hover { background: var(--surface-hover); }

  footer {
    text-align: center;
    padding: 48px 24px 56px;
    border-top: 1px solid var(--border);
  }
  .footer-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }
  .footer-links { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 10px; }
  .footer-links a:hover { color: var(--accent); }
  .footer-copy { font-size: 0.78rem; color: var(--text-secondary); opacity: 0.8; }

  /* ---- CV page ---------------------------------------------------------
     Same tokens as the home page: dark chrome header, themed body below. */
  .cv-head {
    background-image:
      radial-gradient(circle at 1px 1px, rgba(255,255,255,0.08) 1px, transparent 0),
      linear-gradient(180deg, #0a0a0c 0%, #000000 100%);
    background-size: 22px 22px, auto;
    color: var(--chrome-text);
    text-align: center;
    padding: 64px 24px 66px;
  }
  .cv-eyebrow {
    font-size: 0.73rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--chrome-text-dim);
    margin-bottom: 14px;
  }
  .cv-head h1 {
    font-size: clamp(1.85rem, 4.2vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
  }
  .cv-creds { margin-top: 10px; font-size: 0.84rem; color: var(--chrome-text-dim); }
  .cv-title { margin: 18px auto 0; max-width: 560px; font-size: 0.99rem; color: var(--chrome-text-dim); }
  .cv-contact { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 24px; }
  .cv-contact a {
    border: 1px solid rgba(255,255,255,0.24);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.85rem;
    color: var(--chrome-text);
    transition: background .15s ease;
  }
  .cv-contact a:hover { background: rgba(255,255,255,0.10); }
  .cv-actions { display: flex; justify-content: center; margin-top: 22px; }
  .cv-actions svg { flex-shrink: 0; }

  .cv-section { padding: 44px 0 0; }
  .cv-section:last-of-type { padding-bottom: 8px; }
  .cv-section > h2 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 26px;
  }
  .cv-summary { color: var(--text-secondary); font-size: 0.97rem; max-width: 70ch; }

  .cv-entry + .cv-entry { margin-top: 30px; }
  .cv-entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
  .cv-role { font-size: 1.01rem; font-weight: 600; letter-spacing: -0.01em; }
  .cv-dates { font-size: 0.83rem; color: var(--text-secondary); white-space: nowrap; }
  .cv-entry-id { min-width: 0; }
  .cv-org { font-size: 0.89rem; color: var(--text-secondary); margin-top: 3px; }
  .cv-bullets { list-style: none; margin-top: 12px; display: grid; gap: 8px; }
  .cv-bullets li { position: relative; padding-left: 19px; font-size: 0.92rem; color: var(--text-secondary); }
  .cv-bullets li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 0.62em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.55;
  }

  .cv-list { list-style: none; }
  .cv-list li { padding: 13px 0; border-bottom: 1px solid var(--border); }
  .cv-list li:last-child { border-bottom: none; }
  .cv-item-name { font-weight: 600; font-size: 0.94rem; }
  .cv-item-meta { font-size: 0.84rem; color: var(--text-secondary); margin-top: 2px; }
  .cv-item-id { font-size: 0.75rem; color: var(--text-secondary); opacity: 0.75; margin-top: 3px; }

  .cv-skills { display: grid; gap: 15px; }
  .cv-skill-row { display: grid; grid-template-columns: 210px 1fr; gap: 18px; align-items: start; }
  .cv-skill-label { font-size: 0.87rem; font-weight: 600; }
  .cv-skill-value { font-size: 0.91rem; color: var(--text-secondary); }

  .cv-note { font-size: 0.91rem; color: var(--text-secondary); }

  @media (max-width: 640px) {
    /* Long titles wrap and would push the category under them while short ones
       keep it beside them, so stack every row the same way instead. */
    .other-head { flex-direction: column; align-items: flex-start; gap: 3px; }
    .cv-skill-row { grid-template-columns: 1fr; gap: 3px; }
    .cert-list { grid-template-columns: 1fr; }
    .cert-item { border-bottom: 1px solid var(--border); }
    .cert-item:nth-last-child(-n+2) { border-bottom: 1px solid var(--border); }
    .cert-item:last-child { border-bottom: none; }
  }
  @media (max-width: 520px) {
    /* The mark carries the name here, so drop the wordmark visually but keep
       it for screen readers. Also fixes the nav name wrapping at 390px. */
    .nav-wordmark {
      position: absolute;
      width: 1px;
      height: 1px;
      margin: -1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }
    .nav-links { gap: 14px; font-size: 0.82rem; }
    .hero-banner { padding: 68px 20px 72px; }
    .cv-head { padding: 52px 20px 54px; }
    section { padding: 48px 0; }
    .ticker-set li { font-size: 0.83rem; margin-right: 34px; }
    .ticker-set li::after { margin-left: 34px; }
  }
