/* gizza.css — Cursor-inspired editorial chat UI.
 *
 * Foundation tokens (colors, type, spacing) come from suppers-ai/site-kit
 * via the design-system.css link in render_chat(). This file overrides
 * --sa-accent for the gizza brand and aliases the legacy --color-* and
 * --space-* names onto the kit's --sa-* tokens so the rest of this stylesheet did
 * not need a search-and-replace pass. Gizza-specific tokens that have no
 * kit equivalent (timeline pastels, soft canvas, ink-on-canvas hairlines,
 * pill radius) are kept bespoke.
 */

:root {
  /* Brand override — Cursor Orange retained as scarce accent. */
  --sa-accent:        #f54e00;
  --sa-accent-hover:  #d04200;
  --sa-on-accent:     #fff;       /* 3.0:1 on orange — all on-orange surfaces must be large or bold (AA Large) */

  /* Canvas + surfaces. White and warm-cream are gone. */
  --color-canvas:          #ffffff;
  --color-canvas-soft:     #fafafa;
  --color-surface-card:    #ffffff; /* card surface — may diverge from canvas in dark mode */
  --color-surface-strong:  #f5f5f5;

  /* Hairlines — graduated neutrals replacing the cream-tinted set. */
  --color-hairline:        #e5e5e5;
  --color-hairline-soft:   #f1f1f1;
  --color-hairline-strong: #d4d4d4;

  /* Ink + body text. */
  --color-ink:        #0a0a0a;
  --color-body:       #525252;
  --color-muted:      #737373;
  --color-muted-soft: #a3a3a3;

  /* Brand + on-brand */
  --color-primary:        var(--sa-accent);
  --color-primary-active: var(--sa-accent-hover);
  --color-on-primary:     #ffffff;

  /* Semantic state colors — used by chip icons (✓ ✗) and the dialog
   * progress card error variant. NOT used as fills. */
  --color-success: #1f8a65;
  --color-error:   #cf2d56;

  /* Type aliases */
  --font-display: var(--sa-font-sans);     /* Itim from kit */
  --font-mono:    var(--sa-font-mono);

  /* Radius — pill kept bespoke; rest from kit. */
  --radius-xs:   4px;
  --radius-sm:   var(--sa-radius-sm);
  --radius-md:   var(--sa-radius-md);
  --radius-lg:   var(--sa-radius-lg);
  --radius-pill: 9999px;

  /* Spacing — unchanged from current file. */
  --space-xxs:  var(--sa-space-1);
  --space-xs:   var(--sa-space-2);
  --space-sm:   var(--sa-space-3);
  --space-base: var(--sa-space-4);
  --space-md:   20px; /* no kit equivalent between sa-4 (16px) and sa-6 (24px) */
  --space-lg:   var(--sa-space-6);
  --space-xl:   var(--sa-space-8);
  --space-xxl:  var(--sa-space-12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #EEEDED;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Boot shell ───────────────────────────────────────────────────────── */
/* Rendered by /index.html before the SW registers and replaces the page. */

main#app {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.boot {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
}

/* ─── Header band ──────────────────────────────────────────────────────── */
/* Match the chat band's max-width (880px) and inline padding so the brand's
 * left edge aligns with the composer's left edge. The kit's <sa-header>
 * exposes its inner row via part="container", which lets us constrain it
 * from outside the shadow DOM without forking the component. */
sa-header {
  background: #EEEDED;
}
sa-header::part(container) {
  max-width: 880px;
  background: #EEEDED;
}
sa-chat::part(composer) {
  background: #EEEDED;
  border-top-color: transparent;
}
/* Make the brand fill the row so the slotted <a class="brand"> can center
 * itself across the header band. The default shadow layout sets brand
 * flex:0 0 auto + nav flex:1 1 auto, which pins the brand to the left. */
sa-header::part(brand) {
  flex: 1 1 auto;
  justify-content: center;
}
sa-header::part(nav) {
  flex: 0 0 auto;
}

/* ─── Brand (slotted into <sa-header>) ─────────────────────────────────── */

/* Wordmark + crab mascot. The kit's <sa-header> provides the chrome
 * container, sticky behavior, and hairline divider. We just style the
 * slotted contents — magazine voice (400), Cursor Orange wordmark, crab
 * to the left. */
sa-header .brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  text-decoration: none;
  color: var(--color-primary);
  flex: 1 1 auto;
  width: 100%;
}
sa-header .brand-logo {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  object-fit: contain;
  background: transparent;
}

