/* The look of the editor prototype: the proof tree on the left grows from the goal, the dock
   on the right holds the hand, the shelf of lemmas and the workbench. The same type has the
   same colour everywhere (classes c0…c11, worked out in game.taut); a type with something
   not yet known is grey (cq). */
:root {
  color-scheme: light;
  --bg:#f5f6f8; --surface:#ffffff; --fg:#161b24; --muted:#5a6475; --line:#d9dde5;
  --accent:#0b6e8a; --hole:#b86e00; --ok:#1a7a47; --err:#b3261e; --code-bg:#eceff4;
  --t-atom:#8a96ab;
  --canvas:#10151d; --grid:#1b2431; --node:#1b2431; --node-line:#33405a; --node-fg:#e6ebf2; --node-sub:#8e9bb0;
  --font-body:"Zen Kaku Gothic New","Hiragino Sans","Noto Sans JP",sans-serif;
  --font-mono:"JetBrains Mono",ui-monospace,Menlo,monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg:#0e1218; --surface:#161c26; --fg:#e4e9f1; --muted:#9aa5b8; --line:#2a3342;
  --accent:#4cc0e0; --hole:#f0a63a; --ok:#4fd08a; --err:#ff7b72; --code-bg:#1d2532; --canvas:#0a0e14;
} }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:#0e1218; --surface:#161c26; --fg:#e4e9f1; --muted:#9aa5b8; --line:#2a3342;
  --accent:#4cc0e0; --hole:#f0a63a; --ok:#4fd08a; --err:#ff7b72; --code-bg:#1d2532; --canvas:#0a0e14;
}
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--fg); font-family:var(--font-body); font-size:15px; line-height:1.7;
  padding-block:24px 48px; padding-left:max(16px,env(safe-area-inset-left,0px)); padding-right:max(16px,env(safe-area-inset-right,0px)); }
main { max-width:70rem; margin:0 auto; min-width:0; }
h1 { font-size:1.4rem; margin:0 0 .2rem; }
h2 { font-size:.8rem; letter-spacing:.06em; color:var(--muted); margin:14px 0 4px; }
.sub { color:var(--muted); margin:0 0 1rem; font-size:.9rem; }
[hidden] { display:none !important; }

/* the colour of each type */
.c0{--c:hsl(205 68% 62%)} .c1{--c:hsl(342 68% 62%)} .c2{--c:hsl(120 68% 62%)} .c3{--c:hsl(257 68% 62%)}
.c4{--c:hsl(35 68% 62%)} .c5{--c:hsl(172 68% 62%)} .c6{--c:hsl(310 68% 62%)} .c7{--c:hsl(88 68% 62%)}
.c8{--c:hsl(225 68% 62%)} .c9{--c:hsl(3 68% 62%)} .c10{--c:hsl(140 68% 62%)} .c11{--c:hsl(278 68% 62%)}
.cq{--c:var(--t-atom)}

/* bars and buttons */
.bar { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:10px; }
.bar .sp { flex:1; }
.levels { gap:6px; margin-bottom:6px; }
.stage-name { font-size:.78rem; color:var(--muted); letter-spacing:.04em; min-width:5.5em; }
button { font:inherit; font-size:.85rem; color:var(--fg); background:var(--surface); border:1px solid var(--line); border-radius:4px; padding:4px 12px; cursor:pointer;
  transition:border-color .15s, box-shadow .15s, transform .1s, opacity .15s; }
button:hover { border-color:var(--accent); }
button:active { transform:translateY(1px); }
button.on { border-color:var(--accent); color:var(--accent); font-weight:700; }
button.off { opacity:.4; }
.levels button.done .mark { color:var(--ok); font-weight:700; }
.levels button.locked, .levels button:disabled { opacity:.4; cursor:not-allowed; }
.levels button:disabled:hover { border-color:var(--line); }
.levels button:disabled:active { transform:none; }
button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.mini { font-size:.78rem; padding:6px 12px; min-height:34px; }
.put { border-color:var(--ok); color:var(--ok); font-weight:700; }
.next { border-color:var(--ok); color:var(--ok); font-weight:700; margin-left:12px; }

.status { font-family:var(--font-mono); font-size:.82rem; padding:3px 10px; border-radius:99px; border:1px solid var(--hole); color:var(--hole); transition:all .25s; }
.status.ok { border-color:var(--ok); color:var(--ok); }
.status.err { border-color:var(--err); color:var(--err); }
.status.load { border-color:var(--accent); color:var(--accent); animation:pulse 1.2s ease-in-out infinite; }

