/* ==========================================================================
   AI Chat UI - styles.css
   Scope: Pure CSS only (no JS assumptions), production-ready, accessible,
   responsive, and themeable for light/dark.
   Fonts: System font stack only (no external fonts).
   ========================================================================== */


/* ==========================================================================
   1) DESIGN SYSTEM TOKENS
   -------------------------------------------------------------------------- */

/* Base tokens */
:root {
  /* Spacing scale (4pt base) */
  --sp-0: 0;
  --sp-1: 0.25rem;   /* 4px */
  --sp-2: 0.5rem;    /* 8px */
  --sp-3: 0.75rem;   /* 12px */
  --sp-4: 1rem;      /* 16px */
  --sp-5: 1.25rem;   /* 20px */
  --sp-6: 1.5rem;    /* 24px */
  --sp-7: 2rem;      /* 32px */
  --sp-8: 2.5rem;    /* 40px */
  --sp-9: 3rem;      /* 48px */
  --sp-10: 4rem;     /* 64px */

  /* Radii */
  --radius-0: 0;
  --radius-1: 0.25rem;   /* 4px */
  --radius-2: 0.5rem;    /* 8px */
  --radius-3: 0.75rem;   /* 12px */
  --radius-4: 1rem;      /* 16px */
  --radius-round: 9999px;

  /* Shadows (subtle, professional) */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-2: 0 2px 6px rgba(0,0,0,0.08);
  --shadow-3: 0 8px 24px rgba(0,0,0,0.12);

  /* Typography */
  --font-sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Font sizes and leading */
  --fs-12: 0.75rem;
  --fs-13: 0.8125rem;
  --fs-14: 0.875rem;
  --fs-16: 1rem;
  --fs-18: 1.125rem;
  --fs-20: 1.25rem;

  --lh-tight: 1.25;
  --lh-normal: 1.5;
  --lh-relaxed: 1.65;

  /* Z-index scale */
  --z-header: 50;
  --z-modal: 100;
  --z-toast: 200;

  /* Layout */
  --container-max: 64rem; /* 1024px */
  --gutter: var(--sp-4);
  --header-h: 3.5rem;
  --composer-h-min: 3.25rem;

  /* Role colors (semantic, referenced by themes) */
  --role-user-bg: hsl(210 10% 92%);
  --role-assistant-bg: hsl(210 20% 98%);

  /* Status colors (semantic) */
  --status-ok:  hsl(152 53% 38%);
  --status-warn: hsl(36 90% 50%);
  --status-err: hsl(0 70% 50%);

  /* Accent (links, primary buttons) */
  --accent: hsl(221 83% 53%);
  --accent-600: hsl(221 77% 47%);
  --accent-700: hsl(221 72% 40%);

  /* Border radius for bubbles/modals/buttons */
  --bubble-radius: var(--radius-3);
  --btn-radius: var(--radius-2);

  /* Transition durations (reduced in motion-respect section) */
  --dur-fast: 120ms;
  --dur: 180ms;
  --dur-slow: 260ms;
}

/* Light theme (default via prefers-color-scheme below) */
html[data-theme="light"] {
  --bg: hsl(210 20% 99%);
  --bg-elev-1: hsl(210 20% 98%);
  --bg-elev-2: hsl(210 16% 96%);
  --panel: hsl(210 20% 98%);
  --muted: hsl(210 10% 40%);
  --text: hsl(210 15% 15%);
  --text-muted: hsl(210 8% 35%);
  --border: hsl(210 16% 90%);
  --border-strong: hsl(210 16% 80%);
  --link: var(--accent);
  --link-hover: var(--accent-600);

  --role-user-bg: hsl(210 14% 95%);
  --role-assistant-bg: hsl(210 20% 98%);

  --code-bg: hsl(220 16% 96%);
  --code-border: hsl(220 16% 88%);
  --inline-code-bg: hsl(220 16% 94%);

  --banner-bg: hsl(45 100% 95%);
  --banner-text: hsl(30 40% 20%);
}

/* Dark theme */
html[data-theme="dark"] {
  --bg: hsl(220 18% 11%);
  --bg-elev-1: hsl(220 16% 14%);
  --bg-elev-2: hsl(220 14% 18%);
  --panel: hsl(220 16% 14%);
  --muted: hsl(220 10% 70%);
  --text: hsl(220 20% 92%);
  --text-muted: hsl(220 10% 70%);
  --border: hsl(220 14% 22%);
  --border-strong: hsl(220 12% 28%);
  --link: hsl(217 92% 72%);
  --link-hover: hsl(217 86% 66%);

  --role-user-bg: hsl(220 14% 20%);
  --role-assistant-bg: hsl(220 12% 16%);

  --code-bg: hsl(220 14% 16%);
  --code-border: hsl(220 12% 24%);
  --inline-code-bg: hsl(220 14% 18%);

  --banner-bg: hsl(32 90% 18%);
  --banner-text: hsl(32 80% 92%);
}

