/* ==========================================================================
   modern.css — v2 design layer, loaded after style.css.
   Design system: tokens per mode (light/dark) × accent (earth/ocean/slate/violet).
   style.css keeps every component layout; this file re-skins it: glass surfaces,
   bento cards, gradients, motion, the theme switcher, mobile menu and new graphics.
   ========================================================================== */
:root {
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 18px; --r-lg: 26px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --on-accent: #fff;
}
/* ---------- accents (light values) ---------- */
[data-accent="earth"]  { --purple: #a8510c; --purple-ink: #8a3f06; --accent-2: #4d7c0f; --accent-3: #c2410c; --glow: 217, 119, 6; }
[data-accent="ocean"]  { --purple: #0b6e8a; --purple-ink: #075a72; --accent-2: #1d4ed8; --accent-3: #0d9488; --glow: 14, 165, 233; }
[data-accent="slate"]  { --purple: #475569; --purple-ink: #334155; --accent-2: #0f766e; --accent-3: #64748b; --glow: 100, 116, 139; }
[data-accent="violet"] { --purple: #6a3fd8; --purple-ink: #5531c2; --accent-2: #c2478f; --accent-3: #3b82c4; --glow: 124, 77, 255; }

/* ---------- light mode ---------- */
[data-mode="light"] {
  --bg: #f6f4ef; --bg-2: #ebe7de; --surface: #ffffff; --ink: #14161c; --muted: #575c68; --line: #dfdad0;
  --glass: rgba(255, 255, 255, .66); --glass-brd: rgba(20, 22, 28, .08);
  --purple-soft: color-mix(in srgb, var(--purple) 14%, #fff); --purple-tint: color-mix(in srgb, var(--purple) 6%, #fff);
  --input-ink: #0000d6; --hatch: rgba(20, 22, 28, .28);
  --shadow: 0 1px 2px rgba(20, 22, 28, .04), 0 10px 30px -8px rgba(20, 22, 28, .10);
  --shadow-lg: 0 2px 6px rgba(20, 22, 28, .06), 0 30px 60px -12px rgba(20, 22, 28, .18);
  --mesh-a: rgba(var(--glow), .16); --mesh-b: color-mix(in srgb, var(--accent-2) 12%, transparent);
  color-scheme: light;
}
/* ---------- dark mode ---------- */
[data-mode="dark"] {
  --bg: #0b1016; --bg-2: #151c25; --surface: #121922; --ink: #e9edf2; --muted: #a3adbb; --line: #253041;
  --glass: rgba(18, 25, 34, .62); --glass-brd: rgba(255, 255, 255, .08);
  --purple-soft: color-mix(in srgb, var(--purple) 30%, #0b1016); --purple-tint: color-mix(in srgb, var(--purple) 14%, #0b1016);
  --input-ink: #8ab4ff; --hatch: rgba(0, 0, 0, .35);
  --fill: #b97a8e; --sand: #c5a45c; --silt: #5f9c8d; --clay: #8c7bc8; --gravel: #c27d58; --peat: #9b7f63; --rock: #7d8399;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -10px rgba(0, 0, 0, .55);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .35), 0 30px 70px -10px rgba(0, 0, 0, .7);
  --mesh-a: rgba(var(--glow), .22); --mesh-b: color-mix(in srgb, var(--accent-2) 20%, transparent);
  color-scheme: dark;
}
[data-mode="dark"][data-accent="earth"]  { --purple-ink: #f6b26b; }
[data-mode="dark"][data-accent="ocean"]  { --purple-ink: #67d3f0; }
[data-mode="dark"][data-accent="slate"]  { --purple: #5b6b82; --purple-ink: #c3cede; }
[data-mode="dark"][data-accent="violet"] { --purple-ink: #b9a2ff; }
/* headings & numbers that used --purple as text colour need the readable ink in dark mode */
[data-mode="dark"] .hero h1 span, [data-mode="dark"] .stat b, [data-mode="dark"] .panel .big-num { color: var(--purple-ink); }

/* smooth theme transition (only while switching, so normal interaction stays snappy) */
.theme-anim, .theme-anim *, .theme-anim *::before, .theme-anim *::after {
  transition: background-color .4s var(--ease), color .4s var(--ease), border-color .4s var(--ease), fill .4s, stroke .4s, box-shadow .4s !important;
}

/* ---------- base ---------- */
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--mesh-a), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, var(--mesh-b), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  font-feature-settings: "cv11", "ss01";
}
body::before { /* faint survey grid */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 70%);
}
::selection { background: var(--purple); color: #fff; }
h1, h2, h3, h4 { letter-spacing: -.025em; }
.wrap { max-width: 1200px; }
:focus-visible { outline: 3px solid var(--purple-ink); outline-offset: 3px; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--purple); color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 600; text-decoration: none; transition: top .2s; }
.skip:focus { top: 12px; }
.eyebrow { color: var(--purple-ink); font-weight: 600; letter-spacing: .16em; }
.sec-head .eyebrow::before, .lib-hero > .eyebrow::before { content: ""; display: inline-block; width: 22px; height: 2px; margin-right: 10px; vertical-align: middle; background: linear-gradient(90deg, var(--purple), var(--accent-2)); border-radius: 2px; }
.sec-head h2, .lib-hero h1 { background: linear-gradient(100deg, var(--ink) 30%, color-mix(in srgb, var(--purple-ink) 85%, var(--ink))); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: .06em; }
.sec-head p, .lib-hero p { color: var(--muted); }

/* ---------- glass navbar ---------- */
.nav { background: var(--glass); backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px); border-bottom: 1px solid var(--glass-brd); }
.nav .wrap { padding-block: 10px; }
.brand { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
.brand img { transition: transform .5s var(--ease); }
.brand:hover img { transform: rotate(-8deg) scale(1.08); }
.nav-links a { position: relative; color: var(--muted); font-weight: 500; }
.nav-links a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav-links a.on, .nav-links a[aria-current="page"] { color: var(--purple-ink); background: var(--purple-soft); }
.depth { background: var(--glass); border: 1px solid var(--glass-brd); box-shadow: none; }
.gauge { background: transparent; height: 3px; }
.gauge i { background: linear-gradient(90deg, var(--purple), var(--accent-2), var(--accent-3)); box-shadow: 0 0 12px rgba(var(--glow), .6); }
.nav-tools { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--glass-brd); background: var(--glass); color: var(--ink); cursor: pointer; transition: transform .2s var(--ease), background .2s; }
.icon-btn:hover { transform: translateY(-1px); background: var(--purple-soft); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
/* theme popover */
.theme-pop { position: absolute; right: clamp(16px, 4vw, 40px); top: calc(100% + 8px); width: 270px; padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--glass-brd); box-shadow: var(--shadow-lg); display: grid; gap: 12px; z-index: 40; transform-origin: top right; animation: pop .22s var(--ease); }
.theme-pop[hidden] { display: none; }
.theme-pop h4 { font: 600 .7rem/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.mode-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 14px; background: var(--bg-2); }
.mode-seg button { display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; padding: 9px; border-radius: 10px; background: transparent; color: var(--muted); font: 600 .84rem var(--font-body); cursor: pointer; }
.mode-seg button svg { width: 16px; height: 16px; }
.mode-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatches button { display: grid; gap: 6px; justify-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 9px 4px 7px; background: transparent; color: var(--muted); font: 600 .7rem var(--font-body); cursor: pointer; }
.swatches button i { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.swatches button[aria-pressed="true"] { border-color: var(--purple); color: var(--ink); background: var(--purple-tint); }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-6px); } }

@media (max-width: 860px) {
  .menu-btn { display: inline-grid; }
  .nav-links { position: fixed; inset: 62px 12px auto 12px; flex-direction: column; align-items: stretch; gap: 4px; padding: 12px; border-radius: 22px; background: var(--surface); border: 1px solid var(--glass-brd); box-shadow: var(--shadow-lg); transform: translateY(-12px) scale(.98); opacity: 0; visibility: hidden; transition: all .25s var(--ease); max-height: calc(100vh - 90px); overflow: auto; }
  .nav-links li.opt { display: block; }
  .nav-links a { display: block; padding: 13px 16px; font-size: 1rem; border-radius: 14px; }
  .nav.open .nav-links { transform: none; opacity: 1; visibility: visible; }
}

/* ---------- buttons & chips ---------- */
.btn { border-radius: 14px; padding: 12px 20px; background: var(--glass); border-color: var(--glass-brd); backdrop-filter: blur(8px); transition: transform .25s var(--ease), box-shadow .25s, background .2s, border-color .2s; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn.primary { background: linear-gradient(135deg, var(--purple), color-mix(in srgb, var(--purple) 70%, var(--accent-2))); border-color: transparent; box-shadow: 0 8px 24px -8px rgba(var(--glow), .7); }
.btn.primary:hover { box-shadow: 0 14px 30px -8px rgba(var(--glow), .85); background: linear-gradient(135deg, var(--purple-ink), var(--purple)); }
[data-mode="dark"] .btn.primary:hover { background: linear-gradient(135deg, var(--purple), color-mix(in srgb, var(--purple) 55%, #000)); }
.chip { border-radius: 12px; background: var(--glass); border-color: var(--glass-brd); transition: all .2s var(--ease); }
.chip:hover { border-color: var(--purple); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--purple); border-color: var(--purple); color: #fff; box-shadow: 0 6px 18px -6px rgba(var(--glow), .7); }
.seg { border-radius: 14px; background: var(--bg-2); }
.seg button { border-radius: 10px; }
.tag { background: var(--purple-tint); border: 1px solid color-mix(in srgb, var(--purple) 18%, transparent); }
.search { border-radius: 14px !important; background: var(--glass) !important; border: 1px solid var(--glass-brd) !important; color: var(--ink); transition: box-shadow .2s, border-color .2s; }
.search:focus { outline: none; border-color: var(--purple) !important; box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 22%, transparent); }

/* ---------- glass / bento surfaces ---------- */
.stat, .panel, .pcard, .card, .bh-log, .bh-panel, .picker, .post, .slide, .cap, .toolcard, .note, .teaser, .sk-out, .cline, .cpt, .lib-sec, .wb, .split, .est-side, .tool-grid > *, .docs > * {
  background: var(--glass); border: 1px solid var(--glass-brd); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
}
.panel, .pcard, .card, .bh-log, .bh-panel, .picker, .teaser, .cpt, .post { border-radius: var(--r-lg); }
.card, .pcard, .toolcard, .slide, .note, .post, .stat, .cap, .wb { transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s; }
.card:hover, .pcard:hover, .toolcard:hover, .slide:hover, .note:hover, .post:hover, .wb:hover { box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--purple) 40%, transparent); }
.tilt { transform-style: preserve-3d; will-change: transform; }
.tilt::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(var(--glow), .12), transparent 45%); opacity: 0; transition: opacity .3s; }
.tilt:hover::after { opacity: 1; }
.stat, .toolcard, .cap, .slide, .wb, .note, .post { position: relative; }

/* ---------- hero ---------- */
.hero { position: relative; isolation: isolate; }
.hero-canvas { position: absolute; inset: -40px calc(-50vw + 50%) 0; width: 100vw; height: calc(100% + 40px); z-index: -1; pointer-events: none; opacity: .9; mask-image: linear-gradient(#000 60%, transparent); }
.hero h1 { font-weight: 700; letter-spacing: -.045em; }
.hero h1 span { background: linear-gradient(110deg, var(--purple-ink), var(--accent-2) 60%, var(--accent-3)); -webkit-background-clip: text; background-clip: text; color: transparent !important; background-size: 200% 100%; animation: shimmer 8s ease-in-out infinite alternate; }
@keyframes shimmer { to { background-position: 100% 0; } }
.hero .role { font-family: var(--font-display); font-weight: 600; }
.status { background: var(--glass); border: 1px solid var(--glass-brd); backdrop-filter: blur(10px); }
.cpt { box-shadow: var(--shadow-lg); }
.hero > div:first-child > * { animation: rise .8s var(--ease) both; }
.hero > div:first-child > *:nth-child(2) { animation-delay: .08s; } .hero > div:first-child > *:nth-child(3) { animation-delay: .16s; }
.hero > div:first-child > *:nth-child(4) { animation-delay: .24s; } .hero > div:first-child > *:nth-child(5) { animation-delay: .32s; }
.hero .cpt { animation: rise 1s .2s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }

/* stats: bento */
.stats { gap: 14px; }
.stat { border-radius: 22px; padding: 22px 22px 20px; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--purple), var(--accent-2)); opacity: .85; }
.stat b { font-family: var(--font-display); font-weight: 700; letter-spacing: -.03em; }
.stat .st-ic { position: absolute; right: 14px; top: 14px; width: 30px; height: 30px; color: var(--purple-ink); opacity: .35; }

/* ---------- strata divider ---------- */
.strata-div { display: block; width: 100%; height: 44px; margin: 8px 0 -8px; opacity: .9; }
.strata-div path { transition: d .6s; }

/* ---------- contact ---------- */
.contact .lead { background: linear-gradient(140deg, var(--purple), color-mix(in srgb, var(--purple) 60%, var(--accent-2)) 70%, var(--accent-3)); box-shadow: 0 30px 60px -20px rgba(var(--glow), .6); }
.contact .lead .btn { color: #1a1a1a; background: #fff; }
.contact .lead p { color: rgba(255,255,255,.92); }
[data-mode="dark"] .pill.good { background: #0f3b2a; color: #7ee2b3; }
[data-mode="dark"] .pill.bad { background: #431818; color: #ffb4b4; }
[data-mode="dark"] .pill.warn { background: #3d2e0a; color: #f5cf73; }
.toast { background: var(--ink); color: var(--bg); }

/* ---------- inner page heroes ---------- */
.lib-hero { position: relative; isolation: isolate; padding-bottom: 34px; }
.lib-hero h1 { font-weight: 700; }
.page-art { position: absolute; right: 0; top: 30px; width: min(420px, 42%); height: auto; z-index: -1; opacity: .5; pointer-events: none; }
@media (max-width: 760px) { .page-art { opacity: .22; width: 70%; } }

/* calculators */
.picker { box-shadow: var(--shadow); }
.picker a, .picker button { border-radius: 12px; transition: background .2s, color .2s, transform .2s var(--ease); }
.picker a:hover, .picker button:hover { transform: translateX(2px); }
.tool { scroll-margin-top: 80px; }
.tool-head h2 { font-weight: 700; }
.fields input, .fields select, .itable input, .itable select, .paste textarea { border-radius: 12px; background: color-mix(in srgb, var(--bg) 70%, transparent); transition: border-color .2s, box-shadow .2s; font-family: var(--font-mono); font-size: .86rem; }
.fields input:focus, .fields select:focus, .itable input:focus, .itable select:focus, .paste textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 20%, transparent); }
.res-big { font-family: var(--font-display); letter-spacing: -.02em; }
.out { border-radius: 20px; }

/* footer */
.foot { border-top: 1px solid var(--glass-brd); background: var(--glass); backdrop-filter: blur(12px); margin-top: 60px; }

/* ---------- back to top ---------- */
.to-top { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 30; width: 48px; height: 48px; border-radius: 16px; border: 1px solid var(--glass-brd); background: var(--glass); backdrop-filter: blur(12px); color: var(--ink); display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow); opacity: 0; transform: translateY(16px); pointer-events: none; transition: all .3s var(--ease); }
.to-top.on { opacity: 1; transform: none; pointer-events: auto; }
.to-top svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.to-top .ring { fill: none; stroke: var(--purple); stroke-width: 2.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }
.to-top .arr { position: relative; width: 18px; height: 18px; }

/* ---------- scroll reveal ---------- */
.js-fx .rv { opacity: 0; transform: translateY(26px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0s); }
.js-fx .rv.in { opacity: 1; transform: none; }

/* ---------- new home sections ---------- */
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.bento > * { grid-column: span 6; min-width: 0; }
.bento .w12 { grid-column: span 12; }
.bento .w7 { grid-column: span 7; } .bento .w5 { grid-column: span 5; }
@media (max-width: 880px) { .bento > *, .bento .w7, .bento .w5 { grid-column: span 12; } }
.gpanel { position: relative; padding: 22px 24px; border-radius: var(--r-lg); background: var(--glass); border: 1px solid var(--glass-brd); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.gpanel h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.gpanel h3 svg { width: 22px; height: 22px; color: var(--purple-ink); }
.gpanel p.sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }
/* experience timeline */
.xp { position: relative; margin-top: 20px; display: grid; gap: 0; }
.xp::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--purple), var(--accent-2), var(--accent-3)); border-radius: 2px; transform-origin: top; transform: scaleY(var(--grow, 1)); transition: transform 1.4s var(--ease); }
.xp-item { position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 14px; padding: 10px 0; }
.xp-item .node { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px solid var(--purple); color: var(--purple-ink); z-index: 1; }
.xp-item .node svg { width: 15px; height: 15px; }
.xp-item b { font-family: var(--font-display); font-size: 1rem; display: block; line-height: 1.25; }
.xp-item small { color: var(--muted); display: block; font-size: .84rem; }
.xp-item .when { font: 600 .72rem/1 var(--font-mono); color: var(--purple-ink); letter-spacing: .06em; display: inline-block; margin-bottom: 4px; }
.xp-bar { height: 6px; border-radius: 6px; background: var(--bg-2); margin-top: 8px; overflow: hidden; }
.xp-bar i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--purple), var(--accent-2)); }
/* charts */
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; margin-top: 16px; }
@media (max-width: 480px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { width: 180px; height: 180px; }
.donut circle.seg-arc { fill: none; stroke-width: 22; transition: stroke-width .25s, opacity .25s; cursor: pointer; }
.donut circle.seg-arc:hover, .donut circle.seg-arc.hl { stroke-width: 28; }
.donut text { fill: var(--ink); font-family: var(--font-display); }
.dlegend { display: grid; gap: 6px; list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.dlegend li { display: flex; align-items: center; gap: 8px; cursor: default; padding: 3px 6px; border-radius: 8px; }
.dlegend li:hover { background: var(--purple-tint); }
.dlegend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dlegend span { margin-left: auto; font-family: var(--font-mono); color: var(--muted); }
.yr-chart { width: 100%; height: 190px; margin-top: 14px; }
.yr-chart rect { fill: url(#yrg); transition: opacity .2s; }
.yr-chart rect:hover { opacity: .75; }
.yr-chart text { fill: var(--muted); font: 500 10px var(--font-mono); }
.yr-chart line { stroke: var(--line); }
/* software / skill tiles */
.soft { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin-top: 16px; }
.soft-t { position: relative; display: grid; justify-items: center; gap: 8px; padding: 16px 8px 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--glass-brd); text-align: center; font-size: .8rem; font-weight: 600; transition: transform .3s var(--ease), border-color .3s, box-shadow .3s; }
.soft-t:hover { transform: translateY(-4px); border-color: var(--purple); box-shadow: var(--shadow); }
.soft-t svg { width: 34px; height: 34px; }
.soft-t small { font: 500 .62rem var(--font-mono); color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.sk-group h3 { display: flex; align-items: center; gap: 8px; }
.sk-group h3 svg { width: 20px; height: 20px; color: var(--purple-ink); }
.radar { width: 100%; max-width: 340px; margin: 10px auto 0; display: block; }
.radar .grid { fill: none; stroke: var(--line); }
.radar .area { fill: color-mix(in srgb, var(--purple) 28%, transparent); stroke: var(--purple-ink); stroke-width: 2; }
.radar text { fill: var(--muted); font: 600 10.5px var(--font-body); }
.radar circle { fill: var(--purple-ink); }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .js-fx .rv { opacity: 1; transform: none; }
  .hero h1 span { animation: none; }
  .hero-canvas { display: none; }
}
body { overflow-x: clip; }
@media (max-width: 520px) { .cpt-read b { font-size: .8rem; overflow-wrap: anywhere; } .cpt-read > div { min-width: 0; } .stat .st-ic { width: 24px; height: 24px; } }

/* =====================================================================
   v3 · animated gradient mesh, interactive ground band, toolkit
   ===================================================================== */
body::after { content: ""; position: fixed; inset: -20vmax; z-index: -2; pointer-events: none;
  background: radial-gradient(38vmax 30vmax at 20% 30%, var(--mesh-a), transparent 70%), radial-gradient(34vmax 28vmax at 80% 70%, var(--mesh-b), transparent 70%), radial-gradient(26vmax 22vmax at 60% 15%, color-mix(in srgb, var(--sand) 14%, transparent), transparent 70%);
  animation: mesh 38s ease-in-out infinite alternate; opacity: .9; }
@keyframes mesh { 0% { transform: translate3d(0, 0, 0) rotate(0) scale(1); } 50% { transform: translate3d(4vmax, -3vmax, 0) rotate(8deg) scale(1.08); } 100% { transform: translate3d(-3vmax, 2vmax, 0) rotate(-6deg) scale(1.02); } }
.strata-div path { transition: none; will-change: transform; }
.lib-hero > .hero-canvas { mask-image: linear-gradient(#000 40%, transparent); opacity: .7; }

.ground-band { position: relative; margin-top: 14px; }
.ground-band svg { display: block; width: 100%; height: auto; cursor: crosshair; border-radius: 14px; background: color-mix(in srgb, var(--surface) 50%, transparent); }
.gb-layer rect { transition: opacity .2s; } .gb-layer:hover rect { opacity: .85 !important; }
.gb-gl { stroke: var(--ink); stroke-width: 2; } .gb-wt { stroke: var(--accent-2); stroke-width: 2; fill: none; }
.gb-t { fill: var(--ink); font: 600 13px var(--font-body, system-ui); }
.gb-shaft { fill: var(--muted); stroke: var(--ink); stroke-width: 1.5; } .gb-ham rect { fill: var(--purple); }
.gb-refusal .gb-read { fill: var(--purple-ink); }
.gb-tool { position: absolute; z-index: 3; max-width: 260px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: .82rem; color: var(--ink); pointer-events: none; }
.gb-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; } .gb-hint { color: var(--muted); font-size: .82rem; }

.major { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.major-c { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px; border-radius: 14px; border: 1px solid var(--glass-brd); background: var(--glass); color: var(--ink); cursor: pointer; font: inherit; transition: transform .2s var(--ease), border-color .2s; }
.major-c:hover, .major-c:focus-visible { transform: translateY(-3px); border-color: var(--purple); }
.major-c svg { width: 100%; height: 44px; color: var(--purple-ink); } .major-c small { color: var(--muted); }
.tk-banner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin: 40px 0; padding: 20px 22px; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-brd); }
.tk-banner p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }

/* toolkit hub */
.tk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin: 18px 0 30px; }
.tk-card { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 16px; border: 1px solid var(--glass-brd); background: var(--glass); color: var(--ink); text-decoration: none; transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; }
.tk-card:hover, .tk-card:focus-visible { transform: translateY(-3px); border-color: var(--purple); box-shadow: var(--shadow-lg); }
.tk-card.on { border-color: var(--purple); box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 30%, transparent); }
.tk-card small { color: var(--muted); font-size: .83rem; }
.tk-ic { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--purple-soft); color: var(--purple-ink); } .tk-ic svg { width: 24px; height: 24px; }
.tk-cat { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--purple-ink); font-weight: 600; }
.tk-std { margin-top: auto; font-size: .74rem; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 6px; }
.tk-panel { margin: 10px 0 40px; padding: 22px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); scroll-margin-top: 80px; }
.tk-head { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: flex-start; }
.tk-head h2 { margin: 2px 0 6px; } .tk-head p { color: var(--muted); max-width: 70ch; margin: 0; }
.tk-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tk-body { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 22px; margin-top: 18px; }
@media (max-width: 860px) { .tk-body { grid-template-columns: 1fr; } }
.tk-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-content: start; }
.tk-f { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
.tk-f.wide, .tk-f:has(textarea) { grid-column: 1 / -1; }
.tk-f input, .tk-f select, .tk-f textarea { font: 500 .92rem var(--font-body, system-ui); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--input-ink); width: 100%; box-sizing: border-box; }
.tk-f textarea { min-height: 110px; font-family: ui-monospace, monospace; font-size: .82rem; }
.tk-f input:focus, .tk-f select:focus, .tk-f textarea:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px color-mix(in srgb, var(--purple) 22%, transparent); }
.tk-out { min-width: 0; }
.tk-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tk-diagram { border-radius: 14px; background: var(--bg); border: 1px solid var(--line); padding: 8px; }
.tk-diagram svg { display: block; width: 100%; height: auto; max-height: 360px; }
.tk-res { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
.tk-res td { padding: 6px 8px; border-bottom: 1px solid var(--line); } .tk-res td:nth-child(2) { text-align: right; font-weight: 700; color: var(--purple-ink); font-variant-numeric: tabular-nums; }
.tk-work { margin-top: 12px; } .tk-work summary { cursor: pointer; font-weight: 600; color: var(--purple-ink); }
.tk-work ol, .tk-work ul, #tk-work { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--muted); line-height: 1.6; }
.tk-disc { font-size: .78rem; color: var(--muted); margin-top: 12px; }
.tk-more { color: var(--muted); }

/* diagram vocabulary (theme-aware) */
.dg-t { fill: var(--ink); font-family: var(--font-body, system-ui); }
.dg-l, .dg-edge { stroke: var(--muted); fill: none; stroke-width: 1; } .dg-edge { stroke-dasharray: 4 3; }
.dg-ld { stroke: #d9534f; fill: #d9534f; stroke-width: 2; } .dg-up { stroke: var(--accent-2); fill: var(--accent-2); stroke-width: 2; }
.dg-sup { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.dg-mem { stroke: var(--ink); stroke-width: 4; fill: none; } .dg-mem2 { stroke: var(--purple-ink); stroke-width: 3; fill: none; }
.dg-bmd { fill: color-mix(in srgb, var(--purple) 25%, transparent); stroke: var(--purple-ink); stroke-width: 1.5; }
.dg-conc { fill: color-mix(in srgb, var(--rock) 30%, transparent); stroke: var(--ink); stroke-width: 1.5; }
.dg-bar, .dg-reo, .dg-dot { fill: var(--ink); } .dg-reo2 { fill: none; stroke: var(--ink); stroke-dasharray: 3 2; }
.dg-na { stroke: var(--accent-2); stroke-dasharray: 6 4; stroke-width: 1.5; }
.dg-curve { fill: none; stroke: var(--purple-ink); stroke-width: 2.2; } .dg-curve2 { fill: none; stroke: var(--accent-2); stroke-width: 2; stroke-dasharray: 6 3; } .dg-curve3 { fill: none; stroke: var(--sand); stroke-width: 2; }
.dg-ok, .dg-barok { fill: #2fa36b; stroke: #2fa36b; } .dg-bad, .dg-barbad { fill: #d9534f; stroke: #d9534f; }
.dg-kern { fill: color-mix(in srgb, var(--accent-2) 18%, transparent); stroke: var(--accent-2); stroke-dasharray: 4 3; }
.dg-tie { stroke: #d9534f; stroke-width: 2.5; } .dg-strut { stroke: var(--accent-2); stroke-width: 2.5; stroke-dasharray: 7 4; }
.dg-pile { fill: color-mix(in srgb, var(--rock) 45%, transparent); stroke: var(--ink); } .dg-col { fill: color-mix(in srgb, var(--purple) 35%, transparent); stroke: var(--ink); }
.dg-slip { fill: none; stroke: #d9534f; stroke-width: 2; stroke-dasharray: 8 4; } .dg-wt { stroke: var(--accent-2); stroke-width: 2; fill: none; }
.dg-res { stroke: #2fa36b; fill: #2fa36b; stroke-width: 2; }
.dg-steel { fill: color-mix(in srgb, var(--purple) 30%, var(--surface)); stroke: var(--ink); stroke-width: 1.2; }
.dg-plate { fill: color-mix(in srgb, var(--rock) 25%, var(--surface)); stroke: var(--ink); }
.dg-bolt { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; } .dg-weld { stroke: var(--purple-ink); stroke-width: 5; fill: none; stroke-linecap: round; }
.dg-mix0 { fill: var(--rock); } .dg-mix1 { fill: var(--sand); } .dg-mix2 { fill: var(--gravel); } .dg-mix3 { fill: var(--silt); }

/* Gantt */
.gt-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.gt-sum { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.gt-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.gt-scroll svg { display: block; }
.gt-bg { fill: var(--bg); } .gt-grid { stroke: var(--line); stroke-width: 1; } .gt-tx { fill: var(--ink); font: 12px var(--font-body, system-ui); } .gt-small { fill: var(--muted); font-size: 10px; }
.gt-bar { fill: color-mix(in srgb, var(--accent-2) 55%, var(--surface)); stroke: var(--ink); stroke-width: .6; cursor: grab; }
.gt-bar.crit { fill: var(--purple); } .gt-bar:focus { outline: none; stroke: var(--purple-ink); stroke-width: 2.5; }
.gt-float { stroke: var(--muted); stroke-width: 2; } .gt-link { fill: none; stroke: var(--muted); stroke-width: 1.2; } .gt-link.crit { stroke: var(--purple-ink); stroke-width: 1.8; } .gt-arrh { fill: var(--muted); }
.gt-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .85rem; }
.gt-table th, .gt-table td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.gt-table input { width: 100%; box-sizing: border-box; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--input-ink); font: inherit; }

@media (prefers-reduced-motion: reduce) { body::after { animation: none; } .tk-card, .major-c { transition: none; } }
@media print {
  body::after, body::before, .hero-canvas { display: none !important; }
  body.print-tool > *:not(main), body.print-tool main > *:not(#tk-panel) { display: none !important; }
  body.print-tool .tk-actions { display: none; } body.print-tool .tk-work[open], body.print-tool .tk-work { display: block; }
  body.print-tool .tk-panel { box-shadow: none; border: 0; }
}
.tk-page .lib-tools { position: static !important; }
.tk-res th, .tk-res td:first-child { text-align: left !important; font-weight: 500; }

/* ==========================================================================
   v4: minimalist colourful figure palette, toolkit tree, BOQ, interactive lab, blog figures
   ========================================================================== */
[data-mode="light"] { --c1: #3b82f6; --c2: #f97316; --c3: #10b981; --c4: #ec4899; --c5: #8b5cf6; --c6: #eab308; --good: #059669; --bad: #e11d48; --bad-soft: rgba(225, 29, 72, .12); --plot-bg: color-mix(in srgb, var(--surface) 70%, var(--bg)); }
[data-mode="dark"]  { --c1: #60a5fa; --c2: #fb923c; --c3: #34d399; --c4: #f472b6; --c5: #a78bfa; --c6: #facc15; --good: #34d399; --bad: #fb7185; --bad-soft: rgba(251, 113, 133, .16); --plot-bg: color-mix(in srgb, var(--surface) 80%, #000); }

/* plots */
.pl { width: 100%; height: auto; display: block; font-family: var(--font-body); overflow: visible; }
.pl-bg { fill: var(--plot-bg); rx: 14px; }
.pl-grid { stroke: var(--line); stroke-width: 1; opacity: .7; }
.pl-tk, .pl-note { fill: var(--muted); font-size: 10.5px; }
.pl-lab { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.pl-strong { fill: var(--ink); font-weight: 700; }
.pl-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pl-fill { opacity: .14; }
.pl-dot { stroke: var(--surface); stroke-width: 1.6; }
.pl-ref { stroke: var(--muted); stroke-dasharray: 4 4; stroke-width: 1.2; }
.pl-mark { stroke: var(--surface); stroke-width: 2; }
.mm { width: 100%; height: auto; display: block; font-family: var(--font-body); }
.mm text { fill: var(--ink); }
.mm-box { stroke: none; }
.mm-seg { transition: opacity .2s; } .mm-seg:hover { opacity: .8; }
.tk-diagram svg + svg { margin-top: 10px; }
.tk-diagram { background: var(--plot-bg); border-radius: 18px; padding: 10px; animation: v4fade .35s var(--ease); }
@keyframes v4fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* refresh v3 diagrams: rounder, lighter, palette-driven */
.tk-diagram .dg-mem { stroke: var(--c1); stroke-linecap: round; }
.tk-diagram .dg-mem2 { stroke: var(--c5); stroke-linecap: round; }
.tk-diagram .dg-bmd { fill: color-mix(in srgb, var(--c5) 18%, transparent); stroke: var(--c5); }
.tk-diagram .dg-curve { stroke: var(--c1); stroke-width: 2.6; stroke-linecap: round; }
.tk-diagram .dg-curve2 { stroke: var(--c2); } .tk-diagram .dg-curve3 { stroke: var(--c3); }
.tk-diagram .dg-ld { stroke: var(--c4); fill: var(--c4); } .tk-diagram .dg-up, .tk-diagram .dg-res { stroke: var(--c3); fill: var(--c3); }
.tk-diagram .dg-conc { fill: color-mix(in srgb, var(--c1) 10%, transparent); stroke: var(--c1); stroke-linejoin: round; }
.tk-diagram .dg-steel, .tk-diagram .dg-col { fill: color-mix(in srgb, var(--c5) 22%, transparent); stroke: var(--c5); }
.tk-diagram .dg-pile, .tk-diagram .dg-plate { fill: color-mix(in srgb, var(--c6) 22%, transparent); stroke: var(--c6); }
.tk-diagram .dg-ok, .tk-diagram .dg-barok { fill: var(--good); stroke: var(--good); } .tk-diagram .dg-bad, .tk-diagram .dg-barbad, .tk-diagram .dg-slip { stroke: var(--bad); }
.tk-diagram .dg-bad, .tk-diagram .dg-barbad { fill: var(--bad); }
.tk-diagram .dg-tie { stroke: var(--c4); } .tk-diagram .dg-strut { stroke: var(--c1); } .tk-diagram .dg-wt { stroke: var(--c1); }
.tk-diagram .dg-weld { stroke: var(--c2); }

/* toolkit layout: sidebar tree + content */
.tk-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 22px; align-items: start; margin-top: 18px; }
.tk-side { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; padding: 14px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--glass-brd); }
.tk-side h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.tk-tree-l0, .tk-tree-l1 { list-style: none; margin: 0; padding: 0; }
.tk-tree-l1 { margin: 2px 0 6px 10px; padding-left: 8px; border-left: 2px solid var(--line); }
.tk-node { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: 0; color: var(--ink); font: inherit; font-size: .9rem; padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.tk-node.tk-f0 { font-weight: 650; }
.tk-node:hover { background: var(--purple-tint); }
.tk-node.on { background: var(--purple-soft); color: var(--purple-ink); }
.tk-node .n, .tk-gh .n { font: 600 .72rem var(--font-mono); color: var(--muted); background: var(--bg-2); padding: 1px 7px; border-radius: 99px; }
.tk-crumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .88rem; margin: 0 0 12px; color: var(--muted); min-height: 1.6em; }
.tk-crumb button { background: none; border: 0; padding: 0; font: inherit; color: var(--purple-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.tk-crumb [aria-current] { color: var(--ink); font-weight: 600; }
#tk-grid.tk-grid { display: block; }
.tk-group { margin: 0 0 22px; }
.tk-gh { font-size: 1rem; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.tk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
@media (max-width: 860px) { .tk-layout { grid-template-columns: 1fr; } .tk-side { position: static; max-height: none; } }

/* BOQ */
.gt-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.gt-tools .tk-f { max-width: 150px; }
#bq-table input { width: 100%; min-width: 60px; font: inherit; color: var(--input-ink); background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
#bq-table td:nth-child(2) { min-width: 220px; }
.bq-amt { font-family: var(--font-mono); white-space: nowrap; text-align: right; }
.bq-sum { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 14px; align-items: center; }
@media (max-width: 700px) { .bq-sum { grid-template-columns: 1fr; } }

/* interactive lab */
.lab-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 16px; margin: 18px 0 30px; }
.demo { background: var(--glass); border: 1px solid var(--glass-brd); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.demo h3 { margin: 0 0 4px; font-size: 1.02rem; } .demo p { margin: 0 0 8px; font-size: .88rem; color: var(--muted); }
.demo svg { width: 100%; height: auto; display: block; background: var(--plot-bg); border-radius: 14px; touch-action: none; }
.demo .dctl { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; font-size: .86rem; }
.demo .dctl input[type=range] { flex: 1 1 140px; accent-color: var(--c1); }
.demo .dout { font: 600 .86rem var(--font-mono); color: var(--ink); }
.demo .drag { cursor: grab; } .demo .drag:active { cursor: grabbing; }
.demo .drag:focus-visible { outline: 3px solid var(--c1); outline-offset: 2px; }
.post-fig { margin: 22px 0; padding: 14px; border-radius: var(--r); background: var(--plot-bg); }
.post-fig svg { width: 100%; height: auto; display: block; }
.post-fig figcaption { font-size: .85rem; color: var(--muted); margin-top: 8px; }
.post-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
@media (prefers-reduced-motion: reduce) { .tk-diagram { animation: none; } .demo * { transition: none !important; animation: none !important; } }

/* ===================== v5: app shell, dimensions, 3D, Excel, palette ===================== */
/* dimension lines (A.dim) */
.dm-line, .dm-ext { stroke: var(--purple); stroke-width: 1.1; fill: none; }
.dm-ext { stroke-dasharray: 2 3; opacity: .7; }
.dm-ah { fill: var(--purple); }
.dm-bg { fill: var(--surface, #fff); stroke: color-mix(in srgb, var(--purple) 40%, transparent); stroke-width: .8; }
.dm-t { font: 600 10.5px/1 "JetBrains Mono", ui-monospace, monospace; fill: var(--purple-ink); letter-spacing: .01em; }
[data-mode="dark"] .dm-t { fill: var(--ink); }
.tk-diagram svg { transition: opacity .25s ease; }
.tk-diagram svg path, .tk-diagram svg rect, .tk-diagram svg circle { vector-effect: non-scaling-stroke; }

/* one tool at a time */
body.tk-solo #tk-grid, body.tk-solo #tk-quick, body.tk-solo #tk-count { display: none; }
.tk-panel.tk-anim { animation: tkIn .38s cubic-bezier(.2,.8,.2,1); }
@keyframes tkIn { from { opacity: 0; transform: translateY(12px) scale(.995); } to { opacity: 1; transform: none; } }
.tk-head .tk-actions { flex-wrap: wrap; }
.btn-xl { background: linear-gradient(135deg, #107c41, #21a366); color: #fff; border-color: transparent; }
.btn-xl:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-xl small { opacity: .8; font-weight: 500; }
.tk-fav[aria-pressed="true"] { color: #eab308; border-color: #eab308; }
.tk-out { display: grid; gap: 14px; align-content: start; }
@media (min-width: 1760px) { .tk-out { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } .tk-out > .tk-badges, .tk-out > .tk-3dbar { grid-column: 1 / -1; } .tk-out > .tk-work { grid-column: 1 / -1; } }
.tk-inputs { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; }
@media (max-width: 860px) { .tk-inputs { position: static; max-height: none; } }

/* hub quick access */
.tk-quick { display: grid; gap: 16px; margin: 6px 0 22px; }
.tk-qrow h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .88rem; transition: transform .18s, border-color .18s, box-shadow .18s; }
.tk-chip .tk-ic { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: color-mix(in srgb, var(--purple) 14%, transparent); color: var(--purple); }
.tk-chip .tk-ic svg { width: 16px; height: 16px; }
.tk-chip:hover { transform: translateY(-2px); border-color: var(--purple); box-shadow: 0 6px 18px rgba(var(--glow), .18); }
.tk-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tk-ftile { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: linear-gradient(160deg, var(--surface), color-mix(in srgb, var(--purple) 6%, var(--surface))); color: var(--ink); cursor: pointer; display: grid; gap: 4px; transition: transform .2s, box-shadow .2s, border-color .2s; }
.tk-ftile b { font-family: "Space Grotesk", sans-serif; font-size: 1rem; }
.tk-ftile span { font-size: .8rem; color: var(--muted); }
.tk-ftile:hover, .tk-ftile:focus-visible { transform: translateY(-3px); border-color: var(--purple); box-shadow: 0 10px 24px rgba(var(--glow), .2); }

/* 2D / 3D */
.tk-3dbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tk-3dbar button { font: inherit; font-size: .85rem; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; transition: background .2s, color .2s; }
.tk-3dbar button[aria-pressed="true"] { background: var(--purple); color: var(--on-accent, #fff); border-color: var(--purple); }
.tk-3dhint { font-size: .75rem; color: var(--muted); margin-left: 6px; opacity: 0; transition: opacity .3s; }
.tk-3dbar.is3d .tk-3dhint { opacity: 1; }
.tk-3dview { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); min-height: 280px; background: radial-gradient(120% 90% at 30% 10%, color-mix(in srgb, var(--purple) 10%, var(--surface)), var(--surface)); }
.tk-3dview canvas { display: block; width: 100%; cursor: grab; touch-action: none; }
.tk-3dview canvas:active { cursor: grabbing; }
.tk-3dview.loading::after { content: "Loading 3D…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .9rem; }
.tk-3d-msg { padding: 24px; color: var(--muted); margin: 0; }

/* command palette */
.cmdk-btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font: inherit; font-size: .85rem; cursor: pointer; }
.cmdk-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.cmdk-btn kbd, .cmdk kbd { font: 600 .7rem/1 "JetBrains Mono", monospace; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--muted); }
.cmdk-btn:hover { border-color: var(--purple); color: var(--ink); }
@media (max-width: 700px) { .cmdk-btn span, .cmdk-btn kbd { display: none; } }
.cmdk { position: fixed; inset: 0; z-index: 1000; background: rgba(8, 12, 20, .45); backdrop-filter: blur(6px); display: grid; justify-items: center; align-items: start; padding: 10vh 16px 16px; animation: fadeIn .18s ease; }
.cmdk[hidden] { display: none; }
.cmdk-box { width: min(680px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.35); overflow: hidden; animation: popIn .22s cubic-bezier(.2,.8,.2,1); }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cmdk-in svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.cmdk-in input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 1.05rem; }
.cmdk ul { list-style: none; margin: 0; padding: 6px; max-height: 52vh; overflow: auto; }
.cmdk li[data-i] { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.cmdk li[aria-selected="true"] { background: color-mix(in srgb, var(--purple) 14%, transparent); }
.cmdk-k { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); }
.cmdk-k.k-tool { background: color-mix(in srgb, var(--purple) 16%, transparent); color: var(--purple-ink); }
[data-mode="dark"] .cmdk-k.k-tool { color: var(--ink); }
.cmdk-t em { font-style: normal; font-size: .66rem; padding: 1px 5px; border-radius: 4px; background: #107c41; color: #fff; margin-left: 4px; vertical-align: 1px; }
.cmdk-s { font-size: .78rem; color: var(--muted); text-align: right; }
.cmdk-none { padding: 18px; color: var(--muted); }
.cmdk-foot { margin: 0; padding: 8px 14px; border-top: 1px solid var(--line); font-size: .75rem; color: var(--muted); display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
@keyframes popIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
body.cmdk-open { overflow: hidden; }

/* theme preview + cursor glow */
.theme-preview { margin-top: 12px; display: grid; gap: 6px; font-size: .78rem; color: var(--muted); }
.tp-card { display: flex; gap: 6px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); }
.tp-card i { flex: 1; height: 26px; border-radius: 8px; background: var(--purple); }
.tp-card i:nth-child(2) { background: var(--accent-2); } .tp-card i:nth-child(3) { background: var(--accent-3); }
.theme-pop.previewing { outline: 2px dashed var(--purple); outline-offset: 3px; }
.cursor-glow body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; background: radial-gradient(600px circle at var(--mx, 50%) var(--my, 30%), rgba(var(--glow), .10), transparent 60%); transition: background .2s; }
/* micro-interactions */
.tk-card { transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s, border-color .2s; }
.tk-card:hover { transform: translateY(-3px); }
.btn:active, .tk-chip:active, .tk-ftile:active { transform: scale(.97); }
.tk-res tr { transition: background .2s; } .tk-res tr:hover { background: color-mix(in srgb, var(--purple) 6%, transparent); }
@media (prefers-reduced-motion: reduce) { .tk-panel.tk-anim, .cmdk, .cmdk-box { animation: none; } .tk-card:hover, .tk-chip:hover, .tk-ftile:hover, .btn-xl:hover { transform: none; } .cursor-glow body::before { display: none; } }
@media print { .tk-3dbar, .tk-3dview, .cmdk-btn, .tk-quick { display: none !important; } }
body.tk-solo .tk-hero, body.tk-solo .lib-hero, body.tk-solo #lab, body.tk-solo .tk-more, body.tk-solo .est-intro { display: none; }
body.tk-solo .tk-layout { margin-top: 12px; }
@media (min-width: 1760px) {
  .tk-out { grid-template-columns: minmax(0, 1.45fr) minmax(250px, 1fr); }
  .tk-out > .tk-diagram, .tk-out > .tk-3dview { grid-column: 1; }
  .tk-out > .tk-res { grid-column: 2; grid-row: 2 / span 2; align-self: start; }
  .tk-out > .tk-3dbar ~ .tk-res { grid-row: 3 / span 2; }
}
.hero-seg { display: inline-flex; gap: 4px; margin-left: auto; }
.hero-seg button { font: inherit; font-size: .75rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.hero-seg button[aria-pressed="true"] { background: var(--purple); color: var(--on-accent, #fff); border-color: var(--purple); }
.hero3d { border-radius: 14px; overflow: hidden; cursor: grab; touch-action: pan-y; }
.hero3d canvas { display: block; width: 100%; }
.hero .cpt [hidden] { display: none !important; }
@media (max-width: 1240px) { .cmdk-btn span { display: none; } .cmdk-btn { padding: 0 10px; } }
@media (max-width: 1100px) { .cmdk-btn kbd { display: none; } }