.task { background:var(--surface); border:1px solid var(--line); border-radius:4px; padding:8px 12px; margin:6px 0 10px; font-size:.9rem; animation:fade .25s ease-out; }
.task .title { font-weight:700; }
.task .sig { display:block; margin-top:4px; font-family:var(--font-mono); font-size:.82rem; color:var(--fg); overflow-x:auto; white-space:pre; }
.task details { margin-top:4px; font-size:.85rem; color:var(--muted); }
.task summary { cursor:pointer; }
.task .answer { margin:4px 0 0; font-family:var(--font-mono); font-size:.8rem; color:var(--fg); white-space:pre-wrap; word-break:break-word; }

/* the board */
.split { display:grid; grid-template-columns:1fr 1fr; gap:14px; align-items:start; }
.pane { min-width:0; }
.sect { font-size:.78rem; color:var(--muted); margin:10px 0 4px; letter-spacing:.04em; }
.sect.first { margin-top:0; }
.dock { position:sticky; top:8px; max-height:calc(100vh - 16px); overflow:auto; background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:8px 10px; min-width:0; }
@media (max-width:760px) {
  .split { display:block; }
  .pane { padding-bottom:12px; }
  .dock { position:sticky; bottom:0; top:auto; max-height:46vh; border-radius:12px 12px 0 0; border-width:2px 0 0; box-shadow:0 -6px 18px rgba(0,0,0,.25);
    background:var(--surface); margin:12px calc(-1 * max(16px,env(safe-area-inset-left,0px))) 0; padding-bottom:max(10px,env(safe-area-inset-bottom,0px)); z-index:5; }
}

.won-banner { display:flex; flex-direction:column; gap:4px; border:2px solid var(--ok); color:var(--ok); border-radius:6px; padding:8px 12px; margin:0 0 8px; font-weight:700;
  animation:win .5s ease-out; }

/* the type of a slot */
.tyc { white-space:nowrap; font-family:var(--font-mono); font-size:.8rem; padding:1px 8px; border-radius:99px; border:1.5px solid var(--c,var(--t-atom));
  background:color-mix(in srgb,var(--c,var(--t-atom)) 18%,var(--surface)); }

/* blocks and slots */
.blk { border:2px solid var(--c,var(--t-atom)); border-radius:10px; background:color-mix(in srgb,var(--c,var(--t-atom)) 16%,var(--surface)); padding:6px 8px 8px; margin:2px 0;
  animation:pop .22s ease-out; }
.blk.src { outline:3px solid var(--accent); outline-offset:1px; }
.bh { display:flex; justify-content:space-between; align-items:center; gap:8px; font-family:var(--font-mono); font-weight:700; font-size:.9rem; overflow-wrap:anywhere; }
.x { cursor:pointer; padding:6px 10px; color:var(--muted); font-size:16px; line-height:1; border-radius:4px; }
.x:hover { color:var(--err); background:color-mix(in srgb,var(--err) 10%,transparent); }
.slot { margin:6px 0 2px; padding:4px 6px 6px; border-radius:8px; border:2px solid var(--c,var(--t-atom)); background:var(--surface); transition:box-shadow .2s, opacity .2s, outline-color .2s; }
.slot .sh { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:4px; font-size:.78rem; font-family:var(--font-mono); color:var(--muted); }
.slot.open { border-style:dashed; cursor:pointer; min-height:48px; }
.slot.open .ph { color:var(--hole); font-size:.85rem; padding:6px 2px; display:block; }
.slot.sel { outline:3px solid var(--hole); outline-offset:1px; }
.slot.compat { box-shadow:0 0 0 4px color-mix(in srgb,var(--ok) 55%,transparent); animation:glow 1.4s ease-in-out infinite; }
.carrying .slot.open:not(.compat) { opacity:.4; }
.leaf { display:flex; align-items:center; gap:4px; }
.pill { display:inline-block; border:2px solid var(--c,var(--t-atom)); border-radius:99px; background:color-mix(in srgb,var(--c,var(--t-atom)) 22%,var(--surface));
  padding:3px 14px; font-family:var(--font-mono); font-weight:700; font-size:.9rem; overflow-wrap:anywhere; animation:pop .22s ease-out; }

/* candidates */
.cand { padding:8px 10px 10px; background:color-mix(in srgb,var(--hole) 8%,var(--surface)); border-left:4px solid var(--hole); }
.cand.inl { margin:0; border-left:0; border-radius:6px; animation:fade .2s ease-out; }
.chip { display:inline-flex; flex-direction:column; gap:1px; text-align:left; min-height:44px; justify-content:center; margin:3px 6px 3px 0; border:2px solid var(--c,var(--t-atom)); border-radius:8px;
  background:color-mix(in srgb,var(--c,var(--t-atom)) 14%,var(--surface)); padding:4px 10px; font-family:var(--font-mono); font-size:.82rem; }
