/* ==========================================================================
   Alwin Simon — Portfolio
   Monochrome, dark-first. Syne (display) · Instrument Sans (body) · JetBrains Mono (labels)
   ========================================================================== */

:root {
  --font-display: "Syne", sans-serif;
  --font-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --nav-h: 64px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  --bg: #09090a;
  --bg-elev: #101013;
  --bg-chip: #131316;
  --text: #f2f2ef;
  --muted: #a4a4a1;
  --line: #232327;
  --line-strong: #3a3a3f;
  --invert-bg: #f2f2ef;
  --invert-text: #0b0b0c;
  --glass: rgba(9, 9, 10, 0.72);
  --dot: rgba(242, 242, 239, 0.5);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f6f3;
  --bg-elev: #ffffff;
  --bg-chip: #eeeeea;
  --text: #131314;
  --muted: #5a5a5e;
  --line: #e2e2dd;
  --line-strong: #c8c8c2;
  --invert-bg: #131314;
  --invert-text: #f6f6f3;
  --glass: rgba(246, 246, 243, 0.78);
  --dot: rgba(19, 19, 20, 0.45);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.25);
  color-scheme: light;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-padding-top: calc(var(--nav-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.35s ease, color 0.35s ease;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0 0 1em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--muted); }

.mono {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--invert-bg);
  color: var(--invert-text);
  border-radius: 6px;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; color: var(--invert-text); }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--text); color: var(--bg); }

/* ---------- Header / Nav ---------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: var(--glass);
  border-bottom: 1px solid var(--line);
}

.nav {
  max-width: 1120px;
  margin: 0 auto;
  height: var(--nav-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand:hover { color: var(--text); }
.brand-dot { color: var(--muted); }

.nav-links {
  display: flex;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  display: inline-block;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-radius: 999px;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.nav-link:hover { color: var(--text); }
.nav-link.active {
  color: var(--text);
  background: var(--bg-chip);
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle, .menu-toggle {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s var(--ease-out);
}
.theme-toggle:hover, .menu-toggle:hover {
  border-color: var(--line-strong);
  background: var(--bg-chip);
}
.theme-toggle:active { transform: scale(0.92); }

:root[data-theme="dark"] .icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }

.menu-toggle { display: none; flex-direction: column; gap: 5px; }
.menu-bar {
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform 0.25s var(--ease-out);
}
.menu-toggle[aria-expanded="true"] .menu-bar:first-child { transform: translateY(3.5px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-bar:last-child { transform: translateY(-3.5px) rotate(-45deg); }

/* Mobile menu */
.mobile-menu {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 32px 24px;
}
.mobile-menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.mobile-link {
  display: block;
  padding: 16px 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.8rem;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(var(--nav-h) + 40px) 24px 80px;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 880px;
  text-align: center;
}

.eyebrow {
  color: var(--muted);
  margin-bottom: 20px;
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
}

.hero-title {
  font-size: clamp(2.6rem, 9vw, 6.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-sub {
  margin: 24px auto 0;
  max-width: 34em;
  font-size: clamp(1rem, 2.2vw, 1.25rem);
  color: var(--muted);
}
.hero-sub strong { color: var(--text); font-weight: 600; }

.hero-cta {
  margin-top: 40px;
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-cta .btn { flex: 0 0 auto; width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--text);
  transition: transform 0.25s var(--ease-out), background-color 0.2s ease, color 0.2s ease, box-shadow 0.25s ease;
  will-change: transform;
}
.btn-solid {
  background: var(--invert-bg);
  color: var(--invert-text);
}
.btn-solid:hover {
  color: var(--invert-text);
  box-shadow: var(--shadow);
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text); }

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
}
.scroll-hint:hover { color: var(--text); }
/* Short viewports: hero content can exceed 100svh — drop the absolute hint so it never overlaps the CTAs */
@media (max-height: 640px) {
  .scroll-hint { display: none; }
}
.scroll-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(var(--muted), transparent);
  overflow: hidden;
}
@media (prefers-reduced-motion: no-preference) {
  .scroll-line { animation: scrollPulse 2.2s ease-in-out infinite; }
  @keyframes scrollPulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
  }
}

/* ---------- Sections ---------- */

.section {
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(80px, 12vw, 140px) 24px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: clamp(32px, 5vw, 56px);
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.section-index {
  color: var(--muted);
}

.section-head h2 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: start;
}

.lede {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.9em;
}

.about-copy p:not(.lede) { color: var(--muted); }

.about-facts {
  display: grid;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.fact {
  display: grid;
  gap: 6px;
  padding: 20px 22px;
  background: var(--bg-elev);
  transition: background-color 0.2s ease;
}
.fact:hover { background: var(--bg-chip); }
.fact-label { color: var(--muted); }
.fact-value { font-weight: 500; }

/* ---------- Skills ---------- */

.skills-clusters { display: grid; gap: clamp(28px, 4vw, 40px); }

.cluster-title {
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-chip);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: default;
  transition: transform 0.25s var(--ease-out), background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.chip:hover {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
  transform: translateY(-3px);
}

.chip-sm {
  min-height: 32px;
  padding: 0 14px;
  font-size: 0.8rem;
}

/* ---------- Projects ---------- */

.project-list { display: grid; gap: 24px; }

.project {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elev);
  padding: clamp(24px, 4vw, 40px);
  transition: border-color 0.25s ease, transform 0.3s var(--ease-out), box-shadow 0.3s ease;
}
.project:hover {
  border-color: var(--line-strong);
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.project-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.project-kicker { color: var(--muted); display: block; margin-bottom: 10px; }

.project-title {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.project-gh {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.25s var(--ease-out);
  will-change: transform;
}
.project-gh:hover {
  background: var(--invert-bg);
  color: var(--invert-text);
  border-color: var(--invert-bg);
}

.project-desc {
  color: var(--muted);
  max-width: 56em;
  margin-bottom: 18px;
}

.project-stack { margin-bottom: 20px; }

.project-expand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 18px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.project-expand:hover { background: var(--bg-chip); border-color: var(--text); }

.expand-plus {
  position: relative;
  width: 12px;
  height: 12px;
}
.expand-plus::before, .expand-plus::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 0;
  width: 12px;
  height: 1.6px;
  background: currentColor;
  transform: translateY(-50%);
  transition: transform 0.25s var(--ease-out);
}
.expand-plus::after { transform: translateY(-50%) rotate(90deg); }
.project-expand[aria-expanded="true"] .expand-plus::after { transform: translateY(-50%) rotate(0deg); }

.project-detail {
  overflow: hidden;
}
.project-detail[hidden] { display: none; }

.detail-list {
  margin: 20px 0 0;
  padding: 20px 0 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
  display: grid;
  gap: 10px;
  color: var(--muted);
}
.detail-list li {
  padding-left: 22px;
  position: relative;
}
.detail-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 1.5px;
  background: var(--muted);
}

