:root {
  --bg: #0e1222; --panel: #151a30; --panel2: #1b2140; --line: #2a3158; --text: #e7ebfb; --dim: #8e97bd;
  --ctl: #b9a0f5; --val: #7fe6c6; --eff: #f6b55e; --ext: #eef2ff; --bad: #ff8f8f;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 "Segoe UI", system-ui, sans-serif; display: flex; flex-direction: column; overflow: hidden; }
button, select, input, textarea { font: inherit; color: inherit; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 11px; cursor: pointer; }
button:hover { border-color: #56609a; }
button.primary { background: var(--val); color: #06251c; border-color: var(--val); font-weight: 600; }
button:disabled { opacity: .4; cursor: default; }
select, input[type=text] { background: #0c1020; border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; }
input[type=text]:focus, textarea:focus, select:focus { outline: 1px solid var(--val); }

header { height: 50px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand span { color: var(--val); font-weight: 500; margin-left: 6px; }
.grow { flex: 1; }
.pick, .chk { color: var(--dim); display: flex; align-items: center; gap: 6px; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 196px minmax(0, 1fr) 372px; }
#palette { border-right: 1px solid var(--line); padding: 4px 10px 14px; overflow-y: auto; }
#palette h3, .cardhead { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); margin: 14px 0 6px; font-weight: 600; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.grid.ops { grid-template-columns: repeat(5, 1fr); }
.tool { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 3px 0 2px; display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 0; }
.tool svg { display: block; }
.tool small { font-size: 9.5px; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tool:hover { background: var(--panel2); }
.grid.ops .tool { padding: 1px 0; }
.empty { grid-column: 1 / -1; color: var(--dim); font-size: 11px; }

#stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#inspector { min-height: 44px; flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 14px; border-bottom: 1px solid var(--line); color: var(--dim); }
#inspector b { color: var(--text); font-weight: 600; }
#inspector code { font: 12px Consolas, monospace; color: var(--val); background: #0c1020; padding: 2px 7px; border-radius: 6px; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#inspector input[type=text] { width: 110px; }
#inspector .chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1px 4px 1px 8px; color: var(--text); }
#inspector .chip button { border: 0; background: none; padding: 0 4px; color: var(--dim); }
#canvas { flex: 1; min-height: 0; width: 100%; display: block; cursor: grab; touch-action: none;
  background: radial-gradient(circle at 1px 1px, #1f2646 1px, transparent 1.4px) 0 0 / 22px 22px, radial-gradient(ellipse at 50% 30%, #161b36, var(--bg) 75%); }
#canvas.panning { cursor: grabbing; }
#status { position: absolute; left: 14px; top: 56px; z-index: 5; background: #0c1020e6; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; color: var(--eff); opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 70%; }
#status.on { opacity: 1; }
#lexicon { flex: none; height: 84px; display: flex; gap: 8px; align-items: center; padding: 6px 14px; border-top: 1px solid var(--line); overflow-x: auto; }
.lex { flex: none; height: 70px; min-width: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--panel); border-radius: 10px; padding: 2px 8px; }
.lex.on { border-color: var(--val); }
.lex small { font: 10px Consolas, monospace; color: var(--dim); }
.lex.add { color: var(--dim); font-size: 12px; }

#side { border-left: 1px solid var(--line); overflow-y: auto; padding: 0 12px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 2px 12px 12px; margin-top: 12px; }
.cardhead .hint { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; opacity: .8; }
#inputs { display: grid; gap: 6px; }
.inrow { display: grid; grid-template-columns: 30px 70px 1fr; align-items: center; gap: 6px; }
.inrow span { font: 11px Consolas, monospace; color: var(--dim); overflow: hidden; text-overflow: ellipsis; }
.inrow input { width: 100%; font: 12px Consolas, monospace; }
.runrow { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.speed { color: var(--dim); display: flex; align-items: center; gap: 4px; margin-left: auto; font-size: 11px; }
.speed input { width: 70px; }
#result { margin-top: 10px; min-height: 20px; font: 12.5px Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
#result .ok { color: var(--val); } #result .bad { color: var(--bad); } #result .dimmer { color: var(--dim); }
#code { width: 100%; height: 250px; resize: vertical; background: #0c1020; border: 1px solid var(--line); border-radius: 8px; padding: 8px; font: 12px/1.45 Consolas, monospace; color: #cfd6f6; white-space: pre; tab-size: 2; }
#codeMsg { font-size: 11.5px; min-height: 16px; margin-top: 4px; color: var(--bad); }
#codeMsg.fine { color: var(--dim); }
.leg { display: grid; grid-template-columns: 40px 1fr; gap: 4px 8px; align-items: center; }
.leg div { color: var(--dim); } .leg b { color: var(--text); font-weight: 600; }
.law { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; color: var(--dim); font-size: 12px; }
.law i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }

/* ---------------------------------------------------------------- glyphs */
svg text { font-family: Consolas, "Cascadia Mono", monospace; text-anchor: middle; }
.hull { fill: #131834cc; stroke: var(--ext); stroke-width: 1.6; opacity: .92; }
.e { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.e.spine { stroke: var(--ctl); stroke-width: 2.6; }
.e.dead { stroke-dasharray: 2 6; opacity: .4; }
.nd.dead { opacity: .4; }
.e.spine.jump { stroke-dasharray: 6 5; }
.e.wire { stroke: var(--val); stroke-width: 1.5; opacity: .8; }
.e.wire.link { stroke-width: 2.4; }
.e.wire.r-recv, .e.wire.r-callee { stroke-dasharray: 3 3; }   /* dashed mint: the thing being called on, not a value handed in */
.e.wire.r-target { stroke: var(--eff); stroke-width: 2; }      /* amber wire: the place a write changes */
.e.exit { stroke: var(--ext); stroke-width: 2.2; stroke-dasharray: 1 6; }
.e.exit.carry { stroke-dasharray: none; stroke: var(--ext); }
.halo { fill: none; stroke: var(--bg); stroke-width: 8; opacity: .9; }
.g { fill: #10152b; stroke-width: 2; stroke-linejoin: round; }
.g.thin { stroke-width: 1.2; } .g.inner { fill: none; opacity: .7; } .g.dash { stroke-dasharray: 3 3; }
.s { fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.s.dash { stroke-dasharray: 3 3; }
.g.ctl, .s.ctl { stroke: var(--ctl); } .f.ctl { fill: var(--ctl); }
.g.val, .s.val { stroke: var(--val); } .f.val { fill: var(--val); }
.g.eff, .s.eff { stroke: var(--eff); } .f.eff { fill: var(--eff); }
.g.ext, .s.ext { stroke: var(--ext); } .f.ext { fill: var(--ext); }
.s.wallgap { stroke: var(--bg); stroke-width: 5; }
.bubble { fill: var(--bg); }
.sig path, .sig rect, .sig circle { stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.t { fill: var(--val); font-size: 11.5px; } .t.sym { font-size: 14px; font-family: "Segoe UI Symbol", "Cambria Math", sans-serif; } .t.sym.sm { font-size: 10px; fill: var(--eff); } .t.str { fill: #cdeee3; }
.lbl { fill: var(--dim); font-size: 10px; pointer-events: none; }
.g-hole { fill: #10152b; stroke: var(--val); stroke-width: 1.6; stroke-dasharray: 4 3; animation: spin 6s linear infinite; }
.g-hole.tgt { stroke: var(--eff); }
.g-holeplus { stroke: var(--dim); stroke-width: 1.4; }
.hit { fill: transparent; stroke: none; }
.nd { cursor: pointer; }
.nd:hover .g, .nd:hover .g-hole { filter: brightness(1.35); }
.nd.sel .hit { stroke: #fff; stroke-width: 1.4; stroke-dasharray: 3 3; fill: #ffffff10; }
.nd.k-port, .nd.k-portfall { cursor: default; }
.nd.born .in { animation: pop .4s ease-out; transform-box: fill-box; transform-origin: center; }
.ins { cursor: pointer; }
.ins .dot { fill: var(--bg); stroke: var(--ctl); stroke-width: 1.4; opacity: .55; }
.ins .plus { stroke: #fff; stroke-width: 1.6; opacity: 0; }
.ins:hover .dot { opacity: 1; r: 6; }
.ins.cur .dot { r: 8; fill: var(--val); stroke: #fff; opacity: 1; animation: beat 1.1s ease-in-out infinite; }
.ins.cur .plus { opacity: 1; stroke: #06251c; }
#canvas.dragging .ins .dot { opacity: 1; r: 5; }
.ins.near .dot { r: 9; fill: var(--eff); opacity: 1; }
.ghost { fill: none; stroke: var(--eff); stroke-width: 2; stroke-dasharray: 4 3; pointer-events: none; }
.mini .hull { stroke-width: 1.4; vector-effect: non-scaling-stroke; fill: none; opacity: .8; }
.mini .e { stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: none; }
.mini .e.exit { stroke-dasharray: none; }
.mini .s, .mini .g { stroke-width: 1; vector-effect: non-scaling-stroke; }

/* ---------------------------------------------------------------- running */
#canvas.ran #scene .e, #canvas.ran #scene .nd, #canvas.running #scene .e, #canvas.running #scene .nd { opacity: .22; transition: opacity .2s; }
#canvas.ran #scene .lit, #canvas.running #scene .lit { opacity: 1 !important; }
#scene .e.spine.lit { filter: drop-shadow(0 0 4px var(--ctl)); }
#scene .e.exit.lit { filter: drop-shadow(0 0 4px var(--ext)); }
#scene .e.wire.lit { opacity: 1 !important; filter: drop-shadow(0 0 3px var(--val)); }
#scene .nd.now .hit { stroke: #fff; stroke-width: 1.6; fill: #ffffff14; }
#scene .nd.now { filter: drop-shadow(0 0 6px #fff); }
.pulse { fill: #fff; filter: drop-shadow(0 0 5px #fff); pointer-events: none; }
.badge { pointer-events: none; }
.badge rect { fill: #0b0f1ef2; stroke: var(--val); stroke-width: 1; }
.badge text { fill: var(--val); font-size: 9.5px; }
.badge.eff rect { stroke: var(--eff); } .badge.eff text { fill: var(--eff); }
.badge.ext rect { stroke: var(--ext); fill: var(--ext); } .badge.ext text { fill: #0b0f1e; font-weight: 700; font-size: 10.5px; }
.tick { stroke: var(--ctl); stroke-width: 2; stroke-linecap: round; }
.count { fill: var(--ctl); font-size: 10px; text-anchor: start; }
@keyframes spin { to { stroke-dashoffset: -28; } }
@keyframes pop { from { transform: scale(.2); opacity: 0; } 70% { transform: scale(1.15); } to { transform: scale(1); opacity: 1; } }
@keyframes beat { 50% { r: 10; } }

/* ---------------------------------------------------------------- practice */
#practiceCard { border-color: #3d4a86; }
#practiceCard[hidden] { display: none; }
.ptitle { font-size: 15px; font-weight: 600; margin: 2px 0 6px; }
.pk { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; border-radius: 5px; padding: 2px 6px; margin-right: 4px; vertical-align: 2px; color: #0b0f1e; }
.pk.read { background: var(--val); } .pk.build { background: var(--eff); } .pk.fix { background: var(--ctl); }
.teach { color: var(--dim); margin: 0 0 8px; }
.task { margin: 0 0 10px; }
.prow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.prow.nav { margin-top: 10px; justify-content: space-between; }
.prow input { flex: 1; min-width: 0; font: 13px Consolas, monospace; }
#pResult { margin-top: 9px; min-height: 18px; }
#pResult .ok, .ptitle .ok { color: var(--val); } #pResult .bad { color: var(--bad); } #pResult .hintline { color: var(--eff); }
#codeCard .cardhead { cursor: pointer; }
#codeCard.shut #code, #codeCard.shut #codeMsg { display: none; }
#codeCard.shut { padding-bottom: 2px; }

/* ---------------------------------------------------------------- lessons: the coach and its pointer */
#coach { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(780px, calc(100% - 36px)); z-index: 6;
  background: #171d38f5; border: 1px solid #4a57a0; border-radius: 14px; padding: 10px 14px 12px; box-shadow: 0 10px 40px #0009; }
#coach[hidden] { display: none; }
.chead { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; }
.chead b { color: var(--text); }
.chead #cClose { margin-left: 4px; border: 0; background: none; color: var(--dim); font-size: 16px; padding: 0 4px; }
.cmode { white-space: nowrap; font-size: 10px; text-transform: uppercase; letter-spacing: 1px; border-radius: 5px; padding: 2px 7px; color: #0b0f1e; font-weight: 700; }
.cmode.watch { background: var(--ctl); } .cmode.wait, .cmode.task { background: var(--eff); }
.cdots { margin-left: auto; display: flex; gap: 4px; }
.cdots i { width: 7px; height: 7px; border-radius: 50%; background: #323a66; }
.cdots i.past { background: #6b76b3; } .cdots i.on { background: var(--val); }
#cText { font-size: 15.5px; line-height: 1.45; margin: 8px 0 10px; min-height: 44px; }
#cText b { color: var(--val); font-weight: 600; }
.crow, .cnav { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.crow { margin-bottom: 9px; }
.cnav .grow { flex: 1; }
#cMsg .ok { color: var(--val); } #cMsg .bad { color: var(--bad); } #cMsg .hintline { color: var(--eff); }
/* a page that asks which path lights next: the two answers sit as the two paths do, and what was called stays listed */
.cpicks { gap: 14px; justify-content: center; }   /* in the middle, like the fork: away from where Run was just pressed, so neither starts out pointed at */
.cpick { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 18px 6px 10px; font-size: 14.5px; font-weight: 600; border-color: var(--ctl); }
.cpick:focus-visible { border-color: #fff; background: #262c56; outline: none; }
@media (hover: hover) { .cpick:hover:not(:disabled) { border-color: #fff; background: #262c56; } }
.cpick.on:disabled { opacity: 1; border-color: #fff; box-shadow: inset 0 0 0 1px #fff; }
.cres { color: var(--dim); font-size: 13px; margin: 7px 0 0; }
.cres .ok { color: var(--val); font-weight: 600; } .cres .bad { color: var(--bad); font-weight: 600; }
/* the replay waits at a fork: both ways out move, the question stays readable, and nothing shows the answer yet */
#canvas.held #scene .ask { opacity: 1 !important; }
#canvas.held #scene .e.ask { stroke-dasharray: 3 7; animation: march .7s linear infinite; }
#canvas.held #scene .e.ask.aim { stroke: #fff; filter: drop-shadow(0 0 5px #fff); }
@keyframes march { to { stroke-dashoffset: -20; } }
button.quiet { border: 0; background: none; color: var(--dim); text-decoration: underline; padding: 4px; }
#hand { position: fixed; z-index: 50; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 2px solid #fff; background: #ffffff38;
  box-shadow: 0 0 14px #fff; pointer-events: none; transition: left .5s cubic-bezier(.3,.7,.3,1), top .5s cubic-bezier(.3,.7,.3,1), transform .15s; }
#hand[hidden] { display: none; }
#hand.press { transform: scale(.55); background: #fff; }
#canvas.spotting #scene > * { opacity: .2; transition: opacity .25s; }
#canvas.spotting #scene > .spot, #scene .spot { opacity: 1 !important; filter: drop-shadow(0 0 5px #fff); }
#scene .hull.spot { stroke-width: 3; }
button.spot, input.spot, #lexicon.spot { outline: 2px solid #fff; outline-offset: 2px; animation: ring 1.1s ease-in-out infinite; }
@keyframes ring { 50% { outline-color: var(--val); box-shadow: 0 0 16px var(--val); } }

/* ---------------------------------------------------------------- home and scores */
#home { position: fixed; inset: 0; z-index: 40; background: #0a0d1bf2; overflow-y: auto; padding: 28px 16px 40px; }
#home[hidden] { display: none; }
.hbox { position: relative; max-width: 980px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 26px 20px; }
#hClose { position: absolute; right: 14px; top: 12px; border: 0; background: none; color: var(--dim); font-size: 20px; }
.hhero { display: flex; gap: 22px; align-items: center; }
.hhero h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: .3px; }
.htag { margin: 0 0 14px; color: var(--dim); font-size: 15px; max-width: 520px; }
.hbtns { display: flex; gap: 8px; }
.hbtns button { font-size: 14px; padding: 8px 16px; }
.hbox h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; margin: 24px 0 8px; }
.hbox h2 span { color: var(--dim); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 8px; }
.hbox h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; margin: 12px 0 6px; }
.hgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 7px; }
.htile { display: grid; grid-template-columns: 22px 1fr; grid-template-rows: auto auto; gap: 0 6px; text-align: left; padding: 8px 10px; border-radius: 10px; background: var(--panel2); }
.htile b { grid-row: 1 / 3; color: var(--dim); font-weight: 600; align-self: center; }
.htile span { font-size: 13px; }
.htile i { font-style: normal; font-size: 11px; color: #39416e; letter-spacing: 1px; min-height: 14px; }
.htile i em { font-style: normal; color: var(--eff); }
.htile.done { border-color: #3e6f63; }
.htile.done i { color: var(--val); }
.htile.done i em { color: var(--eff); }
.hfoot { color: var(--dim); font-size: 12px; margin: 16px 0 0; }
.hnote { margin: 0 30px 14px 0; padding: 8px 12px; border: 1px solid #6b4f2a; border-radius: 9px; background: #2a2114; color: var(--eff); }
.stars { color: var(--eff); letter-spacing: 1px; } .dimstars { color: #39416e; letter-spacing: 1px; }
.parline { color: var(--dim); font-size: 12px; margin-top: 8px; }
.score { margin-top: 6px; } .score b { font-weight: 600; } .score b.ok { color: var(--val); }

.fine { color: var(--dim); font-size: 12px; margin-top: 10px; line-height: 1.5; } .fine b { color: var(--text); }
/* ---------------------------------------------------------------- narrow screens: the canvas comes first, panels stack below */
@media (max-width: 900px) {
  body { overflow: auto; height: auto; }
  header { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  header .grow { display: none; }
  .pick select { max-width: 150px; }
  main { display: flex; flex-direction: column; }
  /* the stage grows with what it holds: the canvas keeps its own height, and the lesson coach sits below it in the flow
     (not over it), so feedback of any length never covers a glyph */
  #stage { order: 1; }
  #canvas { flex: none; height: max(300px, 56vh);
    /* a vertical swipe on empty canvas scrolls the page down to the palette and the panels; a sideways one still pans.
       A touch that starts on a glyph is kept by the glyph (app.js, wirePointer) so a stroke can be dragged any way. */
    touch-action: pan-y; }
  #palette { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  #palette .grid { grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); }
  #side { order: 3; border-left: 0; border-top: 1px solid var(--line); }
  #coach { position: static; transform: none; width: auto; margin: 8px 8px 0; box-shadow: none; }
  #cText { font-size: 14px; }
  .cpicks .cpick { flex: 1; justify-content: center; padding: 6px 8px; }
  .hhero { flex-direction: column; align-items: flex-start; }
}
.hfoot a { color: var(--val); }

.t.str { white-space: pre; }
.ins .hit.touch { display: none; }
@media (pointer: coarse) { .ins .hit.touch { display: inline; fill: transparent; } }
#quickRun { display: none; }
@media (max-width: 900px) { #quickRun { display: block; position: absolute; right: 10px; top: calc(var(--insp, 56px) + 10px); z-index: 6; padding: 8px 18px; font-size: 14px; } }
/* on a phone the page scrolls, so a message is pinned to the screen, not to the canvas that may be far above */
@media (max-width: 900px) { #status { position: fixed; top: auto; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  z-index: 55; width: max-content; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 24px #0009; } }

/* ---------------------------------------------------------------- exercise links (#e=), Make puzzle, embed (?embed=1) */
.xtask { white-space: pre-wrap; word-break: break-word; }
.xcases { margin: 0 0 10px; font-size: 12px; color: var(--dim); }
.xcases b { color: var(--text); font-weight: 600; }
.xcase { margin: 3px 0; word-break: break-all; }
.xcase code { font: 12px Consolas, monospace; color: var(--val); }
.xmore { margin-top: 3px; }
#xResult { margin-top: 9px; min-height: 18px; }
#xResult .ok { color: var(--val); } #xResult .bad { color: var(--bad); }
#embedAttr { display: none; }
#maker { position: fixed; inset: 0; z-index: 45; background: #0a0d1bd9; overflow-y: auto; padding: 24px 12px; }
#maker[hidden] { display: none; }
.mkbox { position: relative; max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 20px 18px; }
.mkbox h2 { font-size: 17px; margin: 0 30px 4px 0; }
#mkClose { position: absolute; right: 12px; top: 10px; border: 0; background: none; color: var(--dim); font-size: 20px; }
.mknote { color: var(--dim); margin: 4px 0 10px; }
.mknote a { color: var(--val); }
.mkgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.mkgrid label, #mkOut label { display: flex; flex-direction: column; gap: 3px; color: var(--dim); font-size: 12px; min-width: 0; }
.mkgrid .wide, #mkOut .wide { grid-column: 1 / -1; }
.mkgrid textarea, #mkOut textarea { background: #0c1020; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px; color: var(--text); resize: vertical; min-width: 0; }
#mkStarter, #mkEmbed, #mkLink { font: 12px Consolas, monospace; }
.mkopts { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.mkopts .chk { flex-direction: row; }
.hint { opacity: .8; }
.mkcasehead { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--dim); font-weight: 600; margin: 14px 0 6px; }
.mkcasehead .hint { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.mkscroll { overflow-x: auto; }
#mkCases { border-collapse: collapse; width: 100%; }
#mkCases th { text-align: left; font: 11px Consolas, monospace; color: var(--dim); padding: 2px 4px; }
#mkCases td { padding: 2px 4px; }
#mkCases .mkIn { width: 100%; min-width: 70px; font: 12px Consolas, monospace; }
#mkCases .mkOut { font: 12px Consolas, monospace; color: var(--val); white-space: nowrap; }
#mkCases .mkDel { padding: 2px 8px; }
#mkIssues { color: var(--bad); margin: 10px 0 0; padding-left: 18px; }
#mkIssues:empty { display: none; }
#mkOut { margin-top: 12px; display: grid; gap: 8px; }
#mkOut[hidden] { display: none; }
.mkrow { display: flex; gap: 6px; align-items: flex-start; }
.mkrow input, .mkrow textarea { flex: 1; min-width: 0; }
.mkrow button { flex: none; }
@media (max-width: 600px) { .mkgrid { grid-template-columns: 1fr; } .mkrow { flex-direction: column; align-items: stretch; } .mkbox { padding: 14px 12px; } }

/* embed: the editor alone, inside another site's frame. Set before first paint by js/embed.js. */
html.embed .brand span, html.embed #homeBtn, html.embed header .pick, html.embed #home, html.embed #legend, html.embed .hfoot, html.embed #makerBtn { display: none !important; }
html.embed #embedAttr { display: inline-block; color: var(--val); white-space: nowrap; font-size: 12px; text-decoration: none; }
html.embed, html.embed body { height: 100%; overflow: hidden; }
html.embed header { gap: 8px; padding: 0 10px; }
/* a frame is smaller than a page: narrower side columns and a shorter strip of shapes give the canvas the room */
html.embed main { grid-template-columns: 168px minmax(0, 1fr) 320px; }
html.embed #lexicon { height: 64px; }
html.embed .lex { height: 52px; }
@media (max-width: 900px) {
  html.embed body { height: 100%; overflow: hidden; }
  html.embed header { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  /* the canvas on top; the palette and the panels scroll inside the frame, never the page around them */
  html.embed main { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  html.embed main > * { flex: none; }
  html.embed #canvas { height: max(170px, calc(100vh - 250px)); }
  html.embed #lexicon { height: 64px; }
  html.embed .lex { height: 52px; }
}
@media (max-width: 480px) { html.embed .brand { display: none; } html.embed header button { padding: 5px 9px; } }
/* the header never runs off the side: short of room, the tagline goes and the menus narrow; between phone and wide
   desktop widths it takes a second row */
header > :not(.grow) { flex: none; }
.brand, header button { white-space: nowrap; }
@media (max-width: 1500px) { .brand span { display: none; } .pick select { max-width: 150px; } }
@media (min-width: 901px) and (max-width: 1360px) { header { height: auto; min-height: 50px; flex-wrap: wrap; padding: 6px 16px; row-gap: 6px; } }
