/* =====================================================================================================================================
   Savannah AI — Chat UI revamp v1 ("cinematic graphite glass")
   Loaded AFTER styles.css. It (1) re-points the design tokens at the new palette and one radius scale, (2) styles the unified composer,
   glass dropdowns, header controls, messages and empty/loading/error states. No markup is invented here: every selector below is a class the
   real views already emit (js/views/savannah.js, js/voiceUi.js, js/glassSelect.js, js/chatHeader.js).

   Palette (brief):  Smoky Black var(--sv-app-bg) · graphite Drab var(--sv-border) · off-white var(--sv-text), plus muted charcoal / stone grey.
   Glass rules:      one blur level (--glass-blur, 14px; 8px on phones), thin 1px borders, a top highlight, a realistic two-layer shadow.
                     Surfaces stay >= 72% opaque so text never sits on a washed-out wash; without backdrop-filter support (or with
                     prefers-reduced-transparency) they fall back to solid graphite-charcoal so contrast is identical.
   ===================================================================================================================================== */

:root {
  /* ---- palette ---- */
  --c-black: var(--sv-app-bg);
  --c-graphite: var(--sv-border);
  --c-offwhite: var(--sv-text);
  --charcoal: var(--sv-composer-bg);
  --charcoal-2: var(--sv-elevated);
  --c-text-2: var(--sv-text-3);          /* secondary text: 7.9:1 on var(--sv-app-bg) */
  --c-text-3: var(--sv-text-3);      /* tertiary text / placeholders: 5.6:1 on var(--sv-app-bg), 4.6:1 on the glass */

  --c-black: var(--c-black);
  --c-white: var(--sv-text);
  --c-grey: var(--c-text-2);
  --silver-border: rgba(var(--sv-text-rgb), 0.16);
  --bg-canvas: var(--c-black);
  --bg-surface: var(--sv-composer-bg);
  --bg-surface-raised: var(--charcoal);
  --bg-surface-hover: var(--charcoal-2);
  --border-subtle: rgba(var(--sv-text-rgb), 0.12);
  --border-strong: rgba(var(--sv-text-rgb), 0.22);
  --text-primary: var(--c-offwhite);
  --text-secondary: var(--c-text-2);
  --text-tertiary: var(--c-text-3);
  --accent: var(--c-offwhite);
  --accent-hover: var(--c-white);
  --accent-dim: rgba(var(--sv-text-rgb), 0.09);
  --success: var(--sv-text-2);
  --warning: var(--sv-text-2);
  --danger: var(--sv-text-3);

  /* ---- one radius scale (was 2/3/4px squares + assorted 10/12/999px) ---- */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  /* ---- glass ---- */
  --glass-fill: rgba(var(--sv-border-rgb), 0.34);            /* graphite drab, translucent */
  --glass-fill-strong: rgba(var(--sv-border-rgb), 0.86);     /* popovers: needs to be readable over message text */
  --glass-solid: var(--sv-elevated);                          /* no-backdrop-filter fallback */
  --glass-border: rgba(var(--sv-text-rgb), 0.16);
  --glass-border-focus: rgba(var(--sv-text-rgb), 0.42);
  --glass-highlight: inset 0 1px 0 rgba(var(--sv-text-rgb), 0.10);
  --glass-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 14px 36px -10px rgba(0, 0, 0, 0.65);
  --glass-shadow-pop: 0 2px 4px rgba(0, 0, 0, 0.5), 0 22px 48px -12px rgba(0, 0, 0, 0.75);
  --glass-blur: blur(14px) saturate(1.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: var(--glass-shadow-pop);

  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  --dur-fast: 140ms;
  --dur: 220ms;

  --chat-col: 760px;       /* readable measure for the conversation + composer */
  --font-chat: var(--font-brand);
}

/* ------------------------------------------------------------------------------------------------------------------------------------
   Canvas + shell
   ------------------------------------------------------------------------------------------------------------------------------------ */
body { background: var(--c-black); }
body.view-ai {
  background:
    none,
    var(--c-black);
  background-attachment: fixed;
}

/* The conversation screen is pinned (header on top, thread filling, composer docked) on every viewport, not only phones. */
body.view-ai { overflow: hidden; }
body.view-ai .app-shell { height: var(--app-height, 100dvh); min-height: 0; overflow: hidden; }
body.view-ai .main-column { height: var(--app-height, 100dvh); min-height: 0; }
body.view-ai main#main { flex: 1; min-height: 0; max-width: none; padding: 0; margin: 0; display: flex; flex-direction: column; overflow: hidden; }
body.view-ai .chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
body.view-ai .chat-panel > .section:first-child { flex: 1; min-height: 0; margin: 0; display: flex; flex-direction: column; }
body.view-ai .chat-panel > .section:first-child > h3 { display: none; }
body.view-ai .chat-panel > .section:first-child > div { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Desktop: the page also carries the chat list above the conversation, so main scrolls and the conversation is a fixed-height stage. */
@media (min-width: 861px) {
  body.view-ai { overflow: auto; }
  body.view-ai main#main { overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; padding: 0 var(--space-5) var(--space-5); }
  body.view-ai main#main > * { order: 2; }                         /* intro + chat list sit below the conversation */
  body.view-ai main#main > .chat-header, body.view-ai main#main > .savannah-tabs, body.view-ai main#main > .chat-panel, body.view-ai main#main > .build-panel { order: 0; width: 100%; }
  body.view-ai main#main > .chat-header, body.view-ai main#main > .savannah-tabs, body.view-ai .chat-panel { max-width: calc(var(--chat-col) + 220px); margin-inline: auto; }
  body.view-ai .chat-panel { height: max(560px, calc(var(--app-height, 100dvh) - 176px)); flex: none; overflow: hidden; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
}

/* ------------------------------------------------------------------------------------------------------------------------------------
   Header: premium circular controls
   ------------------------------------------------------------------------------------------------------------------------------------ */
body.view-ai .chat-header, .mobile-start .start-header {
  flex: none; margin: 0; background: transparent; border-bottom: 0;
  padding: calc(var(--space-3) + var(--safe-top)) calc(var(--space-4) + var(--safe-right)) var(--space-2) calc(var(--space-4) + var(--safe-left));
  max-width: calc(var(--chat-col) + 220px); width: 100%; margin-inline: auto;
}
.chat-header-title { font-family: var(--font-chat); font-weight: 600; letter-spacing: -0.005em; font-size: var(--text-base); color: var(--text-primary); }
.chat-header-project { font-family: var(--font-chat); color: var(--text-secondary); }

.orb-button, .menu-button, .chat-header-menu-toggle {
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%;
  background: var(--glass-fill); border: 1px solid var(--glass-border); color: var(--text-primary);
  box-shadow: var(--glass-highlight), var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast), border-color var(--dur-fast);
}
.orb-button:hover, .menu-button:hover, .chat-header-menu-toggle:hover { border-color: var(--glass-border-focus); background: rgba(var(--sv-border-rgb), 0.5); }
.orb-button:active, .menu-button:active, .chat-header-menu-toggle:active { transform: scale(0.94); }
.usage-orb-label { font-family: var(--font-chat); font-size: var(--text-xs); }

.chat-menu {
  min-width: 208px; padding: 6px; border-radius: var(--radius-lg);
  background: var(--glass-fill-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-highlight), var(--glass-shadow-pop);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  transform-origin: top right; animation: v1-pop-down var(--dur) var(--ease-out);
}
.chat-menu-item { font-family: var(--font-chat); font-size: var(--text-sm); border-radius: var(--radius-sm); transition: background-color var(--dur-fast); }
.chat-menu-item:hover, .chat-menu-item:focus-visible { background: rgba(var(--sv-text-rgb), 0.09); }

/* Chat | Build tabs: quiet underline, aligned to the conversation column. */
body.view-ai .savannah-tabs {
  flex: none; margin: 0 auto; width: 100%; max-width: calc(var(--chat-col) + 220px); gap: var(--space-4);
  padding: 0 calc(var(--space-4) + var(--safe-right)) 0 calc(var(--space-4) + var(--safe-left)); border-bottom: 1px solid var(--border-subtle);
}
.savannah-tab-btn { font-family: var(--font-chat); font-size: var(--text-sm); letter-spacing: 0.02em; min-height: 44px; }

/* ------------------------------------------------------------------------------------------------------------------------------------
   Conversation canvas
   ------------------------------------------------------------------------------------------------------------------------------------ */
.chat-panel { font-family: var(--font-chat); }
.chat-panel .chat-thread {
  flex: 1; min-height: 0; max-height: none; width: 100%; max-width: calc(var(--chat-col) + 2 * var(--space-4)); margin: 0 auto;
  background: transparent; border: 0; border-radius: 0; gap: var(--space-4); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: var(--space-4) calc(var(--space-4) + var(--safe-right)) calc(var(--dock-h, 168px) + var(--space-4)) calc(var(--space-4) + var(--safe-left));
  scroll-padding-bottom: calc(var(--dock-h, 168px) + var(--space-4));
  scrollbar-width: thin; scrollbar-color: rgba(var(--sv-text-rgb), 0.22) transparent;
}
.chat-panel > .section:first-child > div > .hint { flex: none; text-align: center; margin: 0; padding: var(--space-1) var(--space-4); color: var(--text-secondary); }
.chat-panel > .section:first-child > div > .hint.error { color: var(--danger); }

.chat-message {
  max-width: 86%; padding: 12px 16px; border-radius: var(--radius-lg); font-size: 0.96875rem; line-height: 1.6;
  animation: v1-rise var(--dur) var(--ease-out) both;
}
.chat-message .chat-message-meta { text-transform: none; letter-spacing: 0.01em; font-size: var(--sv-type-tool-description-size); color: var(--text-tertiary); margin-bottom: 4px; }
/* User: a rounded graphite glass container, tail corner tightened. */
.chat-message.role-user {
  background: rgba(var(--sv-border-rgb), 0.42); border: 1px solid var(--glass-border); border-bottom-right-radius: 8px; box-shadow: var(--glass-highlight);
}
/* Assistant: no bubble — elegant open text on the canvas, with a hairline brand tick. */
.chat-message.role-assistant {
  align-self: flex-start; max-width: 100%; padding: 2px 4px 2px 18px; background: transparent; border: 0; border-radius: 0; position: relative;
  color: var(--text-primary);
}
.chat-message.role-assistant::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: linear-gradient(to bottom, rgba(var(--sv-text-rgb), 0.55), rgba(var(--sv-text-rgb), 0.06));
}
.chat-message.role-system { max-width: 100%; border-radius: var(--radius-md); background: rgba(var(--sv-composer-bg-rgb), 0.8); border: 1px solid var(--border-subtle); }
.chat-message.role-system.diagnostic { border-color: rgba(var(--sv-text-2-rgb), 0.5); background: rgba(var(--sv-text-2-rgb), 0.10); }
.chat-message-body { overflow-wrap: anywhere; }
.chat-message .chat-message-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat-message .chat-message-actions .btn {
  min-height: 34px; padding: 0 12px; font-family: var(--font-chat); font-size: var(--sv-type-tool-label-size); border-radius: var(--radius-pill);
  background: transparent; color: var(--text-secondary); border: 1px solid var(--border-subtle);
  transition: color var(--dur-fast), border-color var(--dur-fast), background-color var(--dur-fast);
}
.chat-message .chat-message-actions .btn:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--accent-dim); }

