/* =====================================================================
   The model picker and Fast mode switch (public/model-picker.js; worker/model-picker.ts, AGENTS gotcha 194).
   Chat page only. A quiet button in the box (claude.ai's), whose navy bolt fills while Fast mode is on and
   working; a card above it on a laptop, a sheet from the bottom on a phone. Motion: 150-300 ms on the site's ease,
   one short "charge" when Fast comes on, nothing that loops. Everything script shows, hides, places or toggles has
   its transition property listed (gotcha 75 / 167: theme.css's Reduce Motion rule otherwise "transitions" all).
   ===================================================================== */

:root {
  /* The bolt in the brand's navy, never a glow (calm design pass, 24 Oct 2026): its gold was a fourth accent colour right
     under the box, with the black switch a settings look a client does not need (design walk #9). Fast on still reads:
     the bolt fills. */
  --bolt-fill: var(--navy-text);
  --bolt-edge: var(--navy-text);
  --bolt-glow: transparent;
  --bolt-tint: var(--navy-tint);
}

/* ---- the button in the box ---------------------------------------- */

.model-btn {
  flex: none;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  margin-bottom: 3px;
  padding: 0 7px 0 9px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: background-color, color;
  transition-duration: .18s;
  transition-timing-function: var(--ease);
}
@media (hover: hover) {
  .model-btn:hover { background: var(--surface-2); color: var(--text); }
}
.model-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.model-btn:active { background: var(--ink-softer); }
.model-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

/* The bolt: an outline at rest; gold, filled and glowing while Fast is on. On a model without fast mode it folds
   away to nothing (its width, not a jump). */
.model-bolt {
  flex: none;
  width: 15px;
  height: 15px;
  fill: transparent;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linejoin: round;
  overflow: visible;
  transform-origin: 50% 55%;
  transition-property: fill, stroke, filter, width, margin, opacity;
  transition-duration: .24s;
  transition-timing-function: var(--ease);
}
.model-btn.is-fast .model-bolt {
  fill: var(--bolt-fill);
  stroke: var(--bolt-edge);
  stroke-width: 1;
  filter: drop-shadow(0 0 3.5px var(--bolt-glow));
}
.model-btn.no-fast .model-bolt { width: 0; margin-right: -5px; opacity: 0; }
/* The charge: one beat when Fast comes on (or a model with Fast is picked), then the steady glow. */
.model-btn.is-charging .model-bolt { animation: bolt-charge .48s var(--ease) 1; }
@keyframes bolt-charge {
  0%   { transform: scale(.86) rotate(-6deg); filter: drop-shadow(0 0 0 transparent); }
  42%  { transform: scale(1.2) rotate(3deg); filter: drop-shadow(0 0 7px var(--bolt-glow)) drop-shadow(0 0 2px var(--bolt-glow)); }
  100% { transform: none; filter: drop-shadow(0 0 3.5px var(--bolt-glow)); }
}

.model-name { display: inline-block; }
.model-name-short { display: none; }
.model-chev {
  flex: none;
  width: 14px;
  height: 14px;
  opacity: .7;
  transition-property: transform, opacity;
  transition-duration: .2s;
  transition-timing-function: var(--ease);
}
.model-btn[aria-expanded="true"] .model-chev { transform: rotate(180deg); opacity: 1; }

/* ---- the line under the box (a laptop's empty page) ---------------- */
/* Chat look part 4 (Nick, 20 Oct 2026, after claude.ai/new's "Sonnet 5.5 Medium"): the button leaves the box for a
   quiet line just under it, at its right end, its chevron in line with Send's right edge (the box's 12px padding, less
   the button's 7px). The line's room is held from the first paint whatever /api/config later says, so the ways to
   start never move when the button arrives, nor when the picker is off (then the line stays empty: hiding it moved
   the box 13px mid-opening, check-home-intro). Not in a conversation, in voice mode or on a phone. The gap to the ways to start below shrinks by as much as the line adds, near enough (app.css). */
.model-under { display: none; }
@media (min-width: 760.02px) and (min-height: 500.02px), (min-width: 760.02px) and (pointer: fine), (min-width: 760.02px) and (pointer: none) {
  html.chat-empty:not(.voice-open) .composer-wrap > .model-under {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    max-width: min(var(--maxw), 720px);
    min-height: 28px;
    margin: 6px auto 0;
    padding: 0 5px 0 0;
    box-sizing: border-box;
  }
  html.chat-empty .model-under .model-btn { align-self: center; margin-bottom: 0; }
  /* A step quieter than the box's own controls, as claude.ai's line is. */
  html.chat-empty .model-under .model-btn { height: 28px; font-size: 13.5px; }
}

/* ---- the menu (a laptop's card) ----------------------------------- */

