/* Settings, quick first (chat-first UI step 5, 2026-10-12) — settings-quick.js.
   Its own sheet, beside customize.css (step 4's Settings sheet) and
   composer-menus.css (step 5's other lists), so each step's motion can be
   checked whole against the motion pack. */

/* ---------- Settings, quick first (settings-quick.js, UI step 5) -------------------
   A small panel that rises from what opened it — above the sidebar's Settings,
   as ChatGPT's account menu does — and grows into the sheet on Expand. A
   modal <dialog> with a clear backdrop: nothing behind it moves, and a click
   outside lands on the dialog's own box (settings-quick.js). On a phone it is
   a bottom sheet with a grabber. Three ids-free classes carry the motion,
   because the exit plays on a copy with its ids taken off (motion.js). */

dialog.set-quick {
  position: fixed; inset: auto; margin: 0; width: 344px; max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px);
  padding: 0; overflow: hidden; border-radius: 16px; background: var(--surface); box-shadow: var(--elev-3);
  /* Where the stylesheet puts it when nothing measured a place for it (jsdom, or before the first frame). */
  left: 50%; top: 12vh; translate: -50% 0;
}
dialog.set-quick[style*="left"] { translate: none; }
dialog.set-quick::backdrop { background: transparent; }
/* Off with `dialog[open]`'s own rise (style.css), at that rule's weight and
   no more: `:where([open])` keeps this at (0,1,1), so `.is-entering` and
   `.is-leaving` (0,2,0) below win and the panel's own motion plays. As
   `dialog.set-quick[open]` (0,2,1) it beat them both, so the panel never
   animated either way, and `is-entering` only came off by motion.js's 400ms
   fallback (desktop QA, 2026-10-14). */
dialog.set-quick:where([open]) { animation: none; }
dialog.set-quick[open]::backdrop { animation: none; }
.sq-sheet { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
/* Right padding = the body's 8px + an item's 10px,
   so Expand ends on the same line as every button and select under it. */
.sq-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 8px 18px; }
.sq-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.005em; }
.sq-grab { display: none; }
.sq-expand {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background var(--dur-instant) var(--ease-snap), border-color var(--dur-instant) var(--ease-snap);
}
.sq-expand:hover { background: color-mix(in srgb, var(--text) 5%, var(--surface)); }
.sq-expand .ic, .sq-icon .ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sq-body { display: flex; flex-direction: column; padding: 2px 8px 8px; overflow-y: auto; overscroll-behavior: contain; }
.sq-item { display: flex; flex-direction: column; gap: 10px; padding: 12px 10px; }
.sq-item + .sq-item { border-top: 1px solid var(--line); }
.sq-row { display: flex; align-items: flex-start; gap: 11px; }
.sq-icon { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-2); color: var(--text); }
.sq-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sq-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.sq-now { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; white-space: pre-line; }
.sq-now:empty { display: none; }
.sq-sub { font-size: 12px; color: var(--dim); line-height: 1.4; }
/* Wraps rather than running past the panel's edge: "Connect an account" and
   "Add a model key" side by side were 9px wider than the row and the second
   ended 9px right of everything else (desktop QA, 2026-10-14). The 6px gap
   and 9px padding are what make the pair fit on one line at 344px. */
.sq-acts { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 41px; }
.sq-btn {
  height: 30px; padding: 0 9px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-instant) var(--ease-snap), border-color var(--dur-instant) var(--ease-snap);
}
.sq-btn:hover { background: color-mix(in srgb, var(--text) 5%, var(--surface)); border-color: color-mix(in srgb, var(--text) 22%, var(--line-2)); }
.sq-btn:active, .sq-expand:active { transform: scale(.98); }
.sq-side { flex: none; align-self: center; }
.sq-select {
  margin-left: 41px; width: calc(100% - 41px); height: 34px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px;
}
.set-quick :is(.sq-btn, .sq-expand, .sq-select):focus-visible { outline: 2px solid color-mix(in srgb, var(--info) 55%, transparent); outline-offset: 1px; }

/* Arriving: 4px toward the opener and .96 of scale, from the opener's side, on
   the snap curve. Leaving: on the copy, at 0.7 of that, on the exit curve. */
@keyframes sq-fade { from { opacity: 0; } }
@keyframes sq-fade-out { to { opacity: 0; } }
@keyframes sq-in { from { opacity: 0; transform: translateY(var(--sq-dy, 4px)) scale(.96); } }
@keyframes sq-out { to { opacity: 0; transform: translateY(var(--sq-dy, 4px)) scale(.97); } }
@keyframes sq-up { from { transform: translateY(100%); } }
/* From wherever a drag let go of it (`--from`, settings-quick.js), so a sheet
   pulled half way does not jump back up before it goes down. */