/* Empty state */
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; margin: auto; text-align: center; gap: 6px; padding: var(--space-6) var(--space-4); animation: v1-rise 420ms var(--ease-out) both; }
.chat-empty-mark { width: auto; height: 96px; object-fit: contain; margin-bottom: var(--space-2); }
.chat-empty-brand { display: block; font-family: var(--font-brand); font-size: var(--text-xl); letter-spacing: 0.14em; color: var(--text-primary); }
.chat-empty-tagline { display: block; font-size: var(--text-xs); letter-spacing: 0.22em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: var(--space-3); }
.chat-empty-hint { max-width: 34ch; margin: 0; color: var(--text-secondary); line-height: 1.6; font-size: var(--text-sm); }

/* ------------------------------------------------------------------------------------------------------------------------------------
   Composer dock
   ------------------------------------------------------------------------------------------------------------------------------------ */
.chat-panel.has-dock .composer-dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: 0 calc(var(--space-4) + var(--safe-right)) calc(var(--space-3) + var(--safe-bottom)) calc(var(--space-4) + var(--safe-left));
  background: var(--sv-chat-bg);
}
.chat-panel.has-dock .composer-dock > * { pointer-events: auto; width: 100%; max-width: var(--chat-col); }
.keyboard-open .chat-panel.has-dock .composer-dock { padding-bottom: var(--space-2); }

