/* ==========================================================================
   TIPSON.PL — public site stylesheet
   Embedded / IoT / Linux portfolio. Mobile-first, no framework.
   ========================================================================== */

@layer reset, tokens, base, layout, components, sections, utilities;

/* ---------- Fonts (self-hosted, OFL) ---------- */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("../fonts/grotesk-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Space Grotesk"; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url("../fonts/grotesk-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("../fonts/jbmono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap;
  src: url("../fonts/jbmono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Reset ---------- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  img, picture, svg, video, canvas { display: block; max-width: 100%; }
  img { height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; }
  a { color: inherit; }
  ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
  h1, h2, h3, h4 { text-wrap: balance; }
  p { text-wrap: pretty; }
}

/* ---------- Tokens ---------- */
@layer tokens {
  :root {
    color-scheme: dark;
    --bg: #06080c;
    --bg-2: #0a0e15;
    --bg-3: #0f1520;
    --surface: rgb(16 22 32 / 0.62);
    --surface-2: rgb(22 30 44 / 0.72);
    --surface-solid: #0e141e;
    --line: rgb(148 178 214 / 0.13);
    --line-strong: rgb(148 178 214 / 0.26);
    --text: #e7edf5;
    --text-soft: #b8c4d4;
    --muted: #8795a9;
    --accent: #22d3ee;
    --accent-2: #3b82f6;
    --accent-3: #34d399;
    --warn: #fbbf24;
    --danger: #f87171;
    --accent-rgb: 34 211 238;
    --glow: 0 0 0 1px rgb(var(--accent-rgb) / 0.35), 0 10px 40px -10px rgb(var(--accent-rgb) / 0.35);
    --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 20px 50px -24px rgb(0 0 0 / 0.8);
    --grad: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 60%, #8b5cf6 110%);
    --trace: rgb(34 211 238 / 0.08);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

    --step--1: clamp(0.8rem, 0.78rem + 0.1vw, 0.86rem);
    --step-0: clamp(0.95rem, 0.92rem + 0.15vw, 1.05rem);
    --step-1: clamp(1.1rem, 1.04rem + 0.3vw, 1.3rem);
    --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.8rem);
    --step-3: clamp(1.7rem, 1.4rem + 1.4vw, 2.6rem);
    --step-4: clamp(2.3rem, 1.7rem + 3vw, 4.2rem);
    --step-5: clamp(3rem, 1.8rem + 6.4vw, 7.4rem);

    --radius-s: 10px;
    --radius: 18px;
    --radius-l: 26px;
    --gutter: clamp(16px, 4vw, 40px);
    --maxw: 1240px;
    --nav-h: 64px;
    --ease: cubic-bezier(.2, .7, .2, 1);
  }

  :root[data-theme="light"] {
    color-scheme: light;
    --bg: #f4f6f9;
    --bg-2: #eef1f6;
    --bg-3: #e5eaf1;
    --surface: rgb(255 255 255 / 0.72);
    --surface-2: rgb(255 255 255 / 0.9);
    --surface-solid: #ffffff;
    --line: rgb(20 40 70 / 0.12);
    --line-strong: rgb(20 40 70 / 0.24);
    --text: #0c1422;
    --text-soft: #2b3a50;
    --muted: #56657a;
    --accent: #0891b2;
    --accent-2: #2563eb;
    --accent-3: #059669;
    --accent-rgb: 8 145 178;
    --shadow: 0 1px 0 rgb(255 255 255 / 0.6) inset, 0 18px 40px -26px rgb(15 30 60 / 0.35);
    --trace: rgb(8 145 178 / 0.1);
  }
}

/* ---------- Base ---------- */
@layer base {
  html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
  @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

  body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
  }
  h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.12; letter-spacing: -0.02em; font-weight: 700; }
  h1 { font-size: var(--step-4); }
  h2 { font-size: var(--step-3); }
  h3 { font-size: var(--step-1); letter-spacing: -0.01em; }
  a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
  a:hover { color: var(--text); }
  code, kbd, pre, .mono { font-family: var(--font-mono); }
  ::selection { background: rgb(var(--accent-rgb) / 0.3); }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
  .skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 1000;
    background: var(--accent); color: #041016; padding: 10px 16px; border-radius: 10px; font-weight: 600;
  }
  .skip-link:focus { top: 12px; }
  .visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- Layout ---------- */
