/* DAEMON_OS · terminal.daemons.art · by charvelario. Phone first; tablet and desktop get their own layouts. */
@font-face { font-family: 'Daemons Display'; src: url('/fonts/heading.ttf') format('truetype'); font-display: swap; }
:root {
  --bg: #090b0a; --panel: #111412; --panel2: #171b18; --line: #252b26; --ink: #eef3ea; --mute: #9aa597;
  --lime: #c3ff5c; --lav: #c9b8ff; --coral: #ff7a68;
  --fg: #c3ff5c; --tbg: #070a07; --dim: #5f7a45;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: 'Daemons Display', 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --vh: 100dvh;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom); --sal: env(safe-area-inset-left); --sar: env(safe-area-inset-right);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font: 15px/1.4 var(--sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }
.ic { width: 22px; height: 22px; flex: none; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.app {
  height: var(--vh); display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "stage" "tools";
  padding: var(--sat) var(--sar) 0 var(--sal);
}
.top { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 52px; }
.brand { display: flex; align-items: baseline; gap: 6px; color: var(--ink); text-decoration: none; min-width: 0; }
.logo { font: 800 26px/1 var(--display); letter-spacing: .02em; color: var(--ink); }
.logo .u { color: var(--lime); animation: blink 1.1s steps(1) infinite; }
.ver { font: 600 12px/1 var(--mono); color: var(--mute); }
.by { font-size: 12px; color: var(--mute); text-decoration: none; margin-right: auto; padding: 14px 4px; }
.by:hover { color: var(--lime); }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .18s, border-color .18s, transform .12s; }
.pill:active { transform: scale(.96); }
.pill.holder { border-color: color-mix(in srgb, var(--lav) 55%, transparent); color: var(--lav); background: color-mix(in srgb, var(--lav) 10%, var(--panel)); }
.pill .ic { width: 20px; height: 20px; }

.stage { grid-area: stage; display: flex; flex-direction: column; min-height: 0; padding: 0 10px; gap: 8px; }

/* ---------- terminal window ---------- */
.term {
  position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--tbg); border: 1px solid color-mix(in srgb, var(--fg) 22%, #1d221e); border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.4), 0 18px 50px -20px color-mix(in srgb, var(--fg) 30%, transparent), inset 0 0 80px rgba(0,0,0,.55);
  transition: border-color .25s, box-shadow .25s, background-color .25s;
}
.term::after { /* scanlines + vignette, decorative */
  content: ""; position: absolute; inset: 34px 0 0; pointer-events: none; z-index: 2;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.028) 0 1px, transparent 1px 3px), radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0,0,0,.45));
  mix-blend-mode: screen;
}
.term-bar { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 12px; background: color-mix(in srgb, var(--tbg) 82%, #fff 6%); border-bottom: 1px solid color-mix(in srgb, var(--fg) 14%, transparent); flex: none; }
.dots { display: flex; gap: 6px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--coral); }
.dots i:nth-child(2) { background: #ffc34d; }
.dots i:nth-child(3) { background: var(--lime); }
.term-title { flex: 1; text-align: center; font: 600 12px/1 var(--mono); color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-dims { font: 600 12px/1 var(--mono); color: var(--dim); min-width: 44px; text-align: right; }
.term-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px 12px 8px; font: 13px/1.45 var(--mono); color: var(--fg); }
.line { display: flex; align-items: center; gap: 0; min-width: 0; white-space: nowrap; }
.ps1 { color: var(--lime); font-weight: 700; }
.ps1.root { color: var(--lav); }
.path { color: var(--mute); margin-right: 8px; }
.cmd { font: inherit; color: color-mix(in srgb, var(--fg) 70%, #fff); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 32px; text-align: left; padding: 0 2px; border-radius: 4px; min-width: 0; }
.cmd:hover { background: color-mix(in srgb, var(--fg) 12%, transparent); }
.out { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 8px 0 4px; }
.art-wrap { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; }
.art-wrap canvas { display: block; image-rendering: pixelated; transition: opacity .2s var(--ease); }
.art-wrap.fade canvas { animation: fadein .22s var(--ease); }
.skel { position: absolute; inset: 8% 14%; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s;
  background: repeating-linear-gradient(to bottom, color-mix(in srgb, var(--fg) 14%, transparent) 0 8px, transparent 8px 16px);
  -webkit-mask: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent); mask: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent); animation: shimmer 1.4s linear infinite; }
.art-wrap.loading .skel { opacity: .8; }
.art-wrap.loading canvas { opacity: .25; }
.art-wrap.error::before { content: "DAEMON could not load. Retrying…"; color: var(--coral); font-size: 13px; }

/* neofetch block: one compact wrap of chips on phones */
.fetch { margin: 0; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--mute); flex: none; }
.fetch .ft { width: 100%; color: var(--fg); font-weight: 700; display: none; }
.fetch div { display: flex; gap: 6px; }
.fetch dt { color: var(--fg); font-weight: 700; }
.fetch dd { margin: 0; color: color-mix(in srgb, var(--fg) 40%, #fff); }
.fetch .sw { display: flex; gap: 3px; align-items: center; }
.fetch .sw i { width: 14px; height: 10px; border-radius: 2px; }
.log { flex: none; font-size: 12px; color: var(--dim); min-height: 18px; }
.log p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: fadein .2s var(--ease); }
.log p:not(:last-child) { display: none; }
.log .ok { color: var(--fg); }
.log .err { color: var(--coral); }
.prompt { flex: none; min-height: 40px; }
.prompt input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; color: var(--ink); font: 16px var(--mono); caret-color: var(--fg); outline: none; padding: 0; }
.prompt input::placeholder { color: color-mix(in srgb, var(--dim) 80%, transparent); }
.prompt:focus-within { background: color-mix(in srgb, var(--fg) 6%, transparent); border-radius: 6px; }

/* boot */
.boot { position: absolute; inset: 10px 12px; z-index: 3; font-size: 13px; display: none; }
.boot p { margin: 0 0 2px; animation: fadein .12s; }
.boot .okk { color: var(--lime); }
.term.booting .boot { display: block; }
.term.booting .cmdline, .term.booting .out, .term.booting .log, .term.booting .prompt { visibility: hidden; }
.skip { position: absolute; right: 10px; bottom: 10px; z-index: 4; min-height: 44px; padding: 0 16px; border-radius: 999px; background: color-mix(in srgb, var(--fg) 14%, var(--tbg)); color: var(--fg); font: 600 13px var(--mono); display: none; }
.term.booting .skip { display: block; }

/* ---------- picker ---------- */
.picker { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--ink); transition: background .15s, transform .12s; flex: none; }
.icon-btn:hover { background: var(--panel2); }
.icon-btn:active { transform: scale(.92); background: var(--panel2); }
.picker .icon-btn { background: var(--panel); border: 1px solid var(--line); }
.idbox { flex: 1; display: flex; align-items: center; height: 44px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); padding: 0 12px; font: 700 18px var(--mono); color: var(--mute); min-width: 0; }
.idbox:focus-within { border-color: var(--lime); }
.idbox input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font: 700 18px var(--mono); color: var(--ink); padding-left: 4px; }

