/* =============================================================================
   Design tokens
   ============================================================================= */
:root {
  --bg: oklch(0.965 0.009 78);
  --bg-2: oklch(0.945 0.011 78);
  --surface: oklch(0.995 0.004 78);
  --line: oklch(0.85 0.014 72);
  --line-soft: oklch(0.90 0.011 74);
  --ink: oklch(0.26 0.022 62);
  --ink-2: oklch(0.43 0.02 62);
  --ink-3: oklch(0.58 0.016 66);
  --accent: oklch(0.56 0.115 202);
  --accent-dim: oklch(0.66 0.09 205);
  --accent-soft: oklch(0.56 0.115 202 / 0.10);
  --accent-2: oklch(0.56 0.155 22);
  --accent-2-soft: oklch(0.56 0.155 22 / 0.10);
  --accent-2-dim: oklch(0.56 0.155 22 / 0.25);
  --neg: oklch(0.52 0.19 20);
  --warn-ink: oklch(0.5 0.12 60);
  --warn-bd: oklch(0.78 0.09 70);
  --warn-bg: oklch(0.93 0.05 75);
  --maxw: 980px;
  --font-head: "Quicksand", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

/* =============================================================================
   Base reset
   ============================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.012em;
}

a {
  color: inherit;
}

p {
  margin: 0;
}

.mono {
  font-family: var(--font-mono);
}

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 28px;
}

/* Keyboard focus — visible ring, mouse clicks unaffected */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* =============================================================================
   Topbar / Nav
   ============================================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: oklch(0.965 0.009 78 / 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-in {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 62px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 28px;
}

/* brand (home page) */
.brand {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  white-space: nowrap;
}

.brand b {
  color: var(--ink);
  font-weight: 600;
}

.brand-domain {
  color: var(--ink-3);
  font-weight: 400;
}

.brand-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1.5px solid var(--accent);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* full nav (home page only) */
.nav {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
}

.nav-link {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--ink);
}

/* burger toggle — hidden on desktop, shown via responsive block */
.nav-toggle {
  display: none;
  margin-left: auto;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 9px;
  background: none;
  border: 0;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ink-2);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* back link (project / contact pages) */
.back {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.spacer {
  margin-left: auto;
}

/* lang switcher */
.lang {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}

.lang a,
.lang button {
  background: none;
  border: 0;
  color: var(--ink-3);
  padding: 7px 11px;
  cursor: pointer;
  text-decoration: none;
  line-height: 1;
  display: flex;
  align-items: center;
}

.lang a.on,
.lang button.on {
  background: var(--accent);
  color: #fff;
}

/* CV button */
.cv-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

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

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  padding: 13px 24px;
  border-radius: 10px;
  display: inline-flex;
  gap: 9px;
  align-items: center;
  transition: transform .18s, box-shadow .18s, opacity .15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px var(--accent-soft);
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: none;
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--ink-3);
}

/* =============================================================================
   Footer
   ============================================================================= */
footer {
  border-top: 1px solid var(--ink);
  padding: 40px 0 56px;
}

.foot-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.foot-name {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.foot-sep {
  color: var(--ink-3);
}

.foot-lnk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-3);
  text-decoration: none;
  transition: color 0.15s;
}

.foot-lnk:hover {
  color: var(--accent);
}

/* =============================================================================
   Home — Hero (centered editorial)
   ============================================================================= */
.hero {
  padding: 78px 0 30px;
  text-align: center;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 100px;
  padding: 6px 14px;
  margin-bottom: 24px;
}

.hero-kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  margin: 0 0 20px;
}

.hero h1 {
  font-size: clamp(38px, 5.5vw, 62px);
  color: var(--ink);
  max-width: 16ch;
  margin: 0 auto 24px;
}

.hero-lead {
  font-size: 19px;
  color: var(--ink-2);
  line-height: 1.65;
  margin: 0 auto 32px;
  text-wrap: pretty;
}

.hero-cta {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.hero-sub {
  color: var(--ink-3);
  line-height: 1.7;
  padding-top: 12px;
  padding-bottom: 0px;
}

/* =============================================================================
   Home — FIG. 01 Widget figure
   ============================================================================= */
.figure-cap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: 22px;
}

.figure-cap .fig {
  color: var(--ink);
  font-weight: 600;
}

.widget-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 32px;
  box-shadow: 0 8px 30px oklch(0 0 0 / 0.06);
}

