/* Layout concept: a calm, document-like portfolio (overview first, detail pages behind each card).
   Diagrams sit on a dotted "editor canvas" so architecture reads like a Unity node graph. */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f6f3;
  --panel: #ffffff;
  --panel-2: #f1f0ec;
  --canvas: #fbfbfa;
  --dot: #dddbd5;
  --line: #e7e5e0;
  --ink: #2a2926;
  --ink-2: #6f6d68;
  --agent: #2f5fd0;
  --agent-soft: #e4ebfb;
  --human: #b8650a;
  --human-soft: #fbeedb;
  --sys: #0f7b6c;
  --sys-soft: #ddf1ec;
  --wire: #a19e97;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #191919;
    --bg-soft: #202020;
    --panel: #202020;
    --panel-2: #2a2a29;
    --canvas: #1c1c1c;
    --dot: #343432;
    --line: #2f2f2e;
    --ink: #ebeae6;
    --ink-2: #9d9b96;
    --agent: #7ea0ff;
    --agent-soft: #1d2740;
    --human: #f0a540;
    --human-soft: #382a14;
    --sys: #4cc9b0;
    --sys-soft: #14302a;
    --wire: #5f5d58;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #191919;
  --bg-soft: #202020;
  --panel: #202020;
  --panel-2: #2a2a29;
  --canvas: #1c1c1c;
  --dot: #343432;
  --line: #2f2f2e;
  --ink: #ebeae6;
  --ink-2: #9d9b96;
  --agent: #7ea0ff;
  --agent-soft: #1d2740;
  --human: #f0a540;
  --human-soft: #382a14;
  --sys: #4cc9b0;
  --sys-soft: #14302a;
  --wire: #5f5d58;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15.5px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--agent); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.k { font: 500 10.5px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }

.page {
  max-width: 980px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* ---------- top bar ---------- */
nav.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
nav.bar .page { display: flex; align-items: center; gap: 16px; height: 48px; }
nav.bar .who { font: 700 14px var(--display); font-stretch: 110%; text-decoration: none; white-space: nowrap; }
nav.bar .links { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
nav.bar .links a { font-size: 13px; color: var(--ink-2); text-decoration: none; white-space: nowrap; padding: 5px 9px; border-radius: 6px; }
nav.bar .links a:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn { flex: none; width: 32px; height: 32px; border-radius: 7px; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: grid; place-items: center; }

/* ---------- cover + identity (overview) ---------- */
.cover {
  height: 168px; border-bottom: 1px solid var(--line);
  background-color: var(--canvas);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 18px 18px; position: relative; overflow: hidden;
}
.cover svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cover .w { fill: none; stroke: var(--wire); stroke-width: 1.4; opacity: .55; }
.cover .n { fill: var(--panel); stroke: var(--line); }
.cover .p { fill: var(--panel); stroke: var(--wire); stroke-width: 1.3; }
.avatar {
  width: 92px; height: 92px; border-radius: 18px; margin-top: -46px; position: relative;
  background: var(--ink); color: var(--bg); display: grid; place-items: center;
  font: 800 34px var(--display); font-stretch: 115%; box-shadow: 0 0 0 4px var(--bg);
}
h1.name { font: 800 clamp(34px, 6vw, 48px)/1.05 var(--display); font-stretch: 112%; letter-spacing: -.015em; margin: 18px 0 4px; text-wrap: balance; }
.role-line { color: var(--ink-2); font-size: 16px; margin: 0; }

/* ---------- generic blocks ---------- */
section.block { padding-block: 34px 6px; }
h2.sec { font: 700 22px/1.25 var(--display); font-stretch: 106%; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); text-wrap: balance; }
h3.sub { font: 700 17px/1.3 var(--display); font-stretch: 104%; margin: 30px 0 6px; }
p.lead { margin: 0 0 10px; max-width: 68ch; }
p.cap { margin: 0 0 14px; color: var(--ink-2); font-size: 14px; max-width: 70ch; }
.about p { margin: 0 0 6px; max-width: 68ch; }
.about b { font-weight: 600; }

.contact { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 500 13px var(--mono); text-decoration: none; cursor: pointer; }
.chipbtn:hover { background: var(--panel-2); }

/* overview block (detail pages) */
.overview { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.ov-facts { display: grid; align-content: start; border-right: 1px solid var(--line); }
.ov-facts > div { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 3px; }
.ov-facts > div:last-child { border-bottom: 0; }
.ov-facts b { font: 700 19px/1.2 var(--display); font-stretch: 106%; }
.ov-note { font-size: 13px; color: var(--ink-2); }
.ov-hl { padding: 14px 18px 12px; min-width: 0; }
.ov-hl ul { margin: 8px 0 0; padding-left: 18px; }
.ov-hl li { margin: 0 0 6px; }
@media (max-width: 720px) {
  .overview { grid-template-columns: 1fr; }
  .ov-facts { border-right: 0; border-bottom: 1px solid var(--line); grid-template-columns: 1fr 1fr; }
  .ov-facts > div { border-bottom: 0; border-right: 1px solid var(--line); }
  .ov-facts > div:last-child { border-right: 0; }
}
.builtwith { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.builtwith a { color: var(--agent); text-decoration: none; padding: 4px 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); }
.builtwith a:hover { border-color: var(--agent); }

/* package catalog */
.catalog { display: grid; gap: 8px; }
.catalog details { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.catalog summary { cursor: pointer; padding: 10px 14px; font-weight: 600; display: flex; justify-content: space-between; gap: 10px; }
.catalog summary span { font: 500 12px var(--mono); color: var(--ink-2); }
.catalog table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.catalog td { padding: 7px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.catalog td:first-child { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; width: 1%; }
.catalog td:last-child { color: var(--ink-2); }
@media (max-width: 560px) { .catalog td:first-child { white-space: normal; } }

/* project cards */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.cards.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards.c3 .thumb { aspect-ratio: 16 / 9; }
@media (max-width: 860px) { .cards.c3 { grid-template-columns: 1fr; } }
.card { display: grid; grid-template-rows: auto 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.08); transform: translateY(-1px); }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
.card.wide { grid-column: 1 / -1; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); grid-template-rows: auto; }
.thumb { aspect-ratio: 16 / 8; max-width: 100%; background: var(--bg-soft); border-bottom: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; }
.card.wide .thumb { aspect-ratio: auto; min-height: 210px; border-bottom: 0; border-right: 1px solid var(--line); }
.thumb img { width: 92px; height: 92px; border-radius: 22px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.thumb svg { width: 100%; height: 100%; }
.cbody { padding: 14px 16px 16px; display: grid; gap: 8px; align-content: start; }
.cbody h3 { margin: 0; font: 700 18px/1.25 var(--display); font-stretch: 104%; }
.cbody p { margin: 0; color: var(--ink-2); font-size: 14px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: 500 11.5px var(--mono); padding: 2px 8px; border-radius: 5px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.tag.lead { background: var(--human-soft); color: var(--human); }
.tag.core { background: var(--agent-soft); color: var(--agent); }
.tag.live { background: var(--sys-soft); color: var(--sys); }
.tag.mine { background: var(--ink); color: var(--bg); }
.more { font: 500 12.5px var(--mono); color: var(--agent); }
@media (max-width: 720px) {
  .cards { grid-template-columns: 1fr; }
  .card.wide { grid-template-columns: 1fr; }
  .card.wide .thumb { min-height: 170px; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* small cards (earlier work) */
.mini { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mini .card .thumb { aspect-ratio: 16 / 9; }
.mini .card .thumb img { width: 64px; height: 64px; border-radius: 15px; }
.mini .cbody { padding: 11px 12px 13px; gap: 6px; }
.mini .cbody h3 { font-size: 15px; }
.mini .cbody p { font-size: 13px; }
@media (max-width: 860px) { .mini { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* thumbnail SVG classes */
.t-n { fill: var(--panel); stroke: var(--line); stroke-width: 1.2; }
.t-a { fill: var(--agent-soft); stroke: var(--agent); stroke-width: 1.2; }
.t-h { fill: var(--human-soft); stroke: var(--human); stroke-width: 1.2; }
.t-s { fill: var(--sys-soft); stroke: var(--sys); stroke-width: 1.2; }
.t-i { fill: var(--ink); }
.t-g { fill: var(--panel-2); }
.t-w { fill: none; stroke: var(--wire); stroke-width: 1.4; }
.t-t { fill: var(--ink-2); font: 500 9px var(--mono); }

/* experience list */
.exp { display: grid; }
.exp-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.exp-row:last-child { border-bottom: 0; }
.exp-logo { width: 40px; height: 40px; border-radius: 9px; background: var(--panel-2); display: grid; place-items: center; font: 700 14px var(--display); color: var(--ink-2); }
.exp-row.now .exp-logo { background: var(--ink); color: var(--bg); }
.exp-main b { display: block; font-weight: 600; }
.exp-main span { font-size: 13.5px; color: var(--ink-2); }
.exp-when { text-align: right; font: 500 12.5px var(--mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.exp-when b { display: block; color: var(--ink); font-weight: 500; }
@media (max-width: 560px) { .exp-row { grid-template-columns: 34px minmax(0, 1fr); } .exp-logo { width: 34px; height: 34px; } .exp-when { grid-column: 2; text-align: left; } }

/* skills */
.skills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px 26px; }
.skills h4 { margin: 0 0 8px; font: 600 13.5px var(--sans); }
.skills ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.skills li { font-size: 13px; padding: 3px 9px; border-radius: 6px; background: var(--panel-2); }
@media (max-width: 760px) { .skills { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .skills { grid-template-columns: 1fr; } }

/* ---------- detail page ---------- */
.crumb { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink-2); padding-top: 22px; }
.crumb a { text-decoration: none; color: var(--ink-2); }
.crumb a:hover { color: var(--ink); }
.dhead { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: center; margin: 18px 0 10px; }
.dicon { width: 76px; height: 76px; border-radius: 18px; overflow: hidden; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 800 26px var(--display); }
.dicon img { width: 100%; height: 100%; }
.dicon svg { width: 46px; height: 46px; }
.dhead h1 { margin: 0; font: 800 clamp(28px, 5vw, 40px)/1.08 var(--display); font-stretch: 110%; letter-spacing: -.01em; text-wrap: balance; }
.dhead p { margin: 4px 0 0; color: var(--ink-2); }
.props { display: grid; grid-template-columns: 130px minmax(0, 1fr); margin: 14px 0 6px; font-size: 14.5px; }
.props > div { padding: 6px 0; min-width: 0; }
.props .pk { color: var(--ink-2); font-size: 13.5px; }
.props .pv a { color: var(--agent); }
@media (max-width: 520px) { .props { grid-template-columns: 104px minmax(0, 1fr); } }
ul.points { margin: 0; padding-left: 20px; max-width: 74ch; }
ul.points li { margin: 0 0 6px; }
ul.points b { font-weight: 600; }
.feat { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.feat > div { border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; background: var(--panel); min-width: 0; }
.feat b { display: block; font-size: 14px; font-weight: 600; }
.feat span { font-size: 13px; color: var(--ink-2); }
@media (max-width: 760px) { .feat { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .feat { grid-template-columns: 1fr; } }
.next { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); }
.next a { text-decoration: none; display: grid; gap: 2px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 9px; min-width: 200px; }
.next a:hover { background: var(--panel-2); }
.next a span { font-size: 12px; color: var(--ink-2); }
.next a b { font-weight: 600; }
.next a.fwd { text-align: right; margin-left: auto; }
.linkcard { display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; text-decoration: none; background: var(--bg-soft); margin-top: 14px; }
.linkcard:hover { border-color: var(--agent); }
.linkcard b { display: block; }
.linkcard span { color: var(--ink-2); font-size: 13.5px; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0 0 10px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 6px; border: 1.5px solid; }
.legend .h { border-color: var(--human); background: var(--human-soft); }
.legend .a { border-color: var(--agent); background: var(--agent-soft); }
.legend .s { border-color: var(--sys); background: var(--sys-soft); }
.legend .m { border-color: var(--ink); background: var(--ink); }

/* ---------- canvas, nodes, wires ---------- */
.canvas { background-color: var(--canvas); background-image: radial-gradient(var(--dot) 1px, transparent 1.2px); background-size: 18px 18px; border: 1px solid var(--line); border-radius: 12px; }
.scroll { overflow-x: auto; }
.graph { position: relative; }
svg.wires { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; overflow: visible; }
svg.wires path { fill: none; stroke: var(--wire); stroke-width: 1.6; }
svg.wires path.dash { stroke-dasharray: 4 4; }
svg.wires path.hot { stroke: var(--agent); stroke-width: 2; }
svg.wires circle { fill: var(--panel); stroke: var(--wire); stroke-width: 1.5; }
svg.wires circle.hot { stroke: var(--agent); }

.node { --c: var(--wire); position: relative; z-index: 1; display: grid; gap: 2px; text-align: left; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: inset 0 3px 0 var(--c), 0 1px 2px rgba(0,0,0,.04); padding: 10px 11px 9px; font: inherit; font-size: 13px; line-height: 1.35; min-width: 0; }
button.node { cursor: pointer; }
button.node:hover { border-color: var(--c); }
button.node[aria-pressed="true"] { border-color: var(--c); outline: 2px solid color-mix(in srgb, var(--c) 30%, transparent); }
.node b { font-weight: 600; font-size: 13.5px; }
.node .s { color: var(--ink-2); font-size: 12px; }
.node.human { --c: var(--human); background: var(--human-soft); border-color: color-mix(in srgb, var(--human) 40%, var(--line)); }
.node.agent { --c: var(--agent); }
.node.sys { --c: var(--sys); }
.node.stub { border-style: dashed; box-shadow: none; background: transparent; }
.node .mine { position: absolute; top: -8px; right: 8px; padding: 1px 6px; border-radius: 4px; background: var(--ink); color: var(--bg); font: 600 9.5px/1.5 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.node.big { padding: 15px 15px 13px; }
.node.big b { font-family: var(--display); font-stretch: 106%; font-size: 17px; }
.node.code b { font-family: var(--mono); font-size: 12.5px; }

.swim { display: grid; position: relative; }
.lane-bg { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.lane-bg:first-child { border-top: 0; }
.lane-label { z-index: 1; align-self: center; padding: 0 12px; font: 600 10.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.lane-label.human { color: var(--human); }
.lane-label.agent { color: var(--agent); }
.lane-label.sys { color: var(--sys); }
.swim .node { margin: 14px 8px; align-self: center; }

.insp { margin-top: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; display: grid; gap: 4px; min-height: 82px; }
.insp .t { font-weight: 600; font-size: 15px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.insp p { margin: 0; color: var(--ink-2); max-width: 80ch; }

/* column graph (inspector graphs) */
.cgraph { display: grid; column-gap: 64px; row-gap: 30px; padding: 24px; align-items: center; }
.ccol { display: grid; gap: 10px; align-content: center; min-width: 0; }
.cgraph.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cgraph.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 48px; min-width: 900px; }
.cgraph.wide { min-width: 760px; }
.cfoot { grid-column: 1 / -1; display: grid; gap: 10px; }
.cfoot .row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 760px) {
  .cgraph.stack-sm { grid-template-columns: 1fr; row-gap: 20px; padding: 16px; }
  .cgraph.stack-sm svg.wires { display: none; }
  .cfoot .row { grid-template-columns: 1fr 1fr; }
}

/* phase board (state lists) */
.phases { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: 12px; padding: 16px; }
.phase { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; min-width: 0; }
.phase h4 { margin: 0 0 8px; font: 600 13px var(--sans); display: flex; justify-content: space-between; gap: 8px; }
.phase h4 span { font: 500 11px var(--mono); color: var(--ink-2); }
.phase .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.pkg { font: 500 11.5px var(--mono); padding: 3px 7px; border-radius: 5px; background: var(--panel-2); color: var(--ink); }
.pkg.mine { background: var(--ink); color: var(--bg); }
.pkg.dec { background: var(--human-soft); color: var(--human); }
.pkg.mem { background: var(--sys-soft); color: var(--sys); }
@media (max-width: 760px) { .phases { grid-template-columns: 1fr; } }

/* layer stack */
.stack { display: grid; gap: 6px; padding: 16px; }
.lyr { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.lyr .name { display: grid; gap: 1px; }
.lyr .name .lv { font: 600 12px var(--mono); color: var(--agent); }
.lyr .name b { font-size: 13.5px; }
.lyr .pkgs { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.stack-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 16px 14px; font: 500 12px var(--mono); color: var(--ink-2); }
@media (max-width: 700px) { .lyr { grid-template-columns: 1fr; gap: 8px; } }

/* lessons */
.lessons { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.lesson { display: grid; grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1fr); gap: 10px; align-items: start; padding: 11px 0; border-top: 1px solid var(--line); font-size: 14px; }
.lesson .before { color: var(--ink-2); }
.lesson .arrow { color: var(--wire); font-family: var(--mono); text-align: center; }
.lesson .after { font-weight: 500; }
.lesson code { font-family: var(--mono); font-size: 12.5px; }
@media (max-width: 760px) { .lessons { grid-template-columns: 1fr; } }

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.two > div { min-width: 0; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }

footer.foot { margin-top: 56px; border-top: 1px solid var(--line); padding-block: 22px 44px; color: var(--ink-2); font-size: 13px; }