/* Honor system prefers-color-scheme unless overridden via data-theme */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --bg: hsl(220 18% 11%);
    --bg-elev-1: hsl(220 16% 14%);
    --bg-elev-2: hsl(220 14% 18%);
    --panel: hsl(220 16% 14%);
    --muted: hsl(220 10% 70%);
    --text: hsl(220 20% 92%);
    --text-muted: hsl(220 10% 70%);
    --border: hsl(220 14% 22%);
    --border-strong: hsl(220 12% 28%);
    --link: hsl(217 92% 72%);
    --link-hover: hsl(217 86% 66%);

    --role-user-bg: hsl(220 14% 20%);
    --role-assistant-bg: hsl(220 12% 16%);

    --code-bg: hsl(220 14% 16%);
    --code-border: hsl(220 12% 24%);
    --inline-code-bg: hsl(220 14% 18%);

    --banner-bg: hsl(32 90% 18%);
    --banner-text: hsl(32 80% 92%);
  }
}
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    --bg: hsl(210 20% 99%);
    --bg-elev-1: hsl(210 20% 98%);
    --bg-elev-2: hsl(210 16% 96%);
    --panel: hsl(210 20% 98%);
    --muted: hsl(210 10% 40%);
    --text: hsl(210 15% 15%);
    --text-muted: hsl(210 8% 35%);
    --border: hsl(210 16% 90%);
    --border-strong: hsl(210 16% 80%);
    --link: var(--accent);
    --link-hover: var(--accent-600);

    --role-user-bg: hsl(210 14% 95%);
    --role-assistant-bg: hsl(210 20% 98%);

    --code-bg: hsl(220 16% 96%);
    --code-border: hsl(220 16% 88%);
    --inline-code-bg: hsl(220 16% 94%);

    --banner-bg: hsl(45 100% 95%);
    --banner-text: hsl(30 40% 20%);
  }
}

/* Motion respect */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0ms;
    --dur: 0ms;
    --dur-slow: 0ms;
  }
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}


/* ==========================================================================
   2) RESET / NORMALIZE + BASE
   -------------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--fs-16);
  line-height: var(--lh-normal);
  text-rendering: optimizeLegibility;
}

img, svg, video, canvas, audio, iframe, embed, object {
  display: block;
  max-width: 100%;
}

img, svg {
  height: auto;
}

ul[class], ol[class] {
  list-style: none;
  padding: 0;
  margin: 0;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote {
  margin: 0;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

code, kbd, pre, samp {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 1px solid transparent;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* High contrast mode adjustments */
@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid CanvasText;
  }
  .btn {
    border: 1px solid ButtonText;
  }
}


/* ==========================================================================
   3) APP LAYOUT
   Structure assumptions in index.html:
   - header[role="banner"] with brand/status/actions
   - main containing:
     - .reconnect-banner (optional)
     - .transcript (scrollable)
     - .composer (sticky bottom)
   - footer (minimal)
   -------------------------------------------------------------------------- */

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: var(--header-h) 1fr auto;
}

/* Sticky header */
header[role="banner"] {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}

/* Content container with responsive gutters */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header content */
.header-inner {
  display: flex;
  align-items: center;
  height: var(--header-h);
  gap: var(--sp-4);
}

/* Brand/logo */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 600;
  letter-spacing: 0.2px;
}
.brand .logo {
  width: 1.5rem;
  height: 1.5rem;
}

/* Connection status dot */
.status-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: var(--radius-round);
  background: var(--status-ok);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--panel) 70%, transparent);
}
.is-offline .status-dot {
  background: var(--status-err);
}

/* Header actions */
.header-actions {
  margin-left: auto;
  display: inline-flex;
  gap: var(--sp-2);
}
.icon-btn {
  inline-size: 2rem;
  block-size: 2rem;
  display: grid;
  place-items: center;
  border-radius: var(--btn-radius);
  color: var(--text);
  border: 1px solid var(--border);
  background: transparent;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.icon-btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-strong);
}

/* Reconnect banner */
.reconnect-banner {
  position: sticky;
  top: calc(var(--header-h));
  z-index: var(--z-header);
  background: var(--banner-bg);
  color: var(--banner-text);
  border-block: 1px solid var(--border);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--dur-slow) ease, opacity var(--dur) ease;
}
.reconnect-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.reconnect-banner .inner {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--gutter);
}
.reconnect-banner .cta {
  margin-left: auto;
  white-space: nowrap;
}