.composer {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 10px 10px 14px; margin: 0;
  background: var(--glass-fill); border: 1px solid var(--glass-border); border-radius: var(--radius-xl);
  box-shadow: var(--glass-highlight), var(--glass-shadow);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.composer:focus-within { border-color: var(--glass-border-focus); box-shadow: var(--glass-highlight), var(--glass-shadow), 0 0 0 3px rgba(var(--sv-text-rgb), 0.08); }
.composer[data-voice-recording="true"], .composer:has([data-action="stop"]) { border-color: rgba(var(--sv-text-3-rgb), 0.55); }

.composer-field { display: flex; min-width: 0; }
.composer-input {
  display: block; width: 100%; min-height: 28px; max-height: 188px; margin: 0; padding: 6px 4px 4px 2px; resize: none; overflow-y: auto;
  background: transparent; border: 0; border-radius: 0; box-shadow: none; outline: none; color: var(--text-primary);
  font-family: var(--font-chat); font-size: var(--sv-type-body-secondary-size); line-height: 1.5; scrollbar-width: thin;
  field-sizing: content; /* progressive: auto-grow without JS where supported; the JS height fit still applies elsewhere */
}
.composer-input::placeholder { color: var(--c-text-3); opacity: 1; }
.composer-input:focus, .composer-input:focus-visible { outline: none; box-shadow: none; }
@media (max-width: 860px) { .composer-input { font-size: var(--sv-type-body-secondary-size); } } /* >=16px stops iOS Safari zooming the page on focus */

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-width: 0; }
.composer-bar-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; flex-wrap: nowrap; }

/* Circular controls (plus) */
.composer-circle {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border-radius: 50%;
  background: rgba(var(--sv-text-rgb), 0.06); border: 1px solid var(--glass-border); color: var(--text-primary); cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast), border-color var(--dur-fast);
}
.composer-circle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-circle:hover { background: rgba(var(--sv-text-rgb), 0.12); border-color: var(--glass-border-focus); }
.composer-circle:active { transform: scale(0.92); }
.composer-circle[aria-expanded="true"] { background: rgba(var(--sv-text-rgb), 0.16); }
.composer-circle[aria-expanded="true"] svg { transform: rotate(45deg); }
.composer-circle svg { transition: transform var(--dur) var(--ease-out); }

/* ONE contextual action button: mic <-> send <-> stop <-> busy, icons cross-fade in place. */
.composer-action {
  position: relative; flex: none; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid transparent; cursor: pointer;
  background: rgba(var(--sv-text-rgb), 0.10); color: var(--text-primary); border-color: var(--glass-border);
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out), border-color var(--dur);
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.composer-action:hover { background: rgba(var(--sv-text-rgb), 0.18); }
.composer-action:active { transform: scale(0.92); }
.composer-action:disabled { cursor: default; opacity: 0.55; transform: none; }
.composer-action .ca-icon {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transform: scale(0.6) rotate(-25deg);
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); pointer-events: none;
}
.composer-action .ca-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-action[data-action="voice"] .ca-mic,
.composer-action[data-action="send"] .ca-send,
.composer-action[data-action="stop"] .ca-stop,
.composer-action[data-action="busy"] .ca-busy { opacity: 1; transform: none; }
.composer-action[data-action="send"] { background: var(--c-offwhite); color: var(--c-black); border-color: transparent; box-shadow: 0 6px 18px -6px rgba(var(--sv-text-rgb), 0.45); }
.composer-action[data-action="send"]:hover { background: var(--c-white); }
.composer-action[data-action="stop"] { background: var(--danger); color: var(--c-black); border-color: transparent; animation: v1-rec 1.6s ease-in-out infinite; }
.composer-action[data-action="stop"] .ca-stop svg { fill: currentColor; stroke: none; }
.composer-action[data-action="busy"] .ca-busy svg { animation: v1-spin 0.9s linear infinite; }