/* =============================================================================
   Home — Work section (numbered list)
   ============================================================================= */
section.blk {
  padding: 64px 0;
}

section.blk#work {
  padding: 0 0;
  scroll-margin-top: 72px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 14px;
}

.blk h2 {
  font-size: clamp(26px, 3.4vw, 38px);
}

.blk .sub {
  color: var(--ink-2);
  margin: 12px 0 0;
  font-size: 17px;
  max-width: 54ch;
}

/* lead-in between the live FIG. 01 widget and the three project cards */
.work-connector {
  margin: 44px 0 0;
  font-size: 17px;
  color: var(--ink-2);
}

.worklist {
  margin-top: 36px;
  border-top: 1px solid var(--line);
}

.wrow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 28px;
  align-items: baseline;
  padding: 26px 6px;
  border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
  color: inherit;
  transition: background .2s, padding .2s;
  position: relative;
}

.wrow:hover {
  background: var(--surface);
  padding-left: 18px;
  padding-right: 18px;
}

.wrow .num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

.wrow .wmain .wtag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: block;
}

.wrow .wmain h3 {
  font-size: 24px;
  color: var(--ink);
}

.wrow .wmain .wprob {
  color: var(--ink-2);
  font-size: 15.5px;
  margin: 8px 0 0;
  max-width: 50ch;
}

.wrow .wmain .wres {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 10px 0 0;
}

.wrow .arrow {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 18px;
  align-self: center;
  transition: color .2s, transform .2s;
}

.wrow:hover .arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* ── Homelab trio: three live project cards, each proving itself with real data ── */
.hcards {
  margin-top: 30px;
  border-top: 1px solid var(--line);
}

.hcard {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(170px, 220px) 1fr 22px;
  gap: 30px;
  align-items: center;
  padding: 30px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: inherit;
  transition: background .2s, padding .2s;
}

.hcard:hover {
  background: var(--surface);
  padding-left: 18px;
  padding-right: 18px;
}

.hcard-link {
  position: absolute;
  inset: 0;
  text-decoration: none;
}

.hcard-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hcard-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hcard-gh {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color .15s, border-color .15s;
}

.hcard-gh:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.hcard-body {}

.hcard-num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  align-self: center;
}

.hcard-viz {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 104px;
}

.hcard-body h3 {
  font-size: 22px;
  color: var(--ink);
  margin: 0;
}

.hcard-body .wtag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 0 0 8px;
  display: block;
}

.hcard-body .wprob {
  color: var(--ink-2);
  font-size: 15px;
  margin: 8px 0 0;
}

.hcard-body .wres {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-3);
  margin: 10px 0 0;
}

.hcard .arrow {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 18px;
  align-self: center;
  transition: color .2s, transform .2s;
}

.hcard:hover .arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* card 01 visual — live raw meter curve */
.hcard-curve {
  width: 100%;
}

.hcard-curve .ec-readout {
  display: flex;
  align-items: baseline;
  gap: 4px;
  justify-content: flex-end;
}

.hcard-curve .ec-now {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.hcard-curve .ec-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
}

.hcard-curve .ec-plot {
  margin: 8px 0 0;
  border: 0;
}

.hcard-curve .ec-svg {
  height: 80px;
}

/* nilm mini-visual — detection strips, two appliances, two colours */
/* A = chauffe-eau ~2200 VA → accent-2 (brick), top band */
.nd-detect-a {
  fill: var(--accent-2);
}

/* B = other appliance ~1500 VA → accent (teal), bottom band */
.nd-sig-b {
  fill: var(--accent);
  stroke: none;
}

/* nilm SVG: 90px so the curve band (108/150 of viewBox) matches linkystat's 80px curve */
#curve-nilm .ec-svg,
[data-nilm] .ec-svg {
  height: 90px;
}

/* card 02 visual — per-appliance donut */
.hcard-viz .ew {
  display: flex;
  justify-content: center;
  width: 100%;
}

.hcard-viz .ew-donut {
  width: 116px;
  height: 116px;
}

.hcard-viz .ew-total {
  font-size: 20px;
}

.hcard-viz .ew-unit {
  font-size: 9.5px;
  margin-top: 1px;
}

.hcard-viz .ew-totlabel {
  font-size: 7.5px;
  margin-top: 2px;
}

.hcard-viz .ew-cached {
  position: absolute;
  top: -4px;
  right: 0;
  font-size: 9px;
  padding: 2px 6px;
}