/* Main area */
main {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0; /* ensure nested scroll works */
}

/* Transcript panel */
.transcript {
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 0;
}
.transcript .scroll {
  height: 100%;
  overflow: auto;
  padding: var(--sp-6) 0;
}

/* Message groups */
.msg {
  display: grid;
  gap: var(--sp-2);
  margin-block: var(--sp-3);
}
.msg .meta {
  color: var(--text-muted);
  font-size: var(--fs-13);
}
.msg .bubble {
  padding: var(--sp-4) var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--bubble-radius);
  box-shadow: var(--shadow-1);
  max-width: 65ch;
  word-wrap: break-word;
}

/* User vs Assistant styling */
.msg.user .bubble {
  margin-left: auto;
  background: var(--role-user-bg);
}
.msg.assistant .bubble {
  margin-right: auto;
  background: var(--role-assistant-bg);
}

/* Bubble content: text */
.bubble p + p { margin-top: var(--sp-3); }
.bubble a { word-break: break-word; }

/* Lists */
.bubble ul, .bubble ol {
  margin: var(--sp-3) 0 var(--sp-3) var(--sp-5);
}
.bubble li + li {
  margin-top: var(--sp-2);
}

/* Inline code */
.bubble code {
  background: var(--inline-code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-1);
  padding: 0.1rem 0.35rem;
}

/* Pre / code blocks */
.bubble pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-2);
  padding: var(--sp-4);
  overflow: auto;
  max-width: 100%;
  margin-top: var(--sp-3);
  line-height: var(--lh-tight);
}
.bubble pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 0.9em;
}

/* Inline tools: copy/regenerate placeholders */
.msg-tools {
  display: inline-flex;
  gap: var(--sp-1);
  margin-top: var(--sp-2);
}
.msg-tools .icon-btn {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-radius: var(--radius-1);
}

/* Streaming state hook (visual only) */
.is-streaming .msg.assistant .bubble {
  box-shadow: var(--shadow-2);
  border-color: var(--border-strong);
}

/* Composer */
.composer {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: var(--sp-3) 0;
}
.composer .box {
  border: 1px solid var(--border);
  border-radius: var(--radius-3);
  background: var(--bg);
  box-shadow: var(--shadow-1);
  padding: var(--sp-2);
  display: grid;
  gap: var(--sp-2);
}
.composer textarea {
  width: 100%;
  min-height: var(--composer-h-min);
  max-height: 40vh;
  resize: none; /* autosize-friendly; JS can adjust rows/height later */
  border: 0;
  background: transparent;
  color: var(--text);
  padding: var(--sp-2);
  outline: none;
}
.composer .helper {
  color: var(--text-muted);
  font-size: var(--fs-12);
  padding-inline: var(--sp-2);
}

.composer .actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.btn-row {
  display: inline-flex;
  gap: var(--sp-2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  padding: 0.5rem 0.75rem;
  border-radius: var(--btn-radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: background var(--dur) ease, border-color var(--dur) ease, color var(--dur) ease, box-shadow var(--dur) ease;
}
.btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--border-strong);
}
.btn:active {
  transform: translateY(0.5px);
}

.btn-primary {
  background: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 80%, black);
  color: white;
}
.btn-primary:hover {
  background: var(--accent-600);
}
.btn-primary:active {
  background: var(--accent-700);
}

.btn-danger {
  background: color-mix(in oklab, var(--status-err) 92%, black 8%);
  border-color: color-mix(in oklab, var(--status-err) 80%, black);
  color: white;
}
.btn-danger:hover {
  background: color-mix(in oklab, var(--status-err) 88%, black 12%);
}

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Footer */
footer {
  color: var(--text-muted);
  font-size: var(--fs-12);
  padding: var(--sp-3) 0 var(--sp-6);
}


/* ==========================================================================
   4) DIALOG (Settings Modal)
   Structure assumptions:
   - .modal-backdrop (fixed)
   - .modal (centered)
   - .modal > .modal-header, .modal-body, .modal-footer
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: color-mix(in oklab, var(--bg) 40%, black 60%);
  opacity: 0.66;
  z-index: var(--z-modal);
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  z-index: calc(var(--z-modal) + 1);
}
.modal .card {
  width: min(42rem, 100%);
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.modal-header, .modal-footer {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal-footer {
  border-top: 1px solid var(--border);
  border-bottom: 0;
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
}
.modal-body {
  padding: var(--sp-4);
  display: grid;
  gap: var(--sp-4);
}

/* Form controls */
.form-row {
  display: grid;
  gap: var(--sp-2);
}
.label {
  font-weight: 600;
  font-size: var(--fs-14);
}
.help {
  color: var(--text-muted);
  font-size: var(--fs-12);
}