.model-menu {
  position: fixed;
  z-index: 50;
  top: 0;
  left: 0;
  width: 344px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
  transform-origin: 100% 100%;
  animation: model-pop .2s var(--ease);
  /* Placed by script in one step (gotcha 75). */
  transition-property: none;
}
.model-menu[hidden] { display: none; }
.model-menu[data-side="below"] { transform-origin: 100% 0; animation-name: model-drop; }
.model-menu.is-closing { pointer-events: none; animation: model-out .15s ease forwards; }
@keyframes model-pop  { from { opacity: 0; transform: translateY(6px) scale(.97); } }
@keyframes model-drop { from { opacity: 0; transform: translateY(-6px) scale(.97); } }
@keyframes model-out  { to { opacity: 0; transform: translateY(4px) scale(.98); } }

.model-head { display: none; }

.model-list { display: flex; flex-direction: column; }
.model-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 9px 10px 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: background-color;
  transition-duration: .15s;
}
@media (hover: hover) {
  .model-list:not(:has(.model-radio:focus-visible)) .model-opt:hover { background: var(--ink-soft); }
}
.model-opt:active { background: var(--ink-soft); }
/* The radio is the real control (arrows, "1 of 3"); the row draws it. */
.model-radio {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.model-opt:has(.model-radio:focus-visible),
.model-menu.is-keyed .model-opt:has(.model-radio:focus) { background: var(--ink-soft); outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.model-opt-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.model-opt-name { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--text); }
/* Balanced lines, never one word alone on the last (design critic, finding 3). */
.model-opt-line { font-size: 13px; line-height: 1.35; color: var(--text-faint); text-wrap: pretty; }
.model-row-hint { text-wrap: pretty; }
.model-row-hint:empty { display: none; }
.model-tick {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--text);
  margin-right: -3px;
  opacity: 0;
  transform: scale(.55);
  transition-property: opacity, transform;
  transition-duration: .2s;
  transition-timing-function: var(--ease);
}
.model-opt.is-picked .model-tick { opacity: 1; transform: none; }

.model-sep { height: 1px; margin: 5px 12px; background: var(--line); }

/* ---- the Fast mode row and its switch ------------------------------ */

.model-fast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 9px 10px 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.model-fast.is-off { cursor: default; }
.model-fast.is-off .model-opt-name { opacity: .55; }
.model-fast .model-opt-name { transition-property: opacity; transition-duration: .2s; }

.model-switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface-3);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: background-color, box-shadow, opacity;
  transition-duration: .22s;
  transition-timing-function: var(--ease);
}
.model-switch::before {
  /* A 44px target round the 28px track (gotcha 96). */
  content: '';
  position: absolute;
  inset: -8px -4px;
}
.model-switch { box-shadow: inset 0 0 0 1px var(--line-strong); }
.model-switch[aria-checked="true"] { background: var(--navy-fill); box-shadow: none; }
/* Disabled reads as a real, quiet control with an edge, never a half-drawn ghost (design critic, finding 4). */
.model-switch[aria-disabled="true"] { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; }
.model-switch[aria-disabled="true"] .model-knob { box-shadow: 0 1px 2px rgba(11, 11, 16, 0.12); }
.model-switch:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.model-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(11, 11, 16, 0.18), 0 2px 6px rgba(11, 11, 16, 0.10);
  /* A spring: a little past, then home. */
  transition-property: transform, background-color;
  transition-duration: .26s, .22s;
  transition-timing-function: cubic-bezier(.3, 1.45, .5, 1), var(--ease);
}
.model-switch[aria-checked="true"] .model-knob { transform: translateX(20px); background: var(--on-navy); }
.model-knob-bolt {
  width: 13px;
  height: 13px;
  /* On the white knob: the logo's navy, which stays dark in the dark theme too. */
  fill: var(--navy-fill);
  stroke: var(--navy-fill);
  stroke-width: 1;
  opacity: 0;
  transform: scale(.4) rotate(-20deg);
  transition-property: opacity, transform;
  transition-duration: .22s;
  transition-timing-function: cubic-bezier(.3, 1.45, .5, 1);
}
.model-switch[aria-checked="true"] .model-knob-bolt { opacity: 1; transform: none; }
/* Fast coming on: one soft ring out of the track (transparent since the calm design pass: no glow). */
.model-fast.is-charging .model-switch { animation: fast-ring .6s var(--ease) 1; }
@keyframes fast-ring {
  0%   { box-shadow: 0 0 0 0 var(--bolt-glow); }
  100% { box-shadow: 0 0 0 9px transparent; }
}
.model-fast.is-charging .model-knob-bolt { animation: knob-charge .48s var(--ease) 1; }
@keyframes knob-charge {
  0%   { transform: scale(.6) rotate(-12deg); }
  50%  { transform: scale(1.18) rotate(4deg); filter: drop-shadow(0 0 4px var(--bolt-glow)); }
  100% { transform: none; }
}