/* ─── Brand mascot (still + video + eyes) ──────────────────────────────── */
/* Container layers a still PNG (with empty eye sockets), a video that
 * overlays it during animation, and two pupil overlays that track the
 * mouse. The .brand-still and .brand-video both fill the box; the JS state
 * machine toggles which is visible. Eye sockets are absolutely positioned
 * over the white eyeball areas of the still images. */
sa-header .brand-mascot {
  position: relative;
}
sa-header .brand-still,
sa-header .brand-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
sa-header .brand-video[hidden] { display: none; }
sa-header .brand-still[hidden] { display: none; }

sa-header .brand-eyes {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
sa-header .brand-eye-socket {
  position: absolute;
  width: 8.5%;  /* slightly smaller than the white eyeball so the pupil
                 * stays inside the iris with room to roam */
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
}
sa-header .brand-eye {
  width: 55%;
  height: 55%;
  object-fit: contain;
  transition: transform 60ms linear;
}

/* Per-pose pupil placement — coordinates measured visually from each
 * source PNG's white eyeball centers (1254×1254 canvas). */
sa-header .brand-mascot[data-pose="resting"] .brand-eye-left  { left: 45.0%; top: 60.5%; }
sa-header .brand-mascot[data-pose="resting"] .brand-eye-right { left: 58.0%; top: 60.5%; }
sa-header .brand-mascot[data-pose="sign"]    .brand-eye-left  { left: 45.5%; top: 58.2%; }
sa-header .brand-mascot[data-pose="sign"]    .brand-eye-right { left: 56.5%; top: 58.2%; }

/* Hide eyes while a video is playing (the video has its own baked-in eyes). */
sa-header .brand-mascot[data-pose="video"] .brand-eyes { display: none; }
sa-header .brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 400;
  color: inherit;
  letter-spacing: -0.02em;
}

/* The settings cog renders inside the composer once gizza-app.js moves it
 * there at init. Hide it in its original slot so there's no flash of
 * unstyled glyph during boot. */
sa-header #open-settings { display: none; }

/* ─── Chat band ────────────────────────────────────────────────────────── */
/* Layout (max-width, vertical sizing, padding) is owned by <sa-chat>.
 * We just style the slotted #messages container. */

#messages {
  display: flex;
  flex-direction: column;
  gap: var(--space-base);
}

.empty {
  color: var(--color-muted);
  text-align: center;
  padding: var(--space-xxl) 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
}

/* ─── Bubbles ──────────────────────────────────────────────────────────── */

.bubble {
  max-width: 75%;
  padding: var(--space-sm) var(--space-base);
  border-radius: var(--radius-lg);
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.55;
  font-size: 15px;
}

/* User bubble — pricing-tier-featured inversion (ink-on-canvas reversed).
 * Orange stays scarce; bubbles never use it. */
.bubble.user {
  align-self: flex-end;
  background: var(--color-ink);
  color: var(--color-canvas);
  letter-spacing: 0;
}

/* Assistant bubble — feature-card surface, hairline outline. */
.bubble.assistant {
  align-self: flex-start;
  background: var(--color-surface-card);
  color: var(--color-ink);
  border: 1px solid var(--color-hairline);
  letter-spacing: 0;
}

/* ─── Slash-command autocomplete dropdown ─────────────────────────────── */
#slash-autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: var(--space-xs);
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  max-height: 240px;
  overflow-y: auto;
  z-index: 50;
}

#slash-autocomplete[hidden] {
  display: none;
}

#slash-autocomplete .slash-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 2px;
  width: 100%;
  height: auto;
  text-align: left;
  padding: var(--space-xs) var(--space-base);
  border: none;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-hairline);
}