.chip:hover { transform:translateY(-1px); box-shadow:0 2px 6px rgba(0,0,0,.12); border-color:var(--c,var(--t-atom)); }
.chip b { font-size:.88rem; }
.chip small { color:var(--muted); font-size:.72rem; }
.chip.val { flex-direction:row; align-items:center; gap:8px; border-radius:99px; padding:4px 16px; background:color-mix(in srgb,var(--c,var(--t-atom)) 30%,var(--surface)); }
.chip.val small { color:var(--fg); opacity:.8; }
.chip.fn { border-radius:4px; border-left-width:7px; background:var(--surface); }
.chip.intro { border-style:dashed; }
.sks { display:flex; flex-wrap:wrap; gap:4px; margin-top:2px; }
.sk { font-style:normal; font-size:.72rem; color:var(--muted); border:1.5px dashed var(--c,var(--t-atom)); border-radius:3px; padding:0 6px; }
.none { color:var(--hole); font-size:.85rem; }

/* the dock */
.hyps, .tray { display:flex; flex-wrap:wrap; gap:8px; align-items:center; background:var(--surface); border:1px solid var(--line); border-radius:6px; padding:8px 10px; }
.pillbtn { display:inline-flex; gap:8px; align-items:center; min-height:44px; border:2px solid var(--c,var(--t-atom)); border-radius:99px;
  background:color-mix(in srgb,var(--c,var(--t-atom)) 18%,var(--surface)); padding:4px 14px; font-family:var(--font-mono); font-size:.85rem; }
.pillbtn.src { outline:3px solid var(--accent); outline-offset:1px; }
.pillbtn.used { opacity:.75; }
.badge { font-size:.72rem; color:var(--muted); border:1px solid var(--line); border-radius:99px; padding:0 7px; font-family:var(--font-body); }
.meet { font-size:.72rem; font-weight:700; color:var(--ok); border:1px solid var(--ok); border-radius:99px; padding:0 8px; font-family:var(--font-body); margin-left:6px; }
.srcbtn { cursor:pointer; display:inline-block; padding:6px 0; }
.srcpanel { margin-top:8px; border-radius:6px; }
.ti { user-select:none; cursor:pointer; border:2px solid var(--c,var(--t-atom)); border-radius:10px; background:color-mix(in srgb,var(--c,var(--t-atom)) 16%,var(--surface));
  padding:6px 12px; min-height:44px; display:inline-flex; flex-direction:column; justify-content:center; text-align:left; font-family:var(--font-mono); font-size:.82rem; }
.ti b { font-size:.88rem; }
.ti small { color:var(--muted); font-size:.72rem; }

/* dragging into the blocks: the ghost follows the pointer; the holes that take what is dragged
   light up and the others fade */
.ti, .pillbtn { touch-action:none; user-select:none; cursor:grab; }
.ghost { position:fixed; left:var(--gx,0); top:var(--gy,0); z-index:50; pointer-events:none; opacity:.92; transform:translate(-50%,-110%); }
.bdrag .slot.open:not(.compat) { opacity:.4; }
.bdrag .dock { outline:2px dashed var(--accent); outline-offset:2px; }

/* the views */
.views button[aria-pressed="true"] { border-color:var(--accent); color:var(--accent); font-weight:700; }

/* the node view: a canvas of nodes with ports, joined by wires (an SVG over the nodes). The
   sizes of .node, .hd and .row are the ones nodes.taut places the wires' ends by. */
.scroller { overflow:auto; border-radius:6px; background:var(--canvas); }
.stage { position:relative; min-width:100%; width:var(--w,100%); height:var(--h,470px); user-select:none;
  background-image:radial-gradient(var(--grid) 1px,transparent 1px); background-size:22px 22px; }