/* ---------- Contact ---------- */

.section-contact { padding-bottom: clamp(80px, 10vw, 120px); }

.contact-inner { text-align: center; padding: clamp(8px, 2vw, 24px) 0; }

.contact-lede {
  color: var(--muted);
  font-size: 1.1rem;
  margin-bottom: 28px;
}

.contact-email {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 4.5vw, 2.6rem);
  letter-spacing: -0.02em;
  text-decoration: none;
  border-bottom: 2px solid var(--line-strong);
  padding-bottom: 6px;
  transition: border-color 0.2s ease, transform 0.25s var(--ease-out);
  will-change: transform;
  overflow-wrap: anywhere;
}
.contact-email:hover { color: var(--text); border-color: var(--text); }

.social-row {
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.social-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.25s var(--ease-out);
}
.social-link:hover {
  color: var(--text);
  border-color: var(--line-strong);
  background: var(--bg-chip);
  transform: translateY(-2px);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: clamp(40px, 6vw, 80px);
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
}
.site-footer p { margin: 0; }

/* ---------- Reveal animations ---------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  }
  .reveal.in {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .nav-links { display: none; }
  .menu-toggle { display: flex; }
  body { font-size: 16px; }
  .project-top { flex-direction: row; }
}

@media (min-width: 1800px) {
  .section, .nav { max-width: 1280px; }
  body { font-size: 18px; }
}

/* ==========================================================================
   Enhanced interactivity layer
   ========================================================================== */

/* ---------- Preloader ---------- */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-content: center;
  gap: 28px;
  background: var(--bg);
  animation: preloaderOut 0.8s var(--ease-out) 2.2s forwards; /* fallback dismissal */
}
#preloader.done { animation: preloaderOut 0.7s var(--ease-out) forwards; }
.preloader-inner {
  display: flex;
  align-items: baseline;
  gap: 18px;
  justify-content: center;
}
.preloader-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.4rem, 8vw, 4rem);
  letter-spacing: -0.03em;
}
.preloader-count {
  color: var(--muted);
  font-size: 0.9rem;
}
.preloader-bar {
  width: min(240px, 60vw);
  height: 2px;
  background: var(--line);
  overflow: hidden;
  border-radius: 2px;
}
.preloader-fill {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  animation: preloaderFill 2s var(--ease-out) forwards;
}
@keyframes preloaderFill { to { width: 100%; } }
@keyframes preloaderOut {
  to { opacity: 0; visibility: hidden; transform: translateY(-12px); }
}
html.preloaded #preloader { display: none; }
@media (prefers-reduced-motion: reduce) {
  #preloader { animation: preloaderOut 0.3s ease 0.4s forwards; }
  .preloader-fill { animation-duration: 0.4s; }
}

/* Lock scroll while preloader is up */
html.loading, html.loading body { overflow: hidden; }

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 60;
  background: transparent;
  pointer-events: none;
}
.scroll-progress-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: 0 50%;
  will-change: transform;
}

/* ---------- Advanced cursor (dual-layer, morphing) ---------- */
.cursor { position: fixed; inset: 0; z-index: 95; pointer-events: none; }
.cursor-dot,
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  will-change: transform;
}
.cursor-dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 999px;
  background: var(--text);
  z-index: 96;
}
.cursor-ring {
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  display: grid;
  place-items: center;
  /* animate size + radius on morph, transform driven by JS each frame */
  transition: opacity 0.3s ease, width 0.28s var(--ease-out), height 0.28s var(--ease-out),
              margin 0.28s var(--ease-out), border-radius 0.28s var(--ease-out),
              border-color 0.2s ease, background-color 0.25s ease;
}
.cursor.active .cursor-dot,
.cursor.active .cursor-ring { opacity: 1; }
.cursor.hovering .cursor-ring {
  border-color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.cursor.pressed .cursor-ring { background: color-mix(in srgb, var(--text) 18%, transparent); }
.cursor.hidden-dot .cursor-dot { opacity: 0; }
.cursor-label {
  font-size: 0.56rem;
  letter-spacing: 0.14em;
  color: var(--text);
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
}
.cursor.labelled .cursor-label { opacity: 1; transform: none; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- View Transition theme swipe ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* ---------- 3D tilt on project cards ---------- */
.project-list { perspective: 1200px; }
.project { transform-style: preserve-3d; }
.project.tilting { transition: box-shadow 0.3s ease, border-color 0.25s ease; }

/* ---------- Staggered chip entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  .cluster .chip {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  .cluster.in .chip {
    animation: chipIn 0.5s var(--ease-out) forwards;
    animation-delay: calc(var(--i, 0) * 55ms);
  }
  @keyframes chipIn {
    to { opacity: 1; transform: none; }
  }
}

/* ---------- Scramble caret ---------- */
.hero-title[data-scramble] { min-height: 1.05em; }
.scramble-char { display: inline-block; }
.scramble-char.settling { color: var(--muted); }

/* ==========================================================================
   App-tier interactivity: command palette, terminal, physics, sound, toast
   ========================================================================== */

/* ---------- Nav icon buttons (search / sound) ---------- */
.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s var(--ease-out);
}
.nav-icon-btn:hover { border-color: var(--line-strong); background: var(--bg-chip); }
.nav-icon-btn:active { transform: scale(0.94); }
.cmdk-kbd {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  line-height: 1;
}
#sound-toggle { width: 44px; padding: 0; justify-content: center; }
:root[data-theme] .icon-sound-off { display: none; }
#sound-toggle[aria-pressed="false"] .icon-sound-on { display: none; }
#sound-toggle[aria-pressed="false"] .icon-sound-off { display: block; }

@media (max-width: 560px) {
  .cmdk-kbd { display: none; }
  #cmdk-trigger { width: 44px; padding: 0; justify-content: center; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  z-index: 400;
  max-width: min(90vw, 460px);
  padding: 12px 20px;
  background: var(--invert-bg);
  color: var(--invert-text);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.4s var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Command palette ---------- */
.cmdk {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: start center;
  padding: min(14vh, 140px) 20px 20px;
}
.cmdk[hidden] { display: none; }
.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.cmdk-panel {
  position: relative;
  width: min(600px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: cmdkPop 0.22s var(--ease-out);
}
@media (prefers-reduced-motion: reduce) { .cmdk-panel, .cmdk-backdrop { animation: none; } }
@keyframes cmdkPop { from { opacity: 0; transform: translateY(-10px) scale(0.98); } }
@keyframes fadeIn { from { opacity: 0; } }
.cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.cmdk-input-wrap svg { color: var(--muted); flex: none; }
#cmdk-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
}
#cmdk-input::placeholder { color: var(--muted); }
.cmdk-esc {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
}
.cmdk-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text);
}
.cmdk-item[aria-selected="true"] { background: var(--bg-chip); }
.cmdk-item .cmdk-ic {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
}
.cmdk-item[aria-selected="true"] .cmdk-ic { color: var(--text); border-color: var(--line-strong); }
.cmdk-item-title { flex: 1; font-weight: 500; font-size: 0.95rem; }
.cmdk-item-tag {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.cmdk-empty { padding: 28px 14px; text-align: center; color: var(--muted); font-size: 0.9rem; }
.cmdk-foot {
  display: flex;
  gap: 18px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.62rem;
}
.cmdk-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Terminal ---------- */
.terminal {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 250;
  width: min(580px, calc(100vw - 32px));
  height: min(440px, 70vh);
  min-width: 300px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  resize: both;
  animation: termIn 0.28s var(--ease-out);
}
.terminal[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .terminal { animation: none; } }
@keyframes termIn { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
.terminal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  flex: none;
}
.terminal-bar:active { cursor: grabbing; }
.terminal-dots { display: flex; gap: 6px; }
.terminal-dots i {
  width: 11px; height: 11px; border-radius: 999px;
  background: var(--line-strong);
  display: block;
}
.terminal-title { flex: 1; color: var(--muted); text-align: center; }
.terminal-close {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px; line-height: 1;
}
.terminal-close:hover { color: var(--text); border-color: var(--line-strong); }
.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  cursor: text;
}
.terminal-output { white-space: pre-wrap; word-break: break-word; }
.term-line { animation: termLine 0.25s ease both; }
@media (prefers-reduced-motion: reduce) { .term-line { animation: none; } }
@keyframes termLine { from { opacity: 0; transform: translateY(3px); } }
.term-dim { color: var(--muted); }
.term-accent { color: var(--text); font-weight: 500; }
.term-link { color: var(--text); text-underline-offset: 3px; }
.term-err { color: var(--text); border-left: 2px solid var(--line-strong); padding-left: 8px; }
.terminal-line { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.terminal-prompt { color: var(--muted); flex: none; }
#terminal-input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  caret-color: var(--text);
}
.terminal-body::-webkit-scrollbar, .cmdk-list::-webkit-scrollbar { width: 8px; }
.terminal-body::-webkit-scrollbar-thumb, .cmdk-list::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: 8px;
}