#slash-autocomplete .slash-item:last-child {
  border-bottom: none;
}

#slash-autocomplete .slash-item::before {
  content: none;
}

#slash-autocomplete .slash-item:hover,
#slash-autocomplete .slash-item.is-active {
  background: var(--color-canvas-soft);
}

#slash-autocomplete .slash-cmd {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--color-ink);
}

#slash-autocomplete .slash-desc {
  font-size: 13px;
  color: var(--color-body);
}

/* The composer must be relatively-positioned so the absolute-positioned
 * autocomplete anchors to it. */
#composer {
  position: relative;
}

/* ─── Confirm-yes-no chips (slash-command confirmation flow) ──────────── */
.confirm-chips {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.confirm-chips .confirm-question {
  margin: 0;
  font-size: 15px;
  color: var(--color-ink);
}

.confirm-chips .confirm-buttons {
  display: flex;
  gap: var(--space-xs);
}

.confirm-chips .confirm-yes,
.confirm-chips .confirm-no {
  font: inherit;
  padding: var(--space-xxs) var(--space-base);
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-hairline);
  background: var(--color-canvas);
  color: var(--color-ink);
  cursor: pointer;
}

.confirm-chips .confirm-yes:hover,
.confirm-chips .confirm-no:hover {
  background: var(--color-canvas-soft);
}

.confirm-chips .confirm-yes {
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-canvas);
}

.confirm-chips .confirm-yes:hover {
  filter: brightness(1.1);
}

/* ─── Tool-call chips ─────────────────────────────────────────────────── */
.tool-call {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--color-canvas-soft);
  color: var(--color-body);
  border: 1px solid var(--color-hairline);
  padding: var(--space-xxs) var(--space-sm);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: 0;
  transition: border-color 120ms ease;
}

/* Thinking state — empty .spinner renders as a 7px gray dot. */
.tool-call .spinner:empty {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-muted-soft);
}

/* Done / error state — .spinner has text content (✓ or ✗); render as an
 * inline glyph with semantic color. Explicit resets prevent accidental
 * re-introduction of uppercase or tracking styles from future rule edits. */
.tool-call .spinner:not(:empty) {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-muted);
  letter-spacing: 0;
  text-transform: none;
}

.tool-call .result { opacity: 0.85; }

.tool-call.is-done {
  color: var(--color-ink);
}
.tool-call.is-done .spinner:not(:empty) { color: var(--color-success); }

.tool-call.is-error {
  color: var(--color-error);
  border-color: var(--color-error);
  background: var(--color-canvas);
}
.tool-call.is-error .spinner:not(:empty) { color: var(--color-error); }

/* ─── Composer ─────────────────────────────────────────────────────────── */
/*
 * One unified rounded card. The textarea sits borderless on top, the round
 * orange Send button anchors the bottom-right. The form itself is the input
 * surface — no inner border, no separate button slab.
 */

#composer {
  display: grid;
  grid-template-columns: auto auto auto auto 1fr auto;
  grid-template-rows: 1fr auto;
  gap: var(--space-xs);
  align-items: end;
  width: calc(100% - var(--space-xl));
  max-width: 880px;
  margin: 0 auto var(--space-lg);
  padding: var(--space-base) var(--space-base) var(--space-sm);
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline-strong);
  border-radius: 24px;
  transition: border-color 120ms ease;
}

#composer textarea {
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  resize: none;
  min-height: 28px;
  max-height: 200px;
  padding: 0 var(--space-xs);
  background: transparent;
  color: var(--color-ink);
  border: none;
  outline: none;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: 0;
}

#composer textarea::placeholder { color: var(--color-muted-soft); }

/* Shared icon-button shell for the composer's row-2 controls. Both the
 * settings cog and the send arrow are 36px circles with a centered icon
 * drawn via mask-image (so the icon inherits the button's color, which
 * makes disabled states dim automatically). */
#composer button {
  grid-row: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  font-size: 0;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}

#composer button::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 18px 18px;
          mask-repeat: no-repeat;
          mask-position: center;
          mask-size: 18px 18px;
}

#composer button:active:not(:disabled) { transform: scale(0.94); }

