/* 玻璃液晶 MZI 光子计算 · CNN 部署仿真 — in the look of photonics-layout-cookbook (gh-pages):
   indigo night, cyan light, amber metal, violet and pink accents; drifting aurora, glass cards, pill controls. */

@font-face { font-family: "Cookbook Display"; src: url("/assets/cookbook-display.8bd1350dfc.woff2") format("woff2"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Cookbook Display"; src: url("/assets/cookbook-display-black.3b14c912fd.woff2") format("woff2"); font-weight: 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/assets/inter.0fc98da206.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/assets/jetbrains-mono.2bd66545bd.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #090b1d;
  --bg-2: #0e1128;
  --bg-3: #161a3c;
  --pit: #04050d;
  --surface: rgba(14, 17, 40, .72);
  --line: #232a52;
  --line-2: #373f73;
  --ink: #f6f7ff;
  --ink-2: #c3cae4;
  --ink-3: #8d96ba;
  --ink-thin: #c7cbf4;
  --cy: #5ee7f5;
  --cy-2: #2a9db3;
  --au: #ffc457;
  --pk: #ff8fd8;
  --vi: #9d8cff;
  --mint: #7fe3a1;
  --grad: linear-gradient(90deg, var(--cy), #fff 52%, var(--pk));
  /* roles used by app.js */
  --light: var(--cy);      /* light in the waveguides */
  --sigma: var(--vi);      /* Σ attenuators */
  --lc: var(--mint);       /* liquid-crystal cell */
  --rule: var(--line);
  --rule-2: var(--line-2);
  --tag-meas: #7fe3a1; --tag-sim: #5ee7f5; --tag-est: #ffc457;
  --radius: 18px;
  --cjk: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --display: "Cookbook Display", var(--cjk), system-ui, sans-serif;
  --sans: "Inter", var(--cjk), system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* , *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink-2); font: 13px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
::selection { background: rgba(94, 231, 245, .28); color: #fff; }
:focus-visible { outline: 2px solid var(--cy); outline-offset: 2px; border-radius: 6px; }
b, strong { color: var(--ink); font-weight: 600; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- the night behind the page: three drifting lights, graph-paper dots, a little grain ---------- */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: linear-gradient(180deg, #0c0e28 0%, var(--bg) 44%, #0d0b26 100%); }
.aurora { position: absolute; border-radius: 50%; will-change: transform; }
.aurora.a1 { right: -26vmax; top: -34vmax; width: 86vmax; height: 70vmax; background: radial-gradient(closest-side, rgba(128, 100, 255, .42), rgba(128, 100, 255, .15) 52%, transparent); animation: drift-a 44s ease-in-out infinite alternate; }
.aurora.a2 { left: -34vmax; top: 14vmax; width: 80vmax; height: 72vmax; background: radial-gradient(closest-side, rgba(20, 160, 208, .3), rgba(20, 160, 208, .1) 52%, transparent); animation: drift-b 56s ease-in-out infinite alternate; }
.aurora.a3 { right: -14vmax; bottom: -40vmax; width: 84vmax; height: 64vmax; background: radial-gradient(closest-side, rgba(210, 84, 216, .26), rgba(210, 84, 216, .08) 52%, transparent); animation: drift-c 50s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate3d(-10vmax, 8vmax, 0) scale(1.14); } }
@keyframes drift-b { to { transform: translate3d(9vmax, -7vmax, 0) scale(1.1); } }
@keyframes drift-c { to { transform: translate3d(-8vmax, -6vmax, 0) scale(1.16); } }
.backdrop::before { content: ""; position: absolute; inset: 0; opacity: .55; background-image: radial-gradient(rgba(176, 186, 255, .2) 1px, transparent 1.5px); background-size: 30px 30px; -webkit-mask: radial-gradient(95% 72% at 50% 28%, #000 8%, transparent 76%); mask: radial-gradient(95% 72% at 50% 28%, #000 8%, transparent 76%); }
.backdrop::after { content: ""; position: absolute; inset: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
@media (prefers-reduced-motion: reduce) { .aurora { animation: none; } .flow { animation: none !important; } }

/* ---------- header: transparent, turns to glass when scrolled ---------- */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 22px; padding: 14px 28px; border-bottom: 1px solid transparent; transition: background .3s, border-color .3s; }
.top.is-scrolled { background: linear-gradient(180deg, rgba(9, 11, 26, .985), rgba(8, 10, 22, .96)); border-bottom-color: var(--line); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 0 8px rgba(94, 231, 245, .45)); }
.brand .eyebrow { margin: 0 0 4px; }
.brand h1 { margin: 0; font: 900 21px/1.1 var(--display); letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }
.brand h1 .thin { font-weight: 300; color: var(--ink-thin); }
.brand p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-3); }
.brand p i { color: var(--ink-2); }
.top .spacer { flex: 1; }
.legend-tags { display: flex; gap: 8px; align-items: center; padding: 7px 14px; border: 1px solid var(--line-2); border-radius: 999px; font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

/* small labels wear the gradient of the banner: cyan, white, pink */
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: .7em; width: fit-content; max-width: 100%; font: 500 10.5px/1.4 var(--mono); letter-spacing: .2em; text-transform: uppercase; background: var(--grad) 0 0 / max(100%, 30em) 100% no-repeat; -webkit-background-clip: text; background-clip: text; color: transparent; }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--cy); box-shadow: 0 0 0 4px rgba(94, 231, 245, .14), 0 0 14px rgba(94, 231, 245, .7); flex: none; }

/* data provenance tags */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 18px; padding: 0 7px; border-radius: 999px; border: 1px solid currentColor; font: 600 10px/1 var(--sans); letter-spacing: .04em; white-space: nowrap; text-transform: none; background: color-mix(in srgb, currentColor 10%, transparent); }
.tag.meas { color: var(--tag-meas); }
.tag.sim { color: var(--tag-sim); }
.tag.est { color: var(--tag-est); }