/* ---------- Skills physics ---------- */
.skills-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 24px;
}
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease-out);
}
.ghost-btn:hover { background: var(--bg-chip); border-color: var(--text); }
.ghost-btn:active { transform: scale(0.97); }
.skills-clusters { position: relative; }
.skills-clusters.is-physics .cluster { opacity: 0; pointer-events: none; }
.physics-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
  cursor: grab;
}
.physics-canvas:active { cursor: grabbing; }
.physics-hint {
  position: absolute;
  left: 0; bottom: -34px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

/* ---------- Matrix easter egg ---------- */
.matrix-canvas {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: var(--bg);
}

@media (max-width: 560px) {
  .terminal { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
}

/* ==========================================================================
   Email reveal puzzle — circuit router
   ========================================================================== */
.puzzle {
  max-width: 520px;
  margin: 8px auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-elev);
  text-align: left;
}
.puzzle.solved {
  border-color: var(--line-strong);
  transition: border-color 0.4s ease;
}
.puzzle-head { margin-bottom: 18px; }
.puzzle-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  margin-bottom: 10px;
}
.puzzle-tag::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 0 currentColor;
}
.puzzle.solved .puzzle-tag { color: var(--text); }
.puzzle-prompt { margin: 0; color: var(--muted); font-size: 0.95rem; }
.puzzle-src, .puzzle-out { color: var(--text); font-weight: 600; }

.circuit-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
.circuit-port {
  flex: none;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: 0.56rem;
  color: var(--muted);
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease;
}
.circuit-port-in.live { color: var(--text); border-color: var(--line-strong); }
.puzzle.solved .circuit-port-out {
  color: var(--invert-text);
  background: var(--invert-bg);
  border-color: var(--invert-bg);
}
.circuit {
  display: grid;
  gap: 6px;
  touch-action: manipulation;
}
.tile {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  background: var(--bg-chip);
  border-radius: 10px;
  cursor: pointer;
  overflow: hidden;
  transition: background-color 0.25s ease, box-shadow 0.3s ease, transform 0.15s var(--ease-out);
}
.tile:hover { background: var(--line); }
.tile:active { transform: scale(0.94); }
.tile.powered { box-shadow: inset 0 0 0 1px var(--line-strong); }
.tile-svg { width: 100%; height: 100%; display: block; transition: transform 0.32s var(--ease-out); }
.tile-wire {
  fill: none;
  stroke: var(--muted);
  stroke-width: 9;
  stroke-linecap: round;
  transition: stroke 0.25s ease;
}
.tile-node { fill: var(--muted); transition: fill 0.25s ease; }
.tile.powered .tile-wire { stroke: var(--text); }
.tile.powered .tile-node { fill: var(--text); }
.tile.powered .tile-flow {
  fill: none;
  stroke: var(--text);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 10 26;
  opacity: 0.9;
}
@media (prefers-reduced-motion: no-preference) {
  .tile.powered .tile-flow { animation: flow 0.8s linear infinite; }
  @keyframes flow { to { stroke-dashoffset: -36; } }
}
.tile:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.puzzle-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}
.puzzle-status { color: var(--muted); }
.puzzle.solved .puzzle-status { color: var(--text); }
.puzzle-skip {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 8px;
}
.puzzle-skip:hover { color: var(--text); }

.email-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 8px;
  animation: revealIn 0.6s var(--ease-out);
}
.email-reveal[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .email-reveal { animation: none; } }
@keyframes revealIn { from { opacity: 0; transform: translateY(14px); } }
.email-reveal-tag { color: var(--muted); }
.email-copy { min-height: 40px; }

/* ==========================================================================
   Utility dock — tabbed multi-tool (Time / Network / Units / Case / Calc)
   ========================================================================== */