/* Brain (model picker) — leftmost ghost button. Lucide-style `brain` icon.
 * Same shell + hover treatment as the settings cog. */
#composer #open-brain-picker {
  grid-column: 1;
  background: transparent;
  color: var(--color-muted);
}
#composer #open-brain-picker::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z'/><path d='M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z'/><path d='M15 13a4.5 4.5 0 0 1-3-4'/><path d='M17.599 6.5a3 3 0 0 0 .399-1.375'/><path d='M6.003 5.125A3 3 0 0 0 6.401 6.5'/><path d='M3.477 10.896a4 4 0 0 1 .585-.396'/><path d='M19.938 10.5a4 4 0 0 1 .585.396'/><path d='M6 18a4 4 0 0 1-1.967-.516'/><path d='M19.967 17.484A4 4 0 0 1 18 18'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z'/><path d='M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z'/><path d='M15 13a4.5 4.5 0 0 1-3-4'/><path d='M17.599 6.5a3 3 0 0 0 .399-1.375'/><path d='M6.003 5.125A3 3 0 0 0 6.401 6.5'/><path d='M3.477 10.896a4 4 0 0 1 .585-.396'/><path d='M19.938 10.5a4 4 0 0 1 .585.396'/><path d='M6 18a4 4 0 0 1-1.967-.516'/><path d='M19.967 17.484A4 4 0 0 1 18 18'/></svg>");
}
#composer #open-brain-picker:hover {
  background: var(--color-canvas-soft);
  color: var(--color-ink);
}

/* Settings cog — ghost button after the brain. Lucide `settings` icon.
 * Soft canvas-soft hover ring, no fill at rest. */
#composer #open-settings {
  grid-column: 3;
  background: transparent;
  color: var(--color-muted);
}

#composer #open-settings::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><circle cx='12' cy='5' r='2'/><circle cx='12' cy='12' r='2'/><circle cx='12' cy='19' r='2'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'><circle cx='12' cy='5' r='2'/><circle cx='12' cy='12' r='2'/><circle cx='12' cy='19' r='2'/></svg>");
}

/* Composer popup menu — anchored above the ⋯ button by JS. Floats over
 * the chat surface; click-outside dismisses. */
#composer-menu {
  position: fixed;
  z-index: 100;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#composer-menu[hidden] { display: none; }
#composer-menu button,
#composer-menu a {
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 12px;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--color-ink);
  text-decoration: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
}
#composer-menu button:hover,
#composer-menu a:hover { background: var(--color-canvas-soft); }

#composer #open-settings:hover {
  background: var(--color-canvas-soft);
  color: var(--color-ink);
}

/* Send button — Cursor Orange disc on the right of the action row. */
#composer #send {
  grid-column: 6;
  background: var(--color-primary);
  color: var(--color-on-primary);
}

#composer #send::before {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5 12l7-7 7 7'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M12 19V5M5 12l7-7 7 7'/></svg>");
}

#composer #send:hover:not(:disabled) { background: var(--color-primary-active); }

#composer #send:disabled {
  background: var(--color-surface-strong);
  color: var(--color-muted-soft);
  cursor: not-allowed;
}


/* ─── Settings dialog ──────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  background: var(--color-surface-card);
  color: var(--color-ink);
  max-width: 540px;
  width: calc(100% - 32px);
  font-family: var(--font-display);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
}

dialog h2 {
  margin: 0 0 var(--space-lg) 0;
  font-size: 24px;
  font-weight: 400;
  color: var(--color-ink);
}

dialog h3 {
  margin: 0 0 var(--space-xs) 0;
  font-size: 16px;
  font-weight: 400;
  color: var(--color-ink);
}

dialog p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-body);
  margin: var(--space-xs) 0;
}

/* Inline code chips (e.g. "chrome://" inside the WebGPU help text). */
dialog code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--color-surface-strong);
  color: var(--color-ink);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

/* Model row redesign — caption-uppercase "MODEL" label sits above a
 * borderless monospace value. The maud HTML still ships
 *   <p>Model: <code>...</code></p>
 * so we hide the literal "Model: " text by zeroing font-size on the <p>
 * and rebuild the layout around the <code> child. */
