/* Claude Code Simulator — full-bleed terminal */
:root {
  --term: #111112;
  --side: #0c0c0d;
  --fg: #e8e6e3;
  --dim: #8d8d8d;
  --dimmer: #5c5c5c;
  --line: #3b3b3d;
  --orange: #d97757;
  --coral: #ef8f73;
  --amber: #f0c98a;
  --gold: #ffd479;
  --green: #4fbf67;
  --red: #ff6b78;
  --yellow: #e6c27a;
  --blue: #6cb4f5;
  --cyan: #5cc6cf;
  --purple: #c48af0;
  --pane-fs: 12.5px;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--term); color: var(--fg); font: 13px/1.5 var(--mono); -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, textarea:focus-visible, a:focus-visible { outline: 1px dashed var(--orange); outline-offset: 2px; }
b { font-weight: 700; }
.dim { color: var(--dim); }
.g { color: var(--green); font-weight: 700; }
.c { color: var(--cyan); font-weight: 700; }
.b { color: var(--blue); font-weight: 700; }
.r { color: var(--red); font-weight: 700; }
.y { color: var(--yellow); font-weight: 700; }
.star { color: var(--orange); }
.sim { color: var(--dimmer); font-style: italic; font-weight: 400; }

/* ───────── layout: sessions | main (screen + prompt) ───────── */
.app { position: fixed; inset: 0; display: flex; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.screen {
  flex: 1; min-height: 0; overflow: auto;
  padding: 4px 18px 10px;
  scrollbar-color: #333 transparent;
}
.screen.running { overflow: hidden; padding: 2px 14px 6px; }
.view { min-height: 100%; }

/* ───────── sessions sidebar ───────── */
.side {
  flex: none; width: 236px; display: flex; flex-direction: column; gap: 4px;
  background: var(--side); border-right: 1px solid #1f1f21;
  padding: max(12px, env(safe-area-inset-top)) 10px 12px max(10px, env(safe-area-inset-left));
}
.app.side-hidden .side { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px 4px; min-height: 26px; }
.brand { font-weight: 700; white-space: nowrap; }
.newsess { text-align: left; padding: 7px 10px; border: 1px dashed #3a3a3d; border-radius: 7px; color: var(--fg); }
.newsess:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.side-label { font-size: 10.5px; color: var(--dimmer); text-transform: uppercase; letter-spacing: .1em; padding: 10px 6px 2px; }
.side-list { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 1px; scrollbar-width: thin; scrollbar-color: #2a2a2c transparent; }
.sess { position: relative; display: flex; align-items: stretch; border-radius: 7px; }
.sess:hover { background: #161618; }
.sess.active { background: #1c1c1f; box-shadow: inset 2px 0 0 var(--orange); }
.sess-main { flex: 1; min-width: 0; text-align: left; padding: 6px 4px 6px 10px; display: flex; flex-direction: column; gap: 1px; }
.sess-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
.sess-meta { font-size: 11px; color: var(--dimmer); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess.running .sess-meta { color: var(--coral); }
.sess.running .sess-title::before { content: "✻ "; color: var(--orange); }
.sess-del { flex: none; opacity: 0; padding: 0 9px; color: var(--dim); font-size: 14px; }
.sess:hover .sess-del, .sess-del:focus-visible, .sess-del.confirm { opacity: 1; }
.sess-del:hover { color: var(--fg); }
.sess-del.confirm { color: var(--red); font-size: 11px; }
.side.locked .sess:not(.active) .sess-main, .side.locked .newsess { opacity: .4; cursor: not-allowed; }
.side.locked .sess-del { display: none; }
.side-foot { font-size: 11px; color: var(--dimmer); padding: 10px 6px 0; border-top: 1px solid #1f1f21; line-height: 1.55; }
.side-foot b { color: var(--dim); font-weight: 500; }
.side-scrim { display: none; }

/* ───────── top bar: session title + controls (in the flow, so nothing overlaps content) ───────── */
.topbar { flex: none; display: flex; align-items: center; gap: 6px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 2px 18px; min-height: 36px; }
.tb-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--dimmer); font-size: 12px; }
.tb-title b { color: var(--dim); font-weight: 500; }
.tb-fill { flex: 1; }
.ctl {
  width: 30px; height: 26px; display: grid; place-items: center; flex: none;
  border: 1px solid #3a3a3d; border-radius: 6px; background: rgba(17,17,18,.92); color: var(--dim); font-size: 14px;
}
.ctl:hover { color: var(--fg); border-color: #6a6a70; }
.ctl[aria-pressed="false"] { color: var(--dimmer); text-decoration: line-through; }
.ctl svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ctl .fs-out, :root.is-fs .ctl .fs-in { display: none; }
:root.is-fs .ctl .fs-out { display: block; }
#sideShow { display: none; }
.app.side-hidden #sideShow { display: grid; }
.side .ctl { background: transparent; border-color: transparent; }
.side .ctl:hover { border-color: #3a3a3d; }

/* ───────── home ───────── */
.shell-line { white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.welcome { border: 1px solid var(--orange); border-radius: 8px; padding: 10px 16px; margin: 12px 0 18px; max-width: 580px; }
.wl1 { margin-bottom: 6px; }
.tip { margin-top: 6px; color: var(--dimmer); }
.tip b { color: var(--dim); font-weight: 500; }

.convo { display: flex; flex-direction: column; gap: 1px; margin-bottom: 10px; }
.convo:empty { display: none; }
.convo > * { animation: rise .3s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.convo a { color: var(--blue); text-decoration: none; }
.convo a:hover { text-decoration: underline; }
.convo > .msg-line, .convo > .msg-meta { margin-top: 8px; }
.msg-user { color: var(--dim); background: #1a1a1c; padding: 4px 10px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; margin-top: 18px; }
.msg-user:first-child { margin-top: 0; }
.msg-user::before { content: "> "; color: var(--dimmer); }
.msg-line { display: grid; grid-template-columns: 2ch minmax(0, 1fr); white-space: pre-wrap; word-break: break-word; }
.msg-line.ok .bul { color: var(--green); }
.msg-line.err .bul { color: var(--red); }
.msg-line.ans .bul { color: var(--orange); }
.msg-sub { padding-left: 2ch; color: var(--dim); white-space: pre-wrap; word-break: break-word; }
.msg-sub::before { content: "⎿  "; color: var(--dimmer); }
.msg-meta { color: var(--coral); }
.msg-meta.boom { color: var(--gold); }

.answer { white-space: normal; max-width: 860px; }
.answer p { margin: 4px 0 0; }
.ans-title { font-weight: 700; }
.ans-desc { color: var(--dim); font-weight: 400; }
.ans-lead { margin-top: 2px; }
.ans-punch { color: var(--amber); }
.answer.poem p { font-style: italic; margin: 0; }
.ans-h { margin-top: 10px; color: var(--orange); font-weight: 700; font-size: .92em; letter-spacing: .02em; }
.ans-list { margin: 3px 0 0; padding: 0; list-style: none; }
.ans-list li { position: relative; padding-left: 2.2ch; margin-top: 2px; }
.ans-list li::before { content: "•"; position: absolute; left: .4ch; color: var(--orange); }
.ans-rel { margin-top: 10px; color: var(--dim); font-size: .92em; }
.ans-rel a + a::before { content: " · "; color: var(--dimmer); }
.answer code { color: var(--amber); }

/* ───────── the prompt, pinned to the bottom ───────── */
.bottom { flex: none; background: var(--term); padding: 6px 18px max(10px, env(safe-area-inset-bottom)); }
.screen.running + .bottom { padding-left: 14px; padding-right: 14px; }
.prompt { display: flex; align-items: flex-start; gap: 8px; border: 1px solid #5e5e62; border-radius: 8px; padding: 8px 10px 8px 12px; background: #131315; }
.prompt:focus-within { border-color: #8a8a90; }
.caret { line-height: 1.5; padding-top: 1px; }
.prompt textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--fg); font: inherit; line-height: 1.5; min-height: 1.5em; max-height: 9em; padding: 1px 0 0;
}
.prompt textarea::placeholder { color: var(--dimmer); }
.prompt.busy { opacity: .45; pointer-events: none; }
.sendbtn {
  flex: none; align-self: flex-end; width: 28px; height: 28px; margin: -3px -2px -3px 0;
  border-radius: 7px; background: var(--orange); color: #1b0d07;
  font-size: 16px; font-weight: 800; line-height: 1; display: grid; place-items: center;
  transition: opacity .15s, transform .1s, filter .15s, background .2s;
}
.sendbtn:hover:not(:disabled) { filter: brightness(1.12); }
.sendbtn:active:not(:disabled) { transform: scale(.92); }
.sendbtn:disabled { opacity: .3; cursor: default; }
.sendbtn.stop { background: #e8e6e3; color: #111; font-size: 11px; }
.sendbtn.go { background: var(--green); color: #07140a; font-size: 12px; }

.chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 2px 0; font-size: 11.5px; }
.chip-wrap { position: relative; }
.chip { padding: 1px 9px; line-height: 19px; border: 1px solid #333336; border-radius: 999px; color: var(--dim); white-space: nowrap; }
.chip:hover:not(:disabled), .chip[aria-expanded="true"] { color: var(--fg); border-color: #5a5a60; }
.chip:disabled { opacity: .4; cursor: default; }
.chip[aria-checked="true"] { color: #1b0d07; background: var(--orange); border-color: var(--orange); font-weight: 700; }
.chip .x { opacity: .55; }
.chip .badge, .pop .badge { font-size: 9.5px; padding: 0 5px; border-radius: 3px; background: var(--orange); color: #1b0d07; font-weight: 800; margin-left: 6px; letter-spacing: .04em; }
.chips-fill { flex: 1; }
.hintkeys { white-space: nowrap; }
.pop {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 60; min-width: 330px;
  background: #18181a; border: 1px solid #3a3a3d; border-radius: 10px; padding: 6px;
  box-shadow: 0 -16px 50px rgba(0,0,0,.6); animation: rise .15s ease-out both;
}
.pop-row { display: grid; grid-template-columns: 1.6ch minmax(0, 1fr) auto; gap: 2px 8px; align-items: baseline; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; }
.pop-row:hover, .pop-row:focus-visible { background: #232326; outline: none; }
.pop-row .m { color: var(--orange); }
.pop-row .n { color: var(--fg); white-space: nowrap; }
.pop-row .p { color: var(--dim); font-size: 11.5px; white-space: nowrap; }
.pop-row .d { color: var(--dimmer); font-size: 11px; grid-column: 2 / 4; }
.pop-row[aria-checked="true"] .n { color: var(--orange); font-weight: 700; }
.pop-foot { font-size: 11px; color: var(--dimmer); padding: 6px 8px 2px; border-top: 1px solid #262628; margin-top: 4px; }
.pop-agents { min-width: 0; padding: 10px 12px; }
.pop-agents .agents { display: grid; grid-template-columns: repeat(10, 18px); gap: 4px; }
.agent-box { width: 18px; height: 22px; border-radius: 3px; border: 1px solid #444448; }
.agent-box.on { background: var(--orange); border-color: var(--orange); }
.agent-box:hover { border-color: var(--orange); }
.pop-agents .agent-count { margin-top: 8px; font-size: 12px; }

/* ───────── run view ───────── */
#run { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.run-head { flex: none; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.run-left { min-width: 0; flex: 1; }
.tmux { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; font-weight: 500; }
.tmux > * { flex: none; }
.tmux #tmPath { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tmux .tm-fill { flex: 1 1 0; }
.tm-win { font-weight: 800; }
.hud { text-align: right; flex: none; max-width: 56%; }
.hud-cost {
  font-size: clamp(28px, 4.4vw, 54px); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; transition: color .5s, text-shadow .5s;
}
.hud[data-heat="1"] .hud-cost { color: var(--amber); }
.hud[data-heat="2"] .hud-cost { color: var(--coral); }
.hud[data-heat="3"] .hud-cost { color: var(--orange); text-shadow: 0 0 28px rgba(217,119,87,.55); }
.hud[data-heat="4"] .hud-cost { color: var(--gold); text-shadow: 0 0 30px rgba(255,212,121,.7), 0 0 80px rgba(217,119,87,.5); }
.hud-cost.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.08); } 100% { transform: none; } }
.hud-sub { font-size: 11.5px; color: var(--dim); margin-top: 4px; }
.hud-sub span { white-space: nowrap; }
.hud-meter { font-size: 11.5px; color: var(--amber); margin-top: 3px; white-space: nowrap; }
.hud-meter .warm { color: var(--coral); font-weight: 700; }
.hud-meter .hot { color: var(--red); font-weight: 800; animation: blink 0.7s steps(2) infinite; }
.alerts { flex: none; display: flex; align-items: center; height: 20px; margin: 4px 0 2px; font-size: 12px; }
#alerts { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--amber); }
#alerts span { animation: rise .3s ease-out both; }
#alerts .old { color: var(--dimmer); }

.grid { flex: 1; min-height: 0; display: grid; gap: 14px 10px; padding-top: 8px; }
.pane {
  position: relative; min-width: 0; min-height: 0;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 10px 5px;
  display: flex; flex-direction: column;
  font-size: var(--pane-fs); line-height: 1.45;
  background: var(--term);
  transition: border-color .35s, opacity .6s;
  animation: paneIn .4s ease-out both;
}
@keyframes paneIn { from { opacity: 0; } }
.pane-title {
  position: absolute; top: -0.78em; left: 9px; max-width: calc(100% - 18px);
  padding: 0 6px; background: var(--term); line-height: 1.5;
  font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pane-title .spin { color: var(--orange); display: inline-block; width: 1.2ch; }
.pane-title .who { color: var(--dim); font-weight: 500; }
.pane-title .cost { color: var(--dim); font-weight: 400; margin-left: 4px; }
.pane-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.log { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.log > *, .code > *, .elog > *, .ship-term > * { flex-shrink: 0; }
.ln { white-space: nowrap; overflow: hidden; }
.ln .bul { display: inline-block; width: 2ch; }
.ln.ok .bul { color: var(--green); }
.ln.err .bul { color: var(--red); }
.ln.warn .bul { color: var(--yellow); }
.ln.send .bul { color: var(--purple); }
.ln.pend .bul { color: var(--dim); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .15; } }
.ln .tool { font-weight: 700; }
.shout { color: var(--coral); font-weight: 800; letter-spacing: .02em; }
.res { color: var(--dim); white-space: nowrap; overflow: hidden; padding-left: 2ch; }
.res::before { content: "⎿  "; color: var(--dimmer); }
.res.err { color: var(--red); }
.res.ok { color: var(--green); }
.res.warn { color: var(--yellow); }
.res.shout { color: var(--coral); font-weight: 800; }
.todo-item { padding-left: 5ch; color: var(--dim); white-space: nowrap; overflow: hidden; }
.todo-item.done, .res.todo.ok { color: var(--dimmer); text-decoration: line-through; }
.foot { flex: none; white-space: nowrap; overflow: hidden; color: var(--coral); padding-top: 3px; }
.foot .spin { display: inline-block; width: 1.4ch; }
.foot .k { color: var(--dim); }
.ctx { flex: none; font-size: .88em; color: var(--dimmer); white-space: nowrap; overflow: hidden; }
.ctx:empty { display: none; }
.ctx.low { color: var(--yellow); }
.ctx.crit { color: var(--coral); }
.pane.alarm { border-color: #c4545d; }
.pane.warnflash { border-color: #9c8452; }
.pane.done { border-color: #2c5a37; opacity: .78; }
.pane.done .foot { color: var(--green); }
.pane.done .pane-title .spin { color: var(--green); }
.pane.paused { border-color: #6a6a70; }
.pane.paused .foot { color: var(--dim); }
.pane.dead { opacity: .5; }

.dock {
  flex: none; margin-top: 12px;
  background: #151517; border: 1px solid var(--orange); border-radius: 10px;
  padding: 14px 18px; display: flex; gap: 14px 22px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  animation: dockUp .45s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes dockUp { from { transform: translateY(16px); opacity: 0; } }
.dock-sum { min-width: 0; flex: 1 1 380px; }
.dock-sum .t { color: var(--green); font-weight: 700; }
.dock-sum .t.stop { color: var(--amber); }
.dock-sum ul { margin: 6px 0 0; padding: 0; list-style: none; color: var(--dim); font-size: 12px; columns: 2 280px; column-gap: 24px; }
.dock-sum li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sum li b { color: var(--fg); }
.dock-act { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.shipbtn {
  font-size: clamp(20px, 2.4vw, 30px); font-weight: 800; letter-spacing: .18em;
  padding: 14px 34px; border-radius: 8px; background: var(--orange); color: #1b0d07;
  animation: pulse 1.1s ease-in-out infinite;
}
.shipbtn:hover { filter: brightness(1.08); }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(217,119,87,.75), 0 0 30px rgba(217,119,87,.35); }
  50% { box-shadow: 0 0 0 14px rgba(217,119,87,0), 0 0 60px rgba(217,119,87,.6); }
}
.btn { border: 1px solid #555; border-radius: 7px; padding: 8px 16px; color: var(--fg); }
.btn:hover:not(:disabled) { border-color: var(--fg); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1b0d07; font-weight: 800; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .k { opacity: .6; font-weight: 400; margin-left: 8px; font-size: .85em; }

/* ───────── Mythos: frenzy, money rain, smoke ───────── */
.app.frenzy-2 .hud-cost { animation: goldPulse 1.6s ease-in-out infinite; }
@keyframes goldPulse { 50% { filter: brightness(1.25); } }
.app.frenzy-3 .pane:not(.done) { animation: heatPane 1.4s ease-in-out infinite; }
@keyframes heatPane { 50% { border-color: rgba(217,119,87,.75); } }
.app.frenzy-4 .screen { animation: flicker 4.2s steps(1) infinite; }
.app.frenzy-5 .screen { animation: flicker 1.7s steps(1) infinite; filter: saturate(1.25) contrast(1.06); }
@keyframes flicker { 0%, 100% { opacity: 1; } 31% { opacity: .82; } 32% { opacity: 1; } 67% { opacity: .9; } 68% { opacity: 1; } }
.fx-layer { position: fixed; inset: 0; z-index: 45; pointer-events: none; overflow: hidden; }
.coin { position: absolute; top: -50px; color: var(--gold); font-weight: 800; text-shadow: 0 0 12px rgba(255,212,121,.6); animation: coinfall linear forwards; }
@keyframes coinfall { to { transform: translateY(calc(100vh + 80px)) rotate(var(--spin, 180deg)); } }
.smoke { position: fixed; inset: auto 0 0 0; height: 70vh; z-index: 44; pointer-events: none; opacity: 0; transition: opacity 3s; overflow: hidden; }
.smoke[data-level="1"] { opacity: .35; }
.smoke[data-level="2"] { opacity: .75; }
.smoke i {
  position: absolute; bottom: -180px; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(90,86,82,.55), rgba(60,58,56,0) 65%);
  animation: smokeUp 11s linear infinite;
}
.smoke i:nth-child(1) { left: -6%; animation-delay: 0s; } .smoke i:nth-child(2) { left: 10%; animation-delay: -3s; }
.smoke i:nth-child(3) { left: 26%; animation-delay: -6s; } .smoke i:nth-child(4) { left: 42%; animation-delay: -1.5s; }
.smoke i:nth-child(5) { left: 58%; animation-delay: -8s; } .smoke i:nth-child(6) { left: 72%; animation-delay: -4.5s; }
.smoke i:nth-child(7) { left: 84%; animation-delay: -9.5s; } .smoke i:nth-child(8) { left: 94%; animation-delay: -2s; }
@keyframes smokeUp { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-75vh) scale(1.6); opacity: 0; } }

/* ───────── "keep going?" ───────── */
.modal-wrap { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.6); animation: fadeIn .2s ease-out both; }
.modal-wrap.out, .call-wrap.out { animation: fadeOut .25s ease-in both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal {
  width: min(520px, 100%); background: #141416; border: 1px solid var(--orange); border-radius: 14px;
  padding: 22px 24px; box-shadow: 0 30px 100px rgba(0,0,0,.8), 0 0 60px rgba(217,119,87,.25);
  animation: popIn .4s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }
.md-k { color: var(--dim); font-size: 12px; }
.md-amt { font-size: clamp(40px, 9vw, 76px); font-weight: 800; line-height: 1.05; color: var(--gold); text-shadow: 0 0 40px rgba(255,212,121,.45); margin: 6px 0 4px; letter-spacing: -.02em; }
.md-q { font-size: 15px; }
.md-stats { color: var(--dim); font-size: 12px; margin-top: 8px; }
.md-note { margin-top: 10px; color: var(--coral); font-size: 12.5px; }
.md-opts { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ───────── the bank calls ───────── */
.call-wrap {
  position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 16px; background: rgba(0,0,0,.66); animation: fadeIn .3s ease-out both;
}
.call-wrap.talking { background: rgba(0,0,0,.18); transition: background .6s; }
.call-note { font-size: 13px; color: var(--amber); text-align: center; max-width: 420px; background: rgba(10,10,11,.85); padding: 4px 10px; border-radius: 6px; }
.phone {
  position: relative; width: 290px; height: min(580px, calc(100dvh - 90px)); border-radius: 44px;
  background: linear-gradient(180deg, #24324a 0%, #10151f 60%, #0a0c10 100%);
  border: 9px solid #1d1d1f; box-shadow: 0 0 0 2px #3a3a3e, 0 40px 120px rgba(0,0,0,.85);
  color: #fff; font-family: var(--sans); overflow: hidden; display: flex; flex-direction: column;
  animation: phoneUp .55s cubic-bezier(.2,1.2,.4,1) both;
}
@keyframes phoneUp { from { transform: translateY(60px) scale(.94); opacity: 0; } }
.phone::before { content: ""; position: absolute; top: 9px; left: 50%; width: 92px; height: 26px; border-radius: 14px; background: #000; transform: translateX(-50%); z-index: 2; }
.phone.ringing { animation: phoneUp .55s cubic-bezier(.2,1.2,.4,1) both, ringShake 1.3s .6s infinite; }
@keyframes ringShake { 0%, 40%, 100% { transform: none; } 5%, 15%, 25%, 35% { transform: rotate(-2.2deg); } 10%, 20%, 30% { transform: rotate(2.2deg); } }
.ph-status { display: flex; justify-content: space-between; padding: 12px 22px 0; font-size: 12px; font-weight: 600; opacity: .9; }
.ph-scr { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 34px 20px 30px; text-align: center; }
.ph-label { font-size: 13px; opacity: .7; }
.ph-avatar { width: 92px; height: 92px; border-radius: 50%; background: linear-gradient(160deg, #3b4d6b, #233149); display: grid; place-items: center; font-size: 44px; margin: 20px 0 12px; }
.ph-avatar.dim { opacity: .5; }
.ph-name { font-size: 30px; font-weight: 600; letter-spacing: -.01em; }
.ph-name.sm { font-size: 24px; margin-top: 18px; }
.ph-sub { font-size: 14px; opacity: .7; margin-top: 2px; font-variant-numeric: tabular-nums; }
.ph-btns { margin-top: auto; width: 100%; display: flex; justify-content: space-between; padding: 0 6px; }
.ph-btns.one { justify-content: center; }
.ph-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; color: #fff; font-family: var(--sans); }
.ph-btn i { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 27px; }
.ph-decline i { background: #ff3b30; }
.ph-accept i { background: #30c158; animation: acceptPulse 1.2s ease-in-out infinite; }
@keyframes acceptPulse { 50% { box-shadow: 0 0 0 12px rgba(48,193,88,0); } 0%, 100% { box-shadow: 0 0 0 0 rgba(48,193,88,.6); } }
.ph-wave { display: flex; gap: 4px; align-items: center; height: 48px; margin: 26px 0 10px; }
.ph-wave i { width: 4px; height: 8px; border-radius: 2px; background: #9fb4d6; animation: wave .5s ease-in-out infinite alternate; }
.ph-wave i:nth-child(3n) { animation-duration: .38s; } .ph-wave i:nth-child(3n+1) { animation-duration: .62s; } .ph-wave i:nth-child(4n) { animation-delay: -.2s; }
@keyframes wave { to { height: 42px; } }
.ph-caption { font-size: 15px; line-height: 1.45; opacity: .9; min-height: 7.5em; padding: 0 4px; font-style: italic; }
.phone.off { animation: phoneOff .9s cubic-bezier(.6,0,.4,1) forwards; }
.phone.off .ph-scr, .phone.off .ph-status { opacity: 0; transition: opacity .2s; }
@keyframes phoneOff { 0% { filter: brightness(1); } 30% { filter: brightness(3); transform: scaleY(.012) scaleX(1); } 70% { transform: scaleY(.012) scaleX(.02); filter: brightness(4); } 100% { transform: scaleY(0) scaleX(0); opacity: 0; } }
.shutdown { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; padding: 16px; text-align: center; }
.shutdown .glitch { font-size: clamp(26px, 6vw, 72px); color: var(--coral); }

/* ───────── the explosion ───────── */
.boom-wrap { position: fixed; inset: 0; z-index: 100; }
.boom-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.boom-wrap.out { animation: fadeOut .6s ease-in both; }
.boom-flash { position: absolute; inset: 0; background: #fff; pointer-events: none; animation: boomFlash 1.3s ease-out forwards; }
@keyframes boomFlash { 0% { opacity: 1; background: #fff; } 25% { background: #ffcf8a; } 100% { opacity: 0; background: #ff8a3d; } }
body.boom-shake .app { animation: bigShake .9s; }
@keyframes bigShake {
  0%,100% { transform: none; } 10% { transform: translate(-18px, 10px) rotate(-1deg); } 20% { transform: translate(16px, -12px) rotate(1deg); }
  35% { transform: translate(-12px, 8px); } 50% { transform: translate(10px, 4px); } 70% { transform: translate(-5px, -3px); }
}
.aftermath {
  position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 60%, #1a1210, #050404 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px;
  text-align: center; animation: fadeIn 1.4s ease-out both; overflow: auto;
}
.af-boom { font-size: clamp(64px, 14vw, 140px); line-height: 1; filter: drop-shadow(0 0 40px rgba(255,140,60,.7)); animation: popIn .6s cubic-bezier(.2,1.6,.4,1) both; }
.aftermath h1 { margin: 6px 0 0; font-size: clamp(26px, 5vw, 56px); letter-spacing: -.02em; }
.af-bill { color: var(--dim); }
.af-bill b { display: block; color: var(--gold); font-size: clamp(30px, 6vw, 64px); font-weight: 800; letter-spacing: -.02em; text-shadow: 0 0 40px rgba(255,212,121,.4); }
.af-list { list-style: none; margin: 8px 0 14px; padding: 0; color: var(--fg); font-size: 13px; text-align: left; max-width: 640px; }
.af-list li { padding: 2px 0; }
.af-list span { display: inline-block; width: 11ch; color: var(--dimmer); }
.bios { margin: 0; text-align: left; color: #c8c8c8; font: 14px/1.6 var(--mono); min-width: min(520px, 90vw); }

/* ───────── ship overlay ───────── */
.ship { position: fixed; inset: 0; z-index: 50; background: #050506; color: var(--fg); font: 15px/1.55 var(--mono); display: flex; flex-direction: column; overflow: hidden; }
.ship.shake { animation: shake .5s; }
@keyframes shake {
  0%,100% { transform: none; } 15% { transform: translate(-7px, 3px); } 30% { transform: translate(6px, -4px); }
  45% { transform: translate(-5px, 2px); } 60% { transform: translate(4px, 2px); } 80% { transform: translate(-2px, -1px); }
}
.ship-top { flex: none; display: flex; justify-content: flex-end; align-items: center; padding: 8px 16px 0 14px; height: 34px; }
.skip { font-size: 11px; color: #666; }
.skip:hover { color: var(--fg); }
.ship-term { flex: 1; min-height: 0; overflow: hidden; padding: 6px 26px 22px; display: flex; flex-direction: column; justify-content: flex-end; }
.ship-term .l { white-space: pre-wrap; word-break: break-word; }
.ship-term .l.dim { color: var(--dim); }
.ship-term .l.ok { color: var(--green); }
.ship-term .l.err { color: var(--red); }
.ship-term .l.warn { color: var(--yellow); }
.ship-term .l.big { font-size: 1.5em; font-weight: 800; }
.bar { color: var(--orange); }
.live-banner { font-size: clamp(26px, 5vw, 64px); font-weight: 800; color: var(--green); text-shadow: 0 0 30px rgba(79,191,103,.5); margin: 10px 0; }
.bug-stage { position: absolute; inset: 0; display: grid; place-items: center; background: #050506; z-index: 3; }
.bug-stage .inner { text-align: center; padding: 20px; }
.glitch {
  position: relative; display: inline-block;
  font-size: clamp(48px, 13vw, 180px); font-weight: 800; line-height: .95; letter-spacing: -.03em;
  color: #fff; text-shadow: 0 0 40px rgba(255,255,255,.25);
  animation: jitter .18s steps(2) infinite;
}
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; }
.glitch::before { color: #ff3d6e; transform: translate(-4px, 0); clip-path: inset(10% 0 55% 0); animation: slice 1.1s steps(6) infinite; mix-blend-mode: screen; }
.glitch::after { color: #35e6ff; transform: translate(4px, 0); clip-path: inset(55% 0 8% 0); animation: slice 1.4s steps(5) infinite reverse; mix-blend-mode: screen; }
@keyframes jitter { 0% { transform: translate(1px, -1px); } 100% { transform: translate(-2px, 1px); } }
@keyframes slice {
  0% { clip-path: inset(10% 0 70% 0); } 25% { clip-path: inset(60% 0 10% 0); }
  50% { clip-path: inset(30% 0 40% 0); } 75% { clip-path: inset(80% 0 2% 0); } 100% { clip-path: inset(5% 0 85% 0); }
}
.bug-count { margin-top: 18px; font-size: clamp(18px, 3vw, 30px); color: var(--orange); font-weight: 700; font-variant-numeric: tabular-nums; }
.pager { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.pager div { background: #161618; border: 1px solid #333; padding: 6px 12px; border-radius: 6px; font-size: 13px; animation: rise .25s ease-out both; }
.crash { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 62fr) auto minmax(0, 38fr); }
.code { overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 12.5px; background: #0b0b0c; }
.cl { display: grid; grid-template-columns: 6ch 2ch minmax(0, 1fr); white-space: pre; overflow: hidden; }
.cl .n { color: #4b4b4f; text-align: right; padding-right: 1ch; }
.cl .mk { color: var(--red); }
.cl .mk.w { color: var(--yellow); }
.cl .tx { overflow: hidden; }
.cl.e { background: rgba(255,60,80,.12); }
.cl.w { background: rgba(230,194,122,.07); }
.cl .dg { color: var(--red); font-style: italic; }
.cl.w .dg { color: var(--yellow); }
.kw { color: var(--purple); } .str { color: #98c379; } .num { color: #d19a66; } .fn { color: var(--blue); } .cm { color: #5c6370; font-style: italic; } .ty { color: var(--yellow); }
.vimbar { display: flex; font-size: 12px; background: #1d1d20; white-space: nowrap; overflow: hidden; }
.vimbar span { padding: 2px 10px; }
.vimbar .mode { background: #b8434d; color: #fff; font-weight: 800; }
.vimbar .file { background: #2d2d31; overflow: hidden; text-overflow: ellipsis; }
.vimbar .errs { color: var(--red); font-weight: 700; }
.vimbar .warns { color: var(--yellow); }
.vimbar .fill { flex: 1; }
.elog { overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; padding: 6px 14px; font-size: 12px; background: #070707; border-top: 1px solid #222; }
.elog .l { white-space: nowrap; overflow: hidden; }
.elog .e { color: var(--red); } .elog .w { color: var(--yellow); } .elog .s { color: var(--dimmer); } .elog .f { color: #fff; background: #8a1f2b; font-weight: 800; }
.final-wrap { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: center; padding: 24px 12px; background: rgba(0,0,0,.55); animation: fadeIn .4s ease-out both; }
.final { width: 100%; max-width: 760px; background: #121214; border: 1px solid var(--orange); border-radius: 10px; padding: 16px 18px; box-shadow: 0 20px 80px rgba(0,0,0,.8); animation: dockUp .5s cubic-bezier(.2,.9,.3,1) both; }
.final .opts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.crt::after { content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4; background: repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px); }
.ship.rgb { animation: rgbsplit .25s steps(2) 6; }
@keyframes rgbsplit { 0% { filter: none; } 50% { filter: hue-rotate(90deg) saturate(2.4) contrast(1.4); } 100% { filter: invert(1); } }

/* ───────── narrower screens ───────── */
@media (max-width: 900px) {
  .side { width: 210px; }
}
@media (max-width: 720px) {
  body { font-size: 12.5px; }
  .side {
    position: fixed; z-index: 80; top: 0; bottom: 0; left: 0; width: min(300px, 84vw);
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0,0,0,.6);
  }
  .app.side-hidden .side { display: flex; }
  .app.side-open .side { transform: none; }
  .side-scrim { display: block; position: fixed; inset: 0; z-index: 79; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.side-open .side-scrim { opacity: 1; pointer-events: auto; }
  #sideShow { display: grid !important; }
  #sideHide { display: grid; }
  .topbar { padding-left: 12px; }
  .screen { padding: 4px 16px 10px; }
  .screen.running { overflow: auto; padding: 2px 16px 8px; }
  .bottom, .screen.running + .bottom { padding: 6px 16px max(10px, env(safe-area-inset-bottom)); }
  #run { height: auto; min-height: 100%; }
  .run-head { flex-direction: column-reverse; align-items: stretch; gap: 6px; }
  .hud { text-align: left; max-width: none; }
  .grid { grid-template-columns: 1fr !important; grid-template-rows: none !important; }
  .pane { height: 280px; }
  .dock { position: sticky; bottom: 0; padding: 12px 14px; }
  .dock-sum ul { columns: 1; }
  .shipbtn { width: 100%; }
  .prompt textarea { font-size: 16px; }
  .hintkeys { display: none; }
  .pop { left: 0; right: 0; min-width: 0; }
  .chip-wrap { position: static; }
  .chips { position: relative; }
  .ship { font-size: 12.5px; }
  .ship-term { padding: 6px 16px 16px; }
  .code { font-size: 11px; }
  .cl { grid-template-columns: 5ch 2ch minmax(0, 1fr); }
  .final .opts .btn { flex: 1 1 100%; }
  .af-list span { display: block; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ship.shake, .glitch, body.boom-shake .app, .phone.ringing, .app.frenzy-4 .screen, .app.frenzy-5 .screen { animation: none; }
}
