/* Tokens copied from kushshriv.github.io so both sites read as one. */
:root {
  color-scheme: light;
  --bg: #edf6f9; --fg: #1f4450; --muted: #4c7078;
  --card: #e0efed; --line: #b8d5d2; --accent: #2b7068;
  --hover: #d1e7e2; --focus: #246e85; --ok: #2b7068; --warn: #8a5a12;
  --exec: #6d5a96;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c303b; --fg: #dfefef; --muted: #a6c2c4;
  --card: #29454d; --line: #45666c; --accent: #9bd0bd;
  --hover: #34565b; --focus: #9acbdf; --ok: #9bd0bd; --warn: #e6c27a;
  --exec: #c4b2ea;
}
html { --wrap: 860px; --hand: "Architects Daughter", "Segoe Print", "Comic Sans MS", cursive; }
@media (min-width: 1000px) { html { --wrap: 1080px; } }
@media (min-width: 1500px) { html { --wrap: 1280px; } }
* { box-sizing: border-box; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--focus); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
code { font: .88em/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.muted { color: var(--muted); }

/* Header (same as portfolio) */
header.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: var(--wrap); margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 16px; }
.app-mode .top-in { max-width: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--fg); text-decoration: none; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; }
.brand .l1 { fill: var(--accent); }
.brand .l2, .brand .l3 { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.brand .l3 { opacity: .55; }
.repo { display: flex; align-items: center; gap: 10px; min-width: 0; }
.repo .sep { color: var(--line); font-size: 20px; }
.repo a { color: var(--fg); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo a[href]:hover { text-decoration: underline; text-underline-offset: 3px; }
.top-in nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.top-in nav a { color: var(--muted); text-decoration: none; padding: 8px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.top-in nav a:hover { background: var(--hover); color: var(--fg); }
.theme-control { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.theme-control label { position: relative; cursor: pointer; }
.theme-control input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.theme-control span { display: grid; place-items: center; min-height: 32px; min-width: 32px; border-radius: 7px; color: var(--accent); }
.theme-control input:checked + span { background: var(--accent); color: var(--bg); }
.theme-control input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.status { font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.status.high, .status.active { color: var(--ok); }
.status.med, .status.legacy { color: var(--warn); }
.status.low { color: #b3412f; }
.status.alternative, .status.unknown { color: var(--muted); }

/* Shared pieces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--fg); text-decoration: none; font-weight: 500; font-size: 15px; transition: transform .15s, border-color .15s; cursor: pointer; }
.btn:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.sm { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tag { font-size: 11px; padding: 0 7px; line-height: 1.6; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
h2 { font-size: 28px; letter-spacing: -.01em; font-weight: 700; line-height: 1.2; margin-bottom: 12px; }
h3 { font-size: 19px; font-weight: 650; line-height: 1.35; }

/* Landing */
.landing { max-width: var(--wrap); width: 100%; margin: 0 auto; padding: 0 16px 64px; }
.landing section { padding-top: 28px; }
.hero { padding-top: 56px !important; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 14px; }
.hero h1 { font-size: clamp(28px, 6vw, 40px); letter-spacing: -.02em; line-height: 1.15; margin-top: 6px; }
.hero .lede { max-width: 60ch; margin-top: 14px; font-size: 17px; }
.gcard { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--fg); transition: transform .15s, border-color .15s, background .15s; }
.gcard:hover { transform: translateY(-2px); border-color: var(--accent); background: var(--hover); }
.gcard .sketch { height: 170px; margin: -6px -6px 6px; border-radius: 10px; background: var(--bg); border: 1px dashed var(--line); display: grid; place-items: center; overflow: hidden; }
.gcard .sketch svg { width: 100%; height: 100%; }
.gcard p { color: var(--muted); font-size: 15px; }
.gcard .go { margin-top: auto; padding-top: 8px; color: var(--accent); font-weight: 600; font-size: 14px; }
.drop { transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--hover); }
.paste { margin-top: 12px; display: grid; gap: 8px; }
.paste textarea { min-height: 150px; font: 12px/1.45 ui-monospace, Menlo, monospace; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.paste .btn { justify-self: start; }
.err { color: #b3412f; margin-top: 12px; white-space: pre-wrap; font-size: 14px; }
.how { list-style: none; padding: 0; margin-top: 18px; display: grid; gap: 10px; color: var(--muted); }
.how li { display: flex; gap: 12px; align-items: center; }
.how span { width: 26px; height: 26px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; font: 600 13px/1 system-ui; color: var(--accent); }
footer { max-width: var(--wrap); width: 100%; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); }
.app-mode footer { display: none; }

/* App */
.app { flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.levels { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow-x: auto; scrollbar-width: none; }
.levels button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.levels button b { color: var(--accent); font-weight: 650; margin-right: 2px; }
.levels button:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.levels button.on { background: var(--accent); color: var(--bg); }
.levels button.on b { color: var(--bg); }
.levels button:disabled { opacity: .4; cursor: not-allowed; }
.actions { display: flex; gap: 8px; margin-left: auto; }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr); gap: 12px; height: calc(100vh - 130px); min-height: 460px; }
.work > * { min-height: 0; }
.stage { position: relative; padding: 0; overflow: auto; min-width: 0; background: var(--bg); }
.panel { overflow: auto; }
.view { min-height: 100%; }
@media (max-width: 900px) {
  .work { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; }
  .stage { height: 64vh; min-height: 420px; }
  .top-in nav { display: none; }
  .actions { margin-left: 0; }
}

/* Drawings */
.graph { position: absolute; inset: 0; }
.canvas { position: absolute; inset: 0; }
svg.draw { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; }
svg.draw.panning { cursor: grabbing; }
svg.draw.still { pointer-events: none; cursor: inherit; }
svg.draw .node, svg.draw .edge, svg.draw .cluster .hit { cursor: pointer; transition: opacity .2s; }
svg.draw .dim { opacity: .18; }
svg.draw .node.sel path:first-of-type { stroke-width: 2.6; }
svg.draw .node:focus, svg.draw .node:focus-visible { outline: none; }
svg.draw .node:focus-visible path:first-of-type { stroke: var(--focus); stroke-width: 2.6; }
.zoom { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--accent); font-size: 18px; line-height: 1; }
.zoom button:hover { border-color: var(--accent); background: var(--hover); }
.legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; max-width: calc(100% - 24px); padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--card) 92%, transparent); font: 14px/1.4 var(--hand); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 4px; }

