/* Duit website: the mini Duit (SPEC3 §3). Owner: minid. Part parts/minid.html, behaviour js/minid.js.
   A simplified, working copy of the Duit desktop prototype's Ask screen (duit-desktop-client/index.html):
   the same titlebar, rail, composer, starters, bubbles, "Duit · Checked X" lines, cite chips, drafts, the
   "Confirm N in browser" bar, the source drawer and the status glyphs, rewritten under the mini- prefix.
   Sits in the hero (a .hero grid row after the hub), centred, min(1100px, 100% - 2 gutters) wide.

   STATES on .mini-win   .is-home (no session open: composer centred, starters shown)   .is-drawer (source
                         drawer open)   .is-rail (phones: the rail open as an overlay)
   PHONES (< 760px)      no rail (a "Sessions" button in the titlebar opens it), composer at the bottom with
                         the starters above it, the drawer is a bottom sheet. 560px tall.
   SOCKET                .mini-socket sits on the window's top edge, centred: the hub's chute lands on it.
                         .is-glow lights it (js, on duit:sync).
   MOTION                .mini-rise and .mini-caret stop under reduced motion (site.css guard); the js then
                         shows answers whole. */

.minid {
  position: relative; min-width: 0;
  width: min(1100px, 100% - 2 * var(--gutter)); margin-inline: auto;
}
/* one soft glow behind the window, so it lifts off the night sky */
.minid::before {
  content: ""; position: absolute; z-index: -1; left: 8%; right: 8%; top: -40px; height: 360px;
  background: radial-gradient(closest-side, color-mix(in oklch, var(--accent) 8%, transparent), transparent);
  pointer-events: none;
}
.mini-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- Socket: where the hub's chute lands ---------- */
.mini-socket {
  position: absolute; z-index: 2; top: 0; left: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%; background: var(--bg); border: 1px solid color-mix(in srgb, var(--faint) 55%, var(--dim));
}
.mini-socket::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--soft);
  transition: background-color .3s, box-shadow .4s;
}
.mini-socket.is-glow::after { background: var(--accent); box-shadow: 0 0 10px 2px color-mix(in oklch, var(--accent) 50%, transparent); }

/* ---------- Window ---------- */
.mini-win {
  --line: var(--faint);
  position: relative; display: grid; grid-template-rows: 38px minmax(0, 1fr);
  height: 580px; overflow: hidden;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 24px 70px oklch(0% 0 0 / .45);
  font-family: var(--sans); font-size: 14px; line-height: 1.5; text-align: left;
}
.mini-win button { font: inherit; color: inherit; }
.mini-ico { width: 12px; height: 12px; flex: none; }
.mini-win :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Titlebar ---------- */
.mini-bar {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line); user-select: none; -webkit-user-select: none;
}
.mini-lights { display: flex; gap: 8px; }
.mini-lights i { width: 12px; height: 12px; border-radius: 50%; background: var(--faint); border: 1px solid var(--line-strong); }
.mini-title {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-size: 12.5px; color: var(--soft); white-space: nowrap; pointer-events: none;
}
.mini-title b { font-weight: 400; color: var(--text); }
.mini-tag {
  margin-left: auto; padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 4px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.4; letter-spacing: .12em; text-transform: uppercase; color: var(--soft);
}
.mini-rail-btn { display: none; }

/* ---------- Body: rail, main, drawer (two panes at most, like the prototype) ---------- */
.mini-body {
  position: relative; display: grid; grid-template-columns: 208px minmax(0, 1fr) 0px; min-height: 0;
  transition: grid-template-columns .32s var(--ease);
}
.mini-win.is-drawer .mini-body { grid-template-columns: 0px minmax(0, 1fr) 320px; }

