:root {
  --bg: #f6f8fb;
  --bg-alt: #edf1f7;
  --surface: #ffffff;
  --text: #0e1726;
  --muted: #5a6577;
  --line: #dde3ec;
  --health: #0f9d7a;
  --health-soft: rgba(15, 157, 122, .12);
  --it: #4f5bd5;
  --it-soft: rgba(79, 91, 213, .12);
  --alert: #e0533d;
  --monitor-bg: #0b1220;
  --monitor-text: #d7e2f0;
  --ecg: rgba(15, 157, 122, .22);
  --shadow: 0 10px 30px -12px rgba(14, 23, 38, .18);
  --radius: 16px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #070c16;
  --bg-alt: #0b1220;
  --surface: #111a2b;
  --text: #e6edf7;
  --muted: #94a2b8;
  --line: #1e2a40;
  --health: #22d3a6;
  --health-soft: rgba(34, 211, 166, .12);
  --it: #8b95ff;
  --it-soft: rgba(139, 149, 255, .14);
  --monitor-bg: #050912;
  --ecg: rgba(34, 211, 166, .18);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #070c16;
    --bg-alt: #0b1220;
    --surface: #111a2b;
    --text: #e6edf7;
    --muted: #94a2b8;
    --line: #1e2a40;
    --health: #22d3a6;
    --health-soft: rgba(34, 211, 166, .12);
    --it: #8b95ff;
    --it-soft: rgba(139, 149, 255, .14);
    --monitor-bg: #050912;
    --ecg: rgba(34, 211, 166, .18);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Space Grotesk", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: clamp(2.3rem, 5.5vw, 4.2rem); font-weight: 700; }
h2 { font-size: clamp(1.7rem, 3.4vw, 2.5rem); }
h3 { font-size: 1.15rem; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.small { font-size: .78rem; }
.muted { color: var(--muted); }
.max { max-width: 62ch; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--health); outline-offset: 3px; border-radius: 6px; }

/* NAV */
.nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; letter-spacing: .08em; }
.brand svg { width: 28px; height: 28px; fill: none; stroke: var(--health); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.nav nav { display: flex; gap: 22px; margin-left: auto; }
.nav nav a { text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav nav a:hover { color: var(--text); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
@media (max-width: 720px) { .nav nav { display: none; } .icon-btn { margin-left: auto; } }

/* HERO */
.hero { position: relative; overflow: hidden; padding: clamp(48px, 9vw, 110px) clamp(16px, 4vw, 48px) 72px; }
#ecg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.hero-inner {
  position: relative; max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 48px; align-items: center;
}
@media (max-width: 900px) { .hero-inner { grid-template-columns: 1fr; } }
.eyebrow { font-family: "JetBrains Mono", monospace; font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--health); margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.grad { background: linear-gradient(90deg, var(--health), var(--it)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { font-size: 1.13rem; color: var(--muted); max-width: 58ch; }
.lede strong { color: var(--text); }
.role { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--health); }
.caret { display: inline-block; width: 2px; height: 1.05em; background: var(--health); margin-left: 2px; vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.cta.center { justify-content: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 12px 20px; border-radius: 12px; text-decoration: none; font-weight: 600; border: 1px solid var(--line); transition: transform .15s, box-shadow .15s; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.ghost { background: var(--surface); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--health); display: inline-block; }
.dot.live { box-shadow: 0 0 0 0 var(--health); animation: ping 1.8s infinite; }
.dot.warn { background: #f5a524; animation: none; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--health) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 8px transparent; } }

/* MONITOR */
.monitor {
  background: var(--monitor-bg); color: var(--monitor-text);
  border-radius: 20px; padding: 20px; border: 1px solid #1c2840;
  box-shadow: 0 30px 60px -25px rgba(4, 10, 25, .6), inset 0 0 0 1px rgba(255,255,255,.03);
}
.monitor .muted { color: #7d8ba3; }
.monitor-head { display: flex; gap: 12px; align-items: center; padding-bottom: 14px; border-bottom: 1px dashed #22314d; }
.monitor-head img { border-radius: 12px; border: 2px solid #22d3a6; }
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 10px; }
.vital { background: #0d1628; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; border-left: 3px solid; }
.vital .label { font: 500 .7rem "JetBrains Mono", monospace; letter-spacing: .12em; opacity: .8; }
.vital .value { font: 500 2.1rem/1.1 "JetBrains Mono", monospace; }
.vital .unit { font-size: .78rem; opacity: .7; }
.v1 { border-color: #22d3a6; color: #22d3a6; }
.v2 { border-color: #8b95ff; color: #a5adff; }
.v3 { border-color: #f5a524; color: #f5c25a; }
.v4 { border-color: #ff6b8b; color: #ff8fa8; }
.pulse { width: 100%; height: 40px; }
.pulse path { fill: none; stroke: #22d3a6; stroke-width: 2; stroke-dasharray: 600; stroke-dashoffset: 600; animation: draw 2.6s linear infinite; filter: drop-shadow(0 0 4px #22d3a6); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* STRIP */
.strip {
  max-width: 1200px; margin: 0 auto 24px; padding: 0 clamp(16px, 4vw, 48px);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px;
}
.strip > div { padding: 18px 20px; border-top: 1px solid var(--line); }
.strip b { display: block; font-size: 1.5rem; }
.strip span { color: var(--muted); font-size: .9rem; }
@media (max-width: 760px) { .strip { grid-template-columns: 1fr 1fr; } }

/* SECTIONS */
.section { padding: clamp(56px, 8vw, 96px) clamp(16px, 4vw, 48px); }
.section > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.section.alt { background: var(--bg-alt); }
.section-head { margin-bottom: 32px; }
.filters, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.health { background: var(--health); }
.sw.it { background: var(--it); }

/* PROJECT CARDS */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-flow: dense; gap: 20px; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px) { .grid { grid-template-columns: 1fr; } }
.card {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s, opacity .3s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card.health:hover { border-color: var(--health); }
.card.it:hover { border-color: var(--it); }
.card.featured { grid-column: span 2; }
@media (max-width: 680px) { .card.featured { grid-column: auto; } .card .spark { display: none; } }
.card.hidden { display: none; }
.card .tag { align-self: flex-start; font: 500 .72rem "JetBrains Mono", monospace; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.card.health .tag { background: var(--health-soft); color: var(--health); }
.card.it .tag { background: var(--it-soft); color: var(--it); }
.card h3 { font-size: 1.3rem; margin: 0; }
.card p { margin: 0; color: var(--muted); }
.card .metric { display: flex; gap: 18px; flex-wrap: wrap; font-size: .85rem; }
.card .metric b { display: block; font-size: 1.15rem; color: var(--text); }
.stack { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.stack span { font: .75rem "JetBrains Mono", monospace; padding: 3px 8px; border-radius: 6px; background: var(--bg-alt); color: var(--muted); }
.card .more { align-self: flex-start; font: inherit; font-size: .88rem; font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }
.card.health .more { color: var(--health); }
.card.it .more { color: var(--it); }
.card .spark { position: absolute; top: 22px; right: 22px; width: 70px; height: 22px; opacity: .55; }
.card .spark path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.card.health .spark path { stroke: var(--health); }
.card.it .spark path { stroke: var(--it); }

/* PIPELINE */
.pipeline { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; counter-reset: step; }
@media (max-width: 1000px) { .pipeline { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .pipeline { grid-template-columns: 1fr; } }
.pipeline li { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; counter-increment: step; }
.pipeline li::before { content: "0" counter(step); font: 500 .75rem "JetBrains Mono", monospace; color: var(--health); }
.pipeline h3 { margin: 6px 0 6px; }
.pipeline p { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }
.pipeline .repos { display: flex; flex-direction: column; gap: 6px; }
.pipeline .repos a { font: .78rem "JetBrains Mono", monospace; text-decoration: none; padding: 5px 8px; border-radius: 6px; background: var(--bg-alt); overflow-wrap: anywhere; }
.pipeline .repos a.own { background: var(--health-soft); color: var(--health); }
.pipeline .repos a:hover { text-decoration: underline; }
.pipeline .legend { font-size: .75rem; color: var(--muted); }

/* LIVE REPOS */
.toolbar input, .toolbar select {
  font: inherit; font-size: .92rem; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.toolbar input { flex: 1 1 220px; min-width: 0; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; color: var(--muted); cursor: pointer; }
.lang-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line); margin-bottom: 10px; }
.lang-bar span { height: 100%; transition: width .8s ease; }
.lang-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); margin-bottom: 24px; }
.lang-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.repo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.repo {
  display: flex; flex-direction: column; gap: 8px; padding: 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  text-decoration: none; transition: border-color .2s, transform .2s;
}
.repo:hover { border-color: var(--health); transform: translateY(-2px); }
.repo .name { font-weight: 600; overflow-wrap: anywhere; }
.repo .desc { color: var(--muted); font-size: .88rem; flex: 1; }
.repo .meta { display: flex; gap: 12px; flex-wrap: wrap; font: .75rem "JetBrains Mono", monospace; color: var(--muted); }
.repo .fork { color: var(--it); }
.empty { color: var(--muted); padding: 24px 0; }

/* SKILLS */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.skill-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.skill-card h3 { display: flex; gap: 10px; align-items: center; }
.skill-card ul { margin: 0; padding-left: 18px; color: var(--muted); }
.skill-card li { margin: 4px 0; }

/* CONTACT */
.contact { text-align: center; }
.contact .max, .contact .eyebrow { margin-left: auto; margin-right: auto; justify-content: center; }

.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 24px clamp(16px, 4vw, 48px); border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }

/* DIALOG */
dialog {
  width: min(760px, calc(100vw - 32px)); max-height: 88vh; padding: 32px;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 9, 18, .6); backdrop-filter: blur(4px); }
dialog .close { position: absolute; top: 16px; right: 16px; font-size: 1rem; }
dialog h2 { padding-right: 40px; }
dialog h4 { margin: 22px 0 8px; font: 500 .78rem "JetBrains Mono", monospace; letter-spacing: .12em; text-transform: uppercase; color: var(--health); }
dialog ul { padding-left: 20px; margin: 0; }
dialog li { margin: 6px 0; color: var(--muted); }
dialog li b { color: var(--text); }
@media (max-width: 560px) { dialog { padding: 24px 18px; } }

/* REVEAL */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  html { scroll-behavior: auto; }
}