dialog p:has(> code) {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 var(--space-base);
  font-size: 0;
}

dialog p:has(> code)::before {
  content: 'Model';
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  color: var(--color-muted);
}

dialog p > code {
  font-size: 13px;
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-md);
  padding: var(--space-xs) var(--space-sm);
  word-break: break-all;
  color: var(--color-ink);
}

/* button-secondary — neutral dialog button. Tabs + copy-url have their own. */
dialog button:not(.tab):not(.copy-url) {
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline-strong);
  color: var(--color-ink);
  border-radius: var(--radius-md);
  padding: 0 16px;
  height: 38px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

dialog button:not(.tab):not(.copy-url):hover { border-color: var(--color-ink); }

/* Action row sits at the bottom of the dialog: the primary Load model button
 * pushed left, secondaries floating right. We can't restructure the maud
 * HTML, so we anchor on document order — first non-tab/copy button is the
 * primary, the next two are secondaries. */
dialog #load-model {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-color: var(--color-primary);
  margin: var(--space-lg) var(--space-xs) 0 0;
  min-width: 130px;
}

dialog #load-model:hover {
  background: var(--color-primary-active);
  border-color: var(--color-primary-active);
}

dialog #load-model:disabled {
  background: var(--color-surface-strong);
  color: var(--color-muted);
  border-color: var(--color-hairline-strong);
  cursor: not-allowed;
}

dialog #clear-convo,
dialog button[value="close"] {
  margin: var(--space-lg) 0 0 var(--space-xs);
}

.help {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 0;
}

/* ─── Load-progress card ───────────────────────────────────────────────── */
/*
 * Inserted by gizza-app.js while the model downloads. The runtime emits a
 * verbose stage message (e.g. "Fetching param cache[4/30]: 126MB fetched.
 * 15% completed, 11 secs elapsed.") which previously got stuffed into the
 * Load model button text and ballooned it. Now the button stays terse and
 * the message lives here, alongside a thin orange progress bar.
 */
.progress-card {
  margin: var(--space-base) 0 0;
  padding: var(--space-sm) var(--space-base);
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* When the progress card occupies the empty-state slot, mirror the
 * composer's outer geometry so the two cards align vertically. The empty
 * state's inherited padding/uppercase tracker styling doesn't fit a
 * paragraph-length status string, so reset that too. */
.empty:has(.progress-card) {
  padding: 0;
  margin-inline: calc(-1 * var(--sa-space-6));
  text-transform: none;
  letter-spacing: normal;
}
.empty .progress-card {
  /* Match the composer's effective outer width. Composer sits inside
   * sa-chat's `[part="composer"]` (24px horizontal padding) and then sets
   * its own `width: calc(100% - 32px)`. So the composer card is
   * sa-chat-width − 48 − 32 = sa-chat-width − 80. The .empty wrapper
   * already escapes the messages-area 24px padding via negative margin,
   * so its 100% equals sa-chat-width; subtract 80 here. */
  width: calc(100% - var(--sa-space-6) * 2 - var(--space-xl));
  max-width: 880px;
  margin: 0 auto;
  background: var(--color-surface-card);
}

.progress-stage {
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.45;
  color: var(--color-body);
  text-transform: none;
  letter-spacing: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.progress-bar {
  position: relative;
  height: 4px;
  background: var(--color-surface-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width 200ms ease;
}

/* Indeterminate state — pre-percent runtime stages. A short orange chip
 * scans across the track. */
.progress-bar.is-indeterminate .progress-bar-fill {
  width: 32%;
  animation: progress-indeterminate 1.4s ease-in-out infinite;
}

@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.progress-card.is-error {
  background: color-mix(in srgb, var(--color-error) 6%, var(--color-canvas-soft));
  border-color: color-mix(in srgb, var(--color-error) 35%, var(--color-hairline));
}

.progress-card.is-error .progress-stage { color: var(--color-error); }
.progress-card.is-error .progress-bar { display: none; }

/* ─── WebGPU instruction panel ─────────────────────────────────────────── */

#webgpu-warning {
  position: relative;
  margin: var(--space-base) 0 var(--space-md);
  padding: var(--space-md) var(--space-base) var(--space-base);
  background: var(--color-canvas-soft);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
}

#webgpu-warning::before {
  content: 'Setup';
  position: absolute;
  top: -10px;
  left: var(--space-base);
  background: var(--color-surface-card);
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  padding: 3px 10px;
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-pill);
}