.utility {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 250;
  width: min(1240px, calc(100vw - 32px));
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: utilIn 0.3s var(--ease-out);
}
@keyframes utilIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.985); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.utility[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .utility { animation: none; } }
.utility-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  flex: none;
}
.utility-bar:active { cursor: grabbing; }
.utility-title { flex: 1; color: var(--muted); text-align: center; }

/* Tabs */
.utility-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 10px 0;
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.utility-tabs::-webkit-scrollbar { display: none; }
.utab {
  flex: 1 0 auto;
  min-height: 40px;
  padding: 0 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.utab:hover { color: var(--text); }
.utab.active { color: var(--text); border-bottom-color: var(--text); }

.utility-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  overscroll-behavior: contain;
}
.upanel { animation: fadeIn 0.28s ease; }
.upanel[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .upanel { animation: none; } }

/* Shared controls */
.util-select, .util-run, .util-input, .util-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  background: var(--bg-chip);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}
.util-input { cursor: text; font-family: var(--font-body); }
.util-run { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); font-weight: 600; }
.util-run:hover { opacity: 0.9; }
.util-run[disabled] { opacity: 0.5; cursor: progress; }
.util-chip:hover { border-color: var(--text); }
.util-card-title { color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- TIME ---------- */
.clock-pins { display: grid; gap: 10px; margin-bottom: 18px; }
.clock-pin {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 6px 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-elev);
  position: relative;
}
.clock-pin.is-core { border-color: var(--line-strong); }
.clock-pin-name { font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; gap: 8px; }
.clock-pin-tag {
  font-family: var(--font-mono); font-size: 0.54rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--invert-text);
  background: var(--invert-bg); padding: 2px 7px; border-radius: 999px;
}
.clock-pin-zone { grid-column: 1; color: var(--muted); font-family: var(--font-mono); font-size: 0.6rem; }
.clock-pin-time {
  grid-column: 2; grid-row: 1 / 3;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.5rem, 6vw, 2.1rem); line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  text-align: right;
}
.clock-pin-time small { font-size: 0.5em; color: var(--muted); font-family: var(--font-mono); font-weight: 400; }
.clock-pin-date { grid-column: 1; color: var(--muted); font-size: 0.72rem; }
.clock-pin-remove {
  position: absolute; top: 8px; right: 10px;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 4px;
}
.clock-pin-remove:hover { color: var(--text); }

.tz-tool { border-top: 1px solid var(--line); padding-top: 16px; }
.tz-tool-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tz-controls, .tz-add { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tz-controls .util-input { flex: 1; min-width: 150px; }
.tz-controls .util-select, .tz-add .util-select { flex: 1; min-width: 120px; }

/* ---------- NETWORK ---------- */
.net-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.net-phase { flex: 1; }
.net-phase-label { color: var(--muted); display: block; margin-bottom: 8px; }
.net-progress { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.net-progress-fill {
  display: block; height: 100%; width: 0%;
  background: var(--text); border-radius: 999px;
  transition: width 0.3s ease;
}
.net-metrics {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.net-metric {
  display: grid; gap: 4px; padding: 12px 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-chip); text-align: center;
}
.net-metric.pulse { animation: metricPulse 0.5s var(--ease-out); }
@keyframes metricPulse { 0% { border-color: var(--text); } 100% { border-color: var(--line); } }
.net-val {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.35rem; line-height: 1; font-variant-numeric: tabular-nums;
}
.net-unit { color: var(--muted); font-size: 0.52rem; letter-spacing: 0.02em; }
.net-chart-wrap { margin-bottom: 16px; }
.chart-title { display: block; color: var(--muted); margin-bottom: 8px; }
.chart-title em { font-style: normal; color: var(--text); }
.net-chart {
  width: 100%; height: 200px; display: block;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-chip);
}
.net-chart-sm { height: 120px; }
.chart-legend { display: flex; gap: 18px; margin-top: 8px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.lg-down { background: #58a6ff; }
.lg-up { background: #f6a13c; }
.lg-lat { background: #4ade80; }
.net-note { color: var(--muted); margin: 4px 0 0; }
.speed-meta { margin: 12px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.speed-meta div { display: flex; justify-content: space-between; gap: 10px; }
.speed-meta dt { color: var(--muted); font-size: 0.62rem; margin: 0; }
.speed-meta dd { margin: 0; font-size: 0.62rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- UNITS ---------- */
.units-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.units-cat {
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
  font-family: var(--font-mono); font-size: 0.68rem; cursor: pointer;
  transition: all 0.2s ease;
}
.units-cat:hover { color: var(--text); border-color: var(--line-strong); }
.units-cat.active { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.units-io { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 18px; }
.units-field { flex: 1; display: grid; gap: 8px; }
.units-num { width: 100%; font-family: var(--font-display); font-size: 1.3rem; font-weight: 600; padding: 12px; }
.units-swap {
  flex: none; width: 44px; height: 44px; margin-bottom: 2px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--bg-chip); color: var(--text); cursor: pointer; font-size: 18px;
  transition: transform 0.3s var(--ease-out), background-color 0.2s ease;
}
.units-swap:hover { background: var(--bg-elev); }
.units-swap:active { transform: rotate(180deg); }
.units-table { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.units-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; background: var(--bg-elev); font-family: var(--font-mono); font-size: 0.7rem; }
.units-row span:first-child { color: var(--muted); }
.units-row span:last-child { font-variant-numeric: tabular-nums; }

/* ---------- CASE ---------- */
.case-area { width: 100%; resize: vertical; line-height: 1.5; font-size: 0.9rem; }
.case-stats { color: var(--muted); margin: 8px 0 12px; }
.case-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.case-btn {
  padding: 9px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-chip); color: var(--text);
  font-family: var(--font-mono); font-size: 0.64rem; cursor: pointer; text-align: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.case-btn:hover { border-color: var(--text); }
.case-out { background: var(--bg-chip); }
.case-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- CALC ---------- */
.calc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.calc-mode { display: flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.calc-modebtn {
  padding: 7px 16px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-size: 0.68rem; cursor: pointer; transition: all 0.2s ease;
}
.calc-modebtn.active { background: var(--invert-bg); color: var(--invert-text); }
.calc-display {
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elev);
  padding: 16px 18px; margin-bottom: 12px; text-align: right; min-height: 84px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px;
}
.calc-expr { color: var(--muted); font-size: 0.85rem; min-height: 1.2em; word-break: break-all; }
.calc-result {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.8rem, 7vw, 2.4rem); line-height: 1;
  font-variant-numeric: tabular-nums; word-break: break-all;
}
.calc-keys { display: grid; gap: 6px; }
.calc-keys.basic { grid-template-columns: repeat(4, 1fr); }
.calc-keys.sci { grid-template-columns: repeat(6, 1fr); }
.calc-key {
  min-height: 46px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg-chip); color: var(--text);
  font-family: var(--font-mono); font-size: 0.85rem; cursor: pointer;
  transition: transform 0.12s var(--ease-out), background-color 0.2s ease, border-color 0.2s ease;
}
.calc-key:hover { border-color: var(--line-strong); background: var(--bg-elev); }
.calc-key:active { transform: scale(0.94); }
.calc-key.op { color: var(--muted); }
.calc-key.eq { background: var(--invert-bg); color: var(--invert-text); border-color: var(--invert-bg); }
.calc-key.fn { font-size: 0.68rem; }
.calc-key.wide { grid-column: span 2; }
.calc-history { margin-top: 12px; display: grid; gap: 4px; max-height: 96px; overflow-y: auto; }
.calc-history div { color: var(--muted); font-size: 0.66rem; text-align: right; cursor: pointer; padding: 2px 0; }
.calc-history div:hover { color: var(--text); }

@media (max-width: 560px) {
  .utility { left: 8px; right: 8px; top: 50%; bottom: auto; transform: translateY(-50%); width: auto; max-height: 92vh; max-height: 92dvh; }
  @keyframes utilIn { from { opacity: 0; transform: translateY(-46%); } to { opacity: 1; transform: translateY(-50%); } }
  .net-metrics { grid-template-columns: repeat(3, 1fr); }
  .calc-keys.sci { grid-template-columns: repeat(5, 1fr); }
  .units-io { flex-wrap: wrap; }
  .speed-meta { grid-template-columns: 1fr; }
  .net-head { flex-wrap: wrap; }
  .net-metrics { grid-template-columns: repeat(2, 1fr); }
  .toolkit-grid { grid-template-columns: 1fr; }
  .net-log-row { grid-template-columns: 40px 22px 1fr auto; gap: 6px; }
  .biz-actions .util-chip, .preset-row .util-chip { flex: 1 1 auto; text-align: center; }
}

/* ==========================================================================
   v3 — ambient field · content · toolkit · captcha · monitor · offline
   ========================================================================== */

/* Ambient science field sits behind content, above the page background */
.field-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; opacity: 0.42;
}
:root[data-theme="light"] .field-canvas { opacity: 0.5; }
#main { position: relative; z-index: 1; }
.site-footer { position: relative; z-index: 1; }

/* ---------- What I do ---------- */
.focus-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-bottom: 48px;
}
.focus-card {
  position: relative; padding: 28px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--bg-elev);
  transition: transform 0.3s var(--ease-out), border-color 0.25s ease, box-shadow 0.3s ease;
}
.focus-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.focus-num {
  display: inline-block; color: var(--muted); margin-bottom: 14px;
  font-size: 0.72rem; letter-spacing: 0.14em;
}
.focus-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.01em; }
.focus-card p { color: var(--muted); margin: 0; font-size: 0.96rem; }
.cap-block { padding-top: 8px; }
.cap-block .cluster-title { margin-bottom: 16px; }

/* ---------- Toolkit section ---------- */
.toolkit-lede { max-width: 60ch; color: var(--muted); font-size: 1.05rem; margin-bottom: 32px; }
.toolkit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.toolkit-tile {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start;
  text-align: left; padding: 20px; min-height: 104px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-elev);
  color: var(--text); cursor: pointer;
  transition: transform 0.25s var(--ease-out), border-color 0.2s ease, background-color 0.2s ease;
}
.toolkit-tile:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.toolkit-tile-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.toolkit-tile-desc { color: var(--muted); font-size: 0.62rem; line-height: 1.4; }
.toolkit-tile-cta { background: var(--invert-bg); }
.toolkit-tile-cta .toolkit-tile-name, .toolkit-tile-cta .toolkit-tile-desc { color: var(--invert-text); }