/* Glass chips (model + voice language) */
.glass-select { position: relative; display: inline-flex; min-width: 0; }
.glass-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-height: 40px; padding: 0 8px 0 14px; border-radius: var(--radius-pill);
  background: rgba(var(--sv-text-rgb), 0.06); border: 1px solid var(--glass-border); color: var(--text-primary); cursor: pointer;
  font-family: var(--font-chat); font-size: var(--sv-type-tool-label-size); font-weight: 500; letter-spacing: 0.01em; white-space: nowrap;
  transition: background-color var(--dur-fast), border-color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
}
.glass-chip:hover { background: rgba(var(--sv-text-rgb), 0.12); border-color: var(--glass-border-focus); }
.glass-chip:active { transform: scale(0.97); }
.glass-chip:disabled { opacity: 0.5; cursor: default; }
.glass-chip-label { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.glass-chip-caret { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; color: var(--text-secondary); }
.glass-chip-caret svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur) var(--ease-out); }
.glass-chip[aria-expanded="true"] .glass-chip-caret svg { transform: rotate(180deg); }
.lang-chip { padding-left: 12px; }
.lang-chip .glass-chip-label::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px; vertical-align: 1px; border-radius: 50%; background: var(--c-text-3); }

/* Popovers: model list, language list, attachment menu — one component, one look. */
.glass-popover, .attach-menu {
  position: absolute; z-index: 40; left: 0; bottom: calc(100% + 10px); min-width: 252px; max-width: min(340px, calc(100vw - 32px)); max-height: min(60vh, 420px); overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: var(--radius-lg);
  background: var(--glass-fill-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-highlight), var(--glass-shadow-pop);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  opacity: 0; transform: translateY(8px) scale(0.97); transform-origin: bottom left; pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur) var(--ease-out);
  scrollbar-width: thin;
}
.glass-popover[hidden], .attach-menu[hidden] { display: none; }
.glass-popover.open, .attach-menu.open, .attach-menu:not([hidden]) { opacity: 1; transform: none; pointer-events: auto; }
.attach-menu:not([hidden]) { animation: v1-pop-up var(--dur) var(--ease-out); } /* shown by toggling [hidden], so it animates in with a keyframe */
.glass-popover { font-family: var(--font-chat); }
.glass-option, .attach-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 8px 12px; text-align: left;
  background: transparent; border: 0; border-radius: var(--radius-md); color: var(--text-primary); cursor: pointer; font-family: var(--font-chat); font-size: var(--sv-type-subtitle-size);
  transition: background-color var(--dur-fast);
}
.glass-option:hover, .glass-option:focus-visible, .attach-menu-item:hover, .attach-menu-item:focus-visible { background: rgba(var(--sv-text-rgb), 0.10); outline: none; }
.glass-option:focus-visible, .attach-menu-item:focus-visible { box-shadow: inset 0 0 0 1.5px var(--glass-border-focus); }
.glass-option[aria-selected="true"] { background: rgba(var(--sv-text-rgb), 0.07); }
.glass-option-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.glass-option-name { font-weight: 600; letter-spacing: 0.01em; }
.glass-option-detail { font-size: var(--sv-type-tool-description-size); color: var(--text-secondary); line-height: 1.35; }
.glass-option-check { flex: none; width: 18px; height: 18px; color: var(--text-primary); opacity: 0; transition: opacity var(--dur-fast); }
.glass-option-check svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.glass-option[aria-selected="true"] .glass-option-check { opacity: 1; }
.glass-popover .voice-disclosure, .glass-popover .voice-tanglish-note, .glass-popover .hint {
  margin: 4px 6px 2px; padding-top: 8px; border-top: 1px solid var(--border-subtle); font-size: var(--sv-type-tool-description-size); line-height: 1.45; color: var(--text-secondary);
}
.plus-wrap { position: relative; display: inline-flex; flex: none; }
.attach-menu-item { justify-content: flex-start; gap: 12px; }
.attach-menu-icon { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(var(--sv-text-rgb), 0.08); }
.attach-menu-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-chip + .glass-popover, .glass-select:has(.lang-chip) .glass-popover { left: auto; right: 0; transform-origin: bottom right; }

/* Voice status strip (recording / transcribing / error) lives inside the composer, above the input. */
.composer-voice-strip { display: none; align-items: center; gap: 8px; min-height: 30px; padding: 2px 2px 4px; flex-wrap: wrap; }
.composer-voice-strip.active { display: flex; animation: v1-rise var(--dur) var(--ease-out) both; }
.composer-voice-strip .voice-status { flex: 1 1 auto; min-width: 0; margin: 0; color: var(--text-primary); font-family: var(--font-chat); font-size: var(--sv-type-tool-label-size); }
.composer-pill {
  min-height: 32px; padding: 0 14px; border-radius: var(--radius-pill); background: rgba(var(--sv-text-rgb), 0.08); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-family: var(--font-chat); font-size: var(--sv-type-tool-label-size); cursor: pointer; transition: background-color var(--dur-fast);
}
.composer-pill:hover { background: rgba(var(--sv-text-rgb), 0.16); }
.composer [hidden] { display: none !important; } /* component display rules (e.g. .voice-preview{display:flex}) must not defeat [hidden] */
.composer .state, .composer .output { margin: 0; }
.composer .state:empty, .composer .output:empty { display: none; }
.composer .state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 4px 2px; font-family: var(--font-chat); font-size: var(--sv-type-tool-label-size); line-height: 1.45; color: var(--text-secondary); }
.composer .state.error { color: var(--danger); }
.composer .state.success { color: var(--success); }
.composer .voice-preview { margin: 4px 2px 0; }

