public/css/lab.css
/* Browser Lab — plain CSS with custom properties. No framework, no build. */
:root {
--bg: #f4f5f8; --surface: #ffffff; --surface-2: #eef0f5; --ink: #161a23; --muted: #5d6677; --line: #d9dde6;
--accent: #3355ff; --accent-soft: #e3e8ff; --good: #0a8a4c; --warn: #b26b00; --bad: #c62828;
--js: #c79500; --style: #8e44ad; --layout: #1f7a8c; --paint: #d35400; --composite: #2e86de;
--task: #3355ff; --micro: #0a8a4c; --webapi: #b26b00;
--radius: 12px; --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
color-scheme: light dark;
font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
:root { --bg: #0e1117; --surface: #161b24; --surface-2: #1d2430; --ink: #e6e9ef; --muted: #98a2b3; --line: #2a3240;
--accent: #7d95ff; --accent-soft: #232d52; --good: #4ade80; --warn: #fbbf24; --bad: #f87171;
--task: #7d95ff; --micro: #4ade80; --webapi: #fbbf24; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
padding: 7px 13px; border-radius: 9px; transition: transform .1s, background .2s; }
button:hover { background: var(--surface-2); }
button:active { transform: scale(.97); }
button.primary { background: var(--accent); color: #fff; border-color: transparent; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select { font: inherit; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
code, pre, .mono { font-family: var(--mono); font-size: .86rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 10; background: var(--surface); padding: 8px; }
/* ---------------------------------------------------------- layout ---- */
.shell { display: grid; grid-template-columns: 290px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px; border-right: 1px solid var(--line);
background: var(--surface); display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.logo { font-size: 1.6rem; animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.15) rotate(-8deg); } }
#station-nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
#station-nav a { display: grid; grid-template-columns: 22px 22px 1fr auto; gap: 8px; align-items: center; padding: 7px 8px;
border-radius: 8px; color: inherit; text-decoration: none; }
#station-nav a:hover { background: var(--surface-2); }
#station-nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; }
#station-nav .num { color: var(--muted); font-family: var(--mono); font-size: .75rem; }
.badge { font-size: .72rem; font-family: var(--mono); color: var(--muted); background: var(--surface-2); border-radius: 99px; padding: 1px 7px; }
.badge.complete { background: var(--good); color: #fff; }
.progress { margin-top: auto; display: grid; gap: 4px; }
.progress .bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--good)); transition: width .6s; }
#stage { padding: 26px clamp(16px, 3vw, 40px) 60px; max-width: 1200px; outline: none; }
@media (max-width: 860px) {
.shell { grid-template-columns: 1fr; }
.sidebar { position: static; height: auto; }
}
/* --------------------------------------------------------- station ---- */
.station > header h2 { margin: 0 0 4px; font-size: 1.6rem; }
.lede { color: var(--muted); margin: 0 0 18px; max-width: 75ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin: 14px 0; }
.panel h3 { margin: 0 0 10px; font-size: 1.02rem; }
.panel p { max-width: 80ch; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.note { color: var(--muted); font-size: .88rem; }
.missions { list-style: none; padding: 10px 14px; margin: 0 0 6px; display: flex; gap: 6px 18px; flex-wrap: wrap;
background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); font-size: .9rem; }
.missions li::before { content: "◻ "; color: var(--muted); }
.missions li.done { color: var(--good); }
.missions li.done::before { content: "✅ "; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px;
border-radius: 10px; box-shadow: 0 8px 30px #0004; animation: toast-in .35s ease-out; }
@keyframes toast-in { from { transform: translateY(20px); opacity: 0; } }
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.readout { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.readout b { display: block; font-size: 1.25rem; font-family: var(--mono); }
.readout small { color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .9rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.log { font-family: var(--mono); font-size: .82rem; background: var(--surface-2); border-radius: 8px; padding: 8px 10px;
max-height: 260px; overflow: auto; margin: 8px 0 0; list-style: none; }
.log li { padding: 2px 0; border-bottom: 1px solid var(--line); animation: pop .3s ease-out; }
.log li:last-child { border-bottom: 0; }
@keyframes pop { from { opacity: 0; transform: translateX(-6px); } }
/* --------------------------------------------------------- overview --- */
.arch { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.proc { border: 2px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); position: relative; transition: border-color .3s, box-shadow .3s; }
.proc h4 { margin: 0 0 6px; font-size: .95rem; }
.proc ul { margin: 0; padding-left: 18px; font-size: .86rem; color: var(--muted); }
.proc.lit { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.proc .thread { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin: 6px 0 0; font-size: .85rem; transition: background .3s; }
.proc .thread.lit { background: var(--accent-soft); }
.tour-caption { min-height: 3em; font-size: 1.02rem; margin-top: 12px; }
/* --------------------------------------------------------- pipeline --- */
.pipeline { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.stage-pill { padding: 6px 14px; border-radius: 99px; border: 2px solid var(--line); font-weight: 600; font-size: .88rem; opacity: .35; transition: opacity .25s, transform .25s; }
.stage-pill.on { opacity: 1; transform: translateY(-2px); }
.stage-pill.skipped { text-decoration: line-through; }
.stage-pill[data-stage="js"] { border-color: var(--js); }
.stage-pill[data-stage="style"] { border-color: var(--style); }
.stage-pill[data-stage="layout"] { border-color: var(--layout); }
.stage-pill[data-stage="paint"] { border-color: var(--paint); }
.stage-pill[data-stage="composite"] { border-color: var(--composite); }
.stage-pill.flash { animation: flash .5s; }
@keyframes flash { 30% { box-shadow: 0 0 0 6px var(--accent-soft); } }
.track { position: relative; height: 70px; background: var(--surface-2); border-radius: 10px; overflow: hidden; }
.mover { position: absolute; left: 8px; top: 11px; width: 48px; height: 48px; border-radius: 10px; background: var(--accent); }
.bars { display: grid; gap: 1px; max-height: 140px; overflow: hidden; }
.bars div { height: 2px; background: var(--accent); width: 100px; }
.tree { font-family: var(--mono); font-size: .84rem; margin: 0; padding-left: 16px; }
.tree .gone { color: var(--muted); text-decoration: line-through; }
.tree .pseudo { color: var(--paint); }
/* -------------------------------------------------------- waterfall --- */
.waterfall { display: grid; gap: 3px; font-family: var(--mono); font-size: .76rem; }
.wf-row { display: grid; grid-template-columns: 70px 1fr 60px; gap: 8px; align-items: center; }
.wf-track { position: relative; height: 14px; background: var(--surface-2); border-radius: 4px; }
.wf-bar { position: absolute; top: 2px; height: 10px; display: flex; border-radius: 3px; overflow: hidden; transform-origin: left; animation: grow .6s ease-out both; }
.wf-bar span { height: 100%; }
.seg-wait { background: #9aa3b2; } .seg-ttfb { background: var(--good); } .seg-dl { background: var(--accent); }
@keyframes grow { from { transform: scaleX(0); } }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; margin: 6px 0; }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.phases { display: grid; gap: 6px; }
.phase { display: grid; grid-template-columns: 150px 1fr 70px; gap: 10px; align-items: center; font-size: .88rem; }
.phase .fill { height: 12px; border-radius: 6px; background: var(--accent); min-width: 3px; transform-origin: left; animation: grow .7s ease-out both; }
/* ----------------------------------------------------- tls sequence --- */
.seq { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin-top: 8px; }
.seq .actor { text-align: center; font-weight: 700; padding: 6px; border-bottom: 2px solid var(--line); }
.seq .msgs { grid-column: 1 / -1; display: grid; gap: 6px; padding-top: 8px; }
.msg-line { position: relative; padding: 6px 10px; border-radius: 8px; font-size: .86rem; width: 70%; animation: fly .5s ease-out both; }
.msg-line.c2s { justify-self: start; background: var(--accent-soft); border-left: 4px solid var(--accent); }
.msg-line.s2c { justify-self: end; background: var(--surface-2); border-right: 4px solid var(--good); text-align: right; }
.msg-line.c2s::after { content: "→"; position: absolute; right: -18px; top: 6px; color: var(--accent); }
.msg-line.s2c::before { content: "←"; position: absolute; left: -18px; top: 6px; color: var(--good); }
.msg-line small { display: block; color: var(--muted); }
.msg-line .lock { color: var(--good); }
@keyframes fly { from { opacity: 0; transform: translateX(var(--from, -30px)); } }
.msg-line.s2c { --from: 30px; }
.rtt { grid-column: 1 / -1; text-align: center; font-size: .78rem; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 2px; }
/* ------------------------------------------------------- event loop --- */
.loop-grid { display: grid; grid-template-columns: minmax(280px, 1.1fr) 1fr; gap: 14px; }
@media (max-width: 1000px) { .loop-grid { grid-template-columns: 1fr; } }
.code { background: var(--surface-2); border-radius: 10px; padding: 10px 0; margin: 0; overflow-x: auto; counter-reset: ln; }
.code span { display: block; padding: 0 12px; white-space: pre; transition: background .2s; }
.code span::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 2em; color: var(--muted); }
.code span.hl { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
.boxes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.box { border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 92px; background: var(--surface); }
.box h4 { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.box.stack .items { display: flex; flex-direction: column-reverse; } /* newest frame on top */
.token { font-family: var(--mono); font-size: .8rem; padding: 4px 8px; border-radius: 6px; margin: 3px 0; animation: drop .35s cubic-bezier(.2,1.4,.5,1) both; overflow-wrap: anywhere; }
.box.stack .token { background: var(--accent-soft); border: 1px solid var(--accent); }
.box.webapis .token { background: color-mix(in srgb, var(--webapi) 18%, transparent); border: 1px solid var(--webapi); }
.box.tasks .token { background: color-mix(in srgb, var(--task) 15%, transparent); border: 1px solid var(--task); }
.box.micro .token { background: color-mix(in srgb, var(--micro) 15%, transparent); border: 1px solid var(--micro); }
.box.console .token { background: var(--surface-2); }
@keyframes drop { from { opacity: 0; transform: translateY(-10px) scale(.9); } }
.loop-note { min-height: 3.2em; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); margin: 10px 0; }
.wheel { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); flex: none; }
.wheel.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.quiz { display: flex; gap: 6px; flex-wrap: wrap; }
.quiz button.picked { opacity: .35; }
.answer { font-family: var(--mono); font-size: .85rem; }
.ok { color: var(--good); font-weight: 600; } .bad { color: var(--bad); font-weight: 600; }
/* ----------------------------------------------------------- engine --- */
.tiers { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tier { padding: 8px 12px; border-radius: 10px; border: 2px solid var(--line); text-align: center; min-width: 110px; transition: all .3s; }
.tier small { display: block; color: var(--muted); font-size: .75rem; }
.tier.on { border-color: var(--accent); background: var(--accent-soft); transform: scale(1.06); }
.arrow { color: var(--muted); }
.heat { height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.heat span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #3aa0ff, #ffb000, #ff3d00); transition: width .3s; }
.shapes ul { list-style: none; margin: 0; padding-left: 20px; border-left: 2px solid var(--line); }
.shapes > ul { border-left: 0; padding-left: 0; }
.shape { display: inline-flex; gap: 6px; align-items: center; font-family: var(--mono); font-size: .82rem; padding: 3px 8px; margin: 3px 0; border-radius: 6px; background: var(--surface-2); animation: drop .3s both; }
.shape .count { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; font-size: .72rem; }
.ic { font-weight: 700; }
.ic.monomorphic { color: var(--good); } .ic.polymorphic { color: var(--warn); } .ic.megamorphic { color: var(--bad); }
/* ---------------------------------------------------------- threads --- */
canvas { width: 100%; height: auto; display: block; background: var(--surface-2); border-radius: 10px; }
.lanes { display: grid; gap: 6px; }
.lane { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; font-size: .85rem; }
.lane .rail { height: 26px; border-radius: 6px; background: var(--surface-2); position: relative; overflow: hidden; }
.lane .work { position: absolute; top: 3px; bottom: 3px; border-radius: 4px; background: var(--paint); animation: grow .3s both; }
.lane .work.worker { background: var(--good); }
/* ------------------------------------------------------------ vitals --- */
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.gauge { border-radius: var(--radius); padding: 12px 14px; background: var(--surface); border: 2px solid var(--line); transition: border-color .4s; }
.gauge b { font-size: 1.7rem; font-family: var(--mono); display: block; }
.gauge .meter { height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--good) 0 33%, var(--warn) 33% 66%, var(--bad) 66%); position: relative; margin-top: 8px; }
.gauge .needle { position: absolute; top: -4px; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; transition: left .5s cubic-bezier(.3,1.5,.5,1); }
.gauge.good { border-color: var(--good); } .gauge.needs-improvement { border-color: var(--warn); } .gauge.poor { border-color: var(--bad); }
.gauge small { color: var(--muted); }
.shift-banner { background: var(--warn); color: #000; padding: 60px 22px; border-radius: 10px; margin-bottom: 10px; font-weight: 600; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.sample { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.sample h4 { margin: 0; }
.sample h4::before { content: "★ "; color: var(--paint); }
.sample span { margin-right: 10px; }
[role="tab"][aria-selected="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.log li[data-kind="bad"], .log li[data-kind="error"], .log li[data-kind="unhandledrejection"] { color: var(--bad); }
.log li[data-kind="csp"] { color: var(--warn); }
.log li[data-kind="ok"] { color: var(--good); }
.shift-banner.expanded { padding-bottom: 240px; }