svg.wires { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; overflow:visible; }
.wire { fill:none; stroke-width:2.4; stroke:var(--c,var(--t-atom)); }
.wire.tmp { stroke:#e6ebf2; stroke-dasharray:5 4; }
.wire.off { display:none; }
.node { position:absolute; left:var(--x,0); top:var(--y,0); width:176px; background:var(--node); border:1.5px solid var(--node-line); border-radius:7px;
  color:var(--node-fg); font-family:var(--font-mono); font-size:12px; line-height:1.4; animation:pop .22s ease-out; }
.node.hyp { border-color:var(--accent); }
.node.goal { border-color:var(--hole); border-style:dashed; }
.node.goal.won { border-color:var(--ok); border-style:solid; box-shadow:0 0 0 3px color-mix(in srgb,var(--ok) 35%,transparent); }
.node.unused { opacity:.55; }
.node .hd { display:flex; justify-content:space-between; align-items:center; height:30px; padding:0 4px 0 10px; font-weight:600; overflow:hidden; white-space:nowrap; }
.node .hd .x { color:var(--node-sub); padding:4px 10px; }
.node .row { display:flex; align-items:center; gap:6px; height:28px; padding:0 10px; position:relative; }
.node .row.out { justify-content:flex-end; }
.pn { color:var(--node-sub); }
.ty { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:140px; padding:1px 7px; border-radius:99px; border:1.5px solid var(--c,var(--t-atom));
  background:color-mix(in srgb,var(--c,var(--t-atom)) 18%,transparent); }
.port { position:absolute; top:50%; width:16px; height:16px; margin-top:-8px; touch-action:none; border-radius:50%; border:2.5px solid var(--c,var(--t-atom));
  background:var(--canvas); cursor:crosshair; transition:box-shadow .15s, opacity .15s; }
.port::after { content:""; position:absolute; inset:-12px; }
.port.in { left:-9px; }
.port.out { right:-9px; background:var(--c,var(--t-atom)); }
.port.in.open { border-style:dotted; }
.port.in.filled { background:var(--c,var(--t-atom)); cursor:default; }
.port.out.used { cursor:default; }
.port.sel { box-shadow:0 0 0 4px color-mix(in srgb,var(--hole) 55%,transparent); }
.port.compat { box-shadow:0 0 0 4px color-mix(in srgb,var(--ok) 60%,transparent); }
.stage.dragging .port:not(.compat):not(.src):not(.sel) { opacity:.3; }
.hint { color:var(--muted); font-size:.82rem; margin:.4rem 0; }
.pal { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.card { background:var(--surface); border:1px solid var(--line); border-radius:5px; padding:6px 10px; font-family:var(--font-mono); font-size:.78rem; text-align:left; line-height:1.5; }
.card b { display:block; font-size:.85rem; }
.card.dim { opacity:.35; }
.card.hit { border-color:var(--ok); box-shadow:0 0 0 2px color-mix(in srgb,var(--ok) 40%,transparent); }
.extras { display:contents; }

/* the proof term */
.term { font-family:var(--font-mono); font-size:.85rem; background:var(--code-bg); border-radius:4px; padding:10px 12px; overflow-x:auto; white-space:pre-wrap; word-break:break-word; }
.term .hole { color:var(--hole); font-weight:600; }
.drawer { margin-top:12px; font-size:.85rem; color:var(--muted); }
.drawer summary { cursor:pointer; padding:8px 0; }
.source { font-family:var(--font-mono); font-size:.78rem; color:var(--fg); background:var(--code-bg); border-radius:4px; padding:10px 12px; overflow-x:auto; }
.err { color:var(--err); white-space:pre-wrap; font-family:var(--font-mono); font-size:.8rem; }

.skeleton { height:420px; border-radius:8px; background:linear-gradient(90deg,var(--surface),var(--code-bg),var(--surface)); background-size:200% 100%; animation:shimmer 1.4s linear infinite; }
.toast { position:fixed; left:50%; bottom:max(24px,env(safe-area-inset-bottom,0px)); transform:translateX(-50%); background:var(--fg); color:var(--bg); padding:8px 16px; border-radius:8px;
  font-size:.88rem; z-index:40; animation:toast .25s ease-out; box-shadow:0 6px 18px rgba(0,0,0,.25); }

@keyframes pop { from { transform:scale(.96); opacity:.4; } to { transform:none; opacity:1; } }
@keyframes fade { from { opacity:0; } to { opacity:1; } }
@keyframes glow { 50% { box-shadow:0 0 0 6px color-mix(in srgb,var(--ok) 35%,transparent); } }
@keyframes pulse { 50% { opacity:.55; } }
@keyframes shimmer { to { background-position:-200% 0; } }
@keyframes win { 0% { transform:scale(.97); box-shadow:0 0 0 0 color-mix(in srgb,var(--ok) 60%,transparent); } 60% { box-shadow:0 0 0 10px transparent; } 100% { transform:none; } }
@keyframes toast { from { opacity:0; transform:translate(-50%,8px); } to { opacity:1; transform:translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { * { animation:none !important; transition:none !important; } }

/* the level's one-line introduction, and the three tiers of hints */
.intro { margin:-2px -6px 6px; padding:4px 10px; border-left:4px solid var(--accent); border-radius:4px; background:color-mix(in srgb,var(--accent) 12%,var(--surface));
  animation:slidein .35s ease-out; }
.hints { margin-top:6px; display:flex; flex-direction:column; align-items:flex-start; gap:4px; }
.hintbtn { font-size:.82rem; }
.tier { font-size:.85rem; animation:fade .25s ease-out; }
.tier b { display:inline-block; margin-right:8px; padding:0 8px; border-radius:99px; font-size:.72rem; background:var(--code-bg); color:var(--muted); }

/* the tour: the page is dimmed but for the target, which a bubble points at (main.taut, ui.taut) */
main.touring::before { content:""; position:fixed; inset:0; background:rgba(8,12,18,.48); z-index:30; pointer-events:none; animation:fade .3s ease-out; }
.touring .tour-on { position:relative; z-index:31; box-shadow:0 0 0 3px var(--accent),0 0 0 9px color-mix(in srgb,var(--accent) 30%,transparent); }
/* A container that makes its own stacking context comes up with its target. */
.touring .dock:has(.tour-on), .touring .task:has(.tour-on) { position:relative; z-index:31; }
.tourbar { position:relative; z-index:31; display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin:0 0 10px; padding:6px 10px; border-radius:6px;
  background:var(--surface); border:2px solid var(--accent); font-size:.88rem; animation:slidein .3s ease-out; }
.tourbar .step { font-family:var(--font-mono); font-size:.75rem; color:var(--muted); }
.tourbar .skip { margin-left:auto; }
.bubble { position:absolute; left:0; top:calc(100% + 12px); z-index:32; width:max-content; max-width:min(18rem,calc(100vw - 40px)); padding:6px 10px; border-radius:8px;
  background:var(--fg); color:var(--bg); font-family:var(--font-body); font-size:.82rem; font-weight:500; line-height:1.5; text-align:left; white-space:normal;
  pointer-events:none; box-shadow:0 6px 18px rgba(0,0,0,.3); animation:bubble .3s ease-out; }
.bubble::before { content:""; position:absolute; left:18px; top:-6px; width:12px; height:12px; background:var(--fg); transform:rotate(45deg); }
@media (max-width:760px) { .dock .bubble { top:auto; bottom:calc(100% + 12px); } .dock .bubble::before { top:auto; bottom:-6px; } }

/* the idle nudge, and the names a level introduces */
.nudge { animation:nudge 1.8s ease-in-out infinite; }
.new { position:relative; }
.new::after { content:"NEW"; position:absolute; top:-9px; right:-6px; padding:0 5px; border-radius:99px; background:var(--hole); color:#fff; font-size:.58rem; font-weight:700; line-height:1.5; letter-spacing:.04em; }

/* lemmas the player earned, and those not yet earned */
.ti.own { border-style:double; border-width:4px; }
.ti .mine { align-self:flex-start; padding:0 6px; border-radius:99px; background:var(--ok); color:#fff; font-size:.62rem; font-weight:700; }
.ti.locked { opacity:.5; cursor:not-allowed; border-style:dashed; }

/* what does not fit, and why */
.misses { margin-top:6px; font-size:.8rem; color:var(--muted); }
.misses summary { cursor:pointer; }
.chip.miss { opacity:.6; filter:grayscale(1); cursor:default; border-style:dotted; }
.chip.miss:hover { transform:none; box-shadow:none; }

/* a cleared level, a lemma earned, a stage cleared */
.won-line { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.won-banner.celebrate { background:linear-gradient(110deg,transparent 30%,color-mix(in srgb,var(--ok) 18%,transparent) 50%,transparent 70%) 0 0/250% 100%;
  animation:win .5s ease-out, shine 1.6s ease-out .2s 1 both; }
.gift { color:var(--fg); font-weight:500; animation:pop .5s cubic-bezier(.2,1.6,.4,1) .3s both; }
.gift b { font-family:var(--font-mono); padding:0 8px; margin-left:4px; border-radius:6px; border:2px solid var(--ok); }
.stage-clear { font-size:1.1rem; animation:pop .6s cubic-bezier(.2,1.6,.4,1) .5s both; }

/* a level written as text: not built yet */
.soon { border:2px dashed var(--line); border-radius:8px; padding:12px 14px; background:var(--surface); }
.soon p { margin:4px 0 8px; color:var(--muted); font-size:.9rem; }

@keyframes slidein { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
@keyframes bubble { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
@keyframes nudge { 0%,100% { box-shadow:0 0 0 0 transparent; } 50% { box-shadow:0 0 0 6px color-mix(in srgb,var(--accent) 28%,transparent); } }
@keyframes shine { from { background-position:100% 0; } to { background-position:-50% 0; } }