/* Attachments tray */
.composer-attachments { gap: 8px; margin: 0 0 6px; }
.attachment-card { border-radius: var(--radius-md); background: rgba(var(--sv-text-rgb), 0.07); border: 1px solid var(--glass-border); }
.attachment-card.attachment-error { border-color: rgba(var(--sv-text-3-rgb), 0.6); }


/* ------------------------------------------------------------------------------------------------------------------------------------
   Whole-app polish that rides on the new tokens (sidebar, drawers, modals, buttons keep their structure)
   ------------------------------------------------------------------------------------------------------------------------------------ */
.sidebar { background: rgba(var(--sv-composer-bg-rgb), 0.9); border-right: 1px solid var(--border-subtle); }
.btn { border-radius: var(--radius-pill); }
.btn.danger { color: var(--sv-text-2); } /* AA (>= 4.5:1) on the danger tint even over a hovered var(--sv-elevated) row */
.modal { border-radius: var(--radius-xl); background: var(--glass-fill-strong); border: 1px solid var(--glass-border); box-shadow: var(--glass-highlight), var(--glass-shadow-pop); }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select, textarea { border-radius: var(--radius-md); }

/* ------------------------------------------------------------------------------------------------------------------------------------
   Phones: lighter blur (mobile GPUs), tighter gutters, bottom-sheet popovers
   ------------------------------------------------------------------------------------------------------------------------------------ */