/* card 03 visual — live host CPU/RAM/disk */
.hcard-viz .hostbar--mini {
  border: 0;
  background: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  width: 100%;
}

.hcard-viz .hostbar--mini .hb-metrics {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 0;
}

.hcard-viz .hostbar--mini .hb-k {
  width: 46px;
}

.hcard-viz .hostbar--mini .hb-v {
  min-width: 0;
  font-size: 10px;
}

.hcard-viz .hostbar--mini .hb-demo {
  position: absolute;
  top: -4px;
  right: 0;
}

.hcard-viz .hostbar--mini .hb-net {
  font-size: 10px;
  margin-top: 10px;
}

.hcard-viz .hostbar--mini .hb-donuts {
  margin-top: 0;
  justify-content: center;
  gap: 10px;
}


/* =============================================================================
   Home — About section
   ============================================================================= */
.about-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 44px;
  align-items: center;
  margin-top: 20px;
}

.about-grid h2 {
  max-width: 18ch;
}

.about-grid p {
  color: var(--ink-2);
  margin-top: 16px;
  text-wrap: pretty;
}

.portrait {
  aspect-ratio: 4/5;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(1.02);
}

/* =============================================================================
   Energy widget (home + NILM figure)
   ============================================================================= */
.ew {
  position: relative;
  text-align: left;
}

.ew-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 6px;
}

.ew-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ew-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.ew-title {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--ink);
}

.ew-sub {
  font-size: 14px;
  color: var(--ink-3);
  margin: 0;
  max-width: 50ch;
}

.ew-cached {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--warn-ink);
  border: 1px solid var(--warn-bd);
  background: var(--warn-bg);
  padding: 4px 9px;
  border-radius: 6px;
  white-space: nowrap;
  display: none;
}

.ew-body {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 36px;
  align-items: center;
  margin: 28px 0 10px;
}

.ew-donut {
  position: relative;
  width: 220px;
  height: 220px;
  flex: none;
}

.ew-donut svg {
  display: block;
  width: 100%;
  height: 100%;
}

.ew-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}

.ew-total {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.05;
}

.ew-unit {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 2px;
}