#webgpu-warning h3 { margin: 0 0 var(--space-xs) 0; }

#webgpu-warning ol {
  font-size: 13px;
  line-height: 1.6;
  padding-left: 20px;
  margin: var(--space-xs) 0;
}

#webgpu-warning li {
  margin: var(--space-xxs) 0;
  color: var(--color-body);
}

#webgpu-warning code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--color-surface-card);
  border: 1px solid var(--color-hairline);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

#webgpu-warning a {
  color: var(--color-ink);
  text-decoration: underline;
  text-decoration-color: var(--color-hairline-strong);
  text-underline-offset: 3px;
}

#webgpu-warning a:hover { text-decoration-color: var(--color-ink); }

/* Tabs — editorial caption-uppercase row with hairline underline. */
.tabs {
  display: flex;
  gap: var(--space-base);
  margin: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-hairline);
  flex-wrap: wrap;
}

.tabs .tab {
  background: transparent;
  border: none;
  color: var(--color-muted);
  padding: var(--space-xs) 0;
  margin: 0;
  height: auto;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.88px;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  border-radius: 0;
  transition: color 120ms ease, border-color 120ms ease;
}

.tabs .tab:hover { color: var(--color-ink); }

.tabs .tab.active {
  color: var(--color-ink);
  border-bottom-color: var(--color-ink);
}

.tab-panel[hidden] { display: none; }

/* Copyable URL pill (chrome://flags, about:config — browsers block these
 * as anchor hrefs). JetBrains Mono, surface-strong fill, hairline-on-hover. */
.copy-url {
  display: inline-block;
  background: var(--color-surface-strong);
  color: var(--color-ink);
  border: 1px solid transparent;
  padding: 1px 8px;
  margin: 0 2px;
  height: auto;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0;
  cursor: copy;
  transition: border-color 120ms ease, background 120ms ease;
}

.copy-url:hover { border-color: var(--color-ink); }

.copy-url.copied {
  background: var(--color-primary);
  color: var(--color-on-primary);
  cursor: default;
}

/* ─── Markdown-rendered assistant bubbles ──────────────────────────────── */
/*
 * Assistant content goes through marked.parse() so `<p>`, `<ul>`, `<pre>`,
 * `<code>`, etc. all show up inside .bubble.assistant .text.markdown. The
 * parent bubble keeps `white-space: pre-wrap` for plain-text fallback; we
 * reset it here so block elements lay out normally and code fences keep their
 * own monospace formatting.
 */
.bubble.assistant .text.markdown {
  white-space: normal;
  display: block;
}
.bubble.assistant .text.markdown > *:first-child { margin-top: 0; }
.bubble.assistant .text.markdown > *:last-child { margin-bottom: 0; }
.bubble.assistant .text.markdown p { margin: 0.4em 0; }
.bubble.assistant .text.markdown ul,
.bubble.assistant .text.markdown ol { margin: 0.4em 0; padding-left: 1.4em; }
.bubble.assistant .text.markdown code {
  font-family: var(--sa-font-mono, ui-monospace, "SF Mono", Menlo, monospace);
  font-size: 0.92em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1em 0.32em;
  border-radius: 4px;
}
.bubble.assistant .text.markdown pre {
  margin: 0.6em 0;
  padding: 0.8em;
  border-radius: 6px;
  overflow-x: auto;
  /* highlight.js github-dark.css supplies its own background; we just need
   * the padding/scroll. */
}
.bubble.assistant .text.markdown pre code {
  background: transparent;
  padding: 0;
  font-size: 0.88em;
  line-height: 1.5;
}