@media (max-width: 860px) {
  :root { --glass-blur: blur(8px) saturate(1.1); }
  .chat-panel.has-dock .composer-dock { padding-left: calc(var(--space-3) + var(--safe-left)); padding-right: calc(var(--space-3) + var(--safe-right)); }
  .composer { border-radius: 26px; padding: 8px 8px 8px 12px; }
  body.view-ai .chat-header, .mobile-start .start-header { padding-left: calc(var(--space-3) + var(--safe-left)); padding-right: calc(var(--space-3) + var(--safe-right)); }
  .chat-panel .chat-thread { padding-left: calc(var(--space-3) + var(--safe-left)); padding-right: calc(var(--space-3) + var(--safe-right)); }
  .chat-message { max-width: 90%; }
  .glass-popover, .attach-menu { max-width: calc(100vw - 2 * var(--space-3) - var(--safe-left) - var(--safe-right)); }
  .glass-select:has(.model-chip) .glass-popover { min-width: min(300px, calc(100vw - 32px)); }
  .glass-chip { padding-left: 12px; }
}
@media (max-width: 380px) {
  .lang-chip .glass-chip-label::before { display: none; }
  .glass-chip { font-size: var(--sv-type-tool-description-size); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .chat-empty-mark, .chat-empty-tagline { display: none; }
  .composer-input { max-height: 84px; }
}

/* ------------------------------------------------------------------------------------------------------------------------------------
   Motion
   ------------------------------------------------------------------------------------------------------------------------------------ */
@keyframes v1-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes v1-pop-down { from { opacity: 0; transform: translateY(-6px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes v1-pop-up { from { opacity: 0; transform: translateY(8px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes v1-spin{ to { transform: rotate(360deg); } }
@keyframes v1-rec { 0%, 100% { box-shadow: 0 0 0 0 rgba(var(--sv-text-3-rgb), 0.5); } 50% { box-shadow: 0 0 0 9px rgba(var(--sv-text-3-rgb), 0); } }

/* ------------------------------------------------------------------------------------------------------------------------------------
   Fallbacks
   ------------------------------------------------------------------------------------------------------------------------------------ */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .composer, .glass-popover, .attach-menu, .chat-menu, .modal { background: var(--glass-solid); }
}
@media (prefers-reduced-transparency: reduce) {
  .composer, .glass-popover, .attach-menu, .chat-menu, .modal { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .chat-message.role-user { background: var(--sv-border); }
}
@media (prefers-reduced-motion: reduce) {
  .chat-message, .chat-empty, .composer-voice-strip.active, .chat-menu { animation: none !important; }
  .composer-action[data-action="stop"] { animation: none !important; box-shadow: 0 0 0 4px rgba(var(--sv-text-3-rgb), 0.35); }
  .composer-action[data-action="busy"] .ca-busy svg { animation: none !important; }
  .glass-popover, .attach-menu { transform: none; }
}

/* Streaming reply: a live placeholder for the saved message. No animation (reduced-motion safe); neutral tokens only. */
.chat-message.streaming { border-style: dashed; }
.chat-message.streaming .chat-message-body { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.4em; }
.chat-message .chat-message-note { margin-top: 8px; font-size: var(--sv-type-tool-description-size); color: var(--c-grey); }
.chat-message .chat-message-note:empty { display: none; }
.chat-message .chat-message-actions .chat-stream-stop { min-height: 44px; min-width: 88px; }

/* Project Intelligence: the honest one-line "what was retrieved" under a reply's header, and the Project understanding panel. */
.chat-message .chat-context-note { margin: 2px 0 6px; font-size: var(--sv-type-tool-description-size); color: var(--c-grey); }
.chat-message .chat-context-note:empty { display: none; }
.project-intel-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; }
.project-intel-facts dt { color: var(--c-grey); font-size: var(--sv-type-tool-description-size); }
.project-intel-facts dd { margin: 0; overflow-wrap: anywhere; }
.project-intel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.project-intel-actions button, .project-intel-inspect-row button { min-height: 44px; }
.project-intel-inspect-row { display: flex; gap: 8px; margin: 10px 0; }
.project-intel-inspect-row input { flex: 1; min-width: 0; min-height: 44px; }
.project-intel-inspect { max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--sv-type-tool-description-size); }
.project-intel-runs { margin: 4px 0 0; padding-left: 18px; font-size: var(--sv-type-tool-description-size); color: var(--c-grey); }
@media (max-width: 520px) { .project-intel-facts { grid-template-columns: 1fr; } .project-intel-facts dd { margin-bottom: 6px; } }

/* Message editing + conversation branching */
.chat-edit { margin: 6px 0; }
.chat-edit-area { width: 100%; box-sizing: border-box; min-height: 72px; resize: vertical; font: inherit; padding: 10px 12px; border-radius: 12px; }
.branch-switcher { display: inline-flex; align-items: center; gap: 4px; }
.chat-message .chat-message-actions .branch-switcher button { min-width: 44px; min-height: 44px; }
.branch-count { font-size: var(--sv-type-tool-description-size); color: var(--c-grey); min-width: 3.2em; text-align: center; }
.chat-message .chat-routing-note, .chat-message .chat-model-note { margin: 2px 0 6px; font-size: var(--sv-type-tool-description-size); color: var(--c-grey); }

/* Web search: opt-in toggle and verified source citations */
.composer-search { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; cursor: pointer; }
.composer-search svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.composer-search[aria-pressed="true"] { background: rgba(var(--sv-text-rgb), 0.22); border-color: var(--glass-border-focus); }
.chat-citations { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.chat-citations-label { flex-basis: 100%; margin: 0; }
.chat-citation { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--glass-border, rgba(var(--sv-text-rgb), 0.18)); background: rgba(var(--sv-text-rgb), 0.06); color: inherit; text-decoration: none; font-size: var(--sv-type-tool-label-size); }
.chat-citation:hover, .chat-citation:focus-visible { background: rgba(var(--sv-text-rgb), 0.14); border-color: var(--glass-border-focus); }
.chat-citation-n { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 50%; background: rgba(var(--sv-text-rgb), 0.18); font-weight: 600; font-size: var(--sv-type-tool-description-size); }
.chat-citation-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 28ch; }
.chat-citation-domain { opacity: 0.65; font-size: var(--sv-type-tool-description-size); }
.chat-research-note:empty { display: none; }
@media (max-width: 480px) { .composer-search span { display: none; } .composer-search { padding: 0 12px; } .chat-citation-title { max-width: 18ch; } }

/* Lunea viewer: real screenshots of the running app inside Studio */
.lunea-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.lunea-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; border: 1px solid var(--glass-border, rgba(var(--sv-text-rgb), 0.18)); background: rgba(var(--sv-text-rgb), 0.06); }
.lunea-tab { min-height: 44px; min-width: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.lunea-tab[aria-pressed="true"] { background: rgba(var(--sv-text-rgb), 0.2); }
.lunea-route { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--glass-border, rgba(var(--sv-text-rgb), 0.18)); background: rgba(var(--sv-text-rgb), 0.06); color: inherit; font: inherit; max-width: 100%; }
.lunea-stage { display: grid; place-items: center; width: 100%; max-height: 46vh; overflow: auto; border-radius: 14px; border: 1px solid var(--glass-border, rgba(var(--sv-text-rgb), 0.18)); background: rgba(0, 0, 0, 0.25); padding: 8px; }
.lunea-stage[data-viewport="mobile"] .lunea-img { max-width: min(100%, 390px); }
.lunea-stage[data-viewport="tablet"] .lunea-img { max-width: min(100%, 560px); }
.lunea-stage[data-viewport="desktop"] .lunea-img { max-width: 100%; }
.lunea-img { display: block; height: auto; border-radius: 8px; }
.lunea-empty { padding: 32px 16px; text-align: center; }
.lunea-meta, .lunea-note { margin-top: 10px; min-height: 1.2em; }
.lunea-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lunea-actions .btn, .lunea-actions button { min-height: 44px; }

/* Founder Spirit: one quiet line beside a real outcome (never a banner, never a replacement for the real message) */
.chat-spirit { margin-top: 8px; font-size: var(--sv-type-tool-label-size); font-style: italic; opacity: 0.72; line-height: 1.4; }
.sh-founder { margin: 8px 0; padding: 0 0 0 14px; border-left: 2px solid var(--glass-border-focus, rgba(var(--sv-text-rgb), 0.35)); font-size: var(--sv-type-body-secondary-size); line-height: 1.55; }
@media (prefers-reduced-motion: reduce) { .chat-spirit { transition: none; animation: none; } }

/* Voice unavailable: said once, only when the microphone is tapped, as a small note above the composer (never inside it). */
.voice-unavailable-note { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); z-index: 8; max-width: 560px; margin: 0 auto; padding: 8px 12px; border-radius: 12px; background: var(--bg-surface-raised); border: 1px solid var(--border-subtle); color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.4; }
.composer-action.voice-mic.is-unavailable { opacity: .55; }

/* Daily Allowance Reached: a dedicated screen over the chat panel (never an assistant message, never a counter in the composer). Palette: approved tokens only. */
.allowance-screen { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: var(--space-5, 24px); background: var(--bg-canvas, var(--sv-app-bg)); text-align: center; }
.allowance-screen[hidden] { display: none; }
.allowance-inner { max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: var(--space-3, 12px); }
.allowance-kicker { margin: 0; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--text-secondary); }
.allowance-title { margin: 0; font-size: 1.6rem; font-weight: 600; line-height: 1.25; color: var(--text-primary); }
.allowance-copy { margin: 0; color: var(--text-primary); line-height: 1.5; }
.allowance-refresh { margin: var(--space-2, 8px) 0 0; font-size: .85rem; color: var(--text-secondary); }
.allowance-cta { min-height: 48px; padding: 0 28px; border-radius: 999px; margin-top: var(--space-2, 8px); }
.allowance-back { background: none; border: 0; box-shadow: none; color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; min-height: 44px; }

/* Tool Activity Timeline ("Used N tools"): recorded steps only, restrained glass, neutral tokens, Noto Serif inherited. Mobile first: full-width rows, 44px targets,
   wrapping text and no horizontal scroll; identical on desktop. The running indicator is a ring that does not spin under reduced motion. */
.tool-activity { margin: 6px 0 10px; border: 1px solid var(--glass-border, var(--sv-border)); border-radius: var(--ds-radius-sm, 12px); background: rgba(var(--sv-composer-bg-rgb), .38); max-width: 100%; overflow: hidden; }
.tool-activity[hidden] { display: none; }
.tool-activity .sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tool-activity-header { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; background: none; border: 0; color: var(--text-secondary, var(--sv-text-2)); font: inherit; font-size: var(--sv-type-tool-label-size); text-align: left; cursor: pointer; }
.tool-activity-header:hover, .tool-activity-header:focus-visible { color: var(--text-primary, var(--sv-text)); background: rgba(var(--sv-text-rgb), .06); }
.tool-activity-header:focus-visible, .tool-activity-row:focus-visible { outline: 2px solid var(--glass-border-focus, var(--sv-text-2)); outline-offset: -2px; }
.tool-activity-summary-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.tool-activity-summary-state, .tool-activity-row-icon, .tool-activity-row-state { display: inline-grid; place-items: center; flex: 0 0 auto; width: 20px; height: 20px; }
.tool-activity .sv-icon { width: 18px; height: 18px; }
.tool-activity-chevron { flex: 0 0 auto; transition: transform .18s ease; }
.tool-activity-header[aria-expanded="true"] .tool-activity-chevron { transform: rotate(90deg); }
.tool-activity-list { list-style: none; margin: 0; padding: 0 0 4px; border-top: 1px solid var(--ds-line, rgba(var(--sv-text-rgb), .085)); }
.tool-activity-list[hidden] { display: none; }
.tool-activity-item + .tool-activity-item { border-top: 1px solid var(--ds-line, rgba(var(--sv-text-rgb), .085)); }
.tool-activity-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; background: none; border: 0; color: var(--text-primary, var(--sv-text)); font: inherit; font-size: var(--sv-type-tool-label-size); text-align: left; cursor: pointer; }
.tool-activity-row:hover { background: rgba(var(--sv-text-rgb), .05); }
.tool-activity-row-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.tool-activity-row-label { overflow-wrap: anywhere; }
.tool-activity-row-target { color: var(--text-tertiary, var(--sv-text-3)); font-size: var(--sv-type-tool-description-size); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tool-activity-row-meta { flex: 0 0 auto; color: var(--text-tertiary, var(--sv-text-3)); font-size: var(--sv-type-tool-description-size); white-space: nowrap; }
.tool-activity-item[data-status="failed"] .tool-activity-row-label { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.tool-activity-item[data-status="failed"] .tool-activity-row-meta, .tool-activity-item[data-status="failed"] .tool-activity-row-state { color: var(--c-offwhite, var(--sv-text)); }
.tool-activity-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; padding: 4px 12px 12px 42px; font-size: var(--sv-type-tool-description-size); }
.tool-activity-details[hidden] { display: none; }
.tool-activity-details dt { color: var(--text-tertiary, var(--sv-text-3)); }
.tool-activity-details dd { margin: 0; color: var(--text-secondary, var(--sv-text-2)); overflow-wrap: anywhere; white-space: pre-wrap; }
.tool-activity-details dd.tool-activity-error { color: var(--c-offwhite, var(--sv-text)); }
.tool-activity-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.tool-activity-links a { color: var(--text-primary, var(--sv-text)); text-underline-offset: 3px; overflow-wrap: anywhere; display: inline-block; min-height: 24px; }
.tool-activity-spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(var(--sv-text-rgb), .25); border-top-color: var(--text-secondary, var(--sv-text-2)); animation: tool-activity-spin .9s linear infinite; }
@keyframes tool-activity-spin { to { transform: rotate(360deg); } }
@media (max-width: 480px) {
  .tool-activity-details { grid-template-columns: minmax(0, 1fr); padding-left: 12px; gap: 2px; }
  .tool-activity-details dt { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .tool-activity-spinner { animation: none; border-top-color: rgba(var(--sv-text-rgb), .25); border-style: dotted; }
  .tool-activity-chevron { transition: none; }
}
@media (prefers-reduced-transparency: reduce) { .tool-activity { background: var(--glass-solid, var(--sv-elevated)); } }
/* While a reply's real tool steps are shown, the older one-line research status would repeat them: the timeline replaces it. */
.chat-message.streaming:has(> .tool-activity:not([hidden])) > .chat-research-note { display: none; }

/* ---- Connected tools (MCP): the tool sheet, the proposal card and the per-tool settings. Tokens only; text weight rules and 44px targets as everywhere else. ----------------- */
.mcp-sheet { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mcp-title { margin: 0; }
.mcp-sub, .mcp-desc { margin: 0; line-height: 1.5; color: var(--text-secondary); overflow-wrap: anywhere; }
.mcp-server { margin: 10px 0 2px; font-size: var(--sv-type-body-secondary-size); color: var(--text-secondary); }
.mcp-empty { margin: 8px 0 0; color: var(--text-primary); }
.mcp-tool-row {
  display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; min-height: 56px; padding: 10px 14px; text-align: left; cursor: pointer;
  background: rgba(var(--sv-text-rgb), 0.05); border: 1px solid var(--glass-border); border-radius: var(--ds-radius-md); color: var(--text-primary); font-size: var(--sv-type-body-secondary-size);
  transition: background-color var(--dur-fast);
}
.mcp-tool-row:hover, .mcp-tool-row:focus-visible { background: rgba(var(--sv-text-rgb), 0.11); outline: none; box-shadow: inset 0 0 0 1.5px var(--glass-border-focus); }
.mcp-tool-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; }
.mcp-tool-name { overflow-wrap: anywhere; }
.mcp-chip { flex: none; padding: 2px 10px; border: 1px solid var(--border-subtle); border-radius: 999px; font-size: var(--sv-type-tool-description-size); color: var(--text-secondary); white-space: nowrap; }
.mcp-tool-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--sv-type-tool-label-size); line-height: 1.4; color: var(--text-secondary); overflow-wrap: anywhere; }
.mcp-form { display: flex; flex-direction: column; gap: 12px; }
.mcp-field { display: flex; flex-direction: column; gap: 6px; }
.mcp-field-check { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 44px; }
.mcp-label { font-size: var(--sv-type-subtitle-size); color: var(--text-primary); }
.mcp-input { width: 100%; min-height: 44px; box-sizing: border-box; font-size: var(--sv-type-body-secondary-size); }   /* 1rem: iOS Safari does not zoom the page when a field is focused */
.mcp-textarea { min-height: 88px; resize: vertical; }
.mcp-json { font-size: var(--sv-type-subtitle-size); }
.mcp-check { width: 22px; height: 22px; flex: none; }
.mcp-hint { margin: 0; font-size: var(--sv-type-tool-description-size); line-height: 1.4; }
.mcp-status { min-height: 1.2em; margin: 0; font-size: var(--sv-type-subtitle-size); line-height: 1.4; overflow-wrap: anywhere; }
.mcp-status.err, .mcp-proposal-state.err { color: var(--text-primary); border-left: 2px solid var(--glass-border-focus); padding-left: 10px; }
.mcp-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.mcp-actions .btn { min-height: 44px; }
.mcp-actions[hidden] { display: none; }