.ew-totlabel {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.lg-head {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.lg-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.lg-row {
  display: grid;
  grid-template-columns: 10px minmax(80px, 1fr) 1fr 56px 34px;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.lg-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.lg-name {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lg-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--bg-2);
  overflow: hidden;
}

.lg-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 1s cubic-bezier(.4, 0, .1, 1);
}

.ew-in .lg-fill {
  width: var(--w);
}

.lg-val {
  font-family: var(--font-mono);
  color: var(--ink-2);
  font-size: 12px;
  text-align: right;
}

.lg-pct {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 12px;
  text-align: right;
}

.ew-foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
  align-items: baseline;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.ew-privacy {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
}

.ew-privacy:nth-child(2) {
  text-align: center;
}

.ew-privacy:nth-child(3) {
  text-align: right;
}

.ew-cachednote {
  grid-column: 1 / -1;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.5;
  display: none;
}

/* three-act story: hairline separators between raw signal / breakdown / question */
.ew-rule {
  height: 1px;
  background: var(--line-soft);
  margin: 30px 0;
}

/* ── Act 1 · raw aggregate curve ────────────────────────────────────────── */
.ec-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.ec-step {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  padding-right: 2px;
}

.ec-readout {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.ec-now {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ec-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.ec-plot {
  margin: 16px 0 12px;
  border-bottom: 1px solid var(--line-soft);
}

.ec-svg {
  display: block;
  width: 100%;
  height: 150px;
  overflow: hidden;
}

.ec-scroll {
  will-change: transform;
}

.ec-line {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.ec-ready .ec-line {
  opacity: 1;
}

.ec-cap {
  font-size: 13.5px;
  color: var(--ink-3);
  margin: 0;
  line-height: 1.5;
}

/* ── Act 3 · the NILM question (bridge) ─────────────────────────────────── */
.eb-q {
  font-family: var(--font-head);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  margin: 14px 0 0;
  max-width: 58ch;
}

.eb-cta {
  margin-top: 20px;
}

@media (prefers-reduced-motion: reduce) {
  .ec-line {
    transition: none;
  }
}

/* loading state */
@keyframes ew-shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

@keyframes ew-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes ew-pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.22;
  }
}

.ew-spin-arc {
  display: none;
  transform-box: fill-box;
  transform-origin: center;
  transform: rotate(-90deg);
  stroke-linecap: round;
}

.ew-loading .ew-spin-arc {
  display: block;
  animation: ew-spin 1.1s linear infinite;
}

.ew-loading .ew-total {
  animation: ew-pulse 1.3s ease-in-out infinite;
  color: var(--ink-3);
}

.ew-loading .ew-unit,
.ew-loading .ew-totlabel {
  opacity: 0.35;
}

.lg-skel {
  display: block;
  background: linear-gradient(90deg,
      var(--line-soft) 25%,
      var(--line) 50%,
      var(--line-soft) 75%);
  background-size: 200% 100%;
  animation: ew-shimmer 1.4s ease infinite;
  border-radius: 3px;
}

.lg-skel-row {
  display: none;
}

.ew-loading .lg-skel-row {
  display: grid;
}

.ew-loading .lg-skel-row:nth-child(2) .lg-skel {
  animation-delay: 0.08s;
}

.ew-loading .lg-skel-row:nth-child(3) .lg-skel {
  animation-delay: 0.16s;
}

.ew-loading .lg-skel-row:nth-child(4) .lg-skel {
  animation-delay: 0.24s;
}

.ew-loading .lg-skel-row:nth-child(5) .lg-skel {
  animation-delay: 0.32s;
}

@media (prefers-reduced-motion: reduce) {

  .ew-spin-arc,
  .lg-skel,
  .ew-loading .ew-total {
    animation: none !important;
  }
}

/* =============================================================================
   Case study — page header
   ============================================================================= */
.cs-head {
  padding: 64px 0 0;
}

/* case-study header: live mini-visual left of the title; full-width when no visual */
.cs-head-row {
  display: grid;
  grid-template-columns: 188px 1fr;
  gap: 44px;
  align-items: center;
}

.cs-head-row:not(:has(.cs-viz)) {
  grid-template-columns: 1fr;
}

.cs-viz {
  align-self: center;
}

.cs-viz .hcard-viz {
  min-height: 0;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kicker::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--accent-dim);
}

.wip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--warn-ink);
  border: 1px solid var(--warn-bd);
  background: var(--warn-bg);
  padding: 3px 9px;
  border-radius: 100px;
  letter-spacing: 0.03em;
}

.cs-head h1 {
  font-size: clamp(40px, 6vw, 68px);
}

.cs-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  margin: 14px 0 0;
  letter-spacing: 0.02em;
}

.gh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
}

.gh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface);
}

.gh-ic {
  flex: none;
}

.gh-arr {
  color: var(--ink-3);
  font-size: 11px;
}

.gh-btn:hover .gh-arr {
  color: var(--accent);
}

.cs-summary {
  font-size: 20px;
  color: var(--ink-2);
  max-width: 54ch;
  margin: 22px 0 0;
  text-wrap: pretty;
  line-height: 1.55;
}

/* Meta grid */
.meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 38px 0 0;
  border-top: 1px solid var(--ink);
}

.meta .m {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.meta .mk {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.meta .mv {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink);
  margin-top: 6px;
}

/* Figure */
.figure {
  margin: 48px 0 0;
}

.figwrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #0e1014;
  box-shadow: 0 20px 50px oklch(0 0 0 / 0.14);
  cursor: zoom-in;
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

.figwrap:hover {
  box-shadow: 0 24px 64px oklch(0 0 0 / 0.22), 0 0 0 1px var(--accent-soft);
  border-color: oklch(0.56 0.115 202 / 0.35);
}

.figwrap img {
  width: 100%;
  display: block;
}

/* Lightbox */
#lb {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: oklch(0 0 0 / 0.88);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}

#lb.lb-open {
  opacity: 1;
  pointer-events: auto;
}

#lb img {
  max-width: min(92vw, 1440px);
  max-height: 90vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 40px 120px oklch(0 0 0 / 0.55);
  transform: scale(0.95);
  transition: transform 0.34s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: block;
}

#lb.lb-open img {
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {

  #lb,
  #lb img {
    transition: none;
  }
}

.figph {
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--bg-2);
  min-height: 280px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px;
}

.figph .pl {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-3);
  max-width: 34ch;
  line-height: 1.6;
}

.figph .pl b {
  display: block;
  color: var(--ink-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.figwidget {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 26px;
  box-shadow: 0 14px 40px oklch(0 0 0 / 0.08);
}

.figcap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 2px 0;
}

.figcap .fig {
  color: var(--accent);
}

/* Blocks */
.blk-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 36px;
  align-items: start;
}