@layer layout {
  .container { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }
  .container-wide { width: min(100% - 2 * var(--gutter), 1480px); margin-inline: auto; }
  .section { padding-block: clamp(64px, 9vw, 128px); position: relative; }
  .section-tight { padding-block: clamp(40px, 6vw, 80px); }
  .grid { display: grid; gap: clamp(14px, 2vw, 22px); }
  .grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
  .grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); }
  .grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
  .split { display: grid; gap: clamp(28px, 5vw, 64px); align-items: center; }
  @media (min-width: 960px) { .split { grid-template-columns: 1.05fr 1fr; } .split.reverse > :first-child { order: 2; } }
}

/* ---------- Background layers ---------- */
@layer components {
  .bg-layers { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
  .bg-layers::before {
    content: ""; position: absolute; inset: -20% -10% auto -10%; height: 90vh;
    background:
      radial-gradient(40% 55% at 18% 18%, rgb(var(--accent-rgb) / 0.13), transparent 70%),
      radial-gradient(35% 45% at 85% 8%, rgb(59 130 246 / 0.12), transparent 70%);
    filter: blur(10px);
  }
  .bg-grid {
    position: absolute; inset: 0;
    background-image:
      linear-gradient(var(--line) 1px, transparent 1px),
      linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
    opacity: .45;
  }
  .bg-traces { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; }
  .bg-traces path { fill: none; stroke: var(--trace); stroke-width: 1.2; }
  .bg-traces .pulse { stroke: rgb(var(--accent-rgb) / 0.55); stroke-width: 1.6; stroke-dasharray: 6 240; animation: trace-run 7s linear infinite; }
  .bg-traces .pulse:nth-of-type(2n) { animation-duration: 9s; animation-delay: -3s; }
  .bg-traces .pulse:nth-of-type(3n) { animation-duration: 11s; animation-delay: -5s; }
  .bg-traces circle { fill: var(--bg); stroke: var(--trace); stroke-width: 1.2; }
  @keyframes trace-run { to { stroke-dashoffset: -246; } }

  /* ---------- Navigation ---------- */
  .nav {
    position: fixed; inset: 12px 0 auto 0; z-index: 100; pointer-events: none;
  }
  .nav-bar {
    pointer-events: auto;
    width: min(100% - 24px, 1320px); margin-inline: auto; height: var(--nav-h);
    display: flex; align-items: center; gap: 12px; padding: 0 10px 0 16px;
    border: 1px solid var(--line); border-radius: 18px;
    background: color-mix(in srgb, var(--bg) 70%, transparent);
    backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: var(--shadow);
    transition: border-color .3s var(--ease), background .3s var(--ease);
  }
  .nav.scrolled .nav-bar { border-color: var(--line-strong); background: color-mix(in srgb, var(--bg) 84%, transparent); }
  .brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-family: var(--font-display); font-weight: 700; letter-spacing: .14em; }
  .brand-mark { width: 30px; height: 30px; flex: none; }
  .brand small { display: block; font-family: var(--font-mono); font-weight: 400; letter-spacing: .08em; font-size: .62rem; color: var(--muted); line-height: 1; }
  .nav-links { display: none; }
  .nav-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
  .icon-btn {
    width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px;
    color: var(--text-soft); border: 1px solid transparent; transition: .2s var(--ease);
  }
  .icon-btn:hover { color: var(--text); border-color: var(--line); background: var(--surface); }
  .icon-btn svg { width: 20px; height: 20px; }
  .theme-toggle .ico-sun { display: none; }
  :root[data-theme="light"] .theme-toggle .ico-sun { display: block; }
  :root[data-theme="light"] .theme-toggle .ico-moon { display: none; }

  @media (min-width: 1180px) {
    .nav-links { display: flex; gap: 2px; margin: 0 auto; padding: 0; list-style: none; }
    .nav-links a {
      display: block; padding: 8px 10px; border-radius: 10px; text-decoration: none;
      font-family: var(--font-mono); font-size: .72rem; letter-spacing: .06em; color: var(--muted);
      transition: color .2s, background .2s;
    }
    .nav-links a:hover { color: var(--text); background: var(--surface); }
    .nav-links a[aria-current="true"] { color: var(--accent); background: rgb(var(--accent-rgb) / 0.08); }
    .nav-actions { margin-left: 0; }
    .burger { display: none; }
  }

  /* off-canvas */
  .drawer {
    position: fixed; inset: 0; z-index: 200; display: grid; justify-items: end;
    background: rgb(0 0 0 / 0.5); backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; transition: opacity .25s var(--ease), visibility .25s;
  }
  .drawer.open { opacity: 1; visibility: visible; }
  .drawer-panel {
    width: min(88vw, 360px); height: 100%; background: var(--surface-solid); border-left: 1px solid var(--line);
    padding: 20px 18px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto;
    transform: translateX(100%); transition: transform .3s var(--ease);
  }
  .drawer.open .drawer-panel { transform: none; }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .drawer a.dl {
    display: flex; align-items: center; gap: 12px; padding: 12px 12px; border-radius: 12px; text-decoration: none; color: var(--text-soft);
    font-family: var(--font-mono); font-size: .85rem; letter-spacing: .05em;
  }
  .drawer a.dl span { color: var(--muted); font-size: .7rem; width: 22px; }
  .drawer a.dl[aria-current="true"], .drawer a.dl:hover { background: rgb(var(--accent-rgb) / 0.08); color: var(--accent); }

  #scroll-progress { position: fixed; top: 0; left: 0; height: 2px; width: 100%; transform-origin: 0 50%; transform: scaleX(0); background: var(--grad); z-index: 300; }

  /* ---------- Buttons, chips ---------- */
  .btn {
    display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 12px;
    font-weight: 600; font-size: .95rem; text-decoration: none; border: 1px solid var(--line-strong);
    color: var(--text); background: var(--surface); transition: transform .2s var(--ease), border-color .2s, box-shadow .2s, background .2s;
  }
  .btn:hover { transform: translateY(-1px); border-color: rgb(var(--accent-rgb) / 0.6); color: var(--text); }
  .btn-primary { background: var(--grad); color: #03121a; border-color: transparent; box-shadow: 0 10px 30px -12px rgb(var(--accent-rgb) / 0.7); }
  .btn-primary:hover { color: #03121a; box-shadow: 0 14px 34px -10px rgb(var(--accent-rgb) / 0.8); }
  .btn .arr { transition: transform .2s var(--ease); }
  .btn:hover .arr { transform: translateX(3px); }
  .btn-sm { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }

  .chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
  .chip {
    font-family: var(--font-mono); font-size: .72rem; letter-spacing: .02em; padding: 4px 9px; border-radius: 8px;
    border: 1px solid var(--line); color: var(--text-soft); background: rgb(var(--accent-rgb) / 0.04); white-space: nowrap;
  }
  .kicker {
    display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: .75rem;
    letter-spacing: .18em; text-transform: uppercase; color: var(--accent);
  }
  .kicker::before { content: ""; width: 22px; height: 1px; background: currentColor; opacity: .7; }
  .grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .muted { color: var(--muted); }
  .lead { font-size: var(--step-1); color: var(--text-soft); line-height: 1.6; }

  .sec-head { max-width: 760px; margin-bottom: clamp(28px, 4vw, 48px); display: grid; gap: 14px; }
  .sec-head p { color: var(--text-soft); }
  .sec-head.center { margin-inline: auto; text-align: center; justify-items: center; }
  .sec-index { font-family: var(--font-mono); font-size: .75rem; color: var(--muted); letter-spacing: .1em; }

  /* ---------- Cards ---------- */
  .card {
    position: relative; border: 1px solid var(--line); border-radius: var(--radius-l);
    background: var(--surface); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    padding: clamp(20px, 2.4vw, 30px); box-shadow: var(--shadow);
    transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
  }
  .card:hover { border-color: rgb(var(--accent-rgb) / 0.35); }
  .card.spot::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
    background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgb(var(--accent-rgb) / 0.09), transparent 45%);
  }
  .card.spot:hover::before { opacity: 1; }
  .card h3 { margin-bottom: 8px; }
  .card p { color: var(--text-soft); font-size: .95rem; }
  .card-icon {
    width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; margin-bottom: 18px;
    border: 1px solid rgb(var(--accent-rgb) / 0.3); background: rgb(var(--accent-rgb) / 0.08); color: var(--accent);
  }
  .card-icon svg { width: 24px; height: 24px; }
  .card-foot { margin-top: 18px; }

  .skill-card { display: flex; flex-direction: column; gap: 4px; }
  .skill-card .skill-list { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; padding: 0; list-style: none; }
  .skill-card .skill-list li {
    font-family: var(--font-mono); font-size: .76rem; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line);
    background: rgb(0 0 0 / 0.12); color: var(--text-soft); display: flex; align-items: center; gap: 8px;
  }
  :root[data-theme="light"] .skill-card .skill-list li { background: rgb(255 255 255 / 0.6); }
  .skill-card .skill-list li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 8px var(--accent-3); flex: none; }
  .card-tag { position: absolute; top: 18px; right: 20px; font-family: var(--font-mono); font-size: .68rem; color: var(--muted); letter-spacing: .1em; }

  /* ---------- Terminal ---------- */
  .terminal {
    border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden;
    background: color-mix(in srgb, #03060a 88%, transparent); box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.9);
    font-family: var(--font-mono); font-size: clamp(.72rem, .68rem + .2vw, .82rem); color: #cfe3f5;
  }
  :root[data-theme="light"] .terminal { background: #0b1220; }
  .terminal-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; border-bottom: 1px solid rgb(255 255 255 / 0.06); background: rgb(255 255 255 / 0.02); }
  .terminal-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2b3444; }
  .terminal-bar i:nth-child(1) { background: #ef4444aa; } .terminal-bar i:nth-child(2) { background: #f59e0baa; } .terminal-bar i:nth-child(3) { background: #22c55eaa; }
  .terminal-bar em { margin-left: 8px; font-style: normal; color: #7d8ba0; font-size: .72rem; }
  .terminal-body { padding: 14px 16px 16px; min-height: 15.5em; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
  .terminal-body .p { color: #34d399; } .terminal-body .c { color: #22d3ee; } .terminal-body .d { color: #7d8ba0; } .terminal-body .w { color: #fbbf24; } .terminal-body .o { color: #e7edf5; }
  .cursor { display: inline-block; width: .6em; height: 1.1em; vertical-align: -0.18em; background: #22d3ee; animation: blink 1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }

  /* ---------- Scope (oscilloscope panel) ---------- */
  .scope { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #03070b; position: relative; }
  .scope canvas { width: 100%; height: 150px; }
  .scope-meta { position: absolute; top: 8px; left: 12px; right: 12px; display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: .66rem; color: #5f7a93; letter-spacing: .08em; pointer-events: none; }
  .scope-meta b { color: #34d399; font-weight: 500; }

  /* ---------- Project cards ---------- */
  .filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
  .filter-btn {
    font-family: var(--font-mono); font-size: .75rem; letter-spacing: .04em; padding: 8px 13px; border-radius: 10px;
    border: 1px solid var(--line); color: var(--text-soft); background: var(--surface); transition: .2s var(--ease);
  }
  .filter-btn:hover { border-color: var(--line-strong); color: var(--text); }
  .filter-btn[aria-pressed="true"] { border-color: rgb(var(--accent-rgb) / 0.6); color: var(--accent); background: rgb(var(--accent-rgb) / 0.08); }
  .filter-btn .n { color: var(--muted); margin-left: 4px; }
  .filter-meta { font-family: var(--font-mono); font-size: .75rem; color: var(--muted); margin: -12px 0 22px; }

  .projects-grid { display: grid; gap: clamp(14px, 2vw, 22px); grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
  .project { container-type: inline-size; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
  .project[hidden] { display: none; }
  .project-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-3); border-bottom: 1px solid var(--line); }
  .project-media img, .project-media svg { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
  .project:hover .project-media img { transform: scale(1.04); }
  .project-status {
    position: absolute; top: 12px; left: 12px; font-family: var(--font-mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
    padding: 4px 8px; border-radius: 7px; background: rgb(3 8 14 / 0.75); color: #cfe3f5; border: 1px solid rgb(255 255 255 / 0.12); display: inline-flex; gap: 6px; align-items: center;
  }
  .project-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st, #8795a9); box-shadow: 0 0 8px var(--st, transparent); }
  .project-status[data-s="active"] { --st: #34d399; }
  .project-status[data-s="maintained"] { --st: #22d3ee; }
  .project-status[data-s="done"] { --st: #3b82f6; }
  .project-status[data-s="archive"] { --st: #8795a9; }
  .project-status[data-s="experiment"] { --st: #fbbf24; }
  .project-year { position: absolute; top: 12px; right: 12px; font-family: var(--font-mono); font-size: .7rem; color: #cfe3f5; background: rgb(3 8 14 / 0.75); padding: 4px 8px; border-radius: 7px; border: 1px solid rgb(255 255 255 / 0.12); }
  .project-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
  .project-body h3 { font-size: 1.12rem; margin: 0; }
  .project-body p { font-size: .92rem; }
  .project-cats { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; color: var(--accent); text-transform: uppercase; }
  .project-body .chips { margin-top: auto; padding-top: 6px; }
  .project-link { position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
  .project-link:focus-visible { outline-offset: -3px; }
  @container (min-width: 520px) {
    .project-body h3 { font-size: 1.3rem; }
  }

  /* ---------- Timeline ---------- */
  .timeline { position: relative; display: grid; gap: 22px; padding-left: 28px; list-style: none; }
  .timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--accent), var(--accent-2) 60%, transparent); opacity: .5; border-radius: 2px; }
  .tl-item { position: relative; }
  .tl-item::before { content: ""; position: absolute; left: -27px; top: 26px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); box-shadow: 0 0 0 4px rgb(var(--accent-rgb) / 0.12); }
  .tl-item.minor::before { width: 10px; height: 10px; left: -25px; top: 22px; border-color: var(--muted); box-shadow: none; }
  .tl-item .card { padding: 20px 22px; }
  .tl-item.minor .card { padding: 14px 18px; background: transparent; border-style: dashed; backdrop-filter: none; box-shadow: none; }
  .tl-when { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .08em; color: var(--accent); }
  .tl-item h3 { margin: 6px 0 6px; }
  .tl-item.minor h3 { font-size: 1rem; }
  @media (min-width: 900px) {
    .timeline { padding-left: 0; grid-template-columns: 1fr 1fr; column-gap: 64px; row-gap: 26px; }
    .timeline::before { left: 50%; transform: translateX(-1px); }
    .tl-item:nth-child(odd) { grid-column: 1; text-align: right; }
    .tl-item:nth-child(even) { grid-column: 2; margin-top: 60px; }
    .tl-item:nth-child(odd)::before { left: auto; right: -40px; }
    .tl-item:nth-child(even)::before { left: -40px; }
    .tl-item.minor:nth-child(odd)::before { right: -38px; }
    .tl-item.minor:nth-child(even)::before { left: -38px; }
    .tl-item:nth-child(odd) .chips { justify-content: flex-end; }
  }

  /* ---------- Stats ---------- */
  .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 10px; }
  .stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
  .stat b { display: block; font-family: var(--font-display); font-size: var(--step-3); line-height: 1; }
  .stat > span { font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

  /* ---------- Diagrams ---------- */
  .diagram { border: 1px solid var(--line); border-radius: var(--radius-l); background: var(--surface); padding: clamp(14px, 2vw, 24px); }
  .diagram svg { width: 100%; height: auto; }
  .diagram .node rect { fill: var(--bg-2); stroke: var(--line-strong); }
  .diagram .node text { fill: var(--text); font-family: var(--font-mono); font-size: 12px; }
  .diagram .node .sub { fill: var(--muted); font-size: 10px; }
  .diagram .node.hl rect { stroke: rgb(var(--accent-rgb) / 0.7); }
  .diagram .link { stroke: var(--line-strong); stroke-width: 1.5; fill: none; }
  .diagram .flow { stroke: var(--accent); stroke-width: 2; fill: none; stroke-dasharray: 4 14; animation: flow 1.4s linear infinite; }
  .diagram .flow.rev { animation-direction: reverse; stroke: var(--accent-3); }
  .diagram .lbl { fill: var(--muted); font-family: var(--font-mono); font-size: 10px; }
  @keyframes flow { to { stroke-dashoffset: -18; } }

  /* ---------- Music teaser & LAB explorer preview ---------- */
  .eq { display: flex; align-items: flex-end; gap: 3px; height: 44px; }
  .eq i { width: 5px; background: var(--grad); border-radius: 2px; height: 20%; animation: eq 1.2s ease-in-out infinite; }
  .eq i:nth-child(2n) { animation-duration: .9s; } .eq i:nth-child(3n) { animation-duration: 1.5s; } .eq i:nth-child(5n) { animation-delay: -.4s; }
  @keyframes eq { 50% { height: 100%; } }

  .explorer { border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface-solid); font-family: var(--font-mono); font-size: .8rem; }
  .explorer-bar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
  .explorer-bar b { color: var(--accent); font-weight: 500; }
  .explorer table { width: 100%; border-collapse: collapse; }
  .explorer td, .explorer th { padding: 6px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
  .explorer th { font-weight: 500; font-size: .68rem; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
  .explorer td.num, .explorer th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .explorer tr:hover td { background: rgb(var(--accent-rgb) / 0.05); }
  .explorer .dir::before { content: "▸ "; color: var(--accent); }

  /* ---------- Contact ---------- */
  .contact-card { display: grid; gap: 22px; }
  @media (min-width: 900px) { .contact-card { grid-template-columns: 1.2fr 1fr; align-items: center; } }
  .contact-list { display: grid; gap: 10px; list-style: none; padding: 0; }
  .contact-list a {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line);
    text-decoration: none; color: var(--text); background: var(--surface); transition: .2s var(--ease);
  }
  .contact-list a:hover { border-color: rgb(var(--accent-rgb) / 0.5); transform: translateX(3px); }
  .contact-list svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
  .contact-list small { display: block; color: var(--muted); font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; }

  /* ---------- Footer ---------- */
  .footer { border-top: 1px solid var(--line); padding-block: 40px 30px; margin-top: 40px; font-size: .9rem; }
  .footer-grid { display: grid; gap: 26px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .footer h4 { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; font-weight: 500; }
  .footer ul { list-style: none; padding: 0; display: grid; gap: 6px; }
  .footer a { color: var(--text-soft); text-decoration: none; }
  .footer a:hover { color: var(--accent); }
  .footer-bottom { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; color: var(--muted); font-family: var(--font-mono); font-size: .72rem; }

  .back-top {
    position: fixed; right: 18px; bottom: 18px; z-index: 90; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
    border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--bg) 80%, transparent); color: var(--text); backdrop-filter: blur(10px);
    opacity: 0; transform: translateY(10px); pointer-events: none; transition: .25s var(--ease);
  }
  .back-top.show { opacity: 1; transform: none; pointer-events: auto; }
  .back-top svg { width: 18px; height: 18px; }

  /* ---------- Page head (subpages) ---------- */
  .page-head { padding-top: calc(var(--nav-h) + clamp(56px, 8vw, 110px)); padding-bottom: clamp(24px, 4vw, 48px); }
  .crumbs { font-family: var(--font-mono); font-size: .75rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; list-style: none; padding: 0; }
  .crumbs a { color: var(--muted); text-decoration: none; }
  .crumbs a:hover { color: var(--accent); }
  .crumbs li + li::before { content: "/"; margin-right: 8px; opacity: .5; }

  /* ---------- Project detail ---------- */
  .detail-hero { display: grid; gap: clamp(24px, 4vw, 48px); }
  @media (min-width: 980px) { .detail-hero { grid-template-columns: 1.1fr 1fr; align-items: start; } }
  .facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: .9rem; margin: 0; }
  .facts dt { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
  .facts dd { margin: 0; color: var(--text-soft); }
  .prose { max-width: 72ch; }
  .prose > * + * { margin-top: 1em; }
  .prose h2 { font-size: var(--step-2); margin-top: 1.8em; }
  .prose h3 { margin-top: 1.4em; }
  .prose ul { padding-left: 1.2em; }
  .prose li { margin: .35em 0; color: var(--text-soft); }
  .prose li::marker { color: var(--accent); }
  .prose p { color: var(--text-soft); }
  .spec-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
  .spec-table th, .spec-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
  .spec-table th { font-family: var(--font-mono); font-weight: 500; font-size: .75rem; color: var(--muted); letter-spacing: .06em; width: 38%; }

  .gallery { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
  .gallery button { padding: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--bg-3); aspect-ratio: 4 / 3; position: relative; }
  .gallery button img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
  .gallery button:hover img { transform: scale(1.05); }
  .gallery figcaption, .gallery .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 10px 8px; font-size: .75rem; text-align: left; color: #e7edf5; background: linear-gradient(transparent, rgb(0 0 0 / 0.75)); font-family: var(--font-mono); }

  dialog.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 94vh; margin: auto; color: #fff; }
  dialog.lightbox::backdrop { background: rgb(2 5 9 / 0.88); backdrop-filter: blur(6px); }
  dialog.lightbox img { max-width: 96vw; max-height: 84vh; width: auto; border-radius: 12px; margin-inline: auto; }
  dialog.lightbox p { text-align: center; font-family: var(--font-mono); font-size: .8rem; color: #b8c4d4; margin-top: 10px; }
  dialog.lightbox .lb-close { position: fixed; top: 16px; right: 16px; color: #fff; background: rgb(255 255 255 / 0.1); }
  dialog.lightbox .lb-nav { position: fixed; top: 50%; transform: translateY(-50%); color: #fff; background: rgb(255 255 255 / 0.1); }
  dialog.lightbox .lb-prev { left: 12px; } dialog.lightbox .lb-next { right: 12px; }

  .video { aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #000; position: relative; }
  .video iframe { width: 100%; height: 100%; border: 0; }
  .video-facade { width: 100%; height: 100%; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 50% 40%, #1b2638, #04070b); position: relative; }
  .video-facade span { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: rgb(var(--accent-rgb) / 0.9); color: #03121a; }
  .video-facade em { position: absolute; bottom: 12px; left: 14px; right: 14px; font-style: normal; font-family: var(--font-mono); font-size: .75rem; color: #b8c4d4; text-align: left; }

  .downloads { list-style: none; padding: 0; display: grid; gap: 8px; }
  .downloads a { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--surface); }
  .downloads a:hover { border-color: rgb(var(--accent-rgb) / 0.5); }
  .downloads small { font-family: var(--font-mono); color: var(--muted); font-size: .72rem; white-space: nowrap; }

  .notice { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 14px 16px; color: var(--muted); font-size: .88rem; }

  /* ---------- Music player ---------- */
  .player { border: 1px solid var(--line-strong); border-radius: var(--radius-l); overflow: hidden; background: var(--surface-solid); box-shadow: var(--shadow); }
  .player-vis { position: relative; height: clamp(150px, 22vw, 220px); background: #03070b; }
  .player-vis canvas { width: 100%; height: 100%; }
  .player-now { position: absolute; left: 20px; bottom: 16px; right: 20px; display: grid; gap: 2px; }
  .player-now b { font-family: var(--font-display); font-size: var(--step-2); color: #fff; }
  .player-now span { font-family: var(--font-mono); font-size: .75rem; color: #7d8ba0; }
  .player-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 18px; border-top: 1px solid var(--line); }
  .pbtn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--text); }
  .pbtn:hover { border-color: rgb(var(--accent-rgb) / 0.5); }
  .pbtn.big { width: 52px; height: 52px; background: var(--grad); color: #03121a; border: 0; }
  .pbtn[aria-pressed="true"] { color: var(--accent); border-color: rgb(var(--accent-rgb) / 0.6); }
  .pbtn svg { width: 20px; height: 20px; }
  .seek { flex: 1 1 220px; display: flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: .75rem; color: var(--muted); }
  input[type="range"] { accent-color: var(--accent); width: 100%; }
  .vol { display: flex; align-items: center; gap: 8px; width: 140px; color: var(--muted); }
  .tracks { list-style: none; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
  .track { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
  .track:hover { border-color: var(--line-strong); }
  .track[aria-current="true"] { border-color: rgb(var(--accent-rgb) / 0.6); background: rgb(var(--accent-rgb) / 0.08); }
  .track .no { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); width: 26px; }
  .track .t { flex: 1; font-weight: 500; font-size: .92rem; }
  .track .c { font-family: var(--font-mono); font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

  /* ---------- LAB page ---------- */
  .lab { display: grid; gap: 16px; }
  @media (min-width: 1000px) { .lab { grid-template-columns: 300px 1fr; align-items: start; } }
  .lab-tree { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-solid); padding: 8px; font-family: var(--font-mono); font-size: .8rem; max-height: 70vh; overflow: auto; position: sticky; top: calc(var(--nav-h) + 24px); }
  .lab-tree button { display: flex; width: 100%; gap: 8px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--text-soft); text-align: left; }
  .lab-tree button:hover { background: rgb(var(--accent-rgb) / 0.06); color: var(--text); }
  .lab-tree button[aria-current="true"] { background: rgb(var(--accent-rgb) / 0.1); color: var(--accent); }
  .lab-tree .grp { font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 12px 10px 4px; }
  .lab-tree .n { margin-left: auto; color: var(--muted); font-size: .7rem; }
  .lab-view { display: grid; gap: 14px; min-width: 0; }
  .lab-info { display: grid; gap: 10px; }
  .lab-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .lab-kv div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
  .lab-kv b { display: block; font-family: var(--font-mono); font-size: .95rem; font-weight: 500; }
  .lab-kv span { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
  .lab-files { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--surface-solid); max-height: 70vh; }
  .lab-files table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: .78rem; }
  .lab-files th, .lab-files td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
  .lab-files th { position: sticky; top: 0; background: var(--surface-solid); color: var(--muted); font-weight: 500; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; user-select: none; }
  .lab-files td.num, .lab-files th.num { text-align: right; font-variant-numeric: tabular-nums; }
  .lab-files td a { color: var(--text); text-decoration: none; }
  .lab-files td a:hover { color: var(--accent); text-decoration: underline; }
  .lab-files .path { color: var(--muted); }
  .lab-search { display: flex; gap: 8px; }
  .lab-search input { flex: 1; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-solid); font-family: var(--font-mono); font-size: .85rem; }

  /* ---------- Reveal ---------- */
  .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); transition-delay: var(--d, 0s); }
  .reveal.in { opacity: 1; transform: none; }
  .no-js .reveal { opacity: 1; transform: none; }
  @media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .bg-traces .pulse, .diagram .flow, .eq i, .cursor { animation: none !important; }
    .card, .btn, .project-media img { transition: none !important; }
  }
}

/* ---------- Sections ---------- */
@layer sections {
  .hero { padding-top: calc(var(--nav-h) + clamp(48px, 9vw, 120px)); padding-bottom: clamp(48px, 7vw, 96px); position: relative; }
  .hero-grid { display: grid; gap: clamp(32px, 5vw, 64px); align-items: center; }
  @media (min-width: 1040px) { .hero-grid { grid-template-columns: 1.15fr 1fr; } }
  .hero-status { display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-family: var(--font-mono); font-size: .72rem; color: var(--text-soft); }
  .hero-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 0 4px rgb(52 211 153 / 0.18); }
  .wordmark {
    font-family: var(--font-display); font-weight: 700; font-size: var(--step-5); letter-spacing: 0.08em; line-height: .95; margin: 22px 0 14px;
    background: linear-gradient(180deg, var(--text) 30%, color-mix(in srgb, var(--text) 45%, transparent)); -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  .hero-sub { font-family: var(--font-mono); font-size: clamp(.78rem, .7rem + .4vw, 1rem); letter-spacing: .04em; color: var(--accent); display: flex; flex-wrap: wrap; gap: 4px 12px; }
  .hero-sub span + span::before { content: "•"; margin-right: 12px; color: var(--muted); }
  .hero h1.role { font-size: var(--step-2); margin: 22px 0 10px; font-weight: 600; color: var(--text); }
  .hero .lead { max-width: 60ch; }
  .hero-ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
  .hero-side { display: grid; gap: 14px; min-width: 0; }
  .hero-meta { margin-top: 34px; }

  .marquee { border-block: 1px solid var(--line); overflow: hidden; background: var(--bg-2); }
  .marquee-track { display: flex; gap: 42px; width: max-content; padding: 14px 0; animation: marquee 48s linear infinite; font-family: var(--font-mono); font-size: .8rem; color: var(--muted); letter-spacing: .06em; }
  .marquee-track b { color: var(--text); font-weight: 500; }
  @keyframes marquee { to { transform: translateX(-50%); } }
  @media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; flex-wrap: wrap; width: auto; justify-content: center; } .marquee-track .dup { display: none; } }

  .about-points { display: grid; gap: 10px; list-style: none; padding: 0; margin-top: 18px; }
  .about-points li { display: flex; gap: 12px; color: var(--text-soft); }
  .about-points li::before { content: "→"; color: var(--accent); font-family: var(--font-mono); }

  .section-alt { background: linear-gradient(180deg, transparent, var(--bg-2) 12%, var(--bg-2) 88%, transparent); }
}

@layer utilities {
  .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 28px; } .mt-4 { margin-top: 44px; }
  .center { text-align: center; }
  .flex { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
  .hide-sm { display: none; }
  @media (min-width: 760px) { .hide-sm { display: initial; } }
}

@media print {
  .nav, .bg-layers, .back-top, .drawer, #scroll-progress, .hero-side { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; backdrop-filter: none; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