/* ---------- Rail ---------- */
.mini-rail { min-width: 0; overflow: hidden; border-right: 1px solid var(--line); transition: border-color .32s; }
.is-drawer .mini-rail { border-right-color: transparent; }
.mini-rail-inner { width: 208px; height: 100%; display: flex; flex-direction: column; padding: 12px 10px 0; }
.mini-new {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; font-size: 13px; letter-spacing: .01em;
  transition: background-color .15s;
}
.mini-new:hover { background: var(--surface); }
.mini-new:active { transform: scale(.98); }
.mini-nav { margin-top: 16px; display: flex; flex-direction: column; gap: 2px; }
.mini-nav-item, .mini-sess {
  display: flex; align-items: center; width: 100%; border: 0; background: transparent; text-align: left;
  border-radius: 6px; color: var(--soft);
}
.mini-nav-item { height: 30px; padding: 0 8px 0 10px; font-size: 13px; }
.mini-nav-item:hover, .mini-sess:hover { background: var(--surface); color: var(--text); }
.mini-nav-item[aria-current="page"] { color: var(--text); background: var(--sel); box-shadow: inset 0 0 0 1px var(--line-strong); }
.mini-nav-item.is-in-session[aria-current="page"] { background: transparent; box-shadow: none; }
.mini-nav-item.is-in-session[aria-current="page"]:hover { background: var(--surface); }
.mini-kbd {
  margin-left: auto; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface);
  font-family: var(--mono); font-size: 10.5px; line-height: 1.5; color: var(--soft);
}
.mini-sessions { margin: 0 0 8px; }
.mini-sess { height: 28px; padding: 0 10px 0 20px; font-size: 12.5px; }
.mini-sess span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sess[aria-current="true"] { background: var(--sel); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.mini-rail-foot {
  margin: auto -10px 0; padding: 12px 18px 13px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--soft); white-space: nowrap;
  transition: color .3s;
}
.mini-rail-foot .g { font-size: 13px; }
.mini-rail-foot.is-flash { color: var(--text); }
.mini-rail-foot.is-flash .g { animation: mini-pulse .9s var(--ease); }
@keyframes mini-pulse { 30% { transform: scale(1.5); } }

/* ---------- Main ---------- */
.mini-main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.mini-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mini-col { width: min(640px, 100% - 48px); margin-inline: auto; }
.mini-head { flex: none; padding: 14px 0 4px; }
.mini-h {
  font-size: 15px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; /* the title is the whole first question */
}
.mini-meta { margin-top: 1px; font-size: 12px; color: var(--soft); }
.mini-hello { display: none; }
.mini-thread {
  flex: 1; min-height: 0; overflow-y: auto; padding: 18px 0 0;
  scrollbar-width: thin; scrollbar-color: var(--faint) transparent; scrollbar-gutter: stable both-edges;
}
/* a fade where the thread scrolls under the session title, deep enough that a line scrolled half out reads as
   faded, not cut (js stick() parks a tall answer's first line just below it: TOP_GAP) */