.blk-h {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: sticky;
  top: 84px;
}

.prose--full {
  grid-column: 1 / -1;
}

.prose p {
  margin: 0 0 16px;
  color: var(--ink-2);
  max-width: 100%;
  text-wrap: pretty;
  line-height: 1.7;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color .2s;
}

.prose a:hover {
  border-bottom-color: var(--accent);
}

.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.prose.flag p:first-child {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
  max-width: 46ch;
}

/* Architecture diagram */
.arch {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 10px;
}

.arch .node {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 13px 16px;
  display: flex;
  align-items: center;
}

.arch .node.acc {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.arch .arr {
  display: flex;
  align-items: center;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 16px;
}

.arch-note {
  font-size: 14px;
  color: var(--ink-3);
  margin: 18px 0 0;
  max-width: 56ch;
  font-style: italic;
}

/* Checklist */
.wlist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wlist .row {
  padding: 18px 0;
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  gap: 6px;
}

.wlist .row:first-child {
  padding-top: 0;
}

.wlist .row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.wlist .rh {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.wlist .rh::before {
  content: "✓";
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 14px;
  flex: none;
}

.wlist--neg .rh::before {
  content: "✗";
  color: var(--neg);
}

.wlist .rp {
  color: var(--ink-2);
  font-size: 15.5px;
  max-width: 58ch;
  margin: 0;
  padding-left: 24px;
  line-height: 1.6;
}

/* Stats grid */
.statgrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.stat {
  background: var(--surface);
  padding: 26px 24px;
}

.stat .sv {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.05;
}

.stat .sl {
  font-size: 14px;
  color: var(--ink-2);
  margin-top: 8px;
  max-width: 30ch;
}

/* Screenshot block */
.cs-screenshot {
  margin: 0 0 1.5rem;
}

.cs-screenshot img {
  width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.cs-scap {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 10px;
  line-height: 1.5;
}

/* NILM widget footer */
.np-foot {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 14px 0 0;
}

/* Sources / references */
.src-section {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
}

.src-head {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 24px;
}

.src-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.src-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 0 12px;
  scroll-margin-top: 80px;
}

.src-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  padding-top: 2px;
  letter-spacing: 0;
}

.src-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.4;
}

a.src-name:hover {
  color: var(--accent);
}

a.src-name::after {
  content: " ↗";
  font-size: 11px;
  opacity: 0.65;
}

.src-note {
  grid-column: 2;
  margin: 5px 0 0;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.6;
  max-width: 66ch;
}

/* Bridge */
.bridge {
  background: var(--ink);
  color: oklch(0.94 0.01 78);
  border-radius: 16px;
  padding: 44px;
  margin-top: 8px;
}

.bridge .bh {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.bridge p {
  color: oklch(0.86 0.012 78);
  margin: 0 0 14px;
  max-width: 60ch;
  text-wrap: pretty;
  line-height: 1.65;
}

.bridge p:last-of-type {
  margin-bottom: 26px;
}

.bridge .cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 16px;
  background: var(--accent);
  color: #fff;
  padding: 13px 22px;
  border-radius: 10px;
  text-decoration: none;
  transition: transform .18s, box-shadow .18s;
}

.bridge .cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px oklch(0.56 0.115 202 / 0.4);
}

/* =============================================================================
   Contact page
   ============================================================================= */
.contact-about {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 56px;
  align-items: start;
  padding: 72px 0 0;
}

.contact-portrait {
  aspect-ratio: 4/5;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  position: sticky;
  top: 90px;
}

.contact-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.contact-name {
  font-size: clamp(38px, 5.5vw, 62px);
  color: var(--ink);
  margin-top: 16px;
}

.contact-role {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-3);
  margin: 14px 0 0;
  letter-spacing: 0.02em;
}

.contact-bio {
  margin-top: 26px;
}

.contact-bio p {
  color: var(--ink-2);
  font-size: 18px;
  margin: 0 0 18px;
  text-wrap: pretty;
  line-height: 1.7;
}

.contact-bio p:last-child {
  margin-bottom: 0;
}

.contact-section {
  padding: 56px 0 72px;
  border-top: 1px solid var(--line);
  margin-top: 56px;
}