/* Inputs */
.input, select, textarea, input[type="number"] {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-2);
  padding: 0.5rem 0.6rem;
  min-height: 2.25rem;
}
.input:focus-visible, select:focus-visible, textarea:focus-visible, input[type="number"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Switch (visual-only) */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.switch input[type="checkbox"] {
  appearance: none;
  width: 2.25rem;
  height: 1.25rem;
  border-radius: var(--radius-round);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  position: relative;
  transition: background var(--dur) ease, border-color var(--dur) ease;
}
.switch input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  border-radius: var(--radius-round);
  background: var(--text-muted);
  transition: left var(--dur) ease, background var(--dur) ease;
}
.switch input[type="checkbox"]:checked {
  background: color-mix(in oklab, var(--accent) 85%, white 15%);
  border-color: var(--accent);
}
.switch input[type="checkbox"]:checked::after {
  left: calc(100% - 1rem - 2px);
  background: white;
}

/* Radios */
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
}
.radio input[type="radio"] {
  width: 1rem; height: 1rem;
}

/* Select */
select {
  padding-right: 2rem;
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
}

/* kbd styling */
.kbd, kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-1);
  background: var(--bg-elev-2);
}


/* ==========================================================================
   5) TOASTS
   -------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  z-index: var(--z-toast);
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3);
}
@media (min-width: 1025px) {
  .toasts {
    top: var(--sp-4);
    right: var(--sp-4);
    left: auto;
    transform: none;
  }
}
@media (max-width: 1024px) {
  .toasts {
    top: var(--sp-3);
    right: 50%;
    transform: translateX(50%);
  }
}

.toast {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  padding: var(--sp-3) var(--sp-4);
  min-width: 16rem;
}
.toast.success {
  border-color: color-mix(in oklab, var(--status-ok) 40%, var(--border));
}
.toast.warn {
  border-color: color-mix(in oklab, var(--status-warn) 40%, var(--border));
}
.toast.error {
  border-color: color-mix(in oklab, var(--status-err) 40%, var(--border));
}


/* ==========================================================================
   6) ACCESSIBILITY & FOCUS
   -------------------------------------------------------------------------- */

/* WCAG AA focus is covered by :focus-visible above.
   Additional helpers: */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus-visible {
  position: fixed;
  left: var(--sp-3);
  top: var(--sp-3);
  width: auto;
  height: auto;
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  box-shadow: var(--shadow-2);
}


/* ==========================================================================
   7) UTILITIES
   -------------------------------------------------------------------------- */

/* Visibility helpers */
.visually-hidden, .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.visually-hidden-focusable:active,
.visually-hidden-focusable:focus {
  position: static !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
}

.hidden { display: none !important; }

/* Truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Flex/grid helpers */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.center { align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

/* Spacing utilities (limited set for production sanity) */
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }

/* Width limits */
.max-w-prose { max-width: 65ch; }

/* Buttons sized icons inside */
.btn .icon, .icon-btn .icon {
  width: 1rem;
  height: 1rem;
}

/* Status helpers for html/body toggles by future JS */
html.is-offline body,
body.is-offline {
  /* Visual hint without being disruptive */
  background-image: linear-gradient(0deg, transparent, transparent 98%, color-mix(in oklab, var(--status-err) 8%, transparent) 98%);
  background-size: 100% 0.75rem;
}


/* ==========================================================================
   8) RESPONSIVE BREAKPOINTS
   - Small: <480px
   - Medium: 480–1024px
   - Large: >1024px
   -------------------------------------------------------------------------- */

/* Small (mobile-first default already set).
   Ensure comfortable gutters and bubble width */
@media (max-width: 479.98px) {
  :root { --gutter: var(--sp-4); }
  .bubble { max-width: 100%; }
  .header-inner { gap: var(--sp-3); }
  .brand { font-size: var(--fs-14); }
  .composer .actions { flex-wrap: wrap; row-gap: var(--sp-2); }
  .toasts { top: var(--sp-3); }
}

/* Medium */
@media (min-width: 480px) and (max-width: 1024px) {
  :root { --gutter: var(--sp-6); }
  .bubble { max-width: 72ch; }
}

/* Large (desktop) */
@media (min-width: 1025px) {
  :root { --gutter: var(--sp-7); }
  .bubble { max-width: 80ch; }
}


/* ==========================================================================
   9) PRINT BASICS (non-essential but safe)
   -------------------------------------------------------------------------- */

@media print {
  header, .composer, .reconnect-banner, .toasts, footer { display: none !important; }
  .bubble { box-shadow: none; background: white; color: black; }
  body { background: white; color: black; }
}