/* L0 */
.l0 { padding: 28px clamp(16px, 4vw, 40px) 40px; max-width: 980px; }
.l0 .shape { font: clamp(22px, 2.8vw, 30px)/1.3 var(--hand); margin-bottom: 14px; }
.l0 .summary { max-width: 70ch; margin-bottom: 18px; }
.l0 .tags { margin: 0 0 24px; }
.l0 .tag { font-size: 13px; padding: 1px 10px; }
.l0 .grid2 h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.l0 ul { list-style: none; padding: 0; display: grid; gap: 10px; }
.langbar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; margin-bottom: 12px; background: var(--bg); border: 1px solid var(--line); }
.langbar i { display: block; }
.legend-row { display: flex; gap: 8px; align-items: center; font-size: 15px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

/* Flows + dives */
.flows, .dives { padding: 16px clamp(12px, 3vw, 28px) 28px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 1px solid var(--line); background: var(--card); padding: 6px 14px; border-radius: 10px; font-size: 14px; color: var(--fg); }
.tabs button:hover { border-color: var(--accent); background: var(--hover); }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.seq { overflow-x: auto; padding-bottom: 4px; }
.seq svg.draw { width: auto; height: auto; cursor: default; touch-action: auto; }
.steps-wrap { margin-top: 14px; }
.steps-wrap summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.steps { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.steps th, .steps td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.steps th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.steps td.n { color: var(--accent); font-weight: 650; width: 28px; }
.md { max-width: 820px; line-height: 1.65; }
.md h1, .md h2, .md h3 { font-family: var(--hand); font-weight: 400; margin: 20px 0 8px; letter-spacing: 0; }
.md h2 { font-size: 24px; } .md h3 { font-size: 20px; }
.md p, .md ul, .md table { margin-bottom: 12px; }
.md ul { padding-left: 20px; }
.md table { border-collapse: collapse; font-size: 14px; }
.md td, .md th { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.md pre { background: var(--card); padding: 12px; border-radius: 10px; overflow-x: auto; }
.missing { display: grid; place-items: center; padding: 48px 16px; text-align: center; }
.missing h2 { font: 26px var(--hand); }
.missing code { display: inline-block; margin-top: 10px; }

/* Panel */
.panel h2 { font: 24px/1.25 var(--hand); margin: 6px 0 6px; letter-spacing: 0; }
.panel h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
.panel p { margin-bottom: 8px; }
.panel ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.panel ul.plain { list-style: none; padding: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; margin-top: 10px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.ev { font: 12.5px/1.45 ui-monospace, Menlo, monospace; overflow-wrap: anywhere; }
.inferred { color: var(--warn); font-size: 13px; font-weight: 600; }
.linkrow { display: flex; gap: 6px; align-items: baseline; font-size: 14px; }
.panel .tag { white-space: nowrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 10px; font-size: 14px; z-index: 20; }
@media (prefers-reduced-motion: reduce) { .btn, .gcard, svg.draw .node { transition: none; } .btn:hover, .gcard:hover { transform: none; } }
@media (max-width: 600px) { .legend { font-size: 12px; gap: 2px 10px; padding: 4px 8px; } .legend svg { width: 22px; height: 14px; } }
.small { font-size: 13px; line-height: 1.5; }