/* ─── Settings model picker ────────────────────────────────────────────── */
.model-picker-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs, 0.4em);
  margin: 0.4em 0 0.6em;
}
.model-picker-row label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink);
  opacity: 0.75;
}
.model-picker-row select {
  font: inherit;
  padding: 0.45em 0.6em;
  border: 1px solid var(--color-hairline);
  border-radius: 6px;
  background: var(--color-surface-card);
  color: var(--color-ink);
}

/* ─── Mobile ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  sa-header .brand h1 { font-size: 30px; }
  sa-header .brand-logo { width: 110px; height: 110px; }
  #composer { width: calc(100% - var(--space-lg)); padding: var(--space-sm) var(--space-sm) var(--space-xs); }
  .bubble { max-width: 92%; }
  dialog { padding: var(--space-lg); }
  dialog h2 { font-size: 22px; }
}

.tool-attachment {
    display: block;
    max-width: 100%;
    max-height: 240px;
    margin-top: 0.5rem;
    border-radius: 4px;
}

/* ─── Upload chips ─────────────────────────────────────────────────────── */
/* The chip strip lives above the textarea inside #composer. Hidden when
 * empty (no padding, no border) so the composer doesn't show extra
 * vertical space when there are no pending uploads. */

#composer #upload-chips {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: 0 var(--space-xs);
  margin-bottom: var(--space-xs);
}
#composer #upload-chips.empty {
  display: none;
}
/* Bump the textarea down to row 2 (chips take row 1). */
#composer:has(#upload-chips:not(.empty)) textarea {
  grid-row: 2;
}

#composer .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--color-hairline-strong);
  border-radius: 14px;
  background: var(--color-surface-card);
  color: var(--color-ink);
  font-size: 13px;
  line-height: 1.2;
  max-width: 240px;
}
#composer .chip .chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
#composer .chip .remove {
  /* Override the inherited 36px composer-button shell. */
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin: 0;
}
#composer .chip .remove:hover {
  color: var(--color-ink);
  background: var(--color-hairline);
}

#composer .upload-error {
  color: var(--color-on-primary, #b00020);
  font-size: 13px;
  padding: 4px 8px;
}

/* ─── Paperclip attach button ──────────────────────────────────────────── */
/* Inherits the 36px circle shell from the existing #composer button rules.
 * Just provide the icon mask. */
#composer #attach {
  grid-row: 2;
  grid-column: 4;
}
#composer #attach::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M21.44 11.05l-9.19 9.19a6 6 0 1 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66L9.41 17.41a2 2 0 0 1-2.83-2.83l8.49-8.49'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M21.44 11.05l-9.19 9.19a6 6 0 1 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66L9.41 17.41a2 2 0 0 1-2.83-2.83l8.49-8.49'/></svg>");
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: contain;
          mask-size: contain;
}

/* ─── Drop overlay ─────────────────────────────────────────────────────── */
/* Full-page dimmer + "Drop image or video to attach" caption. The overlay
 * is created by gizza-app.js and toggled via the [hidden] attribute. */

#drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--color-canvas) 70%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
#drop-overlay[hidden] { display: none; }
#drop-overlay .drop-overlay-inner {
  padding: var(--space-base) var(--space-lg);
  border: 2px dashed var(--color-hairline-strong);
  border-radius: 16px;
  background: var(--color-surface-card);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 18px;
}

/* ─── Empty-state CTA ──────────────────────────────────────────────────── */
/* Primary "Choose a model" button injected by rewriteEmptyState() in
 * gizza-app.js. Replaces the static text placeholder in <div class="empty">. */