/* ---------- layout & panels ---------- */
.layout { display: grid; grid-template-columns: 384px minmax(0, 1fr); gap: 20px; padding: 6px 28px 40px; align-items: start; max-width: 1840px; margin-inline: auto; }
.panel { position: relative; background: linear-gradient(180deg, rgba(24, 28, 64, .8), rgba(12, 14, 34, .84)); contain: layout paint style; isolation: isolate; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .05); }
.zone-title { display: flex; align-items: center; gap: 14px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.zone-title .num { font: 500 11px/1 var(--mono); letter-spacing: .14em; color: var(--cy); padding: 6px 9px; border: 1px solid rgba(94, 231, 245, .35); border-radius: 999px; background: rgba(94, 231, 245, .07); box-shadow: 0 0 18px rgba(94, 231, 245, .12); }
.zone-title h2 { margin: 0; font: 900 22px/1 var(--display); letter-spacing: -.02em; color: var(--ink); }
.zone-title .sub { font: 300 14px/1.2 var(--display); color: var(--ink-thin); letter-spacing: -.005em; }
.zone-title .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- input zone ---------- */
.inputs { position: sticky; top: 80px; max-height: calc(100vh - 96px); display: flex; flex-direction: column; }
.inputs .scroll { overflow: auto; padding: 4px 0 8px; flex: 1; }
.sec { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h3 { margin: 0 0 12px; font: 600 13px/1.3 var(--sans); color: var(--ink); display: flex; align-items: center; gap: 8px; }
.sec h3 .hint { margin-left: auto; font: 500 9.5px/1.3 var(--mono); letter-spacing: .12em; color: var(--ink-3); text-transform: uppercase; }
details.sec > summary { list-style: none; cursor: pointer; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary h3 { margin: 0; }
details.sec[open] > summary h3 { margin-bottom: 12px; }
details.sec > summary h3::after { content: "›"; margin-left: 6px; color: var(--cy); font-size: 16px; line-height: 1; transition: transform .25s var(--ease); }
details.sec[open] > summary h3::after { transform: rotate(90deg); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { display: flex; flex-direction: column; align-items: flex-start; padding: 8px 13px; border: 1px solid var(--line-2); border-radius: 12px; background: rgba(255, 255, 255, .025); cursor: pointer; font-size: 12.5px; line-height: 1.25; color: var(--ink); transition: border-color .2s, background .2s, box-shadow .2s; }
.chip small { color: var(--ink-3); font: 400 10px/1.4 var(--mono); margin-top: 2px; }
.chip:hover { border-color: var(--ink-3); background: rgba(255, 255, 255, .06); }
.chip.on { border-color: var(--cy); background: rgba(94, 231, 245, .1); box-shadow: 0 0 0 1px rgba(94, 231, 245, .25) inset, 0 0 22px rgba(94, 231, 245, .14); }
.chip.on small { color: #9feef7; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(4, 5, 13, .4); }
.seg button { border: 0; background: none; padding: 6px 13px; border-radius: 999px; cursor: pointer; font-size: 12px; color: var(--ink-2); transition: background .2s, color .2s; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.field { display: grid; grid-template-columns: 1fr 104px; gap: 10px; align-items: center; margin: 8px 0; }
.field label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); min-width: 0; }
.field label .tag { flex: none; }
.field .ctl { display: flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(4, 5, 13, .55); overflow: hidden; transition: border-color .2s, box-shadow .2s; }
.field .ctl:hover { border-color: #4a5388; }
.field .ctl:focus-within { border-color: var(--cy); box-shadow: 0 0 0 3px rgba(94, 231, 245, .14), 0 0 18px rgba(94, 231, 245, .12); }
.field input { width: 100%; min-width: 0; border: 0; padding: 7px 9px; outline: none; text-align: right; font: 500 12px var(--mono); color: var(--ink); background: transparent; }
.field input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--cy); }
.field .unit { color: var(--ink-3); font: 400 10.5px var(--mono); padding-right: 9px; white-space: nowrap; }
select { appearance: none; -webkit-appearance: none; border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 28px 7px 10px; font-size: 12px; color: var(--ink); cursor: pointer;
  background: rgba(4, 5, 13, .55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%235ee7f5' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center; transition: border-color .2s; }
select:hover { border-color: #4a5388; }
select:focus { outline: none; border-color: var(--cy); box-shadow: 0 0 0 3px rgba(94, 231, 245, .14); }
option { background: var(--bg-2); color: var(--ink); }
.field select { width: 100%; }
input[type="number"]::-webkit-inner-spin-button { opacity: .35; }
input[type="range"] { accent-color: var(--cy); }
.field-note { color: var(--ink-3); font-size: 11px; margin: -3px 0 8px; line-height: 1.5; }
.derived { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 5, 13, .45); font-size: 11.5px; color: var(--ink-3); }
.derived b { font: 600 11.5px var(--mono); color: var(--cy); }

.layers { display: flex; flex-direction: column; gap: 6px; }
.lrow { display: grid; grid-template-columns: 16px 1.3fr 1fr 1fr 20px; gap: 6px; align-items: center; }
.lrow .idx { font: 11px var(--mono); color: var(--ink-3); }
.lrow select, .lrow input { width: 100%; min-width: 0; border: 1px solid var(--line-2); border-radius: 9px; padding: 6px 7px; font-size: 12px; color: var(--ink); background-color: rgba(4, 5, 13, .55); }
.lrow select { padding-right: 24px; background-position: right 8px center; }
.lrow input { font-family: var(--mono); text-align: right; outline: none; }
.lrow input:focus { border-color: var(--cy); }
.lrow .x { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 16px; padding: 0; transition: color .2s; }
.lrow .x:hover { color: var(--pk); }
.lrow .dim { visibility: hidden; }
.addrow { width: 100%; margin-top: 8px; padding: 7px; border: 1px dashed var(--line-2); border-radius: 10px; background: none; cursor: pointer; color: var(--ink-3); font-size: 12px; transition: border-color .2s, color .2s, background .2s; }
.addrow:hover { border-color: var(--cy); color: var(--cy); background: rgba(94, 231, 245, .05); }
.shape-flow { margin-top: 10px; font: 11px/1.8 var(--mono); color: var(--ink-2); }
.shape-flow span { white-space: nowrap; }
.shape-flow .arrow { color: var(--cy); margin: 0 3px; opacity: .7; }
.warn { color: var(--pk); font-size: 11.5px; margin-top: 6px; }

.run-bar { display: flex; gap: 8px; align-items: center; padding: 16px 22px; border-top: 1px solid var(--line); background: rgba(4, 5, 13, .35); border-radius: 0 0 var(--radius) var(--radius); }
.run-bar .field label { color: var(--ink-3) !important; font: 500 10px var(--mono) !important; letter-spacing: .14em; text-transform: uppercase; }
/* the solid button: white pill, a streak of cyan light crosses it when pointed at */
.btn-run { position: relative; overflow: hidden; flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 18px; border: 1px solid var(--ink); border-radius: 999px; background: var(--ink); color: var(--bg); font: 600 14px/1 var(--sans); letter-spacing: .04em; cursor: pointer; box-shadow: 0 0 0 0 rgba(94, 231, 245, 0), 0 10px 30px -10px rgba(94, 231, 245, .5); transition: background .25s, box-shadow .3s, transform .15s; }
.btn-run::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 38%, rgba(94, 231, 245, .6) 50%, transparent 62%); transform: translateX(-120%); }
.btn-run:hover { background: #fff; box-shadow: 0 0 0 4px rgba(94, 231, 245, .14), 0 14px 36px -10px rgba(94, 231, 245, .65); }
.btn-run:hover::after { transform: translateX(120%); transition: transform .8s var(--ease-out); }
.btn-run:active { transform: translateY(1px); }
.btn-run:disabled { opacity: .55; cursor: progress; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(255, 255, 255, .025); color: var(--ink); font-size: 12px; cursor: pointer; white-space: nowrap; transition: border-color .25s, background .25s, color .25s; }
.btn:hover:not(:disabled) { border-color: var(--ink-3); background: rgba(255, 255, 255, .07); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.seed { width: 74px; }

/* ---------- compute zone ---------- */
.main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stepper { display: flex; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.step { display: flex; align-items: center; gap: 9px; padding: 8px 14px 8px 8px; border: 1px solid transparent; border-radius: 999px; background: none; cursor: pointer; color: var(--ink-3); white-space: nowrap; font-size: 12.5px; transition: color .2s, background .2s, border-color .2s; }
.step .n { width: 22px; height: 22px; border-radius: 50%; border: 1px solid currentColor; display: grid; place-items: center; font: 500 10.5px var(--mono); }
.step:hover:not(:disabled) { color: var(--ink); background: rgba(255, 255, 255, .04); }
.step.on { color: var(--ink); font-weight: 600; border-color: rgba(94, 231, 245, .4); background: rgba(94, 231, 245, .08); }
.step.on .n { background: var(--cy); color: var(--bg); border-color: var(--cy); box-shadow: 0 0 14px rgba(94, 231, 245, .6); }
.step.done:not(.on) { color: var(--ink-2); }
.step:disabled { cursor: default; opacity: .4; }
.stage { position: relative; min-height: 520px; padding: 22px 22px 22px; }
.stage-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.stage-head h3 { margin: 0; font: 900 24px/1.15 var(--display); letter-spacing: -.02em; color: var(--ink); }
.stage-head p { margin: 8px 0 0; max-width: 780px; color: var(--ink-3); font-size: 13px; line-height: 1.65; }
.stage-head p b { color: var(--ink); }
.stage-head .ctrls { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.formula { display: inline-block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--pit); font: 12.5px var(--mono); color: #cfd7ea; }
.placeholder { display: grid; place-items: center; min-height: 480px; color: var(--ink-3); text-align: center; }
.placeholder svg { opacity: .95; filter: drop-shadow(0 0 10px rgba(94, 231, 245, .15)); }
.placeholder h4 { margin: 18px 0 6px; font: 900 22px/1.1 var(--display); color: var(--ink); letter-spacing: -.02em; }

.console-wrap { padding: 0 22px 22px; }
.console-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font: 500 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-3); }
.console { height: 180px; overflow: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--pit); color: #cfd7ea; font: 11.5px/1.7 var(--mono); box-shadow: inset 0 0 40px rgba(94, 231, 245, .03); }
.console .ok { color: var(--mint); } .console .hl { color: var(--pk); } .console .dim { color: #5d6690; } .console .b { color: var(--cy); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--cy); box-shadow: 0 0 0 0 rgba(94, 231, 245, .6); animation: pulse 1.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(94, 231, 245, 0); } 100% { box-shadow: 0 0 0 0 rgba(94, 231, 245, 0); } }

.cap { margin-top: 8px; font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }
.cap b { color: var(--ink); }
.figlabel { font: 700 13px var(--sans); fill: var(--ink); }
.axis text, .tick { font: 10.5px var(--sans); fill: var(--ink-3); }
.grid line { stroke: var(--line); }

.row { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
/* glass card; its edge lights up where the pointer is near it (app.js sets --mx / --my) */
.card, .kpi { position: relative; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .012)); transition: border-color .3s; }
.card { padding: 16px; }
.card::before, .kpi::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s; background: radial-gradient(340px circle at var(--mx, 50%) var(--my, 0%), rgba(94, 231, 245, .08), transparent 62%); }
.card::after, .kpi::after { content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .35s; background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), rgba(94, 231, 245, .9), rgba(157, 140, 255, .35) 45%, transparent 70%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0); }
.card:hover::before, .card:hover::after, .kpi:hover::before, .kpi:hover::after { opacity: 1; }
.card > *, .kpi > * { position: relative; }
.card h4 { margin: 0 0 10px; font: 600 13px/1.3 var(--sans); color: var(--ink); display: flex; gap: 6px; align-items: center; }
.card h4 .tag { margin-left: auto; }

/* mesh */
.mesh-wrap { overflow-x: auto; padding: 8px 0; border: 1px solid var(--line); border-radius: 16px; background: radial-gradient(120% 140% at 50% 0%, rgba(42, 157, 179, .1), transparent 60%), var(--pit); }
.mesh-wrap svg { display: block; }
.mesh-box { position: relative; width: 100%; margin: 0 auto; }
.mesh-box > svg { display: block; width: 100%; height: auto; }
.mesh-light { position: absolute; left: 0; top: 0; pointer-events: none; }
/* detector readout: bars glide to the new reading as the light lands, with a short flash; the very first reading
   fades in from empty; scrubbing sets them directly */
.det-ideal, .det-bar { transition: x .28s var(--ease-out), width .28s var(--ease-out), fill .35s; }
.det-empty .det-ideal, .det-empty .det-bar { opacity: 0; }
.det-first .det-ideal, .det-first .det-bar { animation: det-in .45s var(--ease-out) both; }
@keyframes det-in { from { opacity: 0; } }
/* the flash is a keyframe, not a transition: a transition here would replace the x/width glide */
.det-hit .det-bar { animation: det-hit .3s ease-out; }
@keyframes det-hit { from { fill: #eafdff; } }
.det-instant .det-ideal, .det-instant .det-bar { transition: none; }
@media (prefers-reduced-motion: reduce) { .det-ideal, .det-bar { transition: fill .2s; } }
.mzi-hit { cursor: pointer; }
.mzi-hit:hover .mzi-body, .mzi-hit.sel .mzi-body { stroke: var(--ink); stroke-width: 2.2; }
.flow { stroke-dasharray: 3 9; animation: flow .9s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -12; } }
.paused .flow { animation-play-state: paused; }
canvas.hm { border-radius: 4px; }

/* ---------- output zone ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 20px 22px 8px; }
.kpi { padding: 16px 18px; }
.kpi .lbl { display: flex; align-items: center; gap: 6px; font: 500 10px/1.3 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.kpi .lbl .tag { margin-left: auto; letter-spacing: .04em; }
.kpi .val { margin-top: 10px; font: 300 34px/1 var(--display); letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .val small { margin-left: 5px; font: 400 12.5px var(--sans); color: var(--ink-3); letter-spacing: 0; }
.kpi .foot { margin-top: 8px; font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }
.kpi.hero { border-color: rgba(94, 231, 245, .45); background: radial-gradient(120% 120% at 0% 0%, rgba(94, 231, 245, .2), transparent 60%), radial-gradient(120% 120% at 100% 100%, rgba(255, 143, 216, .14), transparent 60%), rgba(14, 17, 40, .8); box-shadow: 0 0 40px -10px rgba(94, 231, 245, .35); }
.kpi.hero .val { font-weight: 900; background: var(--grad) 0 0 / 100% 100% no-repeat; -webkit-background-clip: text; background-clip: text; color: transparent; }
.kpi.hero .lbl { color: #9feef7; }
.outgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; padding: 14px 22px 22px; }
.outgrid > .card { min-width: 0; }
.span4 { grid-column: span 4; } .span5 { grid-column: span 5; } .span6 { grid-column: span 6; } .span7 { grid-column: span 7; } .span8 { grid-column: span 8; } .span12 { grid-column: span 12; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 12px; }
table.cmp th, table.cmp td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.cmp td { color: var(--ink-2); font-family: var(--mono); font-size: 11.5px; }
table.cmp td:first-child { font-family: var(--sans); font-size: 12px; color: var(--ink); }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp th { font: 500 9.5px/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
table.cmp tr:last-child td { border-bottom: 0; }
table.cmp tbody tr:hover td, table.cmp tr:hover td { background: rgba(255, 255, 255, .025); }
table.cmp td.ok { color: var(--mint); }
table.cmp tr.hl td { background: rgba(94, 231, 245, .08); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 11.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bignote { margin-top: 10px; padding: 11px 13px; border: 1px solid var(--line); border-left: 2px solid var(--cy); border-radius: 12px; background: rgba(94, 231, 245, .04); font-size: 12px; line-height: 1.65; color: var(--ink-2); }
.bignote b { color: var(--ink); }

/* tooltip */
.tip { position: fixed; z-index: 100; max-width: 300px; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(9, 11, 24, .97); box-shadow: 0 18px 50px rgba(0, 0, 0, .6); color: var(--ink-2); font-size: 11.5px; line-height: 1.55; pointer-events: none; opacity: 0; transition: opacity .12s; }
.tip b { color: var(--ink); }
.tip .m { font-family: var(--mono); color: var(--cy); }

/* MZI detail drawer */
.drawer { position: fixed; right: 20px; bottom: 20px; z-index: 50; width: 440px; border: 1px solid var(--line-2); border-radius: 18px; background: rgba(12, 14, 34, .96); box-shadow: 0 30px 90px rgba(0, 0, 0, .7), 0 0 0 1px rgba(94, 231, 245, .06); transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform .35s var(--ease-out), opacity .25s; }
.drawer.open { transform: none; opacity: 1; pointer-events: auto; }
.drawer .dh { display: flex; align-items: center; gap: 8px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.drawer .dh h4 { margin: 0; font: 900 16px/1.2 var(--display); letter-spacing: -.01em; color: var(--ink); }
.drawer .dh button { margin-left: auto; width: 28px; height: 28px; border: 1px solid var(--line-2); border-radius: 50%; background: none; font-size: 15px; line-height: 1; cursor: pointer; color: var(--ink-3); transition: color .2s, border-color .2s; }
.drawer .dh button:hover { color: var(--ink); border-color: var(--ink-3); }
.drawer .db { padding: 12px 16px 16px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12px; }
.kv span:nth-child(odd) { color: var(--ink-3); }
.kv span:nth-child(even) { font-family: var(--mono); text-align: right; color: var(--ink); }

.progress { height: 3px; margin-top: 10px; overflow: hidden; border-radius: 2px; background: var(--line); }
.progress.sweep div { width: 100%; transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease-out); }
.progress div { width: 0; height: 100%; background: linear-gradient(90deg, var(--cy), var(--vi), var(--pk)); box-shadow: 0 0 10px rgba(94, 231, 245, .6); transition: width .2s; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; padding: 6px 16px 32px; }
  .inputs { position: static; max-height: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span4, .span5, .span6, .span7, .span8 { grid-column: span 12; }
  .legend-tags { display: none; }
}
@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  .brand h1 { font-size: 16px; white-space: normal; }
  .brand p { display: none; }
  .kpis { grid-template-columns: 1fr; }
}
/* number inputs: no spinners, the values are typed */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- idle scene of the compute zone (before the first run) ---------- */
.idle { position: relative; isolation: isolate; overflow: hidden; display: grid; place-items: center; min-height: 560px; padding: 30px 20px 40px; border: 1px solid var(--line); border-radius: 18px; text-align: center;
  background: radial-gradient(60% 70% at 50% 38%, rgba(74, 60, 180, .22), transparent 70%), radial-gradient(40% 50% at 18% 90%, rgba(20, 160, 208, .12), transparent 70%), rgba(4, 5, 13, .35); }
/* the dots of the ground, brighter in a circle around the pointer */
.idle::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .6s; background: radial-gradient(rgba(170, 244, 255, .75) 1px, transparent 1.6px) 0 0 / 30px 30px; -webkit-mask: radial-gradient(220px circle at var(--px, 50%) var(--py, 50%), #000, transparent 72%); mask: radial-gradient(220px circle at var(--px, 50%) var(--py, 50%), #000, transparent 72%); }
.idle.is-pointed::before { opacity: 1; }
.idle::after { content: ""; position: absolute; inset: 0; z-index: -2; pointer-events: none; opacity: .5; background: radial-gradient(rgba(176, 186, 255, .16) 1px, transparent 1.5px) 0 0 / 30px 30px; -webkit-mask: radial-gradient(70% 60% at 50% 35%, #000, transparent 80%); mask: radial-gradient(70% 60% at 50% 35%, #000, transparent 80%); }
.idle-in { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; }

/* the die of the idle scene, after the chip of the circuits page of the gh-pages: tilted, lit from within, with a
   sheen that crosses it and a glare that follows the pointer */
.ic-stage { --tilt: 24deg; position: relative; width: 100%; margin: 0 0 30px; perspective: 2200px; }
.ic-halo { position: absolute; inset: -8% 4% -10%; border-radius: 50%; background: radial-gradient(closest-side, rgba(124, 104, 255, .32), rgba(94, 231, 245, .08) 60%, transparent); filter: blur(10px); pointer-events: none; }
.ic-body { position: relative; aspect-ratio: var(--aspect); transform-style: preserve-3d; transform: rotateX(calc(var(--tilt) + var(--ty, 0deg))) rotateY(var(--tx, 0deg)) rotateZ(-1deg); animation: ic-in 1.1s var(--ease-out) backwards; }
.ic-body.is-quiet { animation: none; }
@keyframes ic-in { from { opacity: 0; transform: rotateX(58deg) translateY(50px) rotateZ(-4deg); } }
.ic-body::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: -12%; height: 22%; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .6), transparent); transform: translateZ(-40px); pointer-events: none; }
.ic-tilt { position: absolute; inset: 0; transform-style: preserve-3d; }
.ic-tilt::before { content: ""; position: absolute; inset: 0; border-radius: 18px; background: var(--pit); transform: translateZ(-14px); box-shadow: 0 0 0 1px rgba(255, 255, 255, .1), 0 40px 90px -30px rgba(0, 0, 0, .9); }
.ic-die { position: absolute; inset: 0; overflow: hidden; border-radius: 18px; background: radial-gradient(120% 90% at 22% 12%, #262d66 0, #141838 46%, #080a1c 100%); box-shadow: 0 0 0 1px rgba(255, 255, 255, .26), 0 0 110px rgba(124, 104, 255, .3); }
.ic-die::before { content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none; box-shadow: inset 8px -10px 26px rgba(150, 240, 255, .2), inset -12px 14px 34px rgba(214, 96, 220, .18); }
/* the fill pattern a foundry adds around the circuits */
.ic-die::after { content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .5; background: radial-gradient(circle, rgba(255, 255, 255, .07) 1px, transparent 1.6px) 0 0 / 18px 18px; }
.ic-sheen { position: absolute; inset: -30%; z-index: 1; pointer-events: none; will-change: transform; animation: ic-sheen 14s linear infinite;
  background: linear-gradient(105deg, transparent 38%, rgba(94, 231, 245, .07) 45%, rgba(255, 255, 255, .11) 50%, rgba(255, 143, 216, .07) 55%, transparent 62%); }
@keyframes ic-sheen { from { transform: translateX(-35%); } to { transform: translateX(35%); } }
.ic-glare { position: absolute; inset: 0; z-index: 4; pointer-events: none; background: radial-gradient(45% 55% at var(--gx, 30%) var(--gy, 20%), rgba(255, 255, 255, .1), transparent 70%); }
.ic-svg { position: absolute; inset: 0; z-index: 2; display: block; width: 100%; height: 100%; }
.ic-svg text { font-family: var(--mono); }
.ic-seal { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 8; }
.ic-zone { fill: rgba(255, 255, 255, .018); stroke: rgba(255, 255, 255, .07); stroke-width: 2; }
.ic-tag { font-size: 42px; letter-spacing: .14em; fill: rgba(94, 231, 245, .78); }
.ic-sub { font-size: 36px; letter-spacing: .02em; fill: rgba(200, 210, 240, .38); }
.ic-sect path { fill: none; stroke: rgba(200, 210, 240, .22); stroke-width: 2; }
.ic-sect text { font-size: 40px; letter-spacing: .1em; text-anchor: middle; fill: rgba(200, 210, 240, .55); }
.ic-wire path { fill: none; stroke: rgba(255, 196, 87, .28); stroke-width: 5; }
.ic-pad rect { fill: rgba(255, 196, 87, .1); stroke: rgba(255, 196, 87, .42); stroke-width: 2.5; }
.ic-wg use, .ic-wg path { fill: none; stroke: #39427a; stroke-width: 3.4; stroke-linecap: round; }
/* light in a piece of waveguide: --o is its brightness (|E|^2 from engine.js), --d its place along the core, so the
   light of a new input runs from the inputs to the detectors */
.ic-pc use { fill: none; stroke-linecap: round; transition: opacity .55s var(--ease-out) calc(var(--d, 0) * .9s); }
.ic-pc-glow { stroke: url(#icBeam); stroke-width: 18; opacity: calc(var(--o, 0) * .46); }
.ic-pc-halo { stroke: url(#icBeam); stroke-width: 46; opacity: calc(var(--o, 0) * .12); }
.ic-pc-lit { stroke: url(#icBeam); stroke-width: 5; opacity: var(--o, 0); }
.ic-light { /* bloom comes from .ic-pc-glow / .ic-pc-halo strokes, not a filter: a filter here re-rasterises the whole group every frame */ }
.ic-pc-flow { stroke: #fff; stroke-width: 5; stroke-dasharray: 34 150; opacity: calc(var(--o, 0) * .95); animation: ic-flow 1.9s linear infinite; }
/* no running dashes where there is (almost) no light: each animated dash repaints the die */
.ic-pc.is-dark .ic-pc-flow { animation: none; visibility: hidden; }
@keyframes ic-flow { from { stroke-dashoffset: 176; } to { stroke-dashoffset: 0; } }
/* liquid-crystal cells: the film is as bright as its phase / 2π, with a mint glow around it */
.ic-lc { cursor: help; }
.ic-lc-halo { fill: url(#icLc); opacity: calc(var(--h, 0) * 1.3); }
.ic-lc-film { fill: var(--mint); stroke: rgba(210, 255, 225, .6); stroke-width: 1.2; opacity: calc(.3 + .7 * var(--h, 0)); }
.ic-lc:hover .ic-lc-film { stroke: #fff; stroke-width: 2.4; }
.ic-fib-core { fill: none; stroke: rgba(220, 230, 255, .16); stroke-width: 14; stroke-linecap: round; transition: stroke .4s; }
.ic-fib-end { fill: rgba(220, 230, 255, .3); transition: fill .4s; }
.ic-fib-glow { fill: url(#icFib); opacity: 0; transition: opacity .5s; }
.ic-fib.is-lit .ic-fib-core { stroke: rgba(94, 231, 245, .75); }
.ic-fib.is-lit .ic-fib-end { fill: #fff; }
.ic-fib.is-lit .ic-fib-glow { opacity: 1; }
.ic-det-body { fill: rgba(201, 166, 255, .1); stroke: rgba(201, 166, 255, .6); stroke-width: 2; }
.ic-det-glow { fill: url(#icDet); opacity: calc(var(--o, 0) * 1.2); transition: opacity .6s var(--ease-out) .75s; }
/* the dumps of the Σ attenuators end in absorbers that glow with the light they take */
.ic-abs-end { fill: rgba(157, 140, 255, .25); stroke: rgba(157, 140, 255, .7); stroke-width: 2; }
.ic-abs-glow { fill: url(#icAbs); opacity: calc(var(--o, 0) * 1.2); transition: opacity .6s var(--ease-out) .45s; }
.ic-hit { fill: transparent; cursor: crosshair; }
.ic-inputs { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; }
.ic-label { margin-right: 4px; font: 500 10.5px/1 var(--mono); letter-spacing: .16em; color: var(--ink-3); }
.ic-hint { margin-left: 6px; font-size: 12px; color: var(--ink-3); }
.ic-inputs button { min-width: 58px; min-height: 30px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(255, 255, 255, .02); color: var(--ink-2); font: 500 12px/1 var(--mono); cursor: pointer; transition: color .2s, border-color .2s, background .2s, box-shadow .3s; }
.ic-inputs button:hover { color: var(--ink); border-color: rgba(94, 231, 245, .5); }
.ic-inputs button[aria-pressed="true"] { color: var(--ink); border-color: var(--cy); background: rgba(94, 231, 245, .1); box-shadow: 0 0 24px -6px rgba(94, 231, 245, .6); }
.idle .eyebrow { margin: 0 0 16px; font-size: 10.5px; }
.idle .eyebrow i { font-style: normal; color: var(--ink-3); }
.idle-title { margin: 0; font: 900 clamp(34px, 4.2vw, 56px)/1 var(--display); letter-spacing: -.03em; color: var(--ink); }
.idle-title .thin { font-weight: 300; color: var(--ink-thin); }
/* the heading comes into focus character by character, then a pulse of light runs through it */
.idle-title .w { display: inline-block; white-space: pre; animation: word-in .9s var(--ease-out) calc(var(--n) * 70ms + 60ms) both, lit-word 1.1s ease-out calc(var(--n) * 80ms + 1.4s) both; }
@keyframes word-in { from { opacity: .2; filter: blur(10px); transform: translateY(.3em); } }
@keyframes lit-word { 0%, 100% { text-shadow: none; } 28% { color: #baf8ff; text-shadow: 0 0 .5em rgba(94, 231, 245, .6); } }
.idle-deck { max-width: 34em; margin: 18px 0 0; font-size: 14px; line-height: 1.7; color: var(--ink-3); animation: rise .9s var(--ease) .35s both; }
.idle-deck b { font-weight: 400; color: var(--ink); }
.idle-steps { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; animation: rise .9s var(--ease) .5s both; }
.idle-steps li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 7px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(255, 255, 255, .025); font-size: 12px; color: var(--ink-2); }
.idle-steps b { padding: 3px 7px; border-radius: 999px; background: rgba(94, 231, 245, .1); font: 500 10px/1 var(--mono); letter-spacing: .1em; color: var(--cy); }
.idle-cta { flex: none; margin-top: 24px; padding: 14px 30px; animation: rise .9s var(--ease) .65s both; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

/* ---------- output zone before the first run: ghost tiles that shimmer ---------- */
.out-idle { padding-bottom: 18px; }
.kpi.ghost .lbl { color: #5d6690; }
.kpi.ghost i { display: block; border-radius: 6px; background: linear-gradient(90deg, rgba(255, 255, 255, .04) 0%, rgba(94, 231, 245, .14) 50%, rgba(255, 255, 255, .04) 100%) 0 0 / 200% 100%; animation: shimmer 2.4s linear infinite; }
.kpi.ghost .val i { width: 62%; height: 32px; }
.kpi.ghost .foot i { width: 86%; height: 10px; margin-top: 4px; animation-delay: .2s; }
.kpi.ghost:nth-child(2) i { animation-delay: .15s; } .kpi.ghost:nth-child(3) i { animation-delay: .3s; } .kpi.ghost:nth-child(4) i { animation-delay: .45s; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.out-idle-note { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 0; font: 500 10.5px/1.4 var(--mono); letter-spacing: .14em; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  .ic-body, .ic-sheen, .ic-pc-flow, .kpi.ghost i { animation: none !important; }
  .ic-pc use, .ic-det-glow, .ic-abs-glow { transition: none; }
}
.cap .dim { color: var(--ink-3); }

/* ==================================================================== mobile shell (body.m, ≤640px)
   The viewport is the page: array switch on top, one zone per tab, tab bar at the bottom. Budget: 375×548 (iPhone SE
   in Safari or WeChat, browser bars included), so nothing on a tab needs scrolling; detail opens in a bottom sheet. */
.mbar, .mtabs, .msheet, .m-in, .m-cptools, .m-tick, .m-out { display: none; }
body.m { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; overscroll-behavior: none; }
body.m .top { display: none; }
body.m .layout { flex: 1; min-height: 0; width: 100%; min-width: 0; display: block; padding: 0; overflow: hidden; }
body.m .main { display: contents; }
body.m .panel { display: none; height: 100%; width: 100%; min-width: 0; overflow: hidden; border: 0; border-radius: 0; background: none; box-shadow: none; contain: none; }
body.m .zone-title, body.m .run-bar { display: none; }
body.m[data-tab="in"] #inputs, body.m[data-tab="cp"] #compute, body.m[data-tab="out"] #output { display: flex; flex-direction: column; }

/* --- top: the array switch */
body.m .mbar { display: flex; align-items: center; gap: 8px; flex: none; padding: 8px 10px 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: linear-gradient(180deg, rgba(12, 14, 34, .96), rgba(9, 11, 26, .9)); }
.mbar-mark { width: 26px; height: 26px; flex: none; filter: drop-shadow(0 0 6px rgba(94, 231, 245, .45)); }
.mseg { flex: 1; display: grid; grid-template-columns: .8fr 1fr 1fr 1.25fr 1.25fr; gap: 2px; padding: 3px; border: 1px solid var(--line-2); border-radius: 14px; background: rgba(4, 5, 13, .5); }
.mseg button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 6px 0 5px; border: 0; border-radius: 11px; background: none; color: var(--ink-2); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .25s var(--ease), color .25s; }
.mseg b { font: 600 11.5px/1 var(--mono); letter-spacing: -.04em; color: inherit; white-space: nowrap; }
.mseg small { font: 400 8.5px/1.1 var(--sans); color: var(--ink-3); white-space: nowrap; }
.mseg button.on { background: var(--cy); color: var(--bg); box-shadow: 0 0 18px rgba(94, 231, 245, .55); }
.mseg button.on small { color: rgba(9, 11, 29, .7); }
.mseg button:active { transform: scale(.96); }

/* --- bottom: the tabs */
body.m .mtabs { display: grid; grid-template-columns: repeat(3, 1fr); flex: none; padding: 4px 6px max(4px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(9, 11, 26, .96); }
.mtabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px; border: 0; background: none; color: var(--ink-3); font: 500 11px/1 var(--sans); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mtabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.mtabs button.on { color: var(--cy); }
.mtabs button.on svg { filter: drop-shadow(0 0 6px rgba(94, 231, 245, .7)); }
.mtabs .dot { position: absolute; top: 5px; left: calc(50% + 10px); width: 7px; height: 7px; border-radius: 50%; background: var(--pk); box-shadow: 0 0 8px var(--pk); transform: scale(0); transition: transform .3s var(--ease); }
.mtabs .dot.on { transform: scale(1); }

/* --- 输入 */
body.m .m-in { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 10px 14px 8px; gap: 9px; }
.m-hd h1 { margin: 0; font: 900 19px/1.15 var(--display); letter-spacing: -.02em; color: var(--ink); }
.m-hd p { margin: 3px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-3); }
.m-in section { display: flex; flex-direction: column; gap: 7px; }
.m-in h3 { display: flex; align-items: baseline; gap: 8px; margin: 0; font: 600 12.5px/1.2 var(--sans); color: var(--ink); }
.m-in h3 span { margin-left: auto; font: 400 10.5px/1 var(--sans); color: var(--ink-3); display: inline-flex; gap: 4px; align-items: center; }
.m-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.m-chips button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 6px 8px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(255, 255, 255, .025); color: var(--ink); font: 500 12px/1.15 var(--sans); text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.m-chips small { font: 400 9.5px/1.2 var(--sans); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.m-chips button.on { border-color: var(--cy); background: rgba(94, 231, 245, .1); box-shadow: 0 0 0 1px rgba(94, 231, 245, .25) inset; }
.m-row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.m-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.m-num { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.m-num .l { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-num .c { display: flex; align-items: center; height: 36px; border: 1px solid var(--line-2); border-radius: 10px; background: rgba(4, 5, 13, .55); overflow: hidden; }
.m-num .c:focus-within { border-color: var(--cy); box-shadow: 0 0 0 3px rgba(94, 231, 245, .14); }
/* 16px stops iOS from zooming the page when a field is focused */
.m-num input { flex: 1; width: 100%; min-width: 0; border: 0; padding: 0 8px; outline: none; background: none; color: var(--ink); font: 500 16px/1 var(--mono); text-align: right; }
.m-num i { padding-right: 8px; font: normal 10.5px var(--mono); color: var(--ink-3); }
.m-num .c.sel { border: 0; background: none; }
.m-num select { width: 100%; height: 36px; font-size: 13px; }
.m-chain { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px; border: 1px dashed var(--line-2); border-radius: 10px; background: none; color: var(--ink-2); text-align: left; cursor: pointer; }
.m-chain .flow { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 5px; font: 500 11px/1.4 var(--mono); }
.m-chain .flow i { font-style: normal; color: var(--ink-3); }
.m-chain .L.conv, .m-chain .L.dense { color: var(--cy); }
.m-chain .edit { flex: none; font-size: 11px; color: var(--ink-3); }
.m-chain.bad { border-color: var(--pk); }
.m-foot { display: flex; gap: 8px; margin-top: auto; }
.m-foot .m-all { padding: 0 16px; font-size: 13px; }
.m-foot .btn-run { flex: 1; padding: 13px 18px; font-size: 15px; }

/* --- 计算 */
body.m .m-cptools { display: flex; align-items: center; gap: 8px; flex: none; padding: 8px 12px 0; }
.m-ribbon { flex: 1; display: flex; gap: 12px; min-width: 0; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.m-ribbon b { font: 600 12.5px var(--mono); color: var(--ink); }
.m-cptools .btn { padding: 6px 11px; font-size: 11.5px; }
body.m .stepper { flex: none; gap: 4px; padding: 8px 12px; border: 0; scrollbar-width: none; }
body.m .stepper::-webkit-scrollbar { display: none; }
body.m .step { padding: 0; border: 0; gap: 0; font-size: 0; }
body.m .step .n { width: 28px; height: 28px; font-size: 12px; }
body.m .step.on { padding-right: 12px; gap: 7px; font-size: 12.5px; background: rgba(94, 231, 245, .08); border: 1px solid rgba(94, 231, 245, .4); }
body.m .stage { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: 4px 12px 6px; }
body.m .stage-head { flex: none; }
body.m .stage-head { margin-bottom: 8px; gap: 8px; }
body.m .stage-head > div:first-child { width: 100%; }
body.m .stage-head h3 { font-size: 17px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
body.m .stage-head h3::after { content: "i"; display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid var(--line-2); border-radius: 50%; font: italic 600 10px/1 Georgia, serif; color: var(--ink-3); }
body.m .stage-head p { display: none; font-size: 12px; line-height: 1.55; }
body.m .stage-head.open p { display: block; }
body.m .stage-head .ctrls { margin: 0; width: 100%; }
body.m .stage-head .ctrls select { flex: 1; min-width: 0; font-size: 12px; padding-block: 6px; }
body.m .idle { min-height: 0; height: 100%; padding: 16px 10px; }
body.m .m-tick { display: flex; align-items: center; gap: 8px; flex: none; margin: 0 12px 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--pit); color: #cfd7ea; font: 10.5px/1.3 var(--mono); text-align: left; cursor: pointer; }
.m-tick .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-tick .t .ok { color: var(--mint); } .m-tick .t .hl { color: var(--pk); } .m-tick .t .b { color: var(--cy); } .m-tick .t .dim { color: #8d96ba; }
.m-tick .more { flex: none; color: var(--ink-3); font-family: var(--sans); }
.m-tick .more::after { content: " ↑"; }
.m-tick .pulse-dot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--ink-3); }
.m-tick.live .pulse-dot { background: var(--mint); box-shadow: 0 0 8px var(--mint); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* --- 输出 */
body.m .m-out { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; padding: 10px 12px 8px; }
.m-outhd { display: flex; align-items: center; gap: 8px; }
.m-outhd .who { flex: 1; min-width: 0; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-outhd .who b { font: 600 13px var(--mono); }
.m-mode button { padding: 5px 10px; font-size: 11px; }
.m-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.m-kpi { position: relative; min-width: 0; padding: 9px 11px 8px; border: 1px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, rgba(255, 255, 255, .045), rgba(255, 255, 255, .012)); }
.m-kpi .l { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-kpi .v { margin-top: 4px; font: 300 26px/1 var(--display); letter-spacing: -.02em; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-kpi .v small { margin-left: 3px; font: 400 11.5px var(--sans); color: var(--ink-3); letter-spacing: 0; }
.m-kpi .f { margin-top: 4px; font-size: 10px; line-height: 1.35; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-kpi.hero { border-color: rgba(94, 231, 245, .45); background: radial-gradient(120% 120% at 0% 0%, rgba(94, 231, 245, .2), transparent 60%), radial-gradient(120% 120% at 100% 100%, rgba(255, 143, 216, .14), transparent 60%), rgba(14, 17, 40, .8); }
.m-kpi.hero .v .n { font-weight: 900; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.m-kpi.hero .l { color: #9feef7; }
.m-kpi.changed { animation: kpi-flash .9s var(--ease); }
@keyframes kpi-flash { 0% { border-color: var(--cy); box-shadow: 0 0 0 1px var(--cy), 0 0 24px rgba(94, 231, 245, .45); } 100% { box-shadow: 0 0 0 0 transparent; } }
.m-cmp { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 9px 11px 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(4, 5, 13, .35); }
.m-cmp-hd { display: flex; align-items: baseline; gap: 8px; }
.m-cmp-hd h4 { margin: 0; font: 600 12.5px/1.2 var(--sans); color: var(--ink); }
.m-cmp-hd span { margin-left: auto; font-size: 10px; color: var(--ink-3); }
.m-cmp-plot { flex: 1; min-height: 0; display: flex; justify-content: center; }
.m-cmp-plot svg { width: 100%; height: 100%; }
.m-report { justify-content: center; width: 100%; padding: 9px 12px; font-size: 12px; }
.m-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 0 32px; text-align: center; }
.m-empty p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ink-3); }

/* --- bottom sheet */
body.m .msheet.open { pointer-events: auto; }
body.m .msheet { display: block; position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.msheet-scrim { position: absolute; inset: 0; background: rgba(2, 3, 10, .6); opacity: 0; transition: opacity .28s; }
.msheet-card { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: 88dvh; border: 1px solid var(--line-2); border-bottom: 0; border-radius: 20px 20px 0 0; background: linear-gradient(180deg, #151939, #0c0e24); box-shadow: 0 -30px 80px rgba(0, 0, 0, .6); transform: translateY(100%); transition: transform .32s var(--ease); }
.msheet.open { pointer-events: auto; }
.msheet.open .msheet-scrim { opacity: 1; }
.msheet.open .msheet-card { transform: none; }
.msheet-head { position: relative; display: flex; align-items: center; padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.msheet-head .grab { position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
.msheet-head h4 { margin: 0; font: 900 16px/1.2 var(--display); color: var(--ink); }
.msheet-head button { margin-left: auto; width: 32px; height: 32px; border: 1px solid var(--line-2); border-radius: 50%; background: none; color: var(--ink-2); font-size: 17px; line-height: 1; cursor: pointer; }
.msheet-body { overflow: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.msheet-body #inputScroll { padding: 0; }
.msheet-body .sec { padding: 14px 16px; }
.msheet-body .field input { font-size: 16px; }
.msheet-body #outBody .kpis { grid-template-columns: 1fr 1fr; padding: 14px 14px 4px; gap: 8px; }
.msheet-body #outBody .kpi { padding: 12px; }
.msheet-body #outBody .kpi .val { font-size: 24px; }
.msheet-body #outBody .outgrid { grid-template-columns: 1fr; padding: 10px 14px 20px; }
.msheet-body #outBody .outgrid > .card { grid-column: auto; }
.msheet-body .console-wrap { padding: 12px 14px 16px; }
.msheet-body .console { height: 60dvh; }
body.m .drawer { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 80dvh; overflow: auto; z-index: 70; }
@media (prefers-reduced-motion: reduce) { .msheet-card, .msheet-scrim { transition: none; } .m-kpi.changed { animation: none; } }

/* graphics drawn for the desktop scale down to the phone's width instead of widening the page */
body.m .stage > *, body.m .stage .card { max-width: 100%; min-width: 0; }
body.m .stage [style*="overflow-x"] { max-width: 100%; }
.m-pager { flex: 1; min-height: 0; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-x: contain; scrollbar-width: none; }
.m-pager::-webkit-scrollbar { display: none; }
.m-page { flex: 0 0 100%; min-width: 0; height: 100%; overflow: hidden; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.m-lead { align-self: stretch; }
.m-lead > * { margin: 0 !important; }
.m-page.scroll { overflow-y: auto; }
.m-pz { flex: none; }
.m-pz > * { max-width: none !important; }
.m-pz > * + * { margin-top: 8px; }
.m-dots { flex: none; display: flex; justify-content: center; gap: 6px; padding-top: 6px; }
.m-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line-2); transition: width .25s var(--ease), background .25s; }
.m-dots i.on { width: 18px; background: var(--cy); box-shadow: 0 0 8px rgba(94, 231, 245, .6); }
/* the chip and the CNN chain are wider than a phone: they keep a readable size and pan sideways under a finger,
   fading at the right edge to say there is more */
.m-pz .mesh-wrap, .m-pz [style*="overflow-x"] { overscroll-behavior-x: contain; -webkit-mask: linear-gradient(90deg, #000 88%, transparent); mask: linear-gradient(90deg, #000 88%, transparent); }