.contact-section-head {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.contact-section-title {
  font-size: clamp(26px, 3.4vw, 38px);
  max-width: 20ch;
}

.contact-note {
  color: var(--ink-2);
  font-size: 17px;
  margin: 14px 0 0;
}

.contact-links {
  display: flex;
  flex-direction: column;
  margin-top: 32px;
  border-top: 1px solid var(--ink);
}

.lk {
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: background .16s, padding .16s;
}

.lk:hover {
  background: var(--surface);
  padding-left: 14px;
  padding-right: 14px;
}

.lkk {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lkv {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink);
}

.lkgo {
  font-family: var(--font-mono);
  color: var(--ink-3);
  transition: color .16s, transform .16s;
}

.lk:hover .lkgo {
  color: var(--accent);
  transform: translateX(4px);
}

.cv-cta {
  margin-top: 34px;
  display: inline-flex;
}

/* =============================================================================
   CV page
   ============================================================================= */
.cv-toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  background: oklch(0.965 0.009 78 / 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}

.cv-toolbar .spacer {
  margin-left: auto;
}

.cv-toolbar .back {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
}

.cv-toolbar .back:hover {
  color: var(--accent);
}

.printbtn {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  transition: transform .16s;
}

.printbtn:hover {
  transform: translateY(-1px);
}

.cv-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 34px 16px 60px;
  background: var(--bg);
}

.cv-sheet {
  width: 210mm;
  min-height: 297mm;
  background: oklch(0.995 0.004 78);
  padding: 14mm 16mm 10mm;
  box-shadow: 0 10px 40px oklch(0 0 0 / 0.16);
  position: relative;
  display: flex;
  flex-direction: column;
}

.cv-sheet::after {
  content: attr(data-page);
  position: absolute;
  bottom: 7mm;
  right: 16mm;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.cv-foot-id {
  position: absolute;
  bottom: 7mm;
  left: 16mm;
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

/* CV header */
.cvhead {
  padding-bottom: 13px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 16px;
}

.cvhead h1 {
  font-size: 30px;
  color: var(--ink);
}

.cvhead .cv-role {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
  margin-top: 6px;
  max-width: 62ch;
  line-height: 1.35;
}

.cvhead .cv-stack {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  margin-top: 8px;
  letter-spacing: 0.01em;
}

.cvhead .cv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
  margin-top: 11px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
}

.cvhead .cv-meta .it {
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
}

.cvhead .cv-meta .k {
  color: var(--ink-3);
  text-transform: uppercase;
  font-size: 8.5px;
  letter-spacing: 0.05em;
}

.cvhead .cv-meta a:hover {
  color: var(--accent);
}

.cv-avail {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 100px;
  padding: 4px 11px;
  margin-top: 11px;
}

.cv-avail .d {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.phone-print-only {
  display: none;
}

/* CV sections */
.cv-sec {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.cv-sec:first-of-type {
  border-top: 0;
  padding-top: 6px;
}

.cv-sec .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
  padding-top: 2px;
}

.cv-summary {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.55;
  text-wrap: pretty;
  margin: 0;
}

/* CV experience/project entries */
.cv-entry {
  margin-bottom: 12px;
}

.cv-entry:last-child {
  margin-bottom: 0;
}

.cv-entry .eh {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 14px;
}

.cv-entry .et {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.25;
}

.cv-entry .ed {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  white-space: nowrap;
  text-align: right;
}

.cv-entry .eo {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--accent-dim);
  margin-top: 3px;
}

.cv-entry ul {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.cv-entry li {
  font-size: 10.7px;
  color: var(--ink-2);
  line-height: 1.45;
  padding-left: 13px;
  margin-bottom: 3px;
  position: relative;
  text-wrap: pretty;
}

.cv-entry li:last-child {
  margin-bottom: 0;
}

.cv-entry li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 7px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent-dim);
}

/* CV repos */
.cv-repos {
  margin-top: 9px;
  border-top: 1px dashed var(--line);
  padding-top: 8px;
}

.cv-repos .rh {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.cv-repogrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 22px;
}

.cv-repo {
  font-size: 10px;
  color: var(--ink-2);
  line-height: 1.4;
}

.cv-repo b {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 9.5px;
  color: var(--ink);
}

/* CV education / honors */
.cv-compact .cv-entry {
  margin-bottom: 7px;
}

.cv-compact .ehd {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
  line-height: 1.22;
}

.cv-compact .eo {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--accent-dim);
  margin-top: 1px;
}