.empty-state-cta {
    background: var(--color-primary);
    color: var(--color-on-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    padding: 0 24px;
    height: 44px;
    font-family: var(--font-display);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 120ms ease;
}
.empty-state-cta:hover { background: var(--color-primary-active); }

/* When the empty state is just a sentence with an inline "choose a model"
 * link, ditch the uppercase tracker styling so the prose reads naturally. */
.empty .empty-msg {
    display: inline;
    color: var(--color-muted);
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: normal;
    text-transform: none;
}
.empty-state-link {
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    color: var(--color-primary);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.empty-state-link:hover { color: var(--color-primary-active); }

/* ─── Cycling "thinking…" placeholder in an empty assistant bubble ────── */
.thinking {
    display: inline-flex;
    align-items: baseline;
    gap: 2px;
    color: var(--color-muted);
    font-style: italic;
}
.thinking-word {
    display: inline-block;
    animation: thinking-fade 1.5s ease-in-out infinite;
}
.thinking-dots {
    display: inline-block;
    animation: thinking-pulse 1.2s ease-in-out infinite;
}
@keyframes thinking-fade {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}
@keyframes thinking-pulse {
    0%, 100% { transform: translateY(0); opacity: 0.5; }
    50%      { transform: translateY(-1px); opacity: 1; }
}

/* ─── { } button next to a formatted slash-skill answer ────────────────── */
.raw-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    padding: 1px 6px;
    font-family: var(--sa-mono, ui-monospace, "SF Mono", monospace);
    font-size: 11px;
    font-weight: 600;
    background: var(--color-canvas-soft);
    color: var(--color-muted);
    border: 1px solid var(--color-hairline);
    border-radius: var(--radius-sm);
    cursor: pointer;
    vertical-align: baseline;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.raw-toggle:hover {
    background: var(--color-surface-strong);
    color: var(--color-ink);
    border-color: var(--color-hairline-strong);
}

/* ─── Raw-JSON popup dialog ────────────────────────────────────────────── */
dialog.raw-popup {
    width: min(720px, 90vw);
    max-height: 80vh;
    padding: 0;
    border: 1px solid var(--color-hairline-strong);
    border-radius: var(--radius-lg);
    background: var(--color-surface-card);
    color: var(--color-ink);
    font-family: var(--font-display);
    box-shadow: 0 24px 60px rgba(0,0,0,0.18);
    overflow: hidden;
}
dialog.raw-popup::backdrop { background: rgba(0,0,0,0.4); }
.raw-popup-header {
    display: flex;
    align-items: center;
    gap: var(--space-base);
    padding: var(--space-sm) var(--space-base);
    border-bottom: 1px solid var(--color-hairline);
    background: var(--color-canvas-soft);
}
.raw-popup-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 500;
    color: var(--color-ink);
    flex: 0 0 auto;
}
.raw-popup-tabs {
    flex: 1 1 auto;
    display: flex;
    gap: 4px;
}
.raw-popup-tab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--color-muted);
    cursor: pointer;
    transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}
.raw-popup-tab:hover { color: var(--color-ink); }
.raw-popup-tab.is-active {
    color: var(--color-ink);
    background: var(--color-surface-card);
    border-color: var(--color-hairline);
    font-weight: 500;
}
.raw-popup-close {
    background: transparent;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--color-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.raw-popup-close:hover { color: var(--color-ink); background: var(--color-surface-strong); }
.raw-popup-body {
    margin: 0;
    padding: var(--space-base);
    max-height: 60vh;
    overflow: auto;
    font-family: var(--sa-mono, ui-monospace, "SF Mono", monospace);
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-ink);
    background: var(--color-canvas);
    white-space: pre;
}
.raw-popup-body code {
    font-family: inherit;
    background: none;
    padding: 0;
}
.raw-popup-footer {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-base);
    border-top: 1px solid var(--color-hairline);
    background: var(--color-canvas-soft);
}
.raw-popup-copy {
    padding: 6px 14px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    background: var(--color-primary);
    color: var(--color-on-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
}
.raw-popup-copy:hover { background: var(--color-primary-active); border-color: var(--color-primary-active); }
.raw-popup-copied {
    font-size: 12px;
    color: var(--color-success);
}

/* Standalone tools interlink (SEO + discoverability). */
.gizza-tools { max-width: 720px; margin: 24px auto; padding: 0 16px; }
.gizza-tools h2 { font-size: 16px; margin: 0 0 8px; }
.gizza-tools ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.gizza-tools a { display: inline-block; padding: 6px 12px; border: 1px solid #d1d5db;
  border-radius: 999px; text-decoration: none; color: #4f46e5; font-size: 14px; }
.gizza-tools a:hover { background: #eef2ff; }