.mini-thread { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 24px); mask-image: linear-gradient(to bottom, transparent, #000 24px); }

/* messages (prototype: .msg-user, .bubble, .msg-duit, .who, .line, .cite) */
.mini-msg-user { margin: 6px 0 12px; display: flex; flex-direction: column; align-items: flex-end; }
.mini-who-user { margin: 0 4px 5px; font-size: 12px; color: var(--soft); }
.mini-bubble {
  max-width: 78%; padding: 9px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  font-size: 14.5px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.mini-msg-duit { margin: 0 0 18px; }
.mini-who { display: flex; align-items: center; flex-wrap: wrap; gap: 0 7px; margin-bottom: 3px; font-size: 12.5px; color: var(--soft); }
.mini-who .mini-name { color: var(--text); }
.mini-status { display: inline-flex; align-items: center; gap: 6px; }
.mini-who .g, .mini-batch .g { font-size: 13px; }
.mini-line { font-size: 14.5px; line-height: 1.65; overflow-wrap: anywhere; }
.mini-cite {
  position: relative; display: inline-flex; align-items: center; height: 22px; margin: 2px 0 2px 8px; padding: 0 8px; vertical-align: 1px;
  border: 1px solid var(--line-strong); border-radius: 5px; background: transparent;
  font-size: 12px; line-height: 1; white-space: nowrap; color: var(--soft);
  transition: background-color .15s, border-color .15s;
}
.mini-cite b { margin-right: 4px; font-weight: 400; color: var(--text); }
.mini-cite:hover, .mini-cite[aria-expanded="true"] { background: var(--sel); }
.mini-cite[aria-expanded="true"] { border-color: var(--soft); }
.mini-caret {
  display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--soft);
  animation: mini-blink 1s steps(2) infinite;
}
@keyframes mini-blink { 50% { opacity: 0; } }
.mini-rise { animation: mini-rise .5s var(--ease) both; }
@keyframes mini-rise { from { opacity: 0; transform: translateY(8px); } }

/* steps: what Duit did in each app, ~ then * */
.mini-steps { margin-top: 10px; padding: 2px 12px; border: 1px solid var(--line); border-radius: 8px; }
.mini-step {
  display: grid; grid-template-columns: 1.1ch minmax(0, 1fr) auto; align-items: baseline; gap: 10px;
  padding: 7px 0; font-size: 13px; line-height: 1.45;
}
.mini-step + .mini-step { border-top: 1px solid var(--line); }
.mini-step .g { font-size: 13px; }
.mini-step-app { color: var(--text); }
.mini-step-act { color: var(--soft); }
.mini-step-act::before { content: " · "; }
.mini-step-state { font-size: 12.5px; color: var(--soft); white-space: nowrap; }

/* drafts: one card per customer, edited in place, and the confirm bar */
.mini-drafts { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.mini-draft { padding: 10px 12px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.mini-draft-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 10px; margin: 0 2px 8px; font-size: 13px; }
.mini-to { color: var(--text); }
.mini-where, .mini-edited { color: var(--soft); }
.mini-where::before { content: "· "; }
.mini-edited:empty { display: none; }
.mini-chan { margin-left: auto; font-size: 12px; color: var(--soft); }
.mini-rm, .mini-link {
  padding: 0; border: 0; background: none; color: var(--soft);
  text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px;
}
.mini-rm { font-size: 12px; }
.mini-link { color: var(--text); white-space: nowrap; }
.mini-rm:hover, .mini-link:hover { color: var(--text); text-decoration-color: currentColor; }
.mini-draft-text {
  display: block; width: 100%; min-height: 44px; padding: 8px 10px; resize: none; field-sizing: content;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  font-size: 13.5px; line-height: 1.55; color: var(--text); transition: border-color .15s;
}
.mini-draft-text:hover { border-color: var(--line-strong); }
.mini-draft-text:focus { border-color: var(--soft); }
.mini-removed {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; border: 1px dashed var(--line-strong); border-radius: 10px;
  font-size: 12.5px; color: var(--soft);
}
.mini-batch {
  position: sticky; bottom: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 16px; margin-top: 8px; padding: 10px 0 12px; background: var(--bg); border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--soft);
}
.mini-batch-state { display: inline-flex; align-items: center; gap: 8px; }
.mini-btn-primary {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border: 0; border-radius: 6px;
  background: var(--accent-fill); color: var(--on-accent) !important; font-size: 13px; letter-spacing: .01em; white-space: nowrap;
  transition: background-color .15s, transform .1s;
}
.mini-btn-primary:hover { background: var(--accent-hover); }
.mini-btn-primary:active { transform: scale(.98); }

/* the fallback's suggestions */
.mini-suggest { margin-top: 8px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.mini-suggest button {
  padding: 6px 10px; margin-left: -10px; border: 0; border-radius: 6px; background: transparent; text-align: left;
  font-size: 13.5px; color: var(--soft);
}
.mini-suggest button::before { content: "\2192\00a0\00a0"; content: "\2192\00a0\00a0" / ""; color: var(--dim); }
.mini-suggest button:hover { background: var(--surface); color: var(--text); }

/* ---------- Composer (with the agent tab, Cursor-like, bottom-left) ---------- */
.mini-compose-wrap { flex: none; padding: 8px 0 0; }
.mini-composer {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 8px 14px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.mini-composer:focus-within { border-color: var(--soft); }
/* the text box draws no ring of its own: the composer around it carries the 2px accent ring when focus came from
   the keyboard (js .is-kb; a textarea always matches :focus-visible, so it can't tell), the border change above
   when the visitor clicked or tapped in */
.mini-composer.is-kb { outline: 2px solid var(--accent); outline-offset: 2px; }
.mini-input {
  display: block; width: 100%; min-height: 24px; max-height: 96px; padding: 2px 0; margin: 0;
  border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font-size: 14.5px; line-height: 1.5; field-sizing: content;
}
.mini-input:focus-visible { outline: 0; }
.mini-input::placeholder { color: var(--soft); opacity: 1; }
.mini-composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mini-agent { position: relative; margin-left: -4px; }
.mini-agent-btn {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 7px 0 9px;
  border: 1px solid var(--line); border-radius: 6px; background: transparent;
  font-size: 12.5px; color: var(--soft); transition: background-color .15s, color .15s;
}
.mini-agent-btn:hover, .mini-agent-btn[aria-expanded="true"] { background: var(--sel); color: var(--text); }
.mini-agent-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--soft); }
.mini-agent-name { color: var(--text); }
.mini-chev { width: 10px; height: 10px; margin-left: -1px; }
.mini-agent-btn[aria-expanded="true"] .mini-chev { transform: rotate(180deg); }
.mini-send {
  position: relative; flex: none; width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text);
  transition: background-color .15s, color .15s;
}
.mini-send .mini-ico { width: 14px; height: 14px; }
.mini-send:hover:not(:disabled) { background: var(--sel); }
.mini-send:disabled { color: var(--dim); cursor: default; }