@keyframes sq-down { from { transform: translateY(var(--from, 0px)); } to { transform: translateY(100%); } }
.set-quick.is-entering { transform-origin: var(--sq-origin, 50% 0); animation: sq-in var(--dur-quick) var(--ease-snap) both; }
.set-quick.is-leaving { z-index: 60; transform-origin: var(--sq-origin, 50% 0); animation: sq-out calc(var(--dur-quick) * var(--dur-exit-scale)) var(--ease-exit) both; }
/* Expand's growth (motion.js `grow`) is the sheet's whole arrival. Its own
   rise is not held off here any more: `grow` finishes it before it starts,
   because an `animation: none` taken off at the end started the rise over —
   the sheet blinked out and came up a second time (Chromium, 2026-10-12). */

/* ---------- the phone: one of step 8's sheets ------------------------------------
   A modal in the top layer, so it is over the tab bar and the Ask sheet
   whatever their z-index; its rows stop above the home indicator, its sides
   clear a landscape notch, and every control is a thumb's 44px (phone.css).
   It rises on the panel duration and the snap curve, and leaves — the real
   sheet, from where a drag let it go (settings-quick.js `close`) — at 0.7 of
   that on the exit curve, with the scrim fading out under it rather than
   vanishing before it. While a finger holds it, it is where the finger is. */
@media (max-width: 720px) {
  dialog.set-quick { inset: auto 0 0 0; translate: none; width: 100%; max-width: 100%; max-height: 86dvh; border-radius: 18px 18px 0 0; }
  dialog.set-quick::backdrop { background: var(--scrim); }
  dialog.set-quick[open]::backdrop { animation: dlg-fade var(--dur-panel) var(--ease-snap); }
  dialog.set-quick.is-leaving::backdrop { animation: sq-fade-out calc(var(--dur-panel) * var(--dur-exit-scale)) var(--ease-exit) both; }
  .sq-sheet { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .sq-head { position: relative; padding-top: 22px; touch-action: none; user-select: none; -webkit-user-select: none; }
  .sq-grab { display: block; position: absolute; top: 8px; left: 50%; width: 36px; height: 5px; margin-left: -18px; border-radius: 3px; background: var(--line-2); }
  .sq-body { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .sq-btn, .sq-expand { height: 44px; -webkit-tap-highlight-color: transparent; }
  .sq-btn { padding: 0 14px; border-radius: 12px; font-size: 14px; }
  .sq-expand { padding: 0 14px; font-size: 13.5px; }
  .sq-select { height: 44px; border-radius: 12px; font-size: 15px; }
  .sq-btn:active, .sq-expand:active { transform: scale(.96); }
  .set-quick.is-entering { animation: sq-up var(--dur-panel) var(--ease-snap) both; }
  .set-quick.is-leaving { animation: sq-down calc(var(--dur-panel) * var(--dur-exit-scale)) var(--ease-exit) both; }
  .set-quick.is-dragging { animation: none; }

  /* Expand (app.js `expandSettings`): the big sheet rises out of the small
     one's top edge while the small one stays up under it, so the scrim on
     screen is the small one's until the rise ends — then the big one's, the
     same colour, in the same frame. Its own fade-in is never played: it would
     restart the scrim from clear behind a sheet already up. */
  #settings.from-quick[open]:not(.is-leaving)::backdrop { animation: none; }
  #settings.from-quick.is-growing::backdrop { background: transparent; }
}

/* ---------- reduced motion ---------------------------------------------------------
   Rule six: an 80ms fade, nothing that travels or scales — the phone sheet
   too, which fades in place rather than rising. Expand's growth is a fade in
   motion.js, which reads the same preference. */
@media (prefers-reduced-motion: reduce) {
  .set-quick.is-entering { animation: sq-fade 80ms linear both; }
  .set-quick.is-leaving { animation: sq-fade-out 80ms linear both; }
  dialog.set-quick[open]::backdrop { animation: none; }
  dialog.set-quick.is-leaving::backdrop { animation: sq-fade-out 80ms linear both; }
  .sq-btn:active, .sq-expand:active { transform: none; }
  .sq-btn, .sq-expand { transition: none; }
}

/* ---------- the money rows and switches (cost dashboard slice 2b) ----------
   Three figures with their marks on one wrapping line, the two nearest caps as
   one quiet line each (a warn at 80% in the cap's own amber), the harness
   under the model, and one switch. */
.sq-money { color: var(--text); }
.sq-caps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.sq-caps li { overflow-wrap: anywhere; }
.sq-caps li[data-warn] { color: var(--sun-ink); font-weight: 600; }
.sq-for { display: flex; flex-direction: column; gap: 4px; }
.sq-switch { display: flex; align-items: flex-start; gap: 11px; cursor: pointer; }
.sq-switch input { flex: none; width: 18px; height: 18px; margin: 2px 6px 0 6px; accent-color: var(--info); }
.set-quick .sq-switch input:focus-visible { outline: 2px solid color-mix(in srgb, var(--info) 55%, transparent); outline-offset: 2px; }
.sq-for > .sq-sub { margin-left: 41px; }