.cv-compact .desc {
  font-size: 10.3px;
  color: var(--ink-2);
  line-height: 1.4;
  margin-top: 2px;
  max-width: 64ch;
}

/* CV skills */
.cv-skills {
  display: flex;
  flex-direction: column;
}

.cv-skill {
  display: grid;
  grid-template-columns: 135px 1fr;
  gap: 14px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 10.5px;
}

.cv-skill:last-of-type {
  border-bottom: 0;
}

.cv-skill .sk {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.4;
}

.cv-skill .sv {
  color: var(--ink-2);
  line-height: 1.45;
}

.cv-langs {
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--ink-2);
}

.cv-langs b {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: block;
  margin-bottom: 2px;
}

@media print {
  @page {
    size: A4;
    margin: 0;
  }

  body {
    background: #fff;
  }

  .cv-toolbar {
    display: none;
  }

  .cv-stage {
    padding: 0;
    gap: 0;
    background: #fff;
  }

  .cv-sheet {
    box-shadow: none;
    width: auto;
    min-height: auto;
    height: 297mm;
    page-break-after: always;
  }

  .cv-sheet:last-child {
    page-break-after: auto;
  }

  .phone-print-only {
    display: inline;
  }
}

/* =============================================================================
   Responsive
   ============================================================================= */