/* the agent menu: a listbox above the pill (below it on the desktop home, where the composer is centred) */
.mini-agent-pop {
  position: absolute; z-index: 9; left: 0; bottom: calc(100% + 8px); width: 264px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 14px 40px oklch(0% 0 0 / .5);
  animation: mini-pop .18s var(--ease);
}
@keyframes mini-pop { from { opacity: 0; transform: translateY(4px); } }
.mini-agent-list:focus { outline: none; }
.mini-opt {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) 14px; align-items: center; gap: 11px;
  padding: 7px 10px; border-radius: 6px; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.mini-opt.is-active { background: var(--sel); }
.mini-agent-list:focus-visible .mini-opt.is-active { box-shadow: inset 0 0 0 2px var(--accent); }
.mini-opt .mini-agent-dot { width: 8px; height: 8px; }
.mini-opt[aria-selected="true"] .mini-agent-dot { background: var(--text); }
.mini-opt-name { display: block; font-size: 13.5px; line-height: 1.35; color: var(--text); }
.mini-opt-note { display: block; font-size: 12px; line-height: 1.4; color: var(--soft); }
.mini-opt-check { width: 12px; height: 12px; color: var(--text); visibility: hidden; }
.mini-opt[aria-selected="true"] .mini-opt-check { visibility: visible; }
.mini-agent-foot { margin: 4px 0 0; padding: 8px 10px 5px; border-top: 1px solid var(--line); font-size: 12px; line-height: 1.45; color: var(--soft); }

/* starters and the foot line */
.mini-starters { display: none; margin: 12px 0 0; }
.mini-starters button {
  display: block; width: 100%; padding: 7px 14px; border: 0; border-radius: 6px; background: transparent; text-align: left;
  font-size: 13.5px; color: var(--soft); transition: background-color .15s, color .15s;
}
.mini-starters button:hover { background: var(--surface); color: var(--text); }
.mini-route { flex: none; padding: 10px 12px 12px; text-align: center; font-size: 12px; color: var(--soft); text-wrap: balance; }

/* home: nothing but the input */
.is-home .mini-head, .is-home .mini-thread { display: none; }
.is-home .mini-compose-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 0 0 64px; }
.is-home .mini-composer { padding: 14px 12px 10px 18px; border-radius: 12px; gap: 10px; }
.is-home .mini-input { font-size: 15.5px; }
.is-home .mini-starters { display: block; }
@media (min-width: 760px) {
  .is-home .mini-agent-pop { bottom: auto; top: calc(100% + 8px); }
}
/* short laptop screens (1280x720, 1366x768; the same height cut as hub.css): the home composer sits near the
   window's top instead of its middle, so it and the agent tab show above the fold */
@media (min-width: 760px) and (max-height: 820px) {
  .is-home .mini-compose-wrap { justify-content: flex-start; padding: 48px 0 0; }
}

/* ---------- Setup and Agents pages ---------- */
.mini-page { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.mini-page .mini-col { padding: 24px 0 28px; }
.mini-page-h { font-family: var(--sans); font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em; }
.mini-lede { margin-top: 4px; max-width: 60ch; font-size: 13px; line-height: 1.6; color: var(--soft); }
.mini-label {
  font-family: var(--sans); font-size: 11px; font-weight: 400; line-height: 1.4;
  letter-spacing: .08em; text-transform: uppercase; color: var(--soft);
}
.mini-group-label { margin-top: 18px; padding-bottom: 7px; border-bottom: 1px solid var(--line); }
.mini-conn { padding-top: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 2px 16px; }
.mini-conn li { display: flex; align-items: center; gap: 9px; min-height: 32px; font-size: 13px; white-space: nowrap; }
.mini-conn-crm .g { margin-left: auto; }
/* the hub's #logo-<id> symbols carry their own brand tile (64x64, rounded): shown whole, nothing behind */
.mini-logo { flex: none; width: 20px; height: 20px; display: grid; place-items: center; }
.mini-logo svg { width: 20px; height: 20px; }
.mini-logo.is-fallback { border-radius: 5px; background: var(--sel); color: var(--soft); font-family: var(--mono); font-size: 11px; }
.mini-fine { margin-top: 18px; font-size: 12.5px; line-height: 1.6; color: var(--soft); }
.mini-agents { margin-top: 16px; border-top: 1px solid var(--line); }
.mini-agents li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 14px;
  min-height: 54px; padding: 8px 0; border-bottom: 1px solid var(--line);
}
.mini-agents .mini-n { font-size: 14px; }
.mini-agents .mini-d { font-size: 12px; color: var(--soft); }
.mini-agents .mini-st { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--soft); }
.mini-btn {
  height: 28px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: transparent;
  font-size: 12.5px; white-space: nowrap; transition: background-color .15s;
}
.mini-btn:hover { background: var(--surface); }
.mini-btn[aria-pressed="true"] { background: var(--sel); color: var(--soft); }

