/* The original Strata stylesheet, copied UNCHANGED from the artifact (original/Strata Computer (Copy).html). */
/* Layout: an instrument, not a landing page. Code on the left, the machine on
   the right, and under the screen the five strata the program passes through,
   top (what you wrote) to bottom (what executes it). Each stratum owns one
   colour, used wherever that layer shows up on the page. */
:root {
  --bg: #e9edf2;
  --panel: #f7f8fa;
  --panel-2: #eef1f5;
  --ink: #131a2a;
  --muted: #566074;
  --line: #cfd6e0;
  --focus: #1f6fd1;
  --bad: #c0271f;
  --bad-bg: #fbe4e1;
  /* strata */
  --l-source: #9a5b00;
  --l-compiler: #b8431a;
  --l-assembler: #6344c0;
  --l-cpu: #1a64c4;
  --l-screen: #0b7d6f;
  --s-source: #f6e7c8;
  --s-compiler: #f5dccf;
  --s-assembler: #e3dcf6;
  --s-cpu: #d6e4f7;
  --s-screen: #d0ece7;
  /* code */
  --code-bg: #fcfcfd;
  --syn-com: #7b8496;
  --syn-kw: #6344c0;
  --syn-type: #1a64c4;
  --syn-str: #0b7d6f;
  --syn-num: #b8431a;
  --syn-fn: #131a2a;
  --syn-pre: #9a5b00;
  --heat: #e2572b;
  --bezel: #10141d;
  --bezel-edge: #2a3344;
  --font-display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1019; --panel: #131926; --panel-2: #19202f; --ink: #e4e9f2; --muted: #8a94a8; --line: #252e40;
    --focus: #6fb1ff; --bad: #ff8d83; --bad-bg: #3a1614;
    --l-source: #f0b54a; --l-compiler: #ff8f63; --l-assembler: #aa93ff; --l-cpu: #63adff; --l-screen: #45d1ba;
    --s-source: #2a2314; --s-compiler: #2d1c15; --s-assembler: #201b33; --s-cpu: #14213a; --s-screen: #102a27;
    --code-bg: #0f141f; --syn-com: #6c768a; --syn-kw: #aa93ff; --syn-type: #63adff; --syn-str: #45d1ba;
    --syn-num: #ff8f63; --syn-fn: #e4e9f2; --syn-pre: #f0b54a; --heat: #ff7a45;
    --bezel: #05070b; --bezel-edge: #232c3d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1019; --panel: #131926; --panel-2: #19202f; --ink: #e4e9f2; --muted: #8a94a8; --line: #252e40;
  --focus: #6fb1ff; --bad: #ff8d83; --bad-bg: #3a1614;
  --l-source: #f0b54a; --l-compiler: #ff8f63; --l-assembler: #aa93ff; --l-cpu: #63adff; --l-screen: #45d1ba;
  --s-source: #2a2314; --s-compiler: #2d1c15; --s-assembler: #201b33; --s-cpu: #14213a; --s-screen: #102a27;
  --code-bg: #0f141f; --syn-com: #6c768a; --syn-kw: #aa93ff; --syn-type: #63adff; --syn-str: #45d1ba;
  --syn-num: #ff8f63; --syn-fn: #e4e9f2; --syn-pre: #f0b54a; --heat: #ff7a45;
  --bezel: #05070b; --bezel-edge: #232c3d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
.app {
  max-width: 1320px;
  margin: 0 auto;
  padding-block: 22px 40px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- header ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 32px; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
h1 {
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 0;
}
.tag { font-family: var(--font-display); font-size: clamp(17px, 2vw, 21px); font-weight: 500; margin: 0; color: var(--muted); letter-spacing: -0.01em; }
.lede { margin: 0; max-width: 68ch; color: var(--muted); flex: 1 1 420px; min-width: 0; text-wrap: pretty; }
.lede b { color: var(--ink); font-weight: 600; }

/* ---------- program picker ---------- */
.examples { display: flex; flex-wrap: wrap; gap: 8px; }
.ex {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 7px 13px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); cursor: pointer; text-align: left; min-width: 104px; flex: 1 1 104px; max-width: 190px;
}
.ex b { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.ex span { font-size: 12px; color: var(--muted); line-height: 1.3; }
.ex:hover { border-color: var(--muted); }
.ex[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.ex[aria-pressed="true"] span { color: var(--bg); opacity: 0.72; }

/* ---------- main grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.pane { min-width: 0; display: flex; flex-direction: column; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

.tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); background: var(--panel-2); overflow-x: auto; }
.tab {
  border: 0; background: none; cursor: pointer; padding: 7px 12px 8px; border-radius: 7px 7px 0 0;
  font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); background: var(--panel); border-bottom-color: var(--tab-color, var(--ink)); }
.tab[data-layer="source"] { --tab-color: var(--l-source); }
.tab[data-layer="compiler"] { --tab-color: var(--l-compiler); }
.tab[data-layer="assembler"] { --tab-color: var(--l-assembler); }
.tab[data-layer="cpu"] { --tab-color: var(--l-cpu); }
.tab[data-layer="screen"] { --tab-color: var(--l-screen); }
.tabs .spacer { flex: 1; }
.tabs .hint { align-self: center; font-size: 12px; color: var(--muted); padding: 0 8px 4px; white-space: nowrap; }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }

/* ---------- editor ---------- */
.editor-card { flex: 1; display: flex; flex-direction: column; min-height: 520px; }
.views { position: relative; flex: 1; min-height: 0; background: var(--code-bg); }
.view { position: absolute; inset: 0; }
.code-font { font-family: var(--font-mono); font-size: 12.5px; line-height: 19px; tab-size: 2; font-variant-ligatures: none; }
.editor { display: flex; height: 100%; }
.gutter { flex: none; width: 50px; overflow: hidden; background: var(--panel-2); border-right: 1px solid var(--line); color: var(--muted); user-select: none; }
.gutter-inner { padding: 10px 0 40px; }
.gl { display: block; height: 19px; padding-right: 8px; text-align: right; position: relative; font-size: 11.5px; }
.gl::before { content: ""; position: absolute; left: 0; top: 2px; bottom: 2px; width: calc(var(--h, 0) * 16px); background: var(--heat); opacity: calc(0.25 + var(--h, 0) * 0.75); border-radius: 0 2px 2px 0; }
.gl.err { background: var(--bad); color: var(--panel); }
.code-wrap { position: relative; flex: 1; min-width: 0; }
.code-wrap pre, .code-wrap textarea {
  position: absolute; inset: 0; margin: 0; padding: 10px 12px 40px; border: 0; white-space: pre; overflow: auto;
  font: inherit; line-height: inherit; tab-size: inherit; letter-spacing: 0;
}
.code-wrap pre { pointer-events: none; overflow: hidden; color: var(--ink); }
.code-wrap textarea { resize: none; background: transparent; color: transparent; caret-color: var(--ink); outline: none; -webkit-text-fill-color: transparent; }
.code-wrap textarea::selection { background: color-mix(in srgb, var(--focus) 28%, transparent); }
.errline { position: absolute; left: 0; right: 0; height: 19px; background: var(--bad-bg); pointer-events: none; }
.listing { height: 100%; margin: 0; padding: 10px 12px 40px; overflow: auto; white-space: pre; color: var(--ink); }
.c-com { color: var(--syn-com); font-style: italic; }
.c-kw { color: var(--syn-kw); }
.c-type { color: var(--syn-type); }
.c-str { color: var(--syn-str); }
.c-num { color: var(--syn-num); }
.c-fn { color: var(--syn-fn); font-weight: 600; }
.c-pre { color: var(--syn-pre); }
.c-lab { color: var(--syn-pre); font-weight: 600; }
.c-addr { color: var(--syn-com); }
.c-hex { color: var(--syn-num); }
.statusbar { display: flex; gap: 10px; align-items: baseline; padding: 7px 12px; border-top: 1px solid var(--line); font-size: 13px; background: var(--panel); min-height: 35px; }
.statusbar .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--l-screen); align-self: center; }
.statusbar.bad .dot { background: var(--bad); }
.statusbar.bad { color: var(--bad); background: var(--bad-bg); }
.statusbar .msg { min-width: 0; overflow-wrap: anywhere; }

/* ---------- machine ---------- */
.machine { display: flex; flex-direction: column; gap: 12px; }
.screen-frame {
  position: relative; background: var(--bezel); border: 1px solid var(--bezel-edge); border-radius: 12px; padding: 10px;
  cursor: crosshair; outline-offset: 3px;
}
.screen-frame canvas { display: block; width: 100%; max-width: 100%; aspect-ratio: 4 / 3; image-rendering: pixelated; image-rendering: crisp-edges; border-radius: 4px; background: #000; touch-action: none; }
.screen-frame .badge {
  position: absolute; left: 18px; bottom: 18px; font-size: 12px; padding: 3px 8px; border-radius: 5px;
  background: rgba(5, 7, 11, 0.78); color: #e4e9f2; pointer-events: none; transition: opacity 0.2s;
}
.screen-frame:focus .badge, .screen-frame.used .badge { opacity: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500; font-size: 14px; display: inline-flex; gap: 7px; align-items: center; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 600; }
.btn svg { width: 13px; height: 13px; fill: currentColor; flex: none; }
.btn[aria-pressed="true"] { border-color: var(--l-screen); color: var(--l-screen); }
.controls .keys { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.pad { display: none; gap: 8px; justify-content: space-between; align-items: center; user-select: none; -webkit-user-select: none; touch-action: none; }
.pad .dpad { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 48px); gap: 6px; }
.pad button { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; font-size: 18px; cursor: pointer; touch-action: none; }
.pad button.on { background: var(--ink); color: var(--bg); }
.pad .act { width: 72px; height: 72px; border-radius: 50%; font-weight: 700; }
@media (pointer: coarse) { .pad { display: flex; } .controls .keys, .screen-frame .badge { display: none; } }

/* the strata */
.strata { display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.stratum { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; align-items: baseline; padding: 7px 14px; font-size: 13.5px; }
.stratum + .stratum { border-top: 1px solid var(--line); }
.stratum .name { font-family: var(--font-display); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.stratum .what { min-width: 0; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stratum .what b { font-weight: 600; }
.stratum .what i { font-style: normal; color: var(--muted); }
.stratum[data-layer="source"] { background: var(--s-source); } .stratum[data-layer="source"] .name { color: var(--l-source); }
.stratum[data-layer="compiler"] { background: var(--s-compiler); } .stratum[data-layer="compiler"] .name { color: var(--l-compiler); }
.stratum[data-layer="assembler"] { background: var(--s-assembler); } .stratum[data-layer="assembler"] .name { color: var(--l-assembler); }
.stratum[data-layer="cpu"] { background: var(--s-cpu); } .stratum[data-layer="cpu"] .name { color: var(--l-cpu); }
.stratum[data-layer="screen"] { background: var(--s-screen); } .stratum[data-layer="screen"] .name { color: var(--l-screen); }

.lower { display: flex; flex-direction: column; min-height: 190px; flex: 1; }
.lower .views { min-height: 150px; }
.console { height: 100%; margin: 0; padding: 10px 12px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.console .sys { color: var(--muted); }
.console .bad { color: var(--bad); }
.profile { height: 100%; overflow: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.prow { display: grid; grid-template-columns: minmax(70px, 150px) minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-family: var(--font-mono); }
.prow .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .bar { height: 9px; border-radius: 2px; background: var(--panel-2); overflow: hidden; }
.prow .bar i { display: block; height: 100%; background: var(--l-cpu); border-radius: 2px; }
.prow .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.profile .note { font-family: var(--font-body); color: var(--muted); font-size: 12.5px; margin: 0 0 4px; }
.regs { height: 100%; overflow: auto; padding: 10px 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 2px 14px; align-content: start; font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.regs div { display: flex; gap: 10px; }
.regs span { color: var(--muted); width: 3ch; flex: none; }

/* ---------- about ---------- */
.about { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 28px; padding-top: 6px; }
.about h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 4px; }
.about p { margin: 0; color: var(--muted); font-size: 14px; max-width: 46ch; text-wrap: pretty; }
.about code { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); }
.about .lay { border-top: 3px solid var(--c); padding-top: 10px; min-width: 0; }

@media (max-width: 940px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .machine-pane { order: -1; }
  .editor-card { flex: none; min-height: 0; height: 70vh; max-height: 640px; }
  .lower { flex: none; height: 240px; }
  .tabs .hint { display: none; }
  .stratum { grid-template-columns: 82px minmax(0, 1fr); gap: 8px; padding: 6px 10px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