@media (max-width: 820px) {
  .hero-cta {
    margin-bottom: 36px;
  }

  .ew-body {
    grid-template-columns: 1fr;
    gap: 26px;
  }

  .ew-donut {
    width: 180px;
    height: 180px;
    margin: 0 auto;
  }

  .ec-svg {
    height: 120px;
  }

  .eb-q {
    font-size: 16px;
  }

  .ew-foot {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .ew-privacy:nth-child(2),
  .ew-privacy:nth-child(3) {
    text-align: left;
  }

  .hcard {
    grid-template-columns: 30px 1fr;
    gap: 8px 18px;
    align-items: start;
    padding: 24px 6px;
  }

  .hcard-viz {
    grid-column: 1 / -1;
    order: 3;
    min-height: 0;
    margin-top: 14px;
  }

  .hcard-body {
    grid-column: 2;
  }

  .hcard .arrow {
    display: none;
  }

  .cs-head-row {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .cs-viz {
    max-width: 220px;
  }

  .wrow {
    grid-template-columns: auto 1fr;
    gap: 18px;
  }

  .wrow .arrow {
    display: none;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .meta {
    grid-template-columns: repeat(2, 1fr);
  }

  .blk-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .blk-h {
    position: static;
  }

  .statgrid {
    grid-template-columns: 1fr;
  }

  .bridge {
    padding: 28px;
  }

  .contact-about {
    grid-template-columns: 1fr;
    gap: 32px;
    padding-top: 48px;
  }

  .contact-portrait {
    position: static;
    max-width: 280px;
  }

  .lk {
    grid-template-columns: 100px 1fr auto;
  }

  .cv-sheet {
    width: 100%;
    min-height: 0;
    padding: 22px 18px 40px;
  }

  .cv-sec {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .cv-repogrid {
    grid-template-columns: 1fr;
  }

  .cv-skill {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  /* burger nav */
  .nav-toggle {
    display: flex;
  }

  .nav {
    position: fixed;
    top: 62px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-left: 0;
    padding: 16px 28px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.2s ease, opacity 0.2s ease, visibility 0.2s;
  }

  .nav.open {
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  .nav-link {
    font-size: 16px;
    padding: 10px 0;
    width: 100%;
  }

  .nav .cv-btn {
    margin-top: 6px;
  }

  .nav .lang {
    margin-top: 10px;
  }
}

/* =============================================================================
   NILM widget — Linkya scorecard (bar chart + stat chips + dot strip)
   ============================================================================= */
.np {
  position: relative;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.np-in {
  opacity: 1;
  transform: none;
}

.np-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 16px;
}

.np-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.np-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  text-transform: none;
  letter-spacing: 0;
}

.np-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.np-cached {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--warn-ink);
  border: 1px solid var(--warn-bd);
  background: var(--warn-bg);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* B. daily bar chart */
.np-history {
  margin-bottom: 14px;
}

.np-bars {
  display: block;
  width: 100%;
  height: 80px;
}

.np-bar--bg {
  fill: var(--accent);
  opacity: 0.12;
}

.np-bar {
  fill: var(--accent);
  opacity: 0.65;
}

.np-bar--zero {
  fill: var(--line);
  opacity: 1;
}

/* stat chips row */
.np-chips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 18px;
}

.np-chip {
  background: var(--surface);
  padding: 14px 16px;
}

.np-cv {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
}

.np-cl {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 5px;
}

/* C. cycle dot strip */
.np-cycle-wrap {
  margin-bottom: 6px;
}

.np-dotstrip {
  display: block;
  width: 100%;
  height: 60px;
}

.np-axis-tick {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.np-axis-lbl {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--ink-3);
}

.np-peak-band {
  fill: var(--accent);
  opacity: 0.08;
}

.np-dot {
  fill: var(--accent);
  opacity: 0.65;
}

.np-peak-note {
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 8px 0 0;
  line-height: 1.5;
}

@media (max-width: 640px) {
  .np-chips {
    grid-template-columns: repeat(2, 1fr);
  }

  .np-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Live host banner (homelab transparency) ───────────────────────────── */
.hostbar {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 0 0 0 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.hostbar.hb-on {
  opacity: 1;
  transform: none;
}

.hb-head {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.hb-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  animation: ew-pulse 1.8s ease-in-out infinite;
}

.hb-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}

.hb-demo {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--warn-ink);
  border: 1px solid var(--warn-bd);
  background: var(--warn-bg);
  padding: 2px 7px;
  border-radius: 6px;
}

.hb-spec {
  font-size: 10.5px;
  color: var(--ink-3);
  margin-left: auto;
}

.hb-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 14px 0 10px;
}

.hb-metric {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hb-k {
  font-size: 9.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: none;
  width: 34px;
}

.hb-track {
  position: relative;
  flex: 1 1 auto;
  height: 6px;
  background: oklch(0.93 0.008 78);
  border-radius: 999px;
  overflow: hidden;
}

.hb-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s ease;
}

.hb-v {
  font-size: 10.5px;
  color: var(--ink-2);
  white-space: nowrap;
  flex: none;
  min-width: 92px;
  text-align: right;
}

.hb-net {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.hb-rx,
.hb-tx {
  display: inline-block;
  min-width: 10ch;
  text-align: right;
}

.hb-pulse {
  flex: none;
  align-self: center;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.2;
}

.hb-pulse.hb-ping {
  animation: hb-ping 0.7s ease-out forwards;
}

@keyframes hb-ping {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 80%, transparent);
  }

  50% {
    opacity: 0.6;
    box-shadow: 0 0 0 5px color-mix(in oklch, var(--accent) 0%, transparent);
  }

  100% {
    opacity: 0.2;
    box-shadow: none;
  }
}

.hb-donuts {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.hb-donut {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hb-donut-svg {
  width: 40px;
  height: 40px;
}

.hb-donut-bg {
  fill: none;
  stroke: oklch(0.93 0.008 78);
  stroke-width: 5;
}

.hb-donut-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 20px 20px;
  transition: stroke-dasharray 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.hb-donuts--full {
  gap: 44px;
  margin: 24px 0 4px;
  justify-content: center;
}

.hb-donuts--full .hb-donut-svg {
  width: 80px;
  height: 80px;
}

.hb-donuts--full .hb-donut-bg,
.hb-donuts--full .hb-donut-arc {
  stroke-width: 8;
}

.hb-donuts--full .hb-donut-arc {
  transform-origin: 40px 40px;
}

.hb-donuts--full .hb-donut-pct {
  font-size: 14px;
}

.hb-donut-sub {
  font-size: 9.5px;
  color: var(--ink-3);
  margin-top: 2px;
  text-align: center;
}

.hb-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: oklch(0.88 0.01 78);
  border: 1px solid oklch(0.88 0.01 78);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 22px;
}

.hb-stat {
  background: var(--bg);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hb-stat-label {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hb-stat-val {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  min-width: 8ch;
  text-align: center;
}

.hb-stat .hb-rx,
.hb-stat .hb-tx {
  min-width: 0;
  text-align: center;
}

.hb-donut-pct {
  font-family: var(--font-mono);
  font-size: 8px;
  fill: var(--ink-2);
  text-anchor: middle;
  dominant-baseline: central;
}

.hb-donut-label {
  font-size: 9px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hb-note {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
  margin: 0;
  max-width: 64ch;
}

@media (max-width: 640px) {
  .hb-metrics {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .hb-spec {
    margin-left: 0;
    width: 100%;
  }
}