/* ---- a phone's row in the + sheet (the box has no room for the button) ---- */

.plus-model .model-row-bolt { fill: transparent; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; overflow: visible; }
.plus-model.is-fast .model-row-bolt { fill: var(--bolt-fill); stroke: var(--bolt-edge); stroke-width: 1; color: var(--bolt-edge); filter: drop-shadow(0 0 3px var(--bolt-glow)); }
.model-row-chev { flex: none; width: 18px; height: 18px; color: var(--text-faint); transform: rotate(-90deg); }

/* ---- a phone: the sheet, and a shorter button ---------------------- */

@media (max-width: 760px), (pointer: coarse) and (max-height: 500px) {
  /* The box keeps its one row: the + sheet's first row is the picker here. */
  .composer-wrap .model-btn { display: none; }

  .model-menu,
  .model-menu[data-side="below"],
  .model-menu[data-side="sheet"] {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(100%, 600px);
    max-width: none;
    max-height: calc(100vh - var(--safe-top) - 12px);
    max-height: calc(100dvh - var(--safe-top) - 12px);
    margin: 0 auto;
    padding: 0 8px calc(var(--safe-bottom) + 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
    font-size: 17px;
    transform-origin: 50% 100%;
    /* The + sheet's own timing and curves, so the two sheets move as one system (design critic, finding 8). */
    animation: model-sheet-up .2s cubic-bezier(.2, .8, .2, 1);
  }
  .model-menu.is-closing { animation: model-sheet-down .2s cubic-bezier(.4, 0, .9, .6) forwards; }
  .model-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 18px 4px 6px 14px;
    background: inherit;
  }
  .model-grab {
    position: absolute;
    top: 7px;
    left: 50%;
    width: 36px;
    height: 5px;
    margin-left: -18px;
    border-radius: 3px;
    background: var(--line-strong);
  }
  .model-title { flex: 1 1 auto; margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
  .model-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--ink-soft);
    color: var(--text-dim);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .model-close:active { background: var(--ink-softer); color: var(--text); }
  .model-opt, .model-fast { min-height: 64px; padding: 11px 12px 11px 14px; border-radius: 12px; }
  .model-opt-name { font-size: 17px; font-weight: 500; }
  .model-opt-line { font-size: 13.5px; }
  .model-sep { margin: 6px 14px; }
  .model-tick { width: 22px; height: 22px; }
  .model-switch { width: 52px; height: 32px; border-radius: 16px; }
  .model-knob { width: 28px; height: 28px; }
  .model-switch[aria-checked="true"] .model-knob { transform: translateX(20px); }
  .model-knob-bolt { width: 15px; height: 15px; }

  .model-backdrop { z-index: 55; touch-action: none; backdrop-filter: none; -webkit-backdrop-filter: none; transition-property: none; }
  .model-backdrop.is-closing { pointer-events: none; animation: model-fade-out .2s ease both; }
  /* From the + sheet: at full strength at once, over its fading dim and under both sheets (design critic, finding 1). */
  .model-backdrop.is-handoff { animation: none; z-index: 56; }
  .plus-backdrop.model-handoff-out { opacity: 0; animation: none; transition-property: none; }
  html.model-sheet-open .chat-stage { overflow: hidden; }
}
@keyframes model-sheet-up   { from { transform: translateY(100%); } }
@keyframes model-sheet-down { to { transform: translateY(100%); } }
@keyframes model-fade-out   { to { opacity: 0; } }

/* ---- Reduce Motion: nothing moves; only what is on changes ----------- */

@media (prefers-reduced-motion: reduce) {
  .model-menu, .model-menu[data-side="below"], .model-menu[data-side="sheet"], .model-menu.is-closing,
  .model-backdrop, .model-backdrop.is-closing { animation: none; }
  .model-btn.is-charging .model-bolt, .model-fast.is-charging .model-switch, .model-fast.is-charging .model-knob-bolt { animation: none; }
  .model-knob, .model-knob-bolt, .model-tick, .model-chev, .model-bolt { transition-property: none !important; }
  .model-btn[aria-expanded="true"] .model-chev { transform: none; }
}

@media (forced-colors: active) {
  .model-btn.is-fast .model-bolt, .model-knob-bolt { fill: CanvasText; stroke: CanvasText; filter: none; }
  .model-switch { border: 1px solid ButtonText; }
  .model-switch[aria-checked="true"] { background: Highlight; }
  .model-opt.is-picked { outline: 1px solid Highlight; }
}