/* ---------- toolbar ---------- */
.toolbar { grid-area: tools; display: grid; grid-template-columns: 1fr 1fr 1fr 1.25fr; gap: 6px; padding: 8px 10px calc(8px + var(--sab)); }
.toolbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; border-radius: 14px; color: var(--mute); font-size: 12px; font-weight: 600; transition: background .15s, color .15s, transform .12s; }
.toolbar button:hover, .toolbar button[aria-expanded="true"] { color: var(--ink); background: var(--panel2); }
.toolbar button:active { transform: scale(.94); }
.toolbar .primary { background: var(--lime); color: #0b1004; flex-direction: row; gap: 8px; font-size: 15px; font-weight: 800; }
.toolbar .primary:hover, .toolbar .primary[aria-expanded="true"] { background: #d4ff85; color: #0b1004; }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.55); opacity: 0; transition: opacity .2s; }
.scrim.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: min(78vh, calc(var(--vh) - 60px)); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 4px 16px calc(16px + var(--sab));
  transform: translateY(105%); transition: transform .24s var(--ease); visibility: hidden;
  box-shadow: 0 -20px 60px rgba(0,0,0,.5);
}
.sheet.open { transform: none; visibility: visible; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #3a423b; margin: 6px auto 4px; }
.panels .panel { display: none; }
.panels .panel.active { display: block; }
.ph { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.ph h2 { margin: 0; font: 800 24px/1 var(--display); letter-spacing: .02em; }
.panel { animation: fadein .18s var(--ease); }

.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding-bottom: 6px; }
.mode { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 10px; text-align: left; padding: 10px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); min-height: 76px; transition: border-color .15s, transform .12s; }
.mode canvas { grid-row: span 2; width: 56px; height: 56px; border-radius: 8px; image-rendering: pixelated; }
.mode b { font-size: 15px; align-self: end; }
.mode small { font-size: 12px; color: var(--mute); align-self: start; line-height: 1.25; }
.mode[aria-checked="true"] { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.mode:active { transform: scale(.97); }

.field { padding: 10px 0; border-top: 1px solid var(--line); }
.field:first-of-type { border-top: 0; }
.field.off .chips { opacity: .45; }
.field-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--mute); font-weight: 600; margin-bottom: 8px; min-height: 22px; }
.field-head output { font: 700 14px var(--mono); color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .icon-btn { background: var(--panel2); border: 1px solid var(--line); }
input[type=range] { flex: 1; appearance: none; -webkit-appearance: none; height: 44px; background: transparent; min-width: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--lime), #3a4a2a); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--lime), #3a4a2a); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -10px; border-radius: 50%; background: var(--ink); border: 3px solid var(--lime); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid var(--lime); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; transition: border-color .15s, transform .12s; }
.chip code { font: 12px var(--mono); color: var(--mute); }
.chip[aria-checked="true"] { border-color: var(--lime); box-shadow: inset 0 0 0 1px var(--lime); }
.chip:active { transform: scale(.95); }
.chip:disabled { cursor: default; }
.chip.theme i { width: 16px; height: 16px; border-radius: 4px; background: var(--b); box-shadow: inset 0 0 0 4px var(--b), inset 0 0 0 9px var(--c); border: 1px solid var(--c); }
.chip .lock { width: 16px; height: 16px; color: var(--mute); display: none; }
.chip.locked .lock { display: block; }
.chip.locked { color: var(--mute); }
.toggles { display: flex; gap: 24px; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: #2b322c; position: relative; transition: background .18s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); transition: transform .18s var(--ease); }
.switch input:checked + .track { background: var(--lime); }
.switch input:checked + .track::after { transform: translateX(18px); background: #0b1004; }
.switch input:focus-visible + .track { outline: 2px solid var(--lime); outline-offset: 2px; }
.link { color: var(--lime); font-size: 13px; font-weight: 600; min-height: 32px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font-weight: 700; font-size: 14px; transition: transform .12s, background .15s; white-space: nowrap; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--lime); color: #0b1004; border-color: var(--lime); }
.btn.primary:hover { background: #d4ff85; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; }
.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.target { display: flex; align-items: center; gap: 10px; text-align: left; min-height: 60px; padding: 8px 12px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); transition: border-color .15s, transform .12s, background .2s; min-width: 0; }
.target span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.target b { font-size: 15px; }
.target small { font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.target .tail { width: 18px; height: 18px; color: var(--mute); }
.target:active { transform: scale(.97); }
.target.done { border-color: var(--lime); background: color-mix(in srgb, var(--lime) 10%, var(--panel2)); }
.target.done .tail { color: var(--lime); }
.downloads { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dl { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 64px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); font-weight: 700; font-size: 13px; transition: transform .12s; }
.dl small { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--mute); font-weight: 600; min-height: 14px; }
.dl small .lock { width: 13px; height: 13px; }
.dl:active { transform: scale(.95); }
.note, .hint-line { font-size: 12px; color: var(--mute); margin: 10px 0 0; }
.sub { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--mute); margin: 4px 0 8px; }
.sub .ic { width: 16px; height: 16px; color: var(--lime); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.thumb { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); font: 600 12px var(--mono); color: var(--mute); min-height: 44px; }
.thumb canvas { width: 50px; height: 50px; image-rendering: pixelated; opacity: 0; transition: opacity .2s; }
.thumb.ready canvas { opacity: 1; }
.thumb:active { transform: scale(.95); }
.lookup { display: flex; gap: 8px; margin-top: 12px; }
.lookup input, .restore input { flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 0 12px; font: 16px var(--mono); color: var(--ink); outline: none; }
.lookup input:focus, .restore input:focus { border-color: var(--lime); }

/* wallet */
.lead { margin: 0 0 10px; color: var(--mute); font-size: 14px; }
.perks { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.perks li { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--mute); }
.perks li .ic { width: 18px; height: 18px; }
.perks li.on { color: var(--ink); }
.perks li.on .ic { color: var(--lime); }
.wallets { display: grid; gap: 8px; margin-bottom: 8px; }
.wallet img { border-radius: 6px; }
.wallet { justify-content: flex-start; }
.who { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.addr { font: 700 16px var(--mono); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: color-mix(in srgb, var(--lime) 14%, transparent); color: var(--lime); font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge .ic { width: 14px; height: 14px; }
.badge.root { background: color-mix(in srgb, var(--lav) 16%, transparent); color: var(--lav); }
.badge.dim { background: var(--panel2); color: var(--mute); }
h3 { font: 800 18px/1 var(--display); letter-spacing: .02em; margin: 16px 0 8px; }
.item { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 8px; }
.item.want { border-color: var(--lime); }
.item b { display: block; font-size: 15px; }
.item small { display: block; font-size: 13px; color: var(--mute); margin-top: 2px; }
.buy { display: flex; gap: 8px; }
.buy .btn { flex: 1; }
.row { display: flex; gap: 8px; margin: 12px 0; }
.row .btn { flex: 1; }
.restore { display: flex; gap: 8px; }
.status { min-height: 18px; font-size: 13px; color: var(--lime); margin: 10px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(96px + var(--sab)); z-index: 70; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; max-width: min(92vw, 420px); padding: 12px 16px; border-radius: 14px; background: #1b2118; border: 1px solid color-mix(in srgb, var(--lime) 40%, transparent); color: var(--ink); font-size: 14px; font-weight: 600; box-shadow: 0 10px 40px rgba(0,0,0,.5); transition: opacity .2s var(--ease), transform .2s var(--ease); }
.toast .ic { width: 18px; height: 18px; color: var(--lime); }
.toast.bad .ic { color: var(--coral); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 24px; font-family: var(--mono); }

.flash { animation: flash .6s var(--ease); }
@keyframes flash { 0% { box-shadow: inset 0 0 0 2px var(--lime); } 100% { box-shadow: inset 0 0 0 2px transparent; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { from { background-position: 0 0; } to { background-position: 0 32px; } }

/* ---------- very small phones ---------- */
@media (max-width: 359px) {
  .logo { font-size: 22px; }
  .by { display: none; }
  .brand { margin-right: auto; }
  .toolbar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .toolbar .primary { font-size: 14px; gap: 6px; }
  .targets { grid-template-columns: 1fr; }
  .modes { grid-template-columns: 1fr; }
  .term-body { padding: 8px 8px 6px; }
  .path { margin-right: 6px; }
}
@media (max-height: 640px) and (orientation: portrait) {
  .fetch { display: none; }
  .top { min-height: 48px; padding-top: 4px; padding-bottom: 4px; }
}

/* ---------- phone landscape: the terminal fills the height, tools become a rail ---------- */
@media (orientation: landscape) and (max-height: 540px) {
  .app { grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) 84px; grid-template-areas: "stage top" "stage tools"; padding-bottom: var(--sab); }
  .top { padding: 8px 8px 0 0; min-height: 0; justify-content: center; }
  .top .brand, .top .by { display: none; }
  .top .pill { width: 76px; padding: 0; justify-content: center; flex-direction: column; gap: 2px; min-height: 52px; border-radius: 14px; font-size: 12px; }
  .top .pill span { max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
  .stage { flex-direction: row; padding: 8px 0 8px 10px; }
  .picker { flex-direction: column; width: 56px; }
  .picker .idbox { flex: none; width: 56px; padding: 0 4px; font-size: 14px; justify-content: center; }
  .picker .idbox span { display: none; }
  .picker .idbox input { font-size: 14px; text-align: center; padding: 0; }
  .toolbar { grid-template-columns: none; grid-auto-rows: 1fr; width: 84px; padding: 8px 8px 8px 0; }
  .toolbar button { min-height: 44px; }
  .toolbar .primary { flex-direction: column; gap: 3px; font-size: 13px; }
  .fetch { display: none; }
  .sheet { left: auto; top: 0; width: min(400px, 56vw); max-height: none; border-radius: 20px 0 0 20px; border-top: 0; border-left: 1px solid var(--line); transform: translateX(105%); padding-top: calc(8px + var(--sat)); padding-right: calc(16px + var(--sar)); }
  .sheet .grab { display: none; }
  .toast { bottom: calc(16px + var(--sab)); }
}

/* ---------- tablet: terminal plus a side tool panel ---------- */
@media (min-width: 768px) and (min-height: 560px) {
  .app { grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "top top" "stage side"; }
  .top { padding: 10px 18px; min-height: 60px; }
  .logo { font-size: 30px; }
  .stage { padding: 0 8px 16px 16px; gap: 10px; }
  .toolbar { display: none; }
  .scrim { display: none; }
  .panels { grid-area: side; position: static; transform: none; visibility: visible; max-height: none; border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 0 16px 16px 8px; overflow: auto; }
  .panels .grab, .panels .close { display: none; }
  .panels .panel { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 6px 14px 14px; margin-bottom: 12px; }
  .panels .ph { min-height: 40px; }
  .panels .ph h2 { font-size: 20px; }
  .modes { grid-template-columns: 1fr 1fr; }
  .term-body { padding: 14px 18px 10px; font-size: 14px; }
  .out { flex-direction: row; align-items: stretch; gap: 20px; }
  .fetch { flex-direction: column; flex-wrap: nowrap; justify-content: center; gap: 3px; font-size: 13px; min-width: 190px; max-width: 240px; }
  .fetch .ft { display: block; padding-bottom: 4px; border-bottom: 1px dashed var(--dim); margin-bottom: 4px; }
  .fetch div { gap: 0; }
  .fetch dt { width: 72px; flex: none; }
  .fetch .sw { margin-top: 8px; }
  .log p:not(:last-child) { display: block; }
  .log { min-height: 54px; }
  .sheet.modal { left: 50%; right: auto; top: 50%; bottom: auto; width: min(460px, 92vw); max-height: 86vh; border-radius: 20px; border: 1px solid var(--line); transform: translate(-50%, -46%) scale(.98); opacity: 0; transition: transform .2s var(--ease), opacity .2s; }
  .sheet.modal.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.modal .grab { display: none; }
  .modal ~ .toolbar { display: none; }
  #scrim:not([hidden]) { display: block; }
  .toast { bottom: 28px; }
}
@media (min-width: 768px) and (max-width: 1023px) and (orientation: portrait) {
  .out { flex-direction: column; }
  .fetch { flex-direction: row; flex-wrap: wrap; max-width: none; min-width: 0; gap: 4px 16px; }
  .fetch .ft { width: 100%; border: 0; }
  .fetch dt { width: auto; margin-right: 6px; }
}

/* ---------- desktop: a full workspace ---------- */
@media (min-width: 1200px) and (min-height: 600px) {
  .app { grid-template-columns: 300px minmax(0, 1fr) 360px; grid-template-areas: "top top top" "left stage right"; }
  .panels { display: contents; }
  .col-a { grid-area: left; overflow: auto; padding: 0 0 16px 18px; }
  .col-b { grid-area: right; overflow: auto; padding: 0 18px 16px 0; }
  .stage { padding: 0 16px 18px; }
  .modes { grid-template-columns: 1fr; }
  .mode { min-height: 64px; }
  .mode canvas { width: 48px; height: 48px; }
  .term-body { font-size: 14px; }
}
@media (min-width: 1600px) {
  .app { grid-template-columns: 340px minmax(0, 1fr) 400px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .12s !important; }
  .logo .u { animation: none; }
  .sheet { transition: opacity .15s, visibility .15s; transform: none; opacity: 0; }
  .sheet.open { opacity: 1; }
}