/* ---------- Source drawer (right side on desktop) ---------- */
.mini-drawer {
  min-width: 0; overflow: hidden; border-left: 1px solid transparent; visibility: hidden;
  transition: border-color .32s, visibility 0s .32s;
}
.is-drawer .mini-drawer { border-left-color: var(--line); visibility: visible; transition: border-color .32s; }
.mini-drawer-inner { width: 320px; height: 100%; display: flex; flex-direction: column; }
.mini-drawer-head {
  flex: none; height: 46px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 0 18px; border-bottom: 1px solid var(--line);
}
.mini-icon-btn {
  position: relative; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--soft);
}
.mini-icon-btn:hover { background: var(--surface); color: var(--text); }
.mini-win .mini-icon-btn:focus-visible { outline-offset: -2px; } /* the window edge would clip an outside ring */
.mini-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }
.mini-src-app { font-size: 15px; }
.mini-src-doc { margin-top: 3px; font-size: 13.5px; }
.mini-src-meta { margin-top: 2px; font-size: 12px; color: var(--soft); }
.mini-passage {
  margin-top: 14px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; line-height: 1.8; color: var(--soft);
}
.mini-passage mark { padding: 1px 2px; border-radius: 2px; background: var(--mark); color: var(--text); }
.mini-src-note { margin-top: 12px; font-size: 12px; line-height: 1.6; color: var(--soft); }
.mini-scrim { display: none; }

/* ---------- Toast ---------- */
.mini-toast {
  position: absolute; z-index: 8; top: 12px; left: 50%; width: max-content; max-width: min(440px, 100% - 24px);
  padding: 9px 14px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 13px; line-height: 1.5; opacity: 0; transform: translate(-50%, -6px); pointer-events: none;
  transition: opacity .2s, transform .3s var(--ease);
}
.mini-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.mini-toast-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--soft); }

/* ---------- Narrower desktops: a slimmer rail ---------- */
@media (min-width: 760px) and (max-width: 979.98px) {
  .mini-body { grid-template-columns: 184px minmax(0, 1fr) 0px; }
  .mini-rail-inner { width: 184px; }
  .mini-win.is-drawer .mini-body { grid-template-columns: 0px minmax(0, 1fr) 300px; }
  .mini-drawer-inner { width: 300px; }
  .mini-col { width: calc(100% - 40px); }
}