.mcp-proposal { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 2px; padding: 12px 14px; max-width: 100%; box-sizing: border-box; background: rgba(var(--sv-text-rgb), 0.05); border: 1px solid var(--glass-border); border-radius: var(--ds-radius-md); }
.mcp-proposal[data-status="ran"], .mcp-proposal[data-status="declined"] { opacity: 0.8; }
.mcp-proposal-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mcp-proposal-icon { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: rgba(var(--sv-text-rgb), 0.08); }
.mcp-proposal-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mcp-args { display: flex; flex-direction: column; gap: 4px; }
.mcp-arg { display: flex; gap: 10px; align-items: baseline; font-size: var(--sv-type-subtitle-size); min-width: 0; }
.mcp-arg-k { flex: none; color: var(--text-secondary); }
.mcp-arg-v { min-width: 0; overflow-wrap: anywhere; }
.mcp-proposal-state { margin: 0; min-height: 1.2em; font-size: var(--sv-type-tool-label-size); }

.mcp-perms { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.mcp-perm-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.mcp-perm-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 180px; }
.mcp-perm { min-height: 44px; flex: 0 1 200px; max-width: 100%; }
.mcp-history { margin-top: 8px; }
.mcp-call { margin: 4px 0; font-size: var(--sv-type-tool-label-size); color: var(--text-secondary); overflow-wrap: anywhere; }