/* ---------- Slide-to-verify captcha ---------- */
.captcha { max-width: 460px; margin: 8px auto 0; text-align: left; transition: opacity 0.5s ease, transform 0.5s var(--ease-out), filter 0.5s ease; }
.captcha.solved { opacity: 0; transform: scale(0.97); filter: blur(4px); pointer-events: none; height: 0; margin: 0; overflow: hidden; }
.captcha-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.captcha-tag { color: var(--muted); }
.captcha-hint { color: var(--muted); font-size: 0.62rem; }
.captcha-track {
  position: relative; height: 56px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--bg-chip); overflow: hidden;
  touch-action: none; user-select: none;
}
.captcha-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: color-mix(in srgb, var(--text) 12%, transparent); }
.captcha-slot {
  position: absolute; top: 7px; bottom: 7px; width: 44px; left: 0;
  border: 1.5px dashed var(--line-strong); border-radius: 10px; box-sizing: border-box;
}
.captcha-piece { display: none; }
.captcha-knob {
  position: absolute; top: 6px; bottom: 6px; left: 0; width: 44px; z-index: 3;
  display: grid; place-items: center; border: 0; border-radius: 10px;
  background: var(--invert-bg); color: var(--invert-text); cursor: grab;
  box-shadow: 0 4px 14px -6px rgba(0,0,0,0.6); touch-action: none;
}
.captcha-track.dragging .captcha-knob { cursor: grabbing; }
.captcha-track.ok .captcha-knob { background: var(--text); }
.captcha-track.ok .captcha-fill { background: color-mix(in srgb, var(--text) 20%, transparent); }
.captcha-track.ok .captcha-slot { border-style: solid; border-color: var(--text); }
.captcha-decoy { position: absolute; top: 7px; bottom: 7px; width: 44px; border: 1.5px dashed var(--muted); border-radius: 10px; box-sizing: border-box; opacity: 0.55; transition: opacity 0.4s ease; }
.captcha-decoy.fade { opacity: 0; }
@keyframes captchaBad { 0%,100%{ transform: translateX(0);} 20%{ transform: translateX(-6px);} 60%{ transform: translateX(6px);} }
.captcha-track.bad { animation: captchaBad 0.4s ease; border-color: var(--line-strong); }
@media (prefers-reduced-motion: reduce) { .captcha-track.bad { animation: none; } }
.captcha-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.captcha-status { color: var(--muted); }
.captcha-track.ok ~ .captcha-foot .captcha-status { color: var(--text); }
.captcha-auto { background: transparent; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 6px; font-size: 0.68rem; }
.captcha-auto:hover { color: var(--text); }