/* ---------- Phones: no rail (Sessions opens it), composer at the bottom, drawer as a bottom sheet ---------- */
@media (max-width: 759.98px) {
  .mini-win { height: 560px; grid-template-rows: 44px minmax(0, 1fr); }
  .mini-bar { gap: 4px; padding: 0 8px 0 2px; }
  .mini-lights { display: none; }
  .mini-rail-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 10px; border: 0; border-radius: 6px;
    background: transparent; font-size: 13px; color: var(--soft);
  }
  .mini-rail-btn .mini-ico { width: 14px; height: 14px; }
  .mini-rail-btn:hover, .mini-rail-btn[aria-expanded="true"] { color: var(--text); }
  .mini-title { position: static; transform: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: center; }
  .mini-tag { margin-left: 0; }

  .mini-body, .mini-win.is-drawer .mini-body { grid-template-columns: minmax(0, 1fr); }
  .mini-rail {
    position: absolute; z-index: 6; top: 0; bottom: 0; left: 0; width: min(272px, 86%);
    background: var(--bg); border-right: 1px solid var(--line-strong);
    transform: translateX(-102%); visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s .3s;
  }
  .is-rail .mini-rail { transform: none; visibility: visible; transition: transform .3s var(--ease); }
  .mini-rail-inner { width: 100%; padding-top: 10px; }
  .mini-new { height: 44px; }
  .mini-nav { margin-top: 10px; gap: 0; }
  .mini-nav-item { height: 44px; font-size: 14px; }
  .mini-sess { height: 44px; font-size: 13.5px; }
  .mini-kbd { display: none; }
  .mini-scrim {
    display: block; position: absolute; inset: 0; z-index: 5; background: color-mix(in oklch, var(--bg) 72%, transparent);
    opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s;
  }
  .is-rail .mini-scrim, .is-drawer .mini-scrim { opacity: 1; visibility: visible; transition: opacity .25s; }

  .mini-drawer {
    position: absolute; z-index: 7; left: 0; right: 0; bottom: 0; height: min(76%, 420px);
    background: var(--bg); border: 0; border-top: 1px solid var(--line-strong); border-radius: 12px 12px 0 0;
    transform: translateY(102%); transition: transform .32s var(--ease), visibility 0s .32s;
  }
  .is-drawer .mini-drawer { transform: none; transition: transform .32s var(--ease); }
  .mini-drawer-inner { width: 100%; }
  .mini-drawer-head { height: 48px; padding-right: 4px; }
  .mini-icon-btn { width: 44px; height: 44px; }

  .mini-col { width: calc(100% - 24px); }
  .mini-head { padding-top: 10px; }
  .mini-bubble { max-width: 88%; font-size: 14px; }
  .mini-line { font-size: 14px; }
  .mini-cite { height: 28px; margin-top: 4px; margin-bottom: 4px; }
  /* 44px tap targets without bigger chips: the hit area runs past each small control */
  .mini-cite::after, .mini-agent-btn::after, .mini-send::after { content: ""; position: absolute; inset: -8px -4px; }
  .mini-rm::after, .mini-link::after { content: ""; position: absolute; inset: -13px -6px; }
  .mini-rm, .mini-link { position: relative; }
  .mini-draft-head { margin-bottom: 13px; } /* Remove's hit area ends above the text box, never over it */
  .mini-steps { padding: 2px 10px; }
  .mini-step { grid-template-columns: 1.1ch minmax(0, 1fr); gap: 2px 9px; }
  .mini-step-state { grid-column: 2; }
  .mini-btn-primary { height: 44px; }
  .mini-draft-text { font-size: 16px; } /* 16px keeps iOS from zooming the page when a draft is tapped to edit */
  .mini-suggest button { min-height: 44px; }
  .mini-chan { margin-left: 0; }
  .mini-rm { margin-left: auto; }

  /* home: a short hello in the empty space, starters (moved above the composer by the js), composer last */
  .is-home .mini-hello {
    flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; padding: 12px 28px; text-align: center;
  }
  .mini-hello-mark { width: 22px; height: 22px; color: var(--text); }
  .mini-hello-h { font-size: 17px; line-height: 1.35; }
  .mini-hello-p { max-width: 30ch; font-size: 12.5px; line-height: 1.55; color: var(--soft); }
  .is-home .mini-compose-wrap { flex: none; padding: 0; }
  .mini-compose-wrap { padding-top: 6px; }
  .mini-starters { margin: 0 0 8px; }
  .mini-starters button { min-height: 44px; padding: 10px 12px; font-size: 13.5px; line-height: 1.4; }
  .is-home .mini-composer { padding: 12px 10px 8px 14px; gap: 8px; }
  .is-home .mini-input, .mini-input { font-size: 16px; } /* 16px keeps iOS from zooming the page on focus */
  .mini-agent-btn { height: 32px; }
  .mini-send { width: 36px; height: 36px; }
  .mini-agent-pop { width: min(264px, 100vw - 64px); }
  .mini-opt { min-height: 44px; }
  .mini-route { padding: 8px 12px 10px; font-size: 11.5px; }
  .mini-route-ex { display: none; } /* phones say it in the home screen's hello (.mini-hello-p), with room to spare */
  .mini-page .mini-col { padding-top: 18px; }
  .mini-agents li { grid-template-columns: minmax(0, 1fr) auto; }
  .mini-agents .mini-st { display: none; }
  .mini-btn { height: 44px; }
  .mini-toast { top: 8px; }
}