/* A tool result is data: set it apart a little so it is never mistaken for Savannah's own words. */
.chat-message[data-tool-result="true"] .chat-message-body { border-left: 2px solid var(--glass-border); padding-left: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- Long messages: a compact preview with an inline "Show full prompt" (js/longMessage.js). Presentation only. ---- */
.chat-message-body.lm-user { white-space: pre-wrap; tab-size: 4; overflow-wrap: anywhere; }
.chat-message-body.lm-collapsed {
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 100%); mask-image: linear-gradient(to bottom, #000 62%, transparent 100%);
  padding-bottom: 0.9em;
}
.lm-toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 2px; padding: 0 2px; background: none; border: 0; cursor: pointer;
  color: var(--text-secondary); font: inherit; font-size: var(--sv-type-subtitle-size); text-align: left;
}
.lm-toggle .lm-word { text-decoration: underline; text-underline-offset: 3px; color: var(--text-primary); }
.lm-toggle .lm-count { color: var(--text-tertiary); font-size: var(--sv-type-tool-label-size); }
.lm-toggle:hover .lm-word { text-decoration-thickness: 2px; }
.lm-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--glass-border-focus); border-radius: var(--radius-sm); }
.chat-edit-area { max-height: 60dvh; }
@media (prefers-reduced-motion: reduce) { .chat-message-body.lm-user { transition: none !important; } }
.composer-voice-strip .voice-disclosure { flex: 1 1 100%; margin: 0; font-size: var(--sv-type-tool-description-size); color: var(--text-secondary); }