/* ---------- Command palette: breadcrumb + groups ---------- */
.cmdk-crumb { display: flex; align-items: center; gap: 6px; padding: 12px 16px 0; flex-wrap: wrap; }
.cmdk-crumb[hidden] { display: none; }
.cmdk-crumb-seg { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-family: var(--font-mono); font-size: 0.66rem; padding: 2px 4px; border-radius: 5px; }
.cmdk-crumb-seg:last-of-type, .cmdk-crumb-seg:hover { color: var(--text); }
.cmdk-crumb-sep { color: var(--line-strong); }
.cmdk-item-tag.is-group { color: var(--text); }

/* ---------- Machine monitor HUD ---------- */
.monitor {
  position: fixed; left: 16px; bottom: 16px; z-index: 45;
  font-family: var(--font-mono); max-width: calc(100vw - 32px);
}
.monitor-handle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 999px; background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--muted); cursor: pointer; font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.monitor-handle:hover { color: var(--text); border-color: var(--line-strong); }
.monitor-pulse { width: 8px; height: 8px; border-radius: 999px; background: #4ade80; color: #4ade80; box-shadow: 0 0 0 0 currentColor; }
@media (prefers-reduced-motion: no-preference) { .monitor-pulse { animation: monPulse 2.4s ease-in-out infinite; } }
@keyframes monPulse { 0%,100%{ opacity: 0.45; box-shadow: 0 0 0 0 currentColor; } 50%{ opacity: 1; box-shadow: 0 0 8px 1px currentColor; } }
.monitor-pulse.is-offline { background: #e5534b; color: #e5534b; }
.monitor-net-badge { color: #4ade80; }
.monitor-net-badge.is-offline { color: #e5534b; font-weight: 500; }

/* ---------- Circuit-connection puzzle (contact) ---------- */
.circuit { max-width: 560px; margin: 8px auto 0; text-align: left; transition: opacity 0.5s ease, transform 0.5s var(--ease-out), filter 0.5s ease; }
.circuit.solved { opacity: 0; transform: scale(0.97); filter: blur(4px); pointer-events: none; height: 0; margin: 0; overflow: hidden; }
.circuit-board { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--bg-chip); }
.circuit-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.circuit-cell { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-elev); cursor: pointer; padding: 0; transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease; }
.circuit-cell:hover { border-color: var(--line-strong); }
.circuit-cell:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.circuit-cell svg { display: block; width: 100%; height: 100%; }
.circuit-cell .rot { transform-origin: 50px 50px; transition: transform 0.16s ease; }
@media (prefers-reduced-motion: reduce) { .circuit-cell .rot { transition: none; } }
.circuit-cell .wire { stroke: var(--line-strong); stroke-width: 11; fill: none; stroke-linecap: round; transition: stroke 0.2s ease; }
.circuit-cell .dot { fill: var(--line-strong); transition: fill 0.2s ease; }
.circuit-cell.on .wire { stroke: #4ade80; stroke-dasharray: 12 7; animation: wireFlow 0.55s linear infinite; }
@keyframes wireFlow { to { stroke-dashoffset: -19; } }
@media (prefers-reduced-motion: reduce) { .circuit-cell.on .wire { animation: none; stroke-dasharray: none; } }
.circuit-cell.on .dot { fill: #4ade80; }
.circuit-cell.on { border-color: color-mix(in srgb, #4ade80 45%, var(--line)); box-shadow: 0 0 12px -5px #4ade80; }
.circuit-cell.flash .wire { stroke: #4ade80; }
.circuit-cell.flash { border-color: color-mix(in srgb, #4ade80 45%, var(--line)); }
.circuit-node { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--bg-elev); color: var(--muted); transition: color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease; }
.circuit-src { color: #f6a13c; }
.circuit.live .circuit-bulb, .circuit-bulb.lit { color: #4ade80; border-color: #4ade80; box-shadow: 0 0 16px -4px #4ade80; }
.circuit-bypass { margin-top: 14px; }
.circuit-bypass[hidden] { display: none; }
.circuit-bypass .captcha-hint { display: block; margin-bottom: 10px; }
.circuit-bypass { animation: revealIn 0.5s var(--ease-out); }
@media (prefers-reduced-motion: reduce) { .circuit-bypass { animation: none; } }

/* ---------- Business analyzer v2 ---------- */
.biz-form-3 { grid-template-columns: repeat(3, 1fr); }
.biz-hint { color: var(--muted); font-size: 0.6rem; line-height: 1.45; opacity: 0.85; }
.biz-warns { display: grid; gap: 6px; margin: 0 0 18px; }
.biz-warns:empty { display: none; }
.biz-warn { display: flex; gap: 10px; align-items: baseline; border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: 10px; padding: 9px 13px; font-size: 0.68rem; line-height: 1.5; background: var(--bg-elev); color: var(--muted); font-family: var(--font-mono); }
.biz-warn b { color: var(--text); font-weight: 600; }
.biz-warn.bad { border-left-color: #e5534b; }
.biz-warn.warn { border-left-color: #f6a13c; }
.biz-warn.good { border-left-color: #4ade80; }
.biz-warn.info { border-left-color: #58a6ff; }
.biz-res.good b { color: #4ade80; }
.biz-res.bad b { color: #e5534b; opacity: 1; }
.biz-res.sub { grid-column: 1 / -1; background: var(--bg-chip); font-size: 0.64rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 8px 14px; }
.biz-span2 { grid-column: 1 / -1; }
.tax-plain { border: 1px solid var(--line); border-left: 3px solid #4ade80; border-radius: 10px; background: var(--bg-elev); padding: 12px 14px; color: var(--text); font-size: 0.72rem; line-height: 1.7; margin: 0 0 18px; }
.tax-plain.loss { border-left-color: #e5534b; }
.tax-plain .monitor-dim { display: block; }

/* ---------- Network: route + comms log ---------- */
.net-route { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-top: 16px; background: var(--bg-elev); }
.net-route .util-card-title { display: block; margin-bottom: 8px; }
.net-route-path { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 0.66rem; color: var(--text); margin-bottom: 14px; line-height: 1.8; }
.net-hop { border: 1px solid var(--line-strong); border-radius: 8px; padding: 4px 9px; background: var(--bg-chip); white-space: nowrap; }
.net-hop small { display: block; color: var(--muted); font-size: 0.85em; }
.net-hop-arrow { color: #4ade80; }
.net-log { max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; font-size: 0.6rem; overscroll-behavior: contain; }
.net-log:empty::before { content: "Waiting for the first request\2026"; color: var(--muted); }
.net-log-row { display: grid; grid-template-columns: 52px 34px 1fr auto; gap: 10px; color: var(--muted); padding: 3px 6px; border-radius: 6px; }
.net-log-row:nth-child(odd) { background: var(--bg-chip); }
.net-log-row .t { color: var(--muted); opacity: 0.8; }
.net-log-row .dir { font-weight: 600; }
.net-log-row .dir.d { color: #58a6ff; }
.net-log-row .dir.u { color: #f6a13c; }
.net-log-row .dir.p { color: #4ade80; }
.net-log-row .dir.i { color: var(--text); }
.net-log-row .what { color: var(--text); word-break: break-word; }
.net-log-row .ms { color: var(--muted); text-align: right; white-space: nowrap; }
.net-flow { position: relative; height: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-chip); margin-bottom: 14px; overflow: hidden; }
.net-flow-label { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 0.56rem; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.75; pointer-events: none; }
.pkt { position: absolute; width: 7px; height: 7px; border-radius: 999px; transform: translateY(-50%); }
.pkt-d { background: #58a6ff; box-shadow: 0 0 8px -2px #58a6ff; animation: pktL var(--dur, 1.2s) linear forwards; }
.pkt-u { background: #f6a13c; box-shadow: 0 0 8px -2px #f6a13c; animation: pktR var(--dur, 1.2s) linear forwards; }
.pkt-p { background: #4ade80; box-shadow: 0 0 8px -2px #4ade80; animation: pktR var(--dur, 1.2s) linear forwards; }
@keyframes pktL { from { left: 100%; } to { left: -8px; } }
@keyframes pktR { from { left: -8px; } to { left: 100%; } }
.net-hop.live { border-color: color-mix(in srgb, #4ade80 45%, var(--line-strong)); box-shadow: 0 0 10px -4px #4ade80; }
@media (prefers-reduced-motion: reduce) { .pkt { display: none; } }
.monitor[data-collapsed="false"] .monitor-handle { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.monitor-body {
  width: 300px; max-width: calc(100vw - 32px); margin-top: -1px;
  border: 1px solid var(--line); border-radius: 12px; border-top-left-radius: 4px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  padding: 12px 14px; box-shadow: var(--shadow);
}
.monitor-body[hidden] { display: none; }
.monitor-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.6rem; color: var(--text); margin-bottom: 10px; }
.monitor-dim { color: var(--muted); }
.monitor-close { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; }
.monitor-close:hover { color: var(--text); }
.monitor-grid { display: grid; gap: 7px; }
.mon-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 6px 10px; font-size: 0.62rem; }
.mon-label { color: var(--muted); }
.mon-val { color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }
.mon-spark { grid-column: 1 / -1; width: 100%; height: 30px; opacity: 0.85; }
.monitor-note { color: var(--muted); font-size: 0.54rem; margin: 10px 0 0; opacity: 0.8; }
@media (max-width: 600px) { .monitor { left: 8px; bottom: 8px; } .monitor-body { width: min(300px, calc(100vw - 20px)); } }

/* ---------- Offline overlay + game ---------- */
.offline {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}
.offline[hidden] { display: none; }
.offline-card { max-width: 700px; width: 100%; text-align: center; }
.offline-icon { color: var(--muted); display: inline-block; margin-bottom: 14px; }
.offline-title { font-size: clamp(1.8rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; }
.offline-sub { color: var(--muted); margin: 12px auto 28px; max-width: 44ch; }
.offline-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.offline-game { margin-top: 28px; }
.offline-game[hidden] { display: none; }
#offline-canvas {
  width: 100%; max-width: 640px; height: auto; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-elev); touch-action: none;
}
.offline-game-hint { color: var(--muted); margin-top: 10px; font-size: 0.66rem; }
.offline-reconnect { display: block; margin-top: 22px; color: var(--muted); font-size: 0.66rem; }

/* ---------- Network: options, ISP, metrics (8) ---------- */
.net-metrics { grid-template-columns: repeat(4, 1fr); }
.net-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 14px; color: var(--muted); font-size: 0.66rem; }
.net-opt { display: inline-flex; align-items: center; gap: 6px; }
.net-num { width: 46px; background: var(--bg-chip); border: 1px solid var(--line); border-radius: 6px; color: var(--text); padding: 4px 6px; font-family: var(--font-mono); font-size: 0.66rem; }
.net-isp { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 16px; background: var(--bg-elev); }
.net-isp .util-card-title { display: block; margin-bottom: 10px; }
.net-isp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; font-size: 0.66rem; }
.isp-row { display: flex; justify-content: space-between; gap: 10px; }
.isp-row span:first-child { color: var(--muted); }
.isp-row span:last-child { color: var(--text); text-align: right; word-break: break-word; }

/* ---------- Business / Tax analyzers ---------- */
.tool-lede { color: var(--muted); font-size: 0.7rem; line-height: 1.6; margin: 0 0 18px; }
.tool-lede code { background: var(--bg-chip); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.biz-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.biz-field { display: grid; gap: 6px; }
.biz-field.biz-wide { grid-column: 1 / -1; }
.biz-field > span { color: var(--muted); font-size: 0.68rem; }
.biz-field .biz-dim { color: var(--muted); font-style: normal; font-size: 0.9em; }
.biz-field .util-input { width: 100%; font-family: var(--font-mono); }
.biz-combo { display: flex; gap: 6px; }
.biz-combo .util-input { flex: 1; min-width: 0; }
.biz-mode { flex: none; width: 42px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--bg-chip); color: var(--text); cursor: pointer; }
.biz-mode:hover { border-color: var(--text); }
.expr-eval { display: none; color: var(--muted); font-size: 0.62rem; padding-top: 2px; }
.expr-eval.show { display: block; }
.biz-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.biz-res { display: flex; justify-content: space-between; gap: 10px; padding: 11px 14px; background: var(--bg-elev); font-size: 0.72rem; align-items: baseline; }
.biz-res span { color: var(--muted); }
.biz-res b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; }
.biz-res.hl { background: var(--bg-chip); }
.biz-res.good b { color: #4ade80; }
.biz-res.bad b { color: #e5534b; }
.tool-explain { border: 1px solid var(--line); border-radius: 10px; background: var(--bg-chip); margin-top: 18px; font-size: 0.66rem; }
.tool-explain summary { cursor: pointer; padding: 10px 14px; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; font-size: 0.6rem; list-style: none; display: flex; align-items: center; gap: 9px; user-select: none; }
.tool-explain summary::-webkit-details-marker { display: none; }
.tool-explain summary::before { content: "?"; display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: 0.58rem; color: var(--text); flex: none; }
.tool-explain summary:hover { color: var(--text); }
.tool-explain[open] summary { color: var(--text); border-bottom: 1px solid var(--line); }
.tool-explain-body { padding: 12px 14px 14px; color: var(--muted); line-height: 1.75; display: grid; gap: 9px; }
.tool-explain-body b { color: var(--text); font-weight: 600; }
.tool-explain-body code { color: var(--text); background: var(--bg-elev); border: 1px solid var(--line); padding: 0 5px; border-radius: 4px; }
.biz-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.preset-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.preset-label, .biz-hist-label { color: var(--muted); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
.biz-breakeven { border: 1px solid var(--line); border-left: 3px solid #58a6ff; border-radius: 10px; background: var(--bg-elev); padding: 10px 14px; color: var(--muted); font-size: 0.68rem; line-height: 1.6; margin: 0 0 14px; }
.biz-breakeven b { color: var(--text); }
.biz-breakeven:empty { display: none; }
.biz-history { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.biz-res.ghost { opacity: 0.8; outline: 1px dashed var(--line-strong); outline-offset: -1px; }
.net-verdict { border: 1px solid var(--line); border-left: 3px solid #4ade80; border-radius: 10px; background: var(--bg-elev); padding: 11px 14px; color: var(--text); font-size: 0.7rem; line-height: 1.7; margin: 16px 0 0; }
.util-chip[disabled] { opacity: 0.45; cursor: not-allowed; }
.health-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 4px; }
.health-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg-elev); }
.health-card > .util-card-title { display: block; margin-bottom: 12px; }
.health-form { margin-bottom: 12px; }
.health-form { grid-template-columns: repeat(2, 1fr); }
.health-results { grid-template-columns: 1fr; margin-bottom: 0; }
.health-card .biz-warns { margin: 10px 0 0; }
@media (max-width: 860px) { .health-grid { grid-template-columns: 1fr; } }
.utility-tabs { position: relative; }
.utab-ink { position: absolute; bottom: 0; left: 0; height: 2px; width: 0; background: var(--text); border-radius: 2px; transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: none; }
.biz-warn.warn-in { animation: warnIn 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
@keyframes warnIn { from { opacity: 0; transform: translateX(-8px); } }
@media (prefers-reduced-motion: reduce) { .utab-ink { transition: none; } .biz-warn.warn-in { animation: none; } }
.biz-charts { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.biz-canvas { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-chip); }
.biz-donut { max-width: 300px; }
@media (max-width: 860px) { .biz-form-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .biz-charts { grid-template-columns: 1fr; } .biz-form, .biz-form-3 { grid-template-columns: 1fr; } .biz-results { grid-template-columns: 1fr; } }

/* Touch & coarse-pointer hardening: comfortable hit targets */
@media (pointer: coarse) {
  .utab, .util-chip, .units-cat, .biz-mode, .terminal-close, .monitor-close { min-height: 44px; }
  .nav-icon-btn, .theme-toggle, .menu-toggle, .units-swap { min-width: 44px; min-height: 44px; }
  .util-input, .util-select, .net-num { min-height: 42px; }
  .circuit-cell { min-width: 34px; }
  .calc-keys button { min-height: 48px; }
}
/* Prevent iOS zoom-on-focus (inputs must be ≥16px) */
@media (max-width: 640px) {
  .util-input, .util-select, .terminal-body input, .net-num { font-size: 16px; }
}
/* Very narrow phones (≤380px) */
@media (max-width: 380px) {
  .hero-title { font-size: clamp(2rem, 13vw, 2.6rem); }
  .utility-tabs { overflow-x: auto; scrollbar-width: none; }
  .utility-tabs::-webkit-scrollbar { display: none; }
  .utab { flex: 0 0 auto; }
  .biz-form, .biz-form-3, .health-form { grid-template-columns: 1fr; }
  .circuit-grid { gap: 2px; }
}
/* Short landscape phones: keep the toolkit usable */
@media (max-height: 480px) {
  .utility { left: 50%; right: auto; top: 4px; bottom: 4px; transform: translateX(-50%); width: min(1240px, calc(100vw - 16px)); max-height: none; }
  @keyframes utilIn { from { opacity: 0; } to { opacity: 1; } }
}

/* ---------- Time tools + tz search ---------- */
.tz-add { position: relative; margin-top: 10px; }
.tz-add .util-input { width: 100%; }
.tz-results { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; max-height: 220px; overflow-y: auto; }
.tz-results[hidden] { display: none; }
.tz-result { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; background: var(--bg-elev); border: 0; border-bottom: 1px solid var(--line); color: var(--text); cursor: pointer; font-size: 0.72rem; }
.tz-result:last-child { border-bottom: 0; }
.tz-result:hover { background: var(--bg-chip); }
.tz-result .mono { color: var(--muted); font-size: 0.62rem; }
.time-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.time-tool { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--bg-elev); }
.time-tool .util-card-title { display: block; margin-bottom: 10px; }
.tt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tt-row .util-input { flex: 1; min-width: 0; }
.tt-arrow { color: var(--muted); }
.tt-out { color: var(--text); font-size: 0.72rem; line-height: 1.5; }
@media (max-width: 560px) { .time-tools { grid-template-columns: 1fr; } }

/* ---------- Calc: editable expr + rich history ---------- */
.calc-expr { width: 100%; background: transparent; border: 0; outline: none; text-align: right; color: var(--muted); font-size: 0.9rem; font-family: var(--font-mono); }
.calc-expr::placeholder { color: var(--line-strong); }
.calc-history-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 8px; color: var(--muted); font-size: 0.66rem; }
.calc-hist-clear { background: transparent; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.calc-hist-clear:hover { color: var(--text); }
.calc-history { display: grid; gap: 2px; max-height: 150px; overflow-y: auto; }
.calc-hist-row { display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: 6px; padding: 5px 4px; border-radius: 6px; }
.calc-hist-row:hover { background: var(--bg-chip); }
.calc-hist-expr { color: var(--muted); font-size: 0.66rem; text-align: right; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-hist-expr:hover { color: var(--text); }
.calc-hist-eq { color: var(--line-strong); font-size: 0.66rem; }
.calc-hist-res { color: var(--text); font-size: 0.72rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.calc-hist-edit, .calc-hist-del { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 0.72rem; padding: 2px 4px; }
.calc-hist-edit:hover, .calc-hist-del:hover { color: var(--text); }
.calc-hist-empty { text-align: center; padding: 12px; }

/* ---------- Case: rich contenteditable ---------- */
.case-editor { width: 100%; min-height: 110px; max-height: 220px; overflow-y: auto; line-height: 1.55; font-size: 0.9rem; white-space: pre-wrap; word-break: break-word; }
.case-editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.case-editor:focus { outline: none; border-color: var(--line-strong); }
