/* ==========================================================================
   Jisr — bilingual design tokens and component system.
   All directional spacing uses CSS logical properties for RTL/LTR mirroring.
   ========================================================================== */

/* The root token layer mirrors the generated UI/UX design system and extends it
   with an accessible light theme because the product requires both modes. */
:root {
  /* Direction-neutral font stacks cover Arabic and Latin without a build step. */
  --font-sans: "IBM Plex Sans Arabic", "Inter", "Segoe UI", Tahoma, sans-serif;
  /* Code and endpoint fields always use a technical monospace face. */
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  /* The default dark palette is derived from the persisted design-system master. */
  --color-primary: #6366f1;
  /* A deeper primary is reserved for pressed and gradient states. */
  --color-primary-strong: #7c3aed;
  /* Soft primary tint supports selection, focus, and user bubbles. */
  --color-primary-soft: rgba(99, 102, 241, 0.15);
  /* Text on saturated primary surfaces remains pure contrast white. */
  --color-on-primary: #ffffff;
  /* The deepest page surface uses midnight indigo rather than pure black. */
  --color-bg: #080d1a;
  /* Elevated sidebar and workspace surfaces step up luminance gradually. */
  --color-bg-elevated: #0f172a;
  /* Card surfaces hold message bodies and settings groups. */
  --color-card: #141d31;
  /* A second card tone separates nested controls without hard borders. */
  --color-card-raised: #19243b;
  /* Primary prose has a measured contrast ratio against every surface. */
  --color-text: #f8fafc;
  /* Secondary text remains readable on all dark surfaces. */
  --color-text-muted: #a5b1c6;
  /* Tertiary metadata is used only for timestamps and nonessential hints. */
  --color-text-faint: #7d8aa3;
  /* Borders use a low-opacity white to avoid harsh grid lines. */
  --color-border: rgba(203, 213, 225, 0.13);
  /* Strong borders appear on focused or elevated controls. */
  --color-border-strong: rgba(203, 213, 225, 0.24);
  /* Danger colors are used for destructive actions and error banners. */
  --color-danger: #f87171;
  /* Danger surfaces keep alerts visible without saturating the screen. */
  --color-danger-soft: rgba(248, 113, 113, 0.12);
  /* Success communicates copied state and validated connections. */
  --color-success: #4ade80;
  /* Success surfaces use the same translucent treatment as danger. */
  --color-success-soft: rgba(74, 222, 128, 0.12);
  /* Warning helps explain fallback and retryable conditions. */
  --color-warning: #fbbf24;
  /* Warning surfaces remain distinct from errors. */
  --color-warning-soft: rgba(251, 191, 36, 0.12);
  /* The focus ring is a bright periwinkle visible against dark surfaces. */
  --color-ring: #a5b4fc;
  /* Code surfaces are darker than message cards for syntax separation. */
  --color-code-bg: #070b14;
  /* Inline code earns a barely raised tint. */
  --color-inline-code: #1c2944;
  /* Overlay scrims use indigo-black rather than neutral gray. */
  --color-scrim: rgba(3, 7, 18, 0.72);
  /* The brand gradient ties logo, primary actions, and the empty-state orb. */
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #7c3aed 100%);
  /* Sidebar width leaves enough room for Arabic titles without crowding chat. */
  --sidebar-width: 300px;
  /* The top bar height is referenced by scroll offsets and focus padding. */
  --topbar-height: 72px;
  /* The spacing scale follows the generated standard density dial. */
  --space-1: 4px;
  /* Eight-pixel spacing handles icon and label gaps. */
  --space-2: 8px;
  /* Twelve-pixel spacing handles compact control groups. */
  --space-3: 12px;
  /* Sixteen-pixel spacing is the standard content rhythm. */
  --space-4: 16px;
  /* Twenty-four-pixel spacing separates sections. */
  --space-5: 24px;
  /* Thirty-two-pixel spacing supports large composition gaps. */
  --space-6: 32px;
  /* Forty-eight-pixel spacing is reserved for hero-level padding. */
  --space-7: 48px;
  /* Small radii round chips and tiny buttons. */
  --radius-sm: 8px;
  /* Medium radii round inputs and message cards. */
  --radius-md: 12px;
  /* Large radii shape the composer and large panels. */
  --radius-lg: 18px;
  /* Extra-large radii frame modals and the empty-state orb. */
  --radius-xl: 28px;
  /* Compact shadows keep dark UI depth subtle. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  /* Medium shadows lift the composer from the transcript. */
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.22);
  /* Large shadows isolate dialogs and drawers. */
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.42);
  /* A single motion duration keeps hover and focus transitions coherent. */
  --transition-fast: 160ms ease;
  /* Standard transitions are used for panel and color changes. */
  --transition-base: 240ms cubic-bezier(0.22, 1, 0.36, 1);
  /* The reduced-motion override collapses these durations later. */
  color-scheme: dark;
}

/* The light theme keeps the same semantic token names while raising surface luminance. */
[data-theme="light"] {
  /* Indigo primary is darkened for AA contrast on pale surfaces. */
  --color-primary: #4338ca;
  /* The stronger accent shifts toward violet. */
  --color-primary-strong: #6d28d9;
  /* Soft primary tint is reduced to avoid muddy cards. */
  --color-primary-soft: rgba(67, 56, 202, 0.09);
  /* The page background is a cool off-white rather than pure white. */
  --color-bg: #f2f4fb;
  /* The elevated surface is nearly white with a blue cast. */
  --color-bg-elevated: #e9edf8;
  /* Cards remain off-white to satisfy the no-pure-white anti-pattern. */
  --color-card: #fdfdff;
  /* Raised controls use a slightly cooler tint. */
  --color-card-raised: #f6f7fe;
  /* Primary text is a deep slate for strong contrast. */
  --color-text: #111827;
  /* Secondary text stays above 4.5:1 on the pale background. */
  --color-text-muted: #526079;
  /* Faint metadata remains legible without competing with prose. */
  --color-text-faint: #6d7890;
  /* Borders use dark indigo at low opacity. */
  --color-border: rgba(17, 24, 39, 0.11);
  /* Strong borders define field boundaries. */
  --color-border-strong: rgba(17, 24, 39, 0.22);
  /* Danger is darkened for light-surface contrast. */
  --color-danger: #b91c1c;
  /* Danger tint is softened for banners. */
  --color-danger-soft: rgba(185, 28, 28, 0.08);
  /* Success is darkened for readable confirmation text. */
  --color-success: #15803d;
  /* Success tint matches the calm surface language. */
  --color-success-soft: rgba(21, 128, 61, 0.08);
  /* Warning amber is darkened for text contrast. */
  --color-warning: #a16207;
  /* Warning tint stays warm and translucent. */
  --color-warning-soft: rgba(161, 98, 7, 0.08);
  /* The focus ring returns to the darker primary. */
  --color-ring: #4338ca;
  /* Code keeps its dark treatment in both themes for syntax readability. */
  --color-code-bg: #0d1425;
  /* Inline code uses a pale indigo chip. */
  --color-inline-code: #e9ebfb;
  /* Scrims are lighter in the light theme while still separating dialogs. */
  --color-scrim: rgba(17, 24, 39, 0.36);
  /* Shadows become softer on pale surfaces. */
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  /* Cards lift with a restrained blue shadow. */
  --shadow-md: 0 12px 30px rgba(30, 41, 59, 0.1);
  /* Dialogs use a broad but gentle shadow. */
  --shadow-lg: 0 28px 80px rgba(30, 41, 59, 0.18);
  /* Native controls and scrollbars follow the light appearance. */
  color-scheme: light;
}

/* The reset normalizes box sizing across every component. */
*,
*::before,
*::after {
  /* Border-box keeps padding from changing declared dimensions. */
  box-sizing: border-box;
}

/* Hidden elements must stay hidden even when a component declares display. */
[hidden] {
  /* The important flag overrides button and grid display declarations. */
  display: none !important;
}

/* The document fills the viewport and avoids nested scroll containers. */
html {
  /* Dynamic viewport units accommodate mobile browser chrome. */
  height: 100%;
  /* Smooth scrolling is disabled when reduced motion is preferred later. */
  scroll-behavior: smooth;
  /* Padding keeps focused elements visible below the fixed workspace header. */
  scroll-padding-block-start: calc(var(--topbar-height) + var(--space-4));
}

/* The body owns the core type ramp and color defaults. */
body {
  /* Full-height layout anchors the composer to the viewport bottom. */
  height: 100%;
  /* The app itself handles scrolling within the transcript. */
  overflow: hidden;
  /* Margin reset removes browser defaults. */
  margin: 0;
  /* The bilingual stack shapes Arabic and Latin naturally. */
  font-family: var(--font-sans);
  /* Sixteen pixels is the accessible default read size. */
  font-size: 16px;
  /* The comfortable line height supports mixed-script prose. */
  line-height: 1.65;
  /* Primary text color is semantic for theme switching. */
  color: var(--color-text);
  /* Layered radial tones add depth without images. */
  background:
    radial-gradient(circle at 78% 12%, rgba(99, 102, 241, 0.14), transparent 34%),
    radial-gradient(circle at 8% 88%, rgba(124, 58, 237, 0.1), transparent 30%),
    var(--color-bg);
  /* Font smoothing improves thin Arabic strokes on dark surfaces. */
  -webkit-font-smoothing: antialiased;
  /* Text rendering keeps ligatures predictable. */
  text-rendering: optimizeLegibility;
}

/* Buttons and form controls inherit the product font instead of platform defaults. */
button,
input,
textarea,
select {
  /* Font inheritance preserves Arabic shaping inside controls. */
  font: inherit;
  /* All controls inherit the semantic text color unless overridden. */
  color: inherit;
}

/* Buttons must advertise interactivity and reset native chrome. */
button {
  /* Pointer feedback is required for every clickable control. */
  cursor: pointer;
  /* Borders are declared explicitly by component classes. */
  border: 0;
  /* Native backgrounds are removed for token-driven surfaces. */
  background: none;
  /* Buttons inherit prose line height for balanced labels. */
  line-height: 1.35;
}

/* Disabled controls must not invite clicks. */
button:disabled {
  /* Not-allowed communicates an unavailable action. */
  cursor: not-allowed;
  /* Reduced opacity is the shared disabled treatment. */
  opacity: 0.48;
}

/* Inputs and selects reset native appearance where custom styling applies. */
input,
textarea,
select {
  /* Every field uses the semantic card boundary. */
  border: 1px solid var(--color-border);
  /* Medium radii match the design system input specification. */
  border-radius: var(--radius-sm);
  /* Surface color separates fields from their parent panels. */
  background: var(--color-card-raised);
  /* Inner padding provides an accessible hit area. */
  padding: 10px 12px;
  /* Outline is replaced by a visible focus ring below. */
  outline: none;
  /* Color transitions keep theme changes smooth. */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

/* Focus treatment is shared by every keyboard-operable control. */
:where(button, input, textarea, select, a, summary):focus-visible {
  /* The ring is deliberately strong and never removed. */
  outline: 2px solid var(--color-ring);
  /* A two-pixel offset separates the ring from the component edge. */
  outline-offset: 2px;
}

/* Text selection uses the brand tint for continuity. */
::selection {
  /* Soft primary background remains readable on cards. */
  background: var(--color-primary-soft);
  /* Selected prose keeps the primary text color. */
  color: var(--color-text);
}

/* Images cannot overflow their cards by default. */
img {
  /* Contain prevents visual clipping surprises in message media. */
  max-width: 100%;
  /* Images render as blocks to remove inline baseline gaps. */
  display: block;
}

/* Icons inherit their button color and use a consistent optical size. */
svg {
  /* Inline SVG inherits the surrounding text color. */
  color: currentColor;
  /* The default icon box is compact. */
  width: 20px;
  /* Height matches width to avoid distortion. */
  height: 20px;
  /* Fill is controlled by individual paths or set to none. */
  fill: none;
  /* Strokes use the current text color. */
  stroke: currentColor;
  /* The shared stroke width matches Lucide's friendly technical style. */
  stroke-width: 2;
  /* Rounded caps soften the icon system. */
  stroke-linecap: round;
  /* Joined strokes avoid spiky corners. */
  stroke-linejoin: round;
  /* Icons never flex beyond their intended dimensions. */
  flex: none;
}

/* The hidden SVG sprite must not affect layout. */
.icon-sprite {
  /* Absolute positioning removes the sprite from flow. */
  position: absolute;
  /* Zero dimensions prevent scrollbar artifacts. */
  width: 0;
  /* Height remains zero for the same reason. */
  height: 0;
  /* Overflow hiding keeps symbols inaccessible visually. */
  overflow: hidden;
}

/* Screen-reader-only text remains available to assistive technology. */
.sr-only {
  /* Absolute positioning removes it from visual flow. */
  position: absolute;
  /* A one-pixel box avoids layout shifts. */
  width: 1px;
  /* Height is equally minimal. */
  height: 1px;
  /* Inner padding cannot expand the box. */
  padding: 0;
  /* Negative margin clips the box without breaking focus. */
  margin: -1px;
  /* Hidden overflow completes the clipping. */
  overflow: hidden;
  /* The clip path removes any visible glyph. */
  clip: rect(0, 0, 0, 0);
  /* Whitespace wrapping is disabled. */
  white-space: nowrap;
  /* Borders are irrelevant for the hidden node. */
  border: 0;
}

/* The skip link appears only when focused. */
.skip-link {
  /* Fixed positioning keeps it available from the first Tab press. */
  position: fixed;
  /* Inline start aligns with the active reading direction. */
  inset-inline-start: var(--space-4);
  /* The top offset places it above the workspace. */
  inset-block-start: -80px;
  /* A high layer keeps it above dialogs only when focused. */
  z-index: 200;
  /* Padding provides a usable target. */
  padding: 10px 16px;
  /* The brand surface identifies the shortcut. */
  background: var(--color-primary);
  /* Contrasting text is used on primary. */
  color: var(--color-on-primary);
  /* Rounded corners match the component language. */
  border-radius: var(--radius-sm);
  /* The transition reveals the link smoothly. */
  transition: inset-block-start var(--transition-fast);
}

/* Keyboard users see the skip link above the shell. */
.skip-link:focus {
  /* The visible offset places it on screen. */
  inset-block-start: var(--space-4);
}

/* The app shell is a two-column workspace on desktop. */
.app-shell {
  /* The sidebar has a fixed comfortable width while chat consumes remaining space. */
  display: grid;
  /* Minmax prevents the chat column from overflowing under long code. */
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  /* Full dynamic viewport height supports modern mobile browsers. */
  height: 100dvh;
  /* The shell itself does not scroll; the transcript does. */
  overflow: hidden;
}

/* The sidebar groups history, search, and connection status. */
.sidebar {
  /* Flex column anchors the footer to the bottom. */
  display: flex;
  /* Vertical stacking keeps controls in reading order. */
  flex-direction: column;
  /* A minimum height lets the conversation list scroll independently. */
  min-height: 0;
  /* Inline padding creates a calm gutter without physical left/right rules. */
  padding: var(--space-4) var(--space-3) var(--space-3);
  /* A translucent surface distinguishes navigation from the transcript. */
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(8, 13, 26, 0.92));
  /* The border mirrors to the correct inline end. */
  border-inline-end: 1px solid var(--color-border);
  /* Backdrop blur softens the radial background behind the sidebar. */
  backdrop-filter: blur(18px);
  /* A stacking context supports the mobile transform. */
  position: relative;
  /* The sidebar animates as a drawer on small screens. */
  transition: transform var(--transition-base);
}

/* The light theme replaces the sidebar gradient with layered cool whites. */
[data-theme="light"] .sidebar {
  /* The gradient avoids a flat, heavy panel. */
  background: linear-gradient(180deg, rgba(248, 249, 255, 0.98), rgba(237, 240, 250, 0.95));
}

/* The brand row aligns the logo, copy, and mobile close action. */
.brand {
  /* Flex alignment keeps the mark and two-line copy centered. */
  display: flex;
  /* Small gaps avoid crowding the title. */
  align-items: center;
  /* Gap scales with the spacing token. */
  gap: var(--space-3);
  /* Horizontal padding aligns the brand with sidebar controls. */
  padding-inline: var(--space-2);
  /* Bottom spacing separates identity from the primary action. */
  padding-block-end: var(--space-4);
}

/* The brand mark carries the product gradient. */
.brand-mark {
  /* A fixed square anchors the glyph. */
  width: 38px;
  /* Height matches width for a circular optical container. */
  height: 38px;
  /* The gradient is shared with the prime action. */
  background: var(--gradient-brand);
  /* Rounded corners echo the favicon tile. */
  border-radius: 12px;
  /* Centering keeps the SVG optically balanced. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* A subtle glow separates the mark from the dark sidebar. */
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.28);
}

/* The logo glyph is slightly smaller than its tile. */
.brand-mark svg {
  /* Twenty-two pixels reads clearly at the sidebar scale. */
  width: 22px;
  /* Height matches the width. */
  height: 22px;
  /* White strokes and fills maximize contrast. */
  color: #ffffff;
}

/* The brand copy stacks the product name and promise. */
.brand-copy {
  /* Flex column keeps the hierarchy compact. */
  display: flex;
  /* Text remains in logical order under RTL. */
  flex-direction: column;
  /* A tight line height groups the pair. */
  line-height: 1.35;
  /* Long names may shrink within the sidebar. */
  min-width: 0;
}

/* The product name is the primary identity text. */
.brand-copy strong {
  /* A slightly tighter letter spacing suits the Latin and Arabic pair. */
  font-size: 14px;
  /* Six-hundred weight balances presence and calm. */
  font-weight: 600;
  /* Letter spacing remains neutral for Arabic shaping. */
  letter-spacing: 0;
}

/* The subtitle explains local execution in smaller copy. */
.brand-copy span {
  /* Eleven and a half pixels remains legible at compact density. */
  font-size: 11.5px;
  /* Muted text prevents the subtitle from competing. */
  color: var(--color-text-muted);
  /* One-line truncation preserves the sidebar rhythm. */
  white-space: nowrap;
  /* Overflow hides the clipped tail. */
  overflow: hidden;
  /* Ellipsis communicates truncation. */
  text-overflow: ellipsis;
}

/* The primary new-chat action spans the sidebar width. */
.new-chat-button {
  /* Full width aligns with search and conversation rows. */
  width: 100%;
  /* Flex aligns the plus icon and label. */
  display: flex;
  /* Center alignment reads as a primary action. */
  align-items: center;
  /* Centered content is comfortable for both scripts. */
  justify-content: center;
  /* A small gap separates icon and text. */
  gap: var(--space-2);
  /* Generous vertical padding creates a strong hit area. */
  padding: 11px 14px;
  /* The gradient matches the brand direction. */
  background: var(--gradient-brand);
  /* White text maximizes contrast. */
  color: #ffffff;
  /* Medium radius matches the button system. */
  border-radius: var(--radius-md);
  /* Semibold labels read as actions. */
  font-weight: 600;
  /* A subtle shadow adds lift without animation. */
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.22);
  /* Background position supports the hover sheen. */
  background-size: 120% 120%;
  /* Transitions keep the pointer feedback smooth. */
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-position var(--transition-fast);
}

/* Hover raises the primary action by one pixel, not by layout-shifting scale. */
.new-chat-button:hover {
  /* The one-pixel lift remains subtle. */
  transform: translateY(-1px);
  /* Shadow grows slightly on hover. */
  box-shadow: 0 12px 26px rgba(99, 102, 241, 0.3);
  /* The gradient shifts to suggest interaction. */
  background-position: 100% 0;
}

/* The button compresses on press for tactile feedback. */
.new-chat-button:active {
  /* Returning to the baseline indicates activation. */
  transform: translateY(0);
}

/* Search is a full-width field below the primary action. */
.search-field {
  /* The label is the visual field surface. */
  display: flex;
  /* Icon and input align on one line. */
  align-items: center;
  /* Gap separates the magnifier from text. */
  gap: var(--space-2);
  /* Margin in block direction separates it from adjacent controls. */
  margin-block: var(--space-3);
  /* Inline padding keeps the field compact. */
  padding-inline: 10px;
  /* The surface matches the card language. */
  background: var(--color-card);
  /* Borders are semantic and theme-aware. */
  border: 1px solid var(--color-border);
  /* Compact radius suits the sidebar control. */
  border-radius: var(--radius-sm);
  /* The transition prepares focus feedback. */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* The label responds when the contained input is focused. */
.search-field:focus-within {
  /* The primary border signals focus. */
  border-color: var(--color-primary);
  /* A soft ring provides accessible emphasis. */
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* The search icon is muted until focus. */
.search-field svg {
  /* Sixteen pixels fits the compact row. */
  width: 16px;
  /* Height matches width. */
  height: 16px;
  /* Muted icon prevents visual noise. */
  color: var(--color-text-faint);
}

/* The search input removes its own visual field treatment. */
.search-field input {
  /* Transparent background lets the label own the surface. */
  background: transparent;
  /* The outer label owns the border. */
  border: 0;
  /* Inner padding is reduced. */
  padding: 8px 0;
  /* The input fills the remaining width. */
  flex: 1;
  /* A compact font size suits the sidebar. */
  font-size: 13px;
  /* No permanent outline is needed on the nested input. */
  outline: none;
}

/* Search placeholders remain subtle but readable. */
.search-field input::placeholder {
  /* Muted text supports hierarchy. */
  color: var(--color-text-faint);
}

/* Conversation navigation scrolls independently from the brand and footer. */
.conversation-nav {
  /* Flex growth consumes available sidebar height. */
  flex: 1;
  /* A minimum height enables overflow behavior. */
  min-height: 0;
  /* Flex column keeps the heading fixed while the list scrolls. */
  display: flex;
  /* Vertical stacking is required. */
  flex-direction: column;
}

/* The heading row pairs the label with a count. */
.sidebar-heading {
  /* Flex aligns both ends. */
  display: flex;
  /* The count sits at the inline end. */
  align-items: center;
  /* Space-between creates the deliberate edge alignment. */
  justify-content: space-between;
  /* Inline padding aligns the heading with row content. */
  padding-inline: var(--space-2);
  /* Block spacing separates the heading from the scroll region. */
  padding-block-end: var(--space-2);
  /* Small uppercase-style labels guide scanning. */
  font-size: 10.5px;
  /* Semibold weight makes the label legible at small size. */
  font-weight: 600;
  /* Letter spacing is kept neutral for Arabic. */
  letter-spacing: 0.04em;
  /* Muted text balances hierarchy. */
  color: var(--color-text-faint);
}

/* The count chip is intentionally quiet. */
.conversation-count {
  /* Inline padding creates a pill. */
  padding-inline: 7px;
  /* Minimal block padding keeps the chip compact. */
  padding-block: 1px;
  /* The chip surface is translucent. */
  background: var(--color-primary-soft);
  /* Primary text identifies it as product UI. */
  color: var(--color-text-muted);
  /* A full radius creates a capsule. */
  border-radius: 999px;
  /* Tiny text fits the surrounding metadata scale. */
  font-size: 10px;
}

/* The conversation list is the sidebar scroll region. */
.conversation-list {
  /* Vertical overflow handles long histories. */
  overflow-y: auto;
  /* A minimum height permits flex shrinking. */
  min-height: 0;
  /* Right-side padding leaves room for scrollbars. */
  padding-inline-end: 2px;
  /* A tiny gap separates rows without a table-like grid. */
  display: flex;
  /* Stack rows vertically. */
  flex-direction: column;
  /* A consistent gap improves touch targets. */
  gap: 3px;
  /* Extra bottom padding avoids clipping the last row. */
  padding-block-end: var(--space-3);
}

/* Empty history and search states share a quiet panel. */
.conversation-empty {
  /* Horizontal padding aligns with sidebar copy. */
  padding: 22px 14px;
  /* Centered text reads as an empty state rather than a warning. */
  text-align: center;
  /* Faint metadata keeps the message reassuring. */
  color: var(--color-text-faint);
  /* Compact text fits the sidebar. */
  font-size: 12px;
  /* A dashed border communicates an empty slot. */
  border: 1px dashed var(--color-border);
  /* Rounded corners soften the empty state. */
  border-radius: var(--radius-md);
  /* A small top margin separates it from the heading. */
  margin-block-start: var(--space-2);
}

/* Each conversation row is a grid with a main button and action strip. */
.conversation-item {
  /* Minmax prevents long Arabic titles from expanding the sidebar. */
  display: grid;
  /* The main row flexes while actions keep intrinsic width. */
  grid-template-columns: minmax(0, 1fr) auto;
  /* Center alignment keeps action icons in the row baseline. */
  align-items: center;
  /* A small gap separates the row from actions. */
  gap: 2px;
  /* Rounded corners support hover and selection fills. */
  border-radius: var(--radius-sm);
  /* Relative positioning anchors nothing yet but supports future menus. */
  position: relative;
  /* Prefix animation uses a pseudo-element. */
  padding-inline-start: 0;
  /* Transitions keep active states gentle. */
  transition: background-color var(--transition-fast);
}

/* The active row receives a tinted background. */
.conversation-item.is-active {
  /* Soft primary tint identifies selection. */
  background: var(--color-primary-soft);
}

/* The active row gets a logical inline-start marker. */
.conversation-item.is-active::before {
  /* The marker is an absolute strip. */
  position: absolute;
  /* It hugs the inline start. */
  inset-inline-start: 0;
  /* It spans most of the row height. */
  inset-block: 8px;
  /* It is two pixels wide. */
  width: 2px;
  /* Primary color marks the selection. */
  background: var(--color-primary);
  /* Rounded ends keep it refined. */
  border-radius: 999px;
  /* A small content value makes the pseudo-element render. */
  content: "";
}

/* Hover reveals the row surface. */
.conversation-item:hover {
  /* A low-opacity surface reacts to the pointer. */
  background: var(--color-card);
}

/* The main row button owns the title and metadata. */
.conversation-main {
  /* Full width maximizes the click target. */
  width: 100%;
  /* Left alignment follows the inline start automatically. */
  text-align: start;
  /* Vertical padding creates a comfortable row. */
  padding: 9px 10px;
  /* Zero radius relies on the parent row. */
  border-radius: inherit;
  /* Flex column stacks title and metadata. */
  display: flex;
  /* The title must sit above metadata. */
  flex-direction: column;
  /* A tiny gap balances the two lines. */
  gap: 1px;
  /* Long titles must be allowed to shrink. */
  min-width: 0;
}

/* Conversation titles stay on one line with an ellipsis. */
.conversation-title {
  /* A compact size fits the sidebar. */
  font-size: 12.5px;
  /* Medium weight is readable but quiet. */
  font-weight: 500;
  /* Muted text gives the active model header priority. */
  color: var(--color-text);
  /* Truncation requires hidden overflow. */
  overflow: hidden;
  /* One-line clipping keeps row heights stable. */
  white-space: nowrap;
  /* Ellipsis communicates the clipped tail. */
  text-overflow: ellipsis;
}

/* Conversation metadata uses the faint text token. */
.conversation-meta {
  /* Ten and a half pixels separates metadata from the title. */
  font-size: 10.5px;
  /* Muted contrast keeps the row calm. */
  color: var(--color-text-faint);
  /* Truncation keeps counts and relative times on one line. */
  white-space: nowrap;
  /* Hidden overflow prevents sidebar widening. */
  overflow: hidden;
  /* Ellipsis provides a clean tail. */
  text-overflow: ellipsis;
}

/* The action strip appears on hover or keyboard focus. */
.conversation-actions {
  /* Actions align vertically. */
  display: flex;
  /* Column direction stacks four small buttons in a compact rail. */
  flex-direction: column;
  /* A tiny gap prevents accidental adjacent clicks. */
  gap: 1px;
  /* Right padding matches the navigation gutter. */
  padding-inline-end: 3px;
  /* Hidden actions reduce visual density. */
  opacity: 0;
  /* Visibility is delayed until interaction for keyboard users. */
  transition: opacity var(--transition-fast);
}

/* Show actions when the row is hovered. */
.conversation-item:hover .conversation-actions,
/* Show actions when focus enters the row. */
.conversation-item:focus-within .conversation-actions {
  /* Full opacity is the interactive state. */
  opacity: 1;
}

/* Individual action buttons are compact icon targets. */
.conversation-action {
  /* Square hit target. */
  width: 22px;
  /* Height matches width. */
  height: 22px;
  /* Centering keeps icons optically aligned. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* Rounded corners support hover feedback. */
  border-radius: 6px;
  /* Faint icons stay subordinate. */
  color: var(--color-text-faint);
  /* Transition applies color and background together. */
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Action icons are smaller than primary icons. */
.conversation-action svg {
  /* Fourteen pixels preserves click accuracy in a 22px target. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
}

/* Hover raises action contrast. */
.conversation-action:hover {
  /* Primary text color indicates the hovered action. */
  color: var(--color-text);
  /* A card background separates the target. */
  background: var(--color-card-raised);
}

/* Destructive action hover uses red. */
.conversation-action[data-action="delete"]:hover {
  /* Danger text warns before deletion. */
  color: var(--color-danger);
  /* Danger soft background reinforces intent. */
  background: var(--color-danger-soft);
}

/* The sidebar footer anchors connection status to the bottom. */
.sidebar-footer {
  /* Flex aligns the status dot, text, and shield. */
  display: flex;
  /* Center items vertically. */
  align-items: center;
  /* Small gap keeps the status compact. */
  gap: var(--space-2);
  /* Top padding separates it from the list. */
  padding-block-start: var(--space-3);
  /* Inline padding aligns with the heading. */
  padding-inline: var(--space-2);
  /* A border marks the footer boundary. */
  border-block-start: 1px solid var(--color-border);
  /* Small text suits operational metadata. */
  font-size: 11px;
  /* Muted text avoids stealing attention. */
  color: var(--color-text-muted);
  /* The shield sits at the inline end. */
  justify-content: flex-start;
}

/* The connection dot is a small semantic indicator. */
.status-dot {
  /* Fixed size prevents layout shifts. */
  width: 7px;
  /* Height matches width. */
  height: 7px;
  /* The capsule shape reads as a status light. */
  border-radius: 50%;
  /* The default state is warning while checking. */
  background: var(--color-warning);
  /* A subtle glow improves visibility. */
  box-shadow: 0 0 0 3px var(--color-warning-soft);
  /* The indicator is decorative; text carries the meaning. */
  flex: none;
}

/* A ready connection uses success green. */
.status-dot[data-state="ready"] {
  /* Success background confirms availability. */
  background: var(--color-success);
  /* The matching tint keeps the glow semantic. */
  box-shadow: 0 0 0 3px var(--color-success-soft);
}

/* Mock mode uses the primary violet to distinguish simulation. */
.status-dot[data-state="mock"] {
  /* Primary background identifies simulation rather than failure. */
  background: var(--color-primary);
  /* The tint matches the color. */
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* An offline connection uses danger red. */
.status-dot[data-state="offline"] {
  /* Danger background signals a missing local token or configuration. */
  background: var(--color-danger);
  /* The soft danger ring preserves the status language. */
  box-shadow: 0 0 0 3px var(--color-danger-soft);
}

/* The footer shield sits at the far inline end. */
.footer-shield {
  /* Fourteen pixels is a quiet security cue. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
  /* The icon is pushed to the inline end. */
  margin-inline-start: auto;
  /* Muted color keeps it informational. */
  color: var(--color-text-faint);
}

/* The workspace owns header, transcript, and composer. */
.workspace {
  /* Flex column pins the composer to the bottom. */
  display: flex;
  /* Stacking is required for the three regions. */
  flex-direction: column;
  /* A minimum width prevents grid blowout from long code. */
  min-width: 0;
  /* Full height lets the transcript scroll internally. */
  min-height: 0;
  /* A subtle top highlight separates the workspace from the sidebar. */
  background: linear-gradient(180deg, rgba(8, 13, 26, 0.2), transparent 18%);
}

/* The top bar is a sticky visual anchor within the workspace. */
.topbar {
  /* Fixed height supports scroll offsets and consistent alignment. */
  min-height: var(--topbar-height);
  /* Flex aligns context and actions. */
  display: flex;
  /* Center alignment keeps both groups on one baseline. */
  align-items: center;
  /* Space-between pushes actions to the inline end. */
  justify-content: space-between;
  /* Gap prevents crowding on narrow desktop widths. */
  gap: var(--space-4);
  /* Inline padding aligns with the transcript gutter. */
  padding-inline: var(--space-5);
  /* The border separates content from chat. */
  border-block-end: 1px solid var(--color-border);
  /* Translucency supports a soft backdrop. */
  background: rgba(8, 13, 26, 0.58);
  /* Blur keeps content legible while scrolling beneath. */
  backdrop-filter: blur(20px);
  /* The header must not shrink when the transcript is full. */
  flex: none;
  /* A stacking context keeps overlays predictable. */
  position: relative;
  /* The layer sits below fixed drawers. */
  z-index: 4;
}

/* Light theme header uses a pale translucent surface. */
[data-theme="light"] .topbar {
  /* The lighter scrim mirrors the page tone. */
  background: rgba(242, 244, 251, 0.72);
}

/* The context block stacks the eyebrow and model line. */
.chat-context {
  /* A minimum width avoids squeezing the text reveal. */
  min-width: 0;
  /* Flex column creates the hierarchy. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* A tight gap keeps the pair coherent. */
  gap: 1px;
}

/* Eyebrow labels use a small uppercase-style treatment. */
.eyebrow {
  /* Small text fits metadata. */
  font-size: 10px;
  /* Semibold weight preserves legibility. */
  font-weight: 600;
  /* Spacing is intentionally modest for Arabic. */
  letter-spacing: 0.08em;
  /* Muted color prevents competition. */
  color: var(--color-text-faint);
  /* Uppercase transforms only Latin and is harmless in Arabic. */
  text-transform: uppercase;
}

/* The model line aligns profile and model with a separator. */
.model-line {
  /* Flex keeps the three pieces on one line. */
  display: flex;
  /* Center alignment is correct for mixed text. */
  align-items: center;
  /* A small gap separates profile and model. */
  gap: 6px;
  /* Compact text fits the top bar. */
  font-size: 13px;
  /* Medium weight makes the active model identifiable. */
  font-weight: 500;
  /* Hidden overflow protects the action group. */
  min-width: 0;
}

/* The model separator is decorative and quiet. */
.model-separator {
  /* Faint color reduces visual noise. */
  color: var(--color-text-faint);
}

/* The model identifier is LTR and muted. */
.model-name {
  /* Monospace improves endpoint/model scanning. */
  font-family: var(--font-mono);
  /* Slightly smaller than the profile name. */
  font-size: 11.5px;
  /* Muted text keeps the profile primary. */
  color: var(--color-text-muted);
  /* Truncation prevents action overflow. */
  overflow: hidden;
  /* One-line truncation. */
  white-space: nowrap;
  /* Ellipsis handles long IDs. */
  text-overflow: ellipsis;
  /* A max width balances responsive behavior. */
  max-width: 260px;
}

/* The action group aligns global controls. */
.topbar-actions {
  /* Flex row places controls inline. */
  display: flex;
  /* Center alignment keeps icon buttons aligned. */
  align-items: center;
  /* A consistent gap separates grouped actions. */
  gap: var(--space-2);
  /* The group must not shrink below control widths. */
  flex: none;
}

/* The mode badge communicates live versus mock operation. */
.mode-badge {
  /* Inline flex centers the dot and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap keeps the dot attached to the label. */
  gap: 7px;
  /* Compact padding forms a capsule. */
  padding: 5px 10px;
  /* The border uses the primary tint. */
  border: 1px solid var(--color-border);
  /* Rounded capsule shape. */
  border-radius: 999px;
  /* Small text fits the header. */
  font-size: 10.5px;
  /* Medium weight keeps the label legible. */
  font-weight: 600;
  /* Muted text is appropriate metadata. */
  color: var(--color-text-muted);
  /* A translucent surface separates it from the header. */
  background: var(--color-card);
}

/* The badge dot is smaller than the sidebar status. */
.mode-badge .status-dot {
  /* Five pixels is enough at this scale. */
  width: 6px;
  /* Height matches width. */
  height: 6px;
  /* A thinner ring preserves space. */
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

/* Mock mode uses the primary color for its badge. */
.mode-badge[data-mode="mock"] {
  /* The border becomes violet-tinted. */
  border-color: rgba(124, 58, 237, 0.35);
  /* The text uses primary. */
  color: var(--color-primary);
}

/* The language button has a wider label than icon controls. */
#langToggle {
  /* Flex aligns the symbol and language. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* Gap separates the glyph from the label. */
  gap: 6px;
  /* Compact padding forms a soft button. */
  padding: 7px 10px;
  /* Rounded corners match the header. */
  border-radius: var(--radius-sm);
  /* A card surface separates the toggle. */
  background: var(--color-card);
  /* A border clarifies the control. */
  border: 1px solid var(--color-border);
  /* Small text fits the top bar. */
  font-size: 11.5px;
  /* Medium weight helps the label. */
  font-weight: 600;
  /* Transition applies hover and focus. */
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

/* Hover lifts the language control surface. */
#langToggle:hover {
  /* The border becomes more visible. */
  border-color: var(--color-border-strong);
  /* The raised surface hints interactivity. */
  background: var(--color-card-raised);
}

/* The language glyph uses the display font. */
.lang-symbol {
  /* A small circular badge anchors the symbol. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* Centered glyph. */
  display: grid;
  /* Center both axes. */
  place-items: center;
  /* A soft primary fill identifies the locale control. */
  background: var(--color-primary-soft);
  /* Rounded shape. */
  border-radius: 50%;
  /* Primary color links it to product branding. */
  color: var(--color-primary);
  /* Very small glyph size. */
  font-size: 9px;
}

/* Icon buttons are square, quiet actions. */
.icon-button {
  /* Square 36-pixel target. */
  width: 36px;
  /* Height matches width. */
  height: 36px;
  /* Centered icon. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* Rounded corners match the system. */
  border-radius: var(--radius-sm);
  /* Muted icons avoid visual noise. */
  color: var(--color-text-muted);
  /* Transparent surface by default. */
  background: transparent;
  /* Transitions manage hover and focus. */
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

/* Icon hover reveals a surface and primary text. */
.icon-button:hover {
  /* Primary text signals interaction. */
  color: var(--color-text);
  /* The card surface delineates the target. */
  background: var(--color-card);
}

/* Icon buttons can carry a subtle border when needed. */
.icon-button.subtle {
  /* Explicit border separates it from dense panels. */
  border: 1px solid var(--color-border);
}

/* The theme toggle holds two icons; CSS reveals the correct one. */
.theme-icon {
  /* Icons overlap in the same grid cell. */
  grid-area: 1 / 1;
  /* Default transition cross-fades icon states. */
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

/* The sun icon is visible in dark mode to invite switching to light. */
.theme-icon-sun {
  /* Hidden initially. */
  opacity: 0;
  /* A small rotation adds character without layout shift. */
  transform: rotate(-45deg) scale(0.7);
}

/* When the light theme is active, show the sun icon. */
[data-theme="light"] .theme-icon-sun {
  /* Reveal the sun. */
  opacity: 1;
  /* Settle the icon into place. */
  transform: rotate(0) scale(1);
}

/* Hide the moon icon in light mode. */
[data-theme="light"] .theme-icon-moon {
  /* Fade the moon out. */
  opacity: 0;
  /* Shrink subtly during the transition. */
  transform: scale(0.7);
}

/* Global error banners span the workspace width with a calm danger surface. */
.error-banner {
  /* Flex aligns icon, copy, and close action. */
  display: flex;
  /* Initial alignment puts the icon at the top of multiline copy. */
  align-items: flex-start;
  /* A comfortable gap separates the icon. */
  gap: var(--space-3);
  /* Margin aligns with the transcript gutter. */
  margin: var(--space-3) var(--space-5) 0;
  /* Padding creates a readable alert block. */
  padding: var(--space-3) var(--space-4);
  /* The danger tint is semantic but restrained. */
  background: var(--color-danger-soft);
  /* The border completes the alert surface. */
  border: 1px solid rgba(248, 113, 113, 0.24);
  /* Rounded corners match cards. */
  border-radius: var(--radius-md);
  /* Danger color emphasizes the alert icon. */
  color: var(--color-danger);
  /* The banner is not part of the scrollable transcript. */
  flex: none;
}

/* The banner icon is aligned with the title line. */
.error-banner > svg {
  /* Eighteen pixels fits the alert. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* A small top offset aligns with the title baseline. */
  margin-block-start: 2px;
}

/* The banner copy blocks stack title, message, and hint. */
.error-banner-copy {
  /* Flex column creates hierarchy. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* A tight gap keeps the alert compact. */
  gap: 2px;
  /* The copy consumes remaining width. */
  flex: 1;
  /* A minimum width prevents overflow. */
  min-width: 0;
}

/* The banner title uses the danger color at readable contrast. */
.error-banner-copy strong {
  /* Thirteen pixels is legible without overwhelming chat. */
  font-size: 12.5px;
  /* Semibold weight marks the title. */
  font-weight: 600;
}

/* The banner message keeps the primary text color for readability. */
.error-banner-copy p {
  /* Reset default paragraph margins. */
  margin: 0;
  /* Secondary text is easier to read than all-danger prose. */
  color: var(--color-text);
  /* Twelve and a half pixels is the compact alert scale. */
  font-size: 12.5px;
  /* A relaxed line height handles bilingual warnings. */
  line-height: 1.55;
}

/* The retry hint is additional metadata. */
.error-banner-copy span {
  /* Faint text separates the hint from the message. */
  color: var(--color-text-muted);
  /* Eleven pixels suits secondary guidance. */
  font-size: 11px;
}

/* The close action is pushed to the inline end. */
.error-banner-close {
  /* A smaller target fits the alert. */
  width: 28px;
  /* Height matches width. */
  height: 28px;
  /* The icon is inherited at a smaller size. */
  color: var(--color-danger);
}

/* The transcript fills the center and scrolls independently. */
.chat-main {
  /* Flex growth consumes space between header and composer. */
  flex: 1;
  /* Vertical scrolling supports long conversations. */
  overflow-y: auto;
  /* Horizontal clipping prevents code from widening the workspace. */
  overflow-x: hidden;
  /* Padding creates the main reading gutter. */
  padding: var(--space-4) var(--space-5) var(--space-3);
  /* Scroll padding keeps focus visible above the composer. */
  scroll-padding-block-end: 140px;
  /* A stacking context supports the empty orb. */
  position: relative;
  /* The transcript is the only smooth-scrolling region. */
  scroll-behavior: smooth;
}

/* The empty state is a centered onboarding composition. */
.empty-state {
  /* A comfortable maximum width supports prompt cards. */
  max-width: 880px;
  /* Horizontal auto margins center the content. */
  margin-inline: auto;
  /* Vertical padding balances the available height. */
  padding-block: clamp(28px, 7vh, 76px) var(--space-6);
  /* Centered text reads as an invitation. */
  text-align: center;
  /* A fade-in signals a fresh workspace. */
  animation: fade-up 520ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* The orb is the visual signature of the empty state. */
.orb {
  /* Relative positioning contains the ring and core. */
  position: relative;
  /* A square provides a stable circle. */
  width: 96px;
  /* Height matches width. */
  height: 96px;
  /* Centering creates the glowing core. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* Auto inline margins center the orb. */
  margin-inline: auto;
  /* Bottom spacing separates it from the headline. */
  margin-block-end: var(--space-5);
  /* The brand gradient gives the core life. */
  background: var(--gradient-brand);
  /* A circular shape is essential. */
  border-radius: 32px;
  /* The rotation is subtle and slows under reduced motion. */
  transform: rotate(8deg);
  /* A layered shadow creates glow. */
  box-shadow:
    0 0 0 10px rgba(99, 102, 241, 0.08),
    0 24px 60px rgba(99, 102, 241, 0.32);
  /* A slow float animation adds personality. */
  animation: orb-float 6s ease-in-out infinite;
}

/* The sparkle icon sits centered in the orb. */
.orb > svg {
  /* Thirty pixels is a confident focal icon. */
  width: 30px;
  /* Height matches width. */
  height: 30px;
  /* White icon maximizes contrast. */
  color: #ffffff;
  /* The glyph is upright inside the tilted orb. */
  transform: rotate(-8deg);
}

/* The ring is a decorative orbit around the core. */
.orb-ring {
  /* Absolute positioning covers the core. */
  position: absolute;
  /* Negative inset expands beyond the core. */
  inset: -18px;
  /* A faint border reads as an orbit. */
  border: 1px solid rgba(165, 180, 252, 0.22);
  /* The orbit should be circular. */
  border-radius: 50%;
  /* A dashed variant suggests a technical diagram. */
  border-style: dashed;
  /* The ring rotates slowly. */
  animation: spin 26s linear infinite;
}

/* The kicker introduces the local privacy posture. */
.empty-kicker {
  /* Reset paragraph margins. */
  margin: 0 0 var(--space-2);
  /* Uppercase-style metadata. */
  font-size: 10.5px;
  /* Semibold weight keeps tiny copy legible. */
  font-weight: 600;
  /* Letter spacing is modest for bilingual text. */
  letter-spacing: 0.12em;
  /* Primary color ties the introduction to the brand. */
  color: var(--color-primary);
  /* Uppercase only affects Latin. */
  text-transform: uppercase;
}

/* The empty headline is the largest type on the page. */
.empty-state h1 {
  /* Fluid sizing balances desktop and compact phones. */
  font-size: clamp(28px, 4.2vw, 44px);
  /* Tight line height creates a poster-like headline. */
  line-height: 1.18;
  /* A slightly tighter tracking is safe for Arabic with Plex. */
  letter-spacing: -0.025em;
  /* Strong weight establishes hierarchy. */
  font-weight: 600;
  /* A subtle gradient adds depth. */
  background: linear-gradient(180deg, var(--color-text), var(--color-text-muted));
  /* The gradient clips to the glyphs. */
  -webkit-background-clip: text;
  /* Standard background clipping supports modern browsers. */
  background-clip: text;
  /* The text fill must be transparent for the gradient. */
  -webkit-text-fill-color: transparent;
  /* Reset default heading margins. */
  margin: 0 auto var(--space-3);
  /* A readable max width controls line breaks. */
  max-width: 760px;
}

/* The empty subtitle explains the workflow. */
.empty-subtitle {
  /* A comfortable measure supports bilingual copy. */
  max-width: 620px;
  /* Auto margins center the paragraph. */
  margin: 0 auto;
  /* Muted text separates it from the headline. */
  color: var(--color-text-muted);
  /* Fifteen pixels supports the onboarding tone. */
  font-size: 15px;
  /* The line height keeps Arabic airy. */
  line-height: 1.7;
}

/* Suggestions are a two-column card grid. */
.suggestions {
  /* Grid layout creates a balanced quartet. */
  display: grid;
  /* Two columns work from tablet upward. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* A consistent gap separates cards. */
  gap: var(--space-3);
  /* Top margin separates suggestions from the subtitle. */
  margin-block-start: var(--space-6);
  /* Text alignment inside cards is stage. */
  text-align: start;
}

/* Suggestion cards are tactile surface buttons. */
.suggestion-card {
  /* Flex column creates icon, title, and hint. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* Initial alignment is start. */
  align-items: flex-start;
  /* A small gap keeps the stack tight. */
  gap: 3px;
  /* Padding creates a generous card target. */
  padding: var(--space-4);
  /* The card surface matches the design system. */
  background: var(--color-card);
  /* A semantic border separates cards. */
  border: 1px solid var(--color-border);
  /* Rounded corners match the system. */
  border-radius: var(--radius-md);
  /* A subtle shadow adds depth. */
  box-shadow: var(--shadow-sm);
  /* Text uses the primary color token. */
  color: var(--color-text);
  /* The transition animates hover lift. */
  transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Hover lifts the card and brightens the border. */
.suggestion-card:hover {
  /* A one-pixel lift avoids layout shift. */
  transform: translateY(-2px);
  /* The primary border signals interactivity. */
  border-color: rgba(99, 102, 241, 0.42);
  /* The raised surface differentiates the hovered card. */
  background: var(--color-card-raised);
  /* The shadow deepens slightly. */
  box-shadow: var(--shadow-md);
}

/* The suggestion icon sits in a small brand-tinted tile. */
.suggestion-card > svg {
  /* The tile size is expressed through width and height. */
  width: 30px;
  /* Height matches width. */
  height: 30px;
  /* Inner icon spacing is not possible directly, so padding uses the box. */
  padding: 7px;
  /* A soft primary surface ties the icon to the brand. */
  background: var(--color-primary-soft);
  /* Primary icon color is readable on the tint. */
  color: var(--color-primary);
  /* A compact radius echoes the system. */
  border-radius: 9px;
  /* Margin separates the tile from the title. */
  margin-block-end: var(--space-1);
}

/* Suggestion titles use a readable body size. */
.suggestion-card span {
  /* Thirteen pixels is legible but compact. */
  font-size: 13px;
  /* Medium weight marks the action. */
  font-weight: 500;
  /* A relaxed line height handles wrapping. */
  line-height: 1.5;
}

/* Suggestion hints are secondary metadata. */
.suggestion-card small {
  /* Eleven pixels fits the card. */
  font-size: 11px;
  /* Muted text prevents competition. */
  color: var(--color-text-muted);
  /* Relaxed line height supports Arabic hints. */
  line-height: 1.45;
}

/* Feature chips summarize capabilities at the bottom of onboarding. */
.feature-row {
  /* Flex wrap handles narrow screens. */
  display: flex;
  /* Centered wrapping looks deliberate. */
  justify-content: center;
  /* Gaps separate chips. */
  gap: var(--space-2);
  /* Top margin separates the row. */
  margin-block-start: var(--space-5);
  /* Chips can wrap on mobile. */
  flex-wrap: wrap;
}

/* Feature chips pair a small icon with a label. */
.feature-chip {
  /* Inline flex keeps icon and text together. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and label. */
  gap: 6px;
  /* Capsule padding. */
  padding: 5px 10px;
  /* A faint border gives shape. */
  border: 1px solid var(--color-border);
  /* Rounded pills match metadata controls. */
  border-radius: 999px;
  /* Small text fits the feature row. */
  font-size: 10.5px;
  /* Muted text stays quiet. */
  color: var(--color-text-muted);
  /* Translucent card background. */
  background: var(--color-card);
}

/* Feature icons are smaller than action icons. */
.feature-chip svg {
  /* Fourteen pixels fits the capsule. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
  /* Primary color ties the chip to the product. */
  color: var(--color-primary);
}

/* The message list centers the transcript and fades new content in. */
.message-list {
  /* A max width creates a readable measure. */
  max-width: 900px;
  /* Auto margins center the column. */
  margin-inline: auto;
  /* Bottom padding keeps the last message above the composer. */
  padding-block-end: var(--space-4);
}

/* Each message is a flex row with an avatar and body. */
.message {
  /* Flex creates the two-column message geometry. */
  display: flex;
  /* Avatar aligns with the first content line. */
  align-items: flex-start;
  /* Gap separates avatar and body. */
  gap: var(--space-3);
  /* Vertical spacing separates turns. */
  padding-block: 18px;
  /* A fade-up animation makes streamed turns feel intentional. */
  animation: fade-up 260ms ease both;
}

/* User turns align from the inline end by reversing flex order. */
.message-user {
  /* Row-reverse places the avatar at the inline end. */
  flex-direction: row-reverse;
}

/* The avatar is a fixed circular identity marker. */
.message-avatar {
  /* Fixed size prevents layout shifts. */
  width: 34px;
  /* Height matches width. */
  height: 34px;
  /* Center alignment for the glyph. */
  display: grid;
  /* Center both axes. */
  place-items: center;
  /* A circle matches chat conventions. */
  border-radius: 11px;
  /* The default surface is raised card. */
  background: var(--color-card-raised);
  /* A border separates it from the transcript. */
  border: 1px solid var(--color-border);
  /* The avatar is decorative unless role text is hidden. */
  flex: none;
  /* The mid-sized radius feels tactile. */
  font-size: 11px;
  /* Weight supports initials. */
  font-weight: 700;
}

/* The assistant avatar uses the brand gradient. */
.message-assistant .message-avatar {
  /* The gradient associates the model with branding. */
  background: var(--gradient-brand);
  /* White icon contrast. */
  color: #ffffff;
  /* No border is needed on the saturated surface. */
  border-color: transparent;
  /* A soft glow adds depth. */
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.2);
}

/* The assistant avatar icon is smaller than the button icon. */
.message-assistant .message-avatar svg {
  /* Eighteen pixels fits the 34px avatar. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
}

/* The user avatar uses a soft primary tint. */
.message-user .message-avatar {
  /* Translucent primary distinguishes the user. */
  background: var(--color-primary-soft);
  /* Primary text color marks the user initial. */
  color: var(--color-primary);
  /* No border is needed. */
  border-color: transparent;
}

/* The message body holds metadata, attachments, and prose. */
.message-body {
  /* A minimum width allows long words to wrap. */
  min-width: 0;
  /* A generous measure supports prose. */
  max-width: min(100%, 760px);
  /* Padding is applied to user bubbles and assistant cards. */
  padding: var(--space-3) var(--space-4);
  /* Rounded corners match the card language. */
  border-radius: var(--radius-md);
  /* User messages use a subtle primary tint. */
  background: var(--color-primary-soft);
  /* A faint primary border defines the bubble. */
  border: 1px solid rgba(99, 102, 241, 0.18);
}

/* Assistant messages use a neutral card to prioritize prose. */
.message-assistant .message-body {
  /* Neutral cards separate model prose from the page. */
  background: var(--color-card);
  /* A neutral border keeps the card quiet. */
  border: 1px solid var(--color-border);
  /* The card fills more of the available measure. */
  flex: 1;
  /* A slightly larger maximum improves code display. */
  max-width: min(100%, 820px);
}

/* Metadata aligns role and time. */
.message-meta {
  /* Flex separates role and timestamp. */
  display: flex;
  /* Center alignment keeps the baseline balanced. */
  align-items: center;
  /* A small gap separates the label and time. */
  gap: var(--space-2);
  /* Bottom margin separates metadata from content. */
  margin-block-end: 4px;
  /* Compact type fits metadata. */
  font-size: 10.5px;
  /* Faint color keeps it subordinate. */
  color: var(--color-text-faint);
}

/* User metadata mirrors to the inline end for alignment. */
.message-user .message-meta {
  /* Row reverse places the role at the inline end. */
  flex-direction: row-reverse;
  /* The row aligns with the user bubble's inline end. */
  justify-content: flex-start;
}

/* The role label is emphasized. */
.message-role {
  /* Semibold weight distinguishes the author. */
  font-weight: 600;
  /* Muted text is readable without competing. */
  color: var(--color-text-muted);
}

/* Message prose handles mixed Arabic and English naturally. */
.message-prose {
  /* Opaque bidi treatment lets each paragraph choose direction. */
  unicode-bidi: plaintext;
  /* Word breaking prevents endpoint overflow. */
  overflow-wrap: anywhere;
  /* Fourteen and a half pixels balances code and prose. */
  font-size: 14.5px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.75;
  /* The prose consumes the body width. */
  min-width: 0;
}

/* Paragraphs inside rendered Markdown need stable spacing. */
.message-prose p {
  /* Zero top margin avoids gaps after metadata. */
  margin: 0 0 0.7em;
}

/* The final paragraph removes the trailing gap. */
.message-prose p:last-child {
  /* The bubble padding provides the bottom space. */
  margin-block-end: 0;
}

/* Strong text inside assistant prose is clear but not heavy. */
.message-prose strong {
  /* Semibold weight preserves readability. */
  font-weight: 600;
  /* Primary text color distinguishes emphasis. */
  color: var(--color-text);
}

/* Inline code is isolated LTR content. */
.message-prose code:not(pre code) {
  /* Monospace is essential for technical identifiers. */
  font-family: var(--font-mono);
  /* A compact size fits inline code. */
  font-size: 0.86em;
  /* The inline chip uses a contrasting surface. */
  background: var(--color-inline-code);
  /* Padding keeps glyphs from touching the edge. */
  padding: 1px 5px;
  /* Rounded chip corners. */
  border-radius: 5px;
  /* Direction isolation prevents punctuation inversion in RTL. */
  direction: ltr;
  /* Inline rendering preserves text flow. */
  unicode-bidi: isolate;
}

/* Fenced code blocks always read left-to-right. */
.code-block {
  /* Direction is forced regardless of the document direction. */
  direction: ltr;
  /* Text aligns left inside code. */
  text-align: left;
  /* Horizontal overflow handles long lines. */
  overflow-x: auto;
  /* Code surfaces are dark in both themes. */
  background: var(--color-code-bg);
  /* A subtle border separates the block. */
  border: 1px solid var(--color-border);
  /* Rounded corners match the system. */
  border-radius: var(--radius-sm);
  /* Top margin separates code from prose. */
  margin-block: var(--space-3);
  /* The block uses a small readable monospace. */
  font-family: var(--font-mono);
  /* Twelve and a half pixels fits dense code. */
  font-size: 12.5px;
  /* A compact line height keeps code scannable. */
  line-height: 1.6;
  /* The code block is a positioning context for the copy button. */
  position: relative;
  /* Unicode isolation is essential in RTL documents. */
  unicode-bidi: isolate;
}

/* The code header holds language and copy action. */
.code-block-head {
  /* Flex places the language at the inline start and copy at the end. */
  display: flex;
  /* Center alignment is required. */
  align-items: center;
  /* Space-between pushes the copy button. */
  justify-content: space-between;
  /* A small gap separates the two. */
  gap: var(--space-2);
  /* Inline padding aligns with code text. */
  padding: 6px 10px;
  /* A border separates the header from code. */
  border-block-end: 1px solid rgba(203, 213, 225, 0.1);
  /* Faint text fits code metadata. */
  color: #94a3b8;
  /* Tiny uppercase-style language labels. */
  font-size: 9.5px;
  /* Letter spacing helps Latin labels. */
  letter-spacing: 0.06em;
  /* Uppercase affects only Latin. */
  text-transform: uppercase;
}

/* Code body padding creates breathing room. */
.code-block code {
  /* Display block makes padding and overflow predictable. */
  display: block;
  /* Generous padding supports reading. */
  padding: 12px 14px;
  /* The dark code background is inherited. */
  background: transparent;
  /* White text is readable on the dark code surface. */
  color: #e2e8f0;
  /* Long lines scroll horizontally. */
  white-space: pre;
}

/* The copy button is a small text-and-icon control. */
.code-copy {
  /* Inline flex aligns icon and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and label. */
  gap: 4px;
  /* Compact padding fits the header. */
  padding: 3px 6px;
  /* The button is soft on the dark code surface. */
  background: rgba(148, 163, 184, 0.12);
  /* Light text maintains contrast. */
  color: #cbd5e1;
  /* Rounded corners fit the header. */
  border-radius: 5px;
  /* Small text is sufficient. */
  font-size: 9.5px;
  /* Letter spacing remains neutral. */
  letter-spacing: 0;
  /* The button transitions on hover. */
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

/* Code copy icons are compact. */
.code-copy svg {
  /* Twelve pixels fits the header. */
  width: 12px;
  /* Height matches width. */
  height: 12px;
}

/* Hover brightens the copy action. */
.code-copy:hover {
  /* Brighter text indicates interaction. */
  color: #ffffff;
  /* A stronger translucent surface supports the hover. */
  background: rgba(148, 163, 184, 0.22);
}

/* The streaming indicator is a blinking caret after the latest prose. */
.message.is-streaming .message-prose::after {
  /* The caret is a small inline block. */
  content: "";
  /* It is displayed inline with text. */
  display: inline-block;
  /* A two-pixel width resembles a terminal cursor. */
  width: 2px;
  /* The caret height matches the line box. */
  height: 1em;
  /* A small inline-start margin separates it from text. */
  margin-inline-start: 3px;
  /* Primary color links the caret to streaming. */
  background: var(--color-primary);
  /* The caret sits on the baseline. */
  vertical-align: -0.1em;
  /* The blink animation is subtle. */
  animation: blink 1s steps(2, start) infinite;
}

/* Thinking dots appear before the first token. */
.thinking {
  /* Inline flex keeps the dots and label together. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates dots from text. */
  gap: 8px;
  /* Muted text fits the waiting state. */
  color: var(--color-text-muted);
  /* The label is compact. */
  font-size: 12px;
}

/* The dot container aligns three pulses. */
.thinking-dots {
  /* Inline flex aligns the dots. */
  display: inline-flex;
  /* Small gap between dots. */
  gap: 3px;
}

/* Each dot pulses with a staggered delay. */
.thinking-dots span {
  /* Dots are small circular markers. */
  width: 5px;
  /* Height matches width. */
  height: 5px;
  /* Primary color indicates model activity. */
  background: var(--color-primary);
  /* Circular shape. */
  border-radius: 50%;
  /* The pulse animation repeats. */
  animation: pulse 1.2s ease-in-out infinite;
}

/* The second dot is delayed for a wave effect. */
.thinking-dots span:nth-child(2) {
  /* A short delay creates the sequence. */
  animation-delay: 140ms;
}

/* The third dot completes the wave. */
.thinking-dots span:nth-child(3) {
  /* The final delay offsets the third pulse. */
  animation-delay: 280ms;
}

/* Message attachments sit above the prose. */
.message-attachments {
  /* Flex wrap supports multiple chips. */
  display: flex;
  /* Wrapping prevents overflow. */
  flex-wrap: wrap;
  /* Gaps separate media and documents. */
  gap: var(--space-2);
  /* Bottom margin separates attachments from prose. */
  margin-block-end: var(--space-2);
}

/* Message images render as compact thumbnails. */
.message-image {
  /* Zero margin removes figure defaults. */
  margin: 0;
  /* A border defines the image edge. */
  border: 1px solid var(--color-border);
  /* Rounded corners match cards. */
  border-radius: var(--radius-sm);
  /* Overflow clipping respects the radius. */
  overflow: hidden;
  /* A soft background shows while loading. */
  background: var(--color-card-raised);
  /* The image shrinks within the message. */
  max-width: 320px;
}

/* Thumbnail images crop consistently. */
.message-image img {
  /* The image fills the figure. */
  width: 100%;
  /* A bounded height prevents tall screenshots dominating the transcript. */
  max-height: 220px;
  /* Cover preserves visual content without stretching. */
  object-fit: cover;
}

/* Document chips pair an icon with a name. */
.document-chip {
  /* Inline flex keeps icon and label aligned. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and name. */
  gap: 5px;
  /* Compact padding forms a chip. */
  padding: 4px 8px;
  /* The raised card surface distinguishes the chip. */
  background: var(--color-card-raised);
  /* A border defines the chip. */
  border: 1px solid var(--color-border);
  /* Rounded corners match metadata chips. */
  border-radius: 6px;
  /* Small text fits the attachment row. */
  font-size: 10.5px;
  /* Muted text stays informative. */
  color: var(--color-text-muted);
  /* The chip cannot overflow the message. */
  max-width: 100%;
}

/* Document chip icons are compact. */
.document-chip svg {
  /* Fourteen pixels fits the chip. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
  /* Primary color identifies transferred context. */
  color: var(--color-primary);
}

/* Long document names truncate. */
.document-chip span {
  /* Hidden overflow enables ellipsis. */
  overflow: hidden;
  /* One-line truncation. */
  white-space: nowrap;
  /* Ellipsis marks the clipped tail. */
  text-overflow: ellipsis;
}

/* Message actions appear below prose. */
.message-actions {
  /* Flex aligns the copy control. */
  display: flex;
  /* A top margin separates actions from content. */
  margin-block-start: 6px;
  /* Actions align at the inline end for assistant cards. */
  justify-content: flex-end;
}

/* The copy action is a quiet icon-text button. */
.message-action {
  /* Inline flex aligns icon and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and text. */
  gap: 4px;
  /* Compact padding fits metadata scale. */
  padding: 3px 6px;
  /* Rounded corners match the action system. */
  border-radius: 5px;
  /* Faint color keeps actions secondary. */
  color: var(--color-text-faint);
  /* Small type fits the message footer. */
  font-size: 9.5px;
  /* Transition applies hover feedback. */
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Message action icons are compact. */
.message-action svg {
  /* Twelve pixels fits the footer. */
  width: 12px;
  /* Height matches width. */
  height: 12px;
}

/* Hover raises action contrast. */
.message-action:hover {
  /* Primary text indicates action. */
  color: var(--color-text);
  /* A subtle surface separates the target. */
  background: var(--color-card-raised);
}

/* The composer region is the fixed bottom composition. */
.composer-region {
  /* The region stays at the bottom of the workspace. */
  flex: none;
  /* A maximum width centers the composer with the transcript. */
  max-width: 960px;
  /* Full width ensures the field grows on desktop. */
  width: 100%;
  /* Auto inline margins center the region. */
  margin-inline: auto;
  /* Padding creates separation from the transcript and viewport edge. */
  padding: var(--space-2) var(--space-5) max(14px, env(safe-area-inset-bottom));
  /* Relative positioning supports the drop overlay. */
  position: relative;
  /* A soft gradient fades the transcript into the composer surface. */
  background: linear-gradient(180deg, transparent, var(--color-bg) 24%);
}

/* The attachment tray appears above the composer. */
.attachment-tray {
  /* Flex wrap supports multiple chips. */
  display: flex;
  /* Wrapping each item. */
  flex-wrap: wrap;
  /* Gap between previews. */
  gap: var(--space-2);
  /* Bottom margin separates previews from the field. */
  margin-block-end: var(--space-2);
  /* Fade-in indicates new attachments. */
  animation: fade-up 200ms ease both;
}

/* Pending images use a compact preview card. */
.pending-image {
  /* Relative positioning anchors the remove button. */
  position: relative;
  /* A fixed preview size keeps the tray tidy. */
  width: 76px;
  /* Height matches width. */
  height: 76px;
  /* Rounded corners match the system. */
  border-radius: var(--radius-sm);
  /* Overflow clipping respects the radius. */
  overflow: hidden;
  /* A border defines the preview. */
  border: 1px solid var(--color-border);
  /* A raised surface shows during image load. */
  background: var(--color-card-raised);
}

/* Preview images fill their card. */
.pending-image img {
  /* Full width fills the card. */
  width: 100%;
  /* Full height fills the card. */
  height: 100%;
  /* Cover avoids distortion. */
  object-fit: cover;
}

/* The remove button floats over the preview. */
.attachment-remove {
  /* Absolute positioning places it at the inline end. */
  position: absolute;
  /* The top edge is clipped to the card. */
  inset-block-start: 4px;
  /* The inline end edge follows the document direction. */
  inset-inline-end: 4px;
  /* A small square is an adequate target. */
  width: 20px;
  /* Height matches width. */
  height: 20px;
  /* Centering keeps the icon aligned. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* A dark scrim guarantees icon contrast on any image. */
  background: rgba(3, 7, 18, 0.72);
  /* White icon color. */
  color: #ffffff;
  /* A circular target reads as a close action. */
  border-radius: 50%;
  /* A subtle border separates it from imagery. */
  border: 1px solid rgba(255, 255, 255, 0.24);
  /* Backdrop blur improves contrast. */
  backdrop-filter: blur(4px);
}

/* Remove icons are tiny. */
.attachment-remove svg {
  /* Twelve pixels fits the 20px button. */
  width: 12px;
  /* Height matches width. */
  height: 12px;
}

/* Pending documents use a wider chip with a remove action. */
.pending-document {
  /* Relative positioning anchors the remove control. */
  position: relative;
  /* Inline flex aligns icon and copy. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and text. */
  gap: var(--space-2);
  /* Padding leaves room for the remove button. */
  padding: 7px 32px 7px 10px;
  /* The raised surface distinguishes the document. */
  background: var(--color-card-raised);
  /* A border defines the chip. */
  border: 1px solid var(--color-border);
  /* Rounded corners match the component language. */
  border-radius: var(--radius-sm);
  /* The document may shrink on narrow screens. */
  max-width: min(100%, 320px);
}

/* The directional padding is mirrored by the logical override below. */
[dir="rtl"] .pending-document {
  /* RTL needs the larger padding on the inline start for the remove button. */
  padding: 7px 10px 7px 32px;
}

/* Document preview icons are primary-tinted. */
.pending-document > svg {
  /* Eighteen pixels fits the chip. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* Primary color marks local extraction. */
  color: var(--color-primary);
}

/* The document copy stacks name and metadata. */
.pending-document-copy {
  /* Flex column keeps the pair compact. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* A very tight gap groups metadata. */
  gap: 1px;
  /* Long names must shrink. */
  min-width: 0;
}

/* Pending document names truncate. */
.pending-document-copy strong {
  /* Twelve pixels is legible in the tray. */
  font-size: 11.5px;
  /* Medium weight marks the name. */
  font-weight: 500;
  /* Truncation prevents chip growth. */
  overflow: hidden;
  /* One-line text. */
  white-space: nowrap;
  /* Ellipsis marks overflow. */
  text-overflow: ellipsis;
}

/* Pending document metadata is faint. */
.pending-document-copy small {
  /* Ten pixels fits the compact metadata. */
  font-size: 9.5px;
  /* Muted color keeps it secondary. */
  color: var(--color-text-faint);
}

/* The remove control inside a document chip is positioned logically. */
.pending-document .attachment-remove {
  /* Remove the absolute top inset for the chip layout. */
  inset-block-start: 50%;
  /* The logical end remains four pixels from the edge. */
  inset-inline-end: 5px;
  /* The transform centers it vertically. */
  transform: translateY(-50%);
}

/* The drop overlay is a full composer region surface. */
.drop-overlay {
  /* Absolute positioning covers the composer region. */
  position: absolute;
  /* The inset follows all four edges. */
  inset: 0 var(--space-5) max(14px, env(safe-area-inset-bottom));
  /* A high layer sits above the composer. */
  z-index: 12;
  /* Centering creates the drop invitation. */
  display: flex;
  /* Stack icon and text. */
  flex-direction: column;
  /* Center alignment. */
  align-items: center;
  /* Center content vertically. */
  justify-content: center;
  /* A small gap separates icon and copy. */
  gap: var(--space-2);
  /* A translucent brand surface distinguishes the drop state. */
  background: rgba(67, 56, 202, 0.18);
  /* A dashed primary border communicates a drop zone. */
  border: 2px dashed var(--color-primary);
  /* Rounded corners match the composer. */
  border-radius: var(--radius-lg);
  /* A backdrop blur separates the state. */
  backdrop-filter: blur(10px);
  /* Primary text identifies the action. */
  color: var(--color-text);
  /* Medium text is legible at a glance. */
  font-size: 14px;
  /* Semibold weight signals a mode change. */
  font-weight: 600;
  /* Pointer events are disabled so the underlying field remains stable. */
  pointer-events: none;
}

/* The drop icon is large and primary-tinted. */
.drop-overlay svg {
  /* Thirty-two pixels creates a visual target. */
  width: 32px;
  /* Height matches width. */
  height: 32px;
  /* Primary color ties it to the brand. */
  color: var(--color-primary);
}

/* The composer is a single raised surface. */
.composer {
  /* Border defines the input surface. */
  border: 1px solid var(--color-border);
  /* The raised card distinguishes the field. */
  background: var(--color-card);
  /* Large rounded corners create a modern composition. */
  border-radius: var(--radius-lg);
  /* A shadow lifts it above the transcript gradient. */
  box-shadow: var(--shadow-md);
  /* Overflow clipping respects the radius on focus rings. */
  overflow: hidden;
  /* The transition prepares focus feedback. */
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

/* Focus within the composer strengthens the surface. */
.composer:focus-within {
  /* Primary border identifies active input. */
  border-color: rgba(99, 102, 241, 0.62);
  /* A soft ring adds a second focus cue. */
  box-shadow: 0 0 0 3px var(--color-primary-soft), var(--shadow-md);
}

/* The textarea is borderless inside the composer. */
.composer textarea {
  /* Full width fills the surface. */
  width: 100%;
  /* A minimum height supports one line. */
  min-height: 58px;
  /* A maximum height is applied by JavaScript while resizing. */
  max-height: 190px;
  /* Horizontal padding aligns with toolbar controls. */
  padding: var(--space-4) var(--space-4) var(--space-2);
  /* The textarea itself has no visual border. */
  border: 0;
  /* Transparent background lets the parent own the surface. */
  background: transparent;
  /* Textarea scrolling is enabled after the max height. */
  overflow-y: auto;
  /* Manual resize is disabled to protect layout. */
  resize: none;
  /* Fourteen and a half pixels balances compact and readable. */
  font-size: 14.5px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.65;
  /* Focus rings are handled by the parent. */
  outline: none;
}

/* Composer placeholders use the faint text token. */
.composer textarea::placeholder {
  /* Muted color supports hierarchy. */
  color: var(--color-text-faint);
}

/* The toolbar arranges tools and send actions. */
.composer-toolbar {
  /* Flex aligns the two groups. */
  display: flex;
  /* Center alignment keeps buttons on one baseline. */
  align-items: center;
  /* Space-between pushes send to the inline end. */
  justify-content: space-between;
  /* A gap protects compact screens. */
  gap: var(--space-2);
  /* Horizontal padding aligns with the textarea. */
  padding: 0 var(--space-2) var(--space-2);
}

/* Tool groups align their child buttons. */
.composer-tools,
.send-actions {
  /* Flex keeps controls on one line. */
  display: flex;
  /* Center alignment is required. */
  align-items: center;
  /* Small gaps separate the grouped controls. */
  gap: var(--space-1);
}

/* Tool buttons pair a small icon and optional label. */
.tool-button {
  /* Inline flex centers icon and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and label. */
  gap: 5px;
  /* Compact padding creates a soft action. */
  padding: 6px 8px;
  /* Rounded corners match the toolbar. */
  border-radius: var(--radius-sm);
  /* Faint text keeps tools quiet. */
  color: var(--color-text-muted);
  /* Transitions apply hover feedback. */
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Icons inside tools are small. */
.tool-button svg {
  /* Sixteen pixels fits the compact toolbar. */
  width: 16px;
  /* Height matches width. */
  height: 16px;
}

/* Hover raises tool contrast. */
.tool-button:hover {
  /* Primary text indicates availability. */
  color: var(--color-text);
  /* A soft surface separates the target. */
  background: var(--color-card-raised);
}

/* Tool labels are hidden below the compact breakpoint. */
.tool-label {
  /* Small text fits the toolbar. */
  font-size: 10.5px;
  /* Medium weight preserves legibility. */
  font-weight: 500;
}

/* Composer status is a small live region. */
.composer-status {
  /* Small text fits the toolbar. */
  font-size: 10px;
  /* Muted color keeps status subtle. */
  color: var(--color-text-faint);
  /* The status never expands the toolbar unexpectedly. */
  max-width: 220px;
  /* Long statuses truncate. */
  overflow: hidden;
  /* One-line status. */
  white-space: nowrap;
  /* Ellipsis marks the clipped tail. */
  text-overflow: ellipsis;
}

/* The stop control uses a danger-tinted surface. */
.stop-button {
  /* Inline flex centers icon and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and label. */
  gap: 5px;
  /* Padding creates a compact pill. */
  padding: 7px 10px;
  /* Danger tint identifies cancellation. */
  background: var(--color-danger-soft);
  /* Danger text is readable on the tint. */
  color: var(--color-danger);
  /* Rounded corners match the toolbar. */
  border-radius: var(--radius-sm);
  /* Small text fits the composer. */
  font-size: 10.5px;
  /* Semibold weight marks the action. */
  font-weight: 600;
}

/* The stop icon is square and compact. */
.stop-button svg {
  /* Fourteen pixels fits the button. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
}

/* The send button is the primary circular action. */
.send-button {
  /* The action is a 38-pixel square. */
  width: 38px;
  /* Height matches width. */
  height: 38px;
  /* Centering keeps the paper plane balanced. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* The brand gradient matches the primary action. */
  background: var(--gradient-brand);
  /* White icon contrast. */
  color: #ffffff;
  /* A full radius creates a circle. */
  border-radius: 50%;
  /* A shadow adds elevation. */
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.26);
  /* Transitions animate hover and disabled states. */
  transition: transform var(--transition-fast), filter var(--transition-fast), opacity var(--transition-fast);
}

/* The send icon is compact. */
.send-button svg {
  /* Eighteen pixels is the correct optical size. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* The paper plane points toward the send direction; RTL flips it later. */
  transform: translateX(1px);
}

/* Hover brightens the primary action. */
.send-button:hover:not(:disabled) {
  /* A small brightness boost is enough. */
  filter: brightness(1.08);
  /* The button lifts one pixel. */
  transform: translateY(-1px);
}

/* Pressing returns the action to baseline. */
.send-button:active:not(:disabled) {
  /* The transform prevents a stuck hover state. */
  transform: translateY(0);
}

/* The keyboard hint row is compact and calm. */
.composer-hint {
  /* Flex wrap keeps hints usable on narrow screens. */
  display: flex;
  /* Centering balances the hints. */
  justify-content: center;
  /* Wrapping handles small widths. */
  flex-wrap: wrap;
  /* Gaps separate hint pairs. */
  gap: var(--space-3);
  /* Top margin separates hints from the composer. */
  margin: var(--space-2) 0 0;
  /* Faint text keeps hints subordinate. */
  color: var(--color-text-faint);
  /* Tiny text fits the footer. */
  font-size: 9.5px;
}

/* Hint groups align the keys and labels. */
.composer-hint span {
  /* Inline flex keeps each phrase together. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A tiny gap separates keys and copy. */
  gap: 3px;
}

/* Keyboard keys use a compact chip treatment. */
kbd {
  /* Monospace improves key clarity. */
  font-family: var(--font-mono);
  /* Ten pixels is the smallest functional size. */
  font-size: 9px;
  /* The chip uses a raised surface. */
  background: var(--color-card);
  /* A border makes keys tactile. */
  border: 1px solid var(--color-border);
  /* A subtle bottom border suggests depth. */
  border-block-end-color: var(--color-border-strong);
  /* Compact padding fits the hint row. */
  padding: 1px 4px;
  /* Small radius rounds the key. */
  border-radius: 4px;
  /* Muted text remains readable. */
  color: var(--color-text-muted);
}

/* The overlay layer closes mobile navigation and drawers. */
.overlay {
  /* Fixed positioning covers the viewport. */
  position: fixed;
  /* All edges are pinned. */
  inset: 0;
  /* A scrim separates the surface. */
  background: var(--color-scrim);
  /* Blur deepens the focus on the active panel. */
  backdrop-filter: blur(5px);
  /* The overlay layer sits below drawers but above the shell. */
  z-index: 40;
  /* A fade-in animation softens the appearance. */
  animation: fade-in 180ms ease both;
}

/* The sidebar overlay only exists on compact widths. */
.sidebar-overlay {
  /* A higher layer keeps it below the mobile drawer. */
  z-index: 30;
}

/* The help drawer is a fixed logical inline-end surface. */
.help-drawer {
  /* Fixed positioning anchors it to the viewport. */
  position: fixed;
  /* The inline end maps to the left in RTL and right in LTR. */
  inset-block: 0;
  /* The width is generous but bounded. */
  inset-inline-end: 0;
  /* The drawer takes a comfortable reading width. */
  width: min(520px, 100vw);
  /* A high layer sits above the overlay. */
  z-index: 50;
  /* Flex column supports a fixed header and scrolling body. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* The raised UI surface separates it from the scrim. */
  background: var(--color-bg-elevated);
  /* A border marks the drawer edge. */
  border-inline-start: 1px solid var(--color-border);
  /* A deep shadow establishes separation. */
  box-shadow: var(--shadow-lg);
  /* Off-screen transforms are direction-specific below. */
  transform: translateX(100%);
  /* The drawer transitions into view. */
  transition: transform var(--transition-base);
  /* Visibility transitions prevent off-screen focus. */
  visibility: hidden;
}

/* RTL drawers hide to the physical left. */
[dir="rtl"] .help-drawer {
  /* The negative transform matches the RTL inline end. */
  transform: translateX(-100%);
}

/* The open drawer slides into place. */
.help-drawer.is-open {
  /* The component resets to its resting position. */
  transform: translateX(0);
  /* Visible content is available to assistive technology. */
  visibility: visible;
}

/* The drawer header stays visible while the body scrolls. */
.drawer-header {
  /* Flex aligns the title and close action. */
  display: flex;
  /* Top alignment supports a taller title block. */
  align-items: flex-start;
  /* Space-between pushes the close button to the inline end. */
  justify-content: space-between;
  /* A gap protects the title. */
  gap: var(--space-3);
  /* Padding creates a comfortable header. */
  padding: var(--space-5);
  /* The bottom border separates the sticky header. */
  border-block-end: 1px solid var(--color-border);
  /* The header does not shrink. */
  flex: none;
}

/* Drawer headings use the section scale. */
.drawer-header h2 {
  /* Reset default heading margins. */
  margin: 2px 0 0;
  /* Twenty-one pixels is a confident section title. */
  font-size: 21px;
  /* Tight line height keeps the title compact. */
  line-height: 1.25;
  /* Semibold weight establishes hierarchy. */
  font-weight: 600;
}

/* The drawer body is the scrollable content region. */
.drawer-body {
  /* Overflow scrolling supports long documentation. */
  overflow-y: auto;
  /* Padding creates a readable content gutter. */
  padding: var(--space-5);
  /* The body consumes remaining height. */
  flex: 1;
  /* The body can shrink inside the flex column. */
  min-height: 0;
}

/* Help sections are separated by space rather than cards. */
.help-section {
  /* Bottom margin separates content groups. */
  margin-block-end: var(--space-5);
}

/* Help section headings are compact. */
.help-section h3 {
  /* Reset default heading margins. */
  margin: 0 0 var(--space-3);
  /* Fifteen pixels is a clear subsection level. */
  font-size: 15px;
  /* Semibold weight creates hierarchy. */
  font-weight: 600;
}

/* Quickstart steps use an ordered list with readable spacing. */
.quickstart-list {
  /* Inline start padding follows the reading direction. */
  padding-inline-start: 20px;
  /* Zero block margin keeps the list compact. */
  margin: 0;
  /* Muted text fits instructional copy. */
  color: var(--color-text-muted);
  /* Thirteen pixels is the instructional scale. */
  font-size: 13px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.75;
}

/* Each quickstart step receives block spacing. */
.quickstart-list li {
  /* Spacing separates steps. */
  margin-block-end: 6px;
  /* The step marker inherits primary color. */
  padding-inline-start: 2px;
}

/* Provider cards are compact button surfaces. */
.provider-grid {
  /* A single column keeps endpoint code readable. */
  display: grid;
  /* One column is appropriate for a narrow drawer. */
  grid-template-columns: 1fr;
  /* Gaps separate provider cards. */
  gap: var(--space-2);
}

/* Provider cards align mark, copy, and endpoint code. */
.provider-card {
  /* Grid creates three regions. */
  display: grid;
  /* Auto columns place the mark and copy, with endpoint code below. */
  grid-template-columns: 34px minmax(0, 1fr);
  /* Center alignment keeps the mark and copy together. */
  align-items: center;
  /* Gaps separate the mark and copy. */
  column-gap: var(--space-3);
  /* Row gap separates the endpoint code. */
  row-gap: 5px;
  /* Padding creates a comfortable target. */
  padding: var(--space-3);
  /* Cards use the raised neutral surface. */
  background: var(--color-card);
  /* A border defines the card. */
  border: 1px solid var(--color-border);
  /* Rounded corners match the system. */
  border-radius: var(--radius-md);
  /* Text alignment begins at the inline start. */
  text-align: start;
  /* The transition supports hover feedback. */
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

/* Hover raises the provider card. */
.provider-card:hover {
  /* Primary border signals the action. */
  border-color: rgba(99, 102, 241, 0.42);
  /* The raised surface differentiates it. */
  background: var(--color-card-raised);
}

/* The provider mark is a compact brand-neutral tile. */
.provider-mark {
  /* Fixed size anchors the mark. */
  width: 34px;
  /* Height matches width. */
  height: 34px;
  /* Center alignment for initials. */
  display: grid;
  /* Place-items centers both axes. */
  place-items: center;
  /* A soft primary surface identifies the provider. */
  background: var(--color-primary-soft);
  /* Primary text color is readable. */
  color: var(--color-primary);
  /* Rounded corners match the card. */
  border-radius: 9px;
  /* Small initials are legible. */
  font-size: 10px;
  /* Bold weight helps the two-letter mark. */
  font-weight: 700;
  /* Letter spacing separates the letters. */
  letter-spacing: 0.04em;
}

/* Provider copy stacks name and hint. */
.provider-card > span:nth-child(2) {
  /* Flex column supports the pair. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* A tight gap keeps the pair compact. */
  gap: 1px;
  /* The copy must shrink within the grid. */
  min-width: 0;
}

/* Provider names use the primary text color. */
.provider-card strong {
  /* Thirteen pixels fits the card. */
  font-size: 12px;
  /* Semibold weight marks the provider. */
  font-weight: 600;
}

/* Provider hints are secondary. */
.provider-card small {
  /* Ten and a half pixels suits the hint. */
  font-size: 10.5px;
  /* Muted color keeps the hint quiet. */
  color: var(--color-text-muted);
}

/* Endpoint code spans both grid columns. */
.provider-card code {
  /* The code spans the full card width. */
  grid-column: 1 / -1;
  /* Monospace is essential for endpoints. */
  font-family: var(--font-mono);
  /* Ten pixels is the compact code scale. */
  font-size: 10px;
  /* A dark chip separates the endpoint. */
  background: var(--color-code-bg);
  /* Light code text is readable. */
  color: #cbd5e1;
  /* Padding creates a chip. */
  padding: 4px 6px;
  /* Rounded corners fit the chip. */
  border-radius: 5px;
  /* Direction is fixed LTR. */
  direction: ltr;
  /* Text aligns left regardless of UI direction. */
  text-align: left;
  /* The endpoint may overflow. */
  overflow-x: auto;
  /* One-line endpoint display. */
  white-space: nowrap;
}

/* Specification rows pair an icon with explanatory copy. */
.spec-list {
  /* Flex column stacks the rows. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* Gaps separate rows. */
  gap: var(--space-3);
}

/* Each spec row aligns icon and text. */
.spec-row {
  /* Flex creates the two-column row. */
  display: flex;
  /* Top alignment supports multiple lines. */
  align-items: flex-start;
  /* Gap separates the icon. */
  gap: var(--space-2);
}

/* Spec icons use the primary color. */
.spec-row > svg {
  /* Eighteen pixels fits the row. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* A small top margin aligns with the title. */
  margin-block-start: 2px;
  /* Primary color marks the capability. */
  color: var(--color-primary);
}

/* Spec titles use body text. */
.spec-row strong {
  /* Twelve and a half pixels is legible. */
  font-size: 12.5px;
  /* Semibold weight creates hierarchy. */
  font-weight: 600;
}

/* Spec descriptions are muted and compact. */
.spec-row p {
  /* Zero margin prevents extra gaps. */
  margin: 1px 0 0;
  /* Muted color keeps details secondary. */
  color: var(--color-text-muted);
  /* Eleven and a half pixels suits dense reference copy. */
  font-size: 11.5px;
  /* Relaxed line height supports Arabic. */
  line-height: 1.6;
}

/* Shortcut rows use a definition-list layout. */
.shortcut-list {
  /* Zero margin removes browser defaults. */
  margin: 0;
  /* Flex column stacks each shortcut. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* Rows are separated by borders. */
  gap: 0;
}

/* Each shortcut row aligns keys and description. */
.shortcut-list > div {
  /* Flex creates a stable row. */
  display: flex;
  /* Center alignment keeps keys and copy on one line. */
  align-items: center;
  /* Space-between pushes the description to the inline end. */
  justify-content: space-between;
  /* Gap protects the keys. */
  gap: var(--space-3);
  /* Vertical padding creates row rhythm. */
  padding-block: 7px;
  /* A subtle border separates rows. */
  border-block-end: 1px solid var(--color-border);
}

/* The final row removes its border. */
.shortcut-list > div:last-child {
  /* No divider is needed at the end. */
  border-block-end: 0;
}

/* Definition terms contain the key combination. */
.shortcut-list dt {
  /* Auto width keeps the keys together. */
  flex: none;
  /* Muted keys are readable. */
  color: var(--color-text-muted);
}

/* Definitions describe the action. */
.shortcut-list dd {
  /* Zero margin removes browser defaults. */
  margin: 0;
  /* Small text fits the row. */
  font-size: 11.5px;
  /* Muted color keeps the list quiet. */
  color: var(--color-text-muted);
  /* Text alignment follows the reading direction. */
  text-align: end;
}

/* Troubleshooter entries are native details elements. */
.trouble-item {
  /* A border separates each entry. */
  border: 1px solid var(--color-border);
  /* Rounded corners match the card system. */
  border-radius: var(--radius-sm);
  /* Bottom margin separates entries. */
  margin-block-end: var(--space-2);
  /* The raised card surface distinguishes each item. */
  background: var(--color-card);
  /* Overflow clipping respects the radius. */
  overflow: hidden;
}

/* Summary rows align the icon and title with the native chevron. */
.trouble-item summary {
  /* Flex creates the row. */
  display: flex;
  /* Center alignment is required. */
  align-items: center;
  /* Gap separates the icon from the title. */
  gap: var(--space-2);
  /* Padding creates a usable target. */
  padding: 9px 11px;
  /* Small text fits the reference scale. */
  font-size: 11.5px;
  /* Semibold weight marks the error class. */
  font-weight: 600;
  /* The default marker is hidden because the icon conveys the state. */
  list-style: none;
}

/* The native summary marker is removed in WebKit. */
.trouble-item summary::-webkit-details-marker {
  /* Hiding prevents a duplicate triangle. */
  display: none;
}

/* The alert icon uses warning color. */
.trouble-item summary svg {
  /* Fifteen pixels fits the row. */
  width: 15px;
  /* Height matches width. */
  height: 15px;
  /* Warning color links the entry to error handling. */
  color: var(--color-warning);
}

/* Detail prose is muted and indented. */
.trouble-item p {
  /* Tiny margins create breathing room. */
  margin: 0;
  /* The paragraph is inset from the summary. */
  padding: 0 11px 11px 34px;
  /* Muted text reduces intensity. */
  color: var(--color-text-muted);
  /* Eleven pixels fits reference copy. */
  font-size: 11px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.65;
}

/* RTL detail paragraphs mirror the text inset. */
[dir="rtl"] .trouble-item p {
  /* Logical padding places the inset at the inline start. */
  padding: 0 34px 11px 11px;
}

/* The privacy note closes the help drawer with reassurance. */
.privacy-note {
  /* Flex aligns the shield and copy. */
  display: flex;
  /* Top alignment handles two or three lines. */
  align-items: flex-start;
  /* Gap separates the icon. */
  gap: var(--space-2);
  /* Padding creates a soft panel. */
  padding: var(--space-3);
  /* Success tint communicates safety without alarm. */
  background: var(--color-success-soft);
  /* A green border completes the treatment. */
  border: 1px solid rgba(74, 222, 128, 0.18);
  /* Rounded corners match cards. */
  border-radius: var(--radius-md);
}

/* The privacy shield is green. */
.privacy-note svg {
  /* Eighteen pixels fits the note. */
  width: 18px;
  /* Height matches width. */
  height: 18px;
  /* Success color signals safety. */
  color: var(--color-success);
  /* A small top margin aligns with the text. */
  margin-block-start: 2px;
}

/* Privacy copy is compact. */
.privacy-note p {
  /* Zero margin removes default spacing. */
  margin: 0;
  /* Small text fits the note. */
  font-size: 11.5px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.6;
  /* Muted text keeps the note calm. */
  color: var(--color-text-muted);
}

/* The settings dialog is a native modal surface. */
.settings-dialog {
  /* The dialog width balances fields and profile navigation. */
  width: min(1000px, calc(100vw - 32px));
  /* Height is bounded by the viewport. */
  max-height: min(92dvh, 900px);
  /* Zero padding lets the inner form own spacing. */
  padding: 0;
  /* Borders match the raised surface. */
  border: 1px solid var(--color-border-strong);
  /* Dialog surfaces use the elevated card tone. */
  background: var(--color-bg-elevated);
  /* Large radii create a modern modal. */
  border-radius: var(--radius-xl);
  /* Hardware shadow separates the dialog from the scrim. */
  box-shadow: var(--shadow-lg);
  /* The dialog itself does not scroll; the form does. */
  overflow: hidden;
  /* Text color inherits theme tokens. */
  color: var(--color-text);
}

/* The dialog backdrop dims and blurs the workspace. */
.settings-dialog::backdrop {
  /* The scrim uses the same overlay token. */
  background: var(--color-scrim);
  /* Blur creates depth. */
  backdrop-filter: blur(9px);
}

/* The form is a vertical flex composition. */
.settings-dialog form {
  /* Full height lets the body scroll while header and footer stay fixed. */
  height: 100%;
  /* Flex column supports sticky regions. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* The form may scroll as a last resort on tiny screens. */
  overflow: hidden;
}

/* The settings header aligns the title and close action. */
.settings-header {
  /* Flex row places copy and close. */
  display: flex;
  /* Top alignment supports a longer subtitle. */
  align-items: flex-start;
  /* Space-between pushes close to the inline end. */
  justify-content: space-between;
  /* Gap protects the title. */
  gap: var(--space-4);
  /* Padding creates a comfortable header. */
  padding: var(--space-5) var(--space-5) var(--space-4);
  /* Border separates the scrolling body. */
  border-block-end: 1px solid var(--color-border);
  /* The header does not shrink. */
  flex: none;
}

/* The settings title is a clear modal heading. */
.settings-header h2 {
  /* Reset default margins. */
  margin: 2px 0 3px;
  /* Twenty-four pixels is the modal scale. */
  font-size: 24px;
  /* Tight line height suits a short title. */
  line-height: 1.2;
  /* Semibold weight establishes hierarchy. */
  font-weight: 600;
}

/* The subtitle explains the local storage posture. */
.settings-subtitle {
  /* Zero block margins keep the block compact. */
  margin: 0;
  /* A readable max width prevents long lines. */
  max-width: 680px;
  /* Muted text supports hierarchy. */
  color: var(--color-text-muted);
  /* Twelve pixels fits supporting guidance. */
  font-size: 12px;
  /* Relaxed line height supports Arabic. */
  line-height: 1.6;
}

/* The settings layout separates profile navigation from fields. */
.settings-layout {
  /* Grid creates a fixed profile rail and flexible fields. */
  display: grid;
  /* The profile rail is compact. */
  grid-template-columns: 224px minmax(0, 1fr);
  /* The body consumes remaining height. */
  flex: 1;
  /* A minimum height enables internal scrolling. */
  min-height: 0;
}

/* The profile panel is the secondary navigation rail. */
.profile-panel {
  /* A subtle surface distinguishes it from fields. */
  background: rgba(8, 13, 26, 0.24);
  /* Border mirrors to the inline end. */
  border-inline-end: 1px solid var(--color-border);
  /* Padding creates a compact rail. */
  padding: var(--space-4);
  /* Vertical overflow protects small screens. */
  overflow-y: auto;
}

/* Light theme profile rail uses a pale tint. */
[data-theme="light"] .profile-panel {
  /* The pale surface separates navigation. */
  background: rgba(233, 237, 248, 0.56);
}

/* The panel header aligns its label and add action. */
.profile-panel-head {
  /* Flex aligns the two controls. */
  display: flex;
  /* Center alignment is required. */
  align-items: center;
  /* Space-between pushes add to the inline end. */
  justify-content: space-between;
  /* Bottom margin separates the header. */
  margin-block-end: var(--space-3);
  /* Small semibold text marks section labels. */
  font-size: 11px;
  /* Semibold weight establishes hierarchy. */
  font-weight: 600;
  /* Muted text keeps the rail quiet. */
  color: var(--color-text-muted);
}

/* The profile select wrapper provides a custom chevron. */
.select-wrap {
  /* Relative positioning anchors the icon. */
  position: relative;
}

/* The profile select fills the rail width. */
.select-wrap select {
  /* Full width aligns with the rail. */
  width: 100%;
  /* The native chevron is hidden because an SVG is shown. */
  appearance: none;
  /* Inline end padding leaves room for the icon. */
  padding-inline-end: 30px;
  /* Small text fits the rail. */
  font-size: 12px;
}

/* The custom chevron is positioned at the inline end. */
.select-wrap > svg {
  /* Absolute positioning anchors it. */
  position: absolute;
  /* Center it vertically. */
  inset-block-start: 50%;
  /* The inline end follows document direction. */
  inset-inline-end: 10px;
  /* Transform completes vertical centering. */
  transform: translateY(-50%);
  /* Fourteen pixels fits the select. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
  /* Faint color keeps it subtle. */
  color: var(--color-text-faint);
  /* The icon must not intercept clicks. */
  pointer-events: none;
}

/* The delete profile action uses danger styling. */
.danger-text {
  /* Danger color marks the destructive action. */
  color: var(--color-danger);
}

/* Text buttons are quiet inline actions. */
.text-button {
  /* Inline flex centers optional icons and labels. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and text. */
  gap: 5px;
  /* Padding creates a compact target. */
  padding: 6px 8px;
  /* Rounded corners match controls. */
  border-radius: var(--radius-sm);
  /* Muted text keeps secondary actions quiet. */
  color: var(--color-text-muted);
  /* Small text fits modal actions. */
  font-size: 11.5px;
  /* Medium weight preserves legibility. */
  font-weight: 500;
  /* Transitions apply hover feedback. */
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

/* Text button icons are compact. */
.text-button svg {
  /* Fourteen pixels fits the label scale. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
}

/* Hover raises text button contrast. */
.text-button:hover {
  /* Primary text indicates action. */
  color: var(--color-text);
  /* A subtle surface separates the target. */
  background: var(--color-card);
}

/* The profile rail delete action sits below the selector. */
#deleteProfileBtn {
  /* Top margin separates it from the profile control. */
  margin-block-start: var(--space-2);
  /* Small text fits the rail. */
  font-size: 10.5px;
}

/* Hover on the destructive action uses danger tint. */
#deleteProfileBtn:hover {
  /* Danger text reinforces intent. */
  color: var(--color-danger);
  /* Danger tint provides a hover surface. */
  background: var(--color-danger-soft);
}

/* The profile note reassures about key handling. */
.profile-note {
  /* Flex aligns shield and copy. */
  display: flex;
  /* Top alignment handles wrapping. */
  align-items: flex-start;
  /* Gap separates the icon. */
  gap: 6px;
  /* Top margin separates the note. */
  margin-block-start: var(--space-6);
  /* Padding creates a quiet panel. */
  padding: var(--space-2);
  /* Muted text keeps it informational. */
  color: var(--color-text-faint);
  /* Ten and a half pixels fits the rail. */
  font-size: 10.5px;
  /* Relaxed line height supports Arabic. */
  line-height: 1.6;
}

/* The note icon is small and primary-tinted. */
.profile-note svg {
  /* Fourteen pixels fits the rail. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
  /* Primary color identifies security. */
  color: var(--color-primary);
  /* A small top offset aligns with copy. */
  margin-block-start: 2px;
}

/* The fields area scrolls independently from the rails. */
.settings-fields {
  /* Vertical overflow permits long forms. */
  overflow-y: auto;
  /* Generous padding supports scanning. */
  padding: var(--space-5);
  /* The fields consume remaining width. */
  min-width: 0;
}

/* The field grid supports paired settings. */
.field-grid {
  /* Gap separates cells. */
  gap: var(--space-4);
}

/* Paired fields use two columns on desktop. */
.field-grid.two-column {
  /* Two equal columns balance related values. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  /* Grid display is required. */
  display: grid;
}

/* A field group stacks label, field, and hint. */
.field-group {
  /* Flex column creates the hierarchy. */
  display: flex;
  /* Stacking is required. */
  flex-direction: column;
  /* A small gap groups the pieces. */
  gap: 5px;
  /* Bottom margin separates groups. */
  margin-block-end: var(--space-3);
  /* Fields must shrink within grids. */
  min-width: 0;
}

/* Field labels are compact semibold text. */
.field-label {
  /* Small text fits the settings rhythm. */
  font-size: 11px;
  /* Semibold weight marks the label. */
  font-weight: 600;
  /* Muted text keeps labels subordinate to values. */
  color: var(--color-text-muted);
}

/* Labels that contain outputs align their pieces. */
.field-label output {
  /* Primary color emphasizes the live value. */
  color: var(--color-primary);
  /* Monospace makes numeric values stable. */
  font-family: var(--font-mono);
  /* Small size fits inline metadata. */
  font-size: 10.5px;
  /* A small inline-start margin separates the value. */
  margin-inline-start: 6px;
}

/* Text fields and textareas fill their group. */
.field-group input,
.field-group textarea {
  /* Full width aligns with the field group. */
  width: 100%;
  /* Small text fits the modal density. */
  font-size: 12.5px;
}

/* Field hints are optional supporting copy. */
.field-hint {
  /* Faint color keeps hints subordinate. */
  color: var(--color-text-faint);
  /* Ten and a half pixels fits the compact form. */
  font-size: 10.5px;
  /* Relaxed line height supports Arabic. */
  line-height: 1.5;
}

/* LTR-specific fields isolate endpoint and key content. */
.ltr-field {
  /* Direction is forced left-to-right. */
  direction: ltr;
  /* Text aligns to the left. */
  text-align: left;
  /* Unicode isolation prevents bidi punctuation inversion. */
  unicode-bidi: isolate;
  /* The monospace face suits keys and endpoints. */
  font-family: var(--font-mono);
  /* Slightly smaller text improves long values. */
  font-size: 11.5px;
}

/* The connection actions row aligns discovery controls. */
.connection-actions {
  /* Flex wrap handles compact modal widths. */
  display: flex;
  /* Wrapping supports narrow screens. */
  flex-wrap: wrap;
  /* Center alignment keeps controls on one line. */
  align-items: center;
  /* Gap separates buttons and result text. */
  gap: var(--space-2);
  /* Bottom margin separates the row. */
  margin-block-end: var(--space-3);
}

/* Secondary buttons are bordered cards. */
.secondary-button {
  /* Inline flex centers icon and label. */
  display: inline-flex;
  /* Center alignment is required. */
  align-items: center;
  /* A small gap separates icon and text. */
  gap: 5px;
  /* Padding creates a compact target. */
  padding: 7px 10px;
  /* Card surface separates the button. */
  background: var(--color-card);
  /* Border defines the control. */
  border: 1px solid var(--color-border);
  /* Rounded corners match inputs. */
  border-radius: var(--radius-sm);
  /* Muted text keeps the secondary action quiet. */
  color: var(--color-text-muted);
  /* Small text fits the form. */
  font-size: 10.5px;
  /* Medium weight preserves legibility. */
  font-weight: 500;
  /* Transitions apply hover. */
  transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

/* Secondary icons are compact. */
.secondary-button svg {
  /* Fourteen pixels fits the control. */
  width: 14px;
  /* Height matches width. */
  height: 14px;
}

/* Hover raises the secondary surface. */
.secondary-button:hover:not(:disabled) {
  /* Primary text signals interaction. */
  color: var(--color-text);
  /* A stronger border defines the hover state. */
  border-color: var(--color-border-strong);
  /* The raised surface differentiates it. */
  background: var(--color-card-raised);
}

/* Connection result text is small and state-aware. */
.connection-result {
  /* Small text fits the row. */
  font-size: 10.5px;
  /* Muted text is the default. */
  color: var(--color-text-muted);
  /* Long messages can wrap within the row. */
  flex: 1 1 100%;
  /* Minimum height prevents layout jumps when empty. */
  min-height: 0;
}

/* Success results use green. */
.connection-result.is-ok {
  /* Success color confirms connection. */
  color: var(--color-success);
}

/* Error results use danger red. */
.connection-result.is-error {
  /* Danger color signals failure. */
  color: var(--color-danger);
}

/* The temperature range is horizontally padded for touch. */
.range-grid input[type="range"] {
  /* Zero padding creates a slim track. */
  padding: 0;
  /* The native appearance stays usable and accessible. */
  accent-color: var(--color-primary);
  /* A comfortable block margin centers the track. */
  margin-block: 8px;
  /* Transparent background avoids a field box. */
  background: transparent;
  /* No border is needed around the range. */
  border: 0;
}

/* Number inputs use monospace for alignment. */
#maxTokens {
  /* Monospace makes token counts scan quickly. */
  font-family: var(--font-mono);
}

/* Preset chips are compact quick-fill actions. */
.presets-block {
  /* Top margin separates the preset group. */
  margin-block-start: var(--space-2);
}

/* The preset row wraps across available width. */
.preset-row {
  /* Flex wrap supports six providers. */
  display: flex;
  /* Wrapping prevents horizontal overflow. */
  flex-wrap: wrap;
  /* Gap separates chips. */
  gap: 5px;
  /* Top margin separates the label. */
  margin-block-start: var(--space-2);
}

/* Preset chips use a small bordered capsule. */
.preset-chip {
  /* Compact padding forms the chip. */
  padding: 5px 9px;
  /* Card surface distinguishes it. */
  background: var(--color-card);
  /* A border defines the chip. */
  border: 1px solid var(--color-border);
  /* Capsule shape. */
  border-radius: 999px;
  /* Small text fits the dense group. */
  font-size: 10px;
  /* Medium weight preserves legibility. */
  font-weight: 500;
  /* Muted text keeps quick fills quiet. */
  color: var(--color-text-muted);
  /* Transition applies hover. */
  transition: border-color var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

/* Hover raises preset contrast. */
.preset-chip:hover {
  /* Primary text identifies the action. */
  color: var(--color-primary);
  /* Primary-tinted border signals selection. */
  border-color: rgba(99, 102, 241, 0.45);
  /* Soft primary surface supports the hover. */
  background: var(--color-primary-soft);
}

/* The settings footer holds save and cancel actions. */
.settings-footer {
  /* Flex wraps on narrow screens. */
  display: flex;
  /* Center alignment keeps the action row balanced. */
  align-items: center;
  /* Space-between separates note and actions. */
  justify-content: space-between;
  /* Gap protects the actions. */
  gap: var(--space-3);
  /* Padding creates a stable footer. */
  padding: var(--space-4) var(--space-5);
  /* A top border separates the body. */
  border-block-start: 1px solid var(--color-border);
  /* The footer does not shrink. */
  flex: none;
  /* Block spacing uses the surface tone. */
  background: var(--color-bg-elevated);
}

/* The footer note is quiet guidance. */
.settings-footnote {
  /* Small text fits the footer. */
  font-size: 10.5px;
  /* Faint color keeps it subordinate. */
  color: var(--color-text-faint);
}

/* Footer actions align buttons. */
.settings-footer-actions {
  /* Flex keeps actions together. */
  display: flex;
  /* Center alignment is required. */
  align-items: center;
  /* Gap separates cancel and save. */
  gap: var(--space-2);
}

/* The primary button is a compact gradient action. */
.primary-button {
  /* Inline padding creates a confident button. */
  padding: 9px 16px;
  /* The brand gradient distinguishes primary actions. */
  background: var(--gradient-brand);
  /* White text maximizes contrast. */
  color: #ffffff;
  /* Rounded corners match controls. */
  border-radius: var(--radius-sm);
  /* Semibold weight marks the primary action. */
  font-weight: 600;
  /* Small text fits the modal footer. */
  font-size: 11.5px;
  /* A soft shadow adds elevation. */
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.2);
  /* Transition applies hover. */
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

/* Hover brightens the primary action. */
.primary-button:hover {
  /* A small brightness boost is sufficient. */
  filter: brightness(1.08);
  /* The button lifts one pixel. */
  transform: translateY(-1px);
}

/* The toast stack floats above the composer at the inline end. */
.toast-stack {
  /* Fixed positioning keeps toasts visible regardless of transcript scroll. */
  position: fixed;
  /* The inline end follows the reading direction. */
  inset-inline-end: var(--space-5);
  /* Toasts sit above the composer. */
  inset-block-end: calc(var(--space-6) + 58px);
  /* A high layer sits above drawers and dialogs when shown. */
  z-index: 120;
  /* Flex column stacks messages. */
  display: flex;
  /* Newest toasts appear at the bottom. */
  flex-direction: column;
  /* Gap separates toasts. */
  gap: var(--space-2);
  /* The stack must not intercept interactions outside cards. */
  pointer-events: none;
  /* A responsive max width prevents overflow. */
  max-width: min(360px, calc(100vw - 32px));
}

/* Toasts are compact raised cards. */
.toast {
  /* Padding creates a readable card. */
  padding: 10px 13px;
  /* The elevated card distinguishes the toast. */
  background: var(--color-card-raised);
  /* A border defines the card. */
  border: 1px solid var(--color-border-strong);
  /* Rounded corners match the component system. */
  border-radius: var(--radius-md);
  /* A strong shadow lifts it above chat. */
  box-shadow: var(--shadow-lg);
  /* Small text fits the feedback. */
  font-size: 11.5px;
  /* A relaxed line height supports Arabic. */
  line-height: 1.5;
  /* Primary text color is readable. */
  color: var(--color-text);
  /* Toasts accept no pointer input to avoid blocking the UI. */
  pointer-events: none;
  /* Entry animation slides up. */
  animation: toast-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Success toasts receive a green inline-start border. */
.toast.is-success {
  /* The success border encodes confirmation. */
  border-inline-start: 3px solid var(--color-success);
}

/* Error toasts receive a red inline-start border. */
.toast.is-error {
  /* Danger marks the alert. */
  border-inline-start: 3px solid var(--color-danger);
}

/* Warning toasts receive an amber inline-start border. */
.toast.is-warning {
  /* Warning color marks fallback conditions. */
  border-inline-start: 3px solid var(--color-warning);
}

/* Informational toasts use the primary border. */
.toast.is-info {
  /* Primary color identifies neutral feedback. */
  border-inline-start: 3px solid var(--color-primary);
}

/* Leaving toasts fade out. */
.toast.is-leaving {
  /* The exit animation runs after the display duration. */
  animation: toast-out 180ms ease both;
}

/* The no-script banner is fixed and impossible to miss. */
.noscript-message {
  /* Fixed positioning covers the viewport. */
  position: fixed;
  /* The banner appears at the bottom. */
  inset-block-end: 0;
  /* It spans the viewport width. */
  inset-inline: 0;
  /* Padding creates a readable alert. */
  padding: var(--space-3);
  /* Danger surface signals a functional failure. */
  background: var(--color-danger-soft);
  /* Danger text is readable. */
  color: var(--color-danger);
  /* Centered text is appropriate for a global warning. */
  text-align: center;
  /* The layer sits above all UI. */
  z-index: 300;
  /* Small text keeps the banner compact. */
  font-size: 12px;
}

/* Utility: mobile-only controls are hidden on desktop. */
.mobile-only {
  /* The class is revealed in the compact breakpoint. */
  display: none;
}

/* The link styling is limited to rendered Markdown links if added later. */
.message-prose a {
  /* Primary color identifies links. */
  color: var(--color-primary);
  /* Underline improves discoverability. */
  text-decoration: underline;
  /* The underline offset avoids Arabic descenders. */
  text-underline-offset: 2px;
}

/* Scrollbars use theme-aware colors. */
* {
  /* Firefox scrollbar width and color. */
  scrollbar-width: thin;
  /* The thumb uses a translucent neutral. */
  scrollbar-color: var(--color-border-strong) transparent;
}

/* WebKit scrollbars receive a narrow treatment. */
*::-webkit-scrollbar {
  /* Thin scrollbars preserve content width. */
  width: 7px;
  /* Horizontal scrollbars match. */
  height: 7px;
}

/* The scrollbar track stays transparent. */
*::-webkit-scrollbar-track {
  /* Transparent tracks blend into panels. */
  background: transparent;
}

/* The scrollbar thumb is rounded and subtle. */
*::-webkit-scrollbar-thumb {
  /* The thumb uses the border-strong token. */
  background: var(--color-border-strong);
  /* Rounded ends create a soft thumb. */
  border-radius: 999px;
}

/* Hover strengthens the scrollbar thumb. */
*::-webkit-scrollbar-thumb:hover {
  /* Primary tint signals interactivity. */
  background: var(--color-primary);
}

/* The animation keyframes start with a fade and small upward movement. */
@keyframes fade-up {
  /* Initial state is transparent and slightly lower. */
  from {
    /* Hidden content starts at zero opacity. */
    opacity: 0;
    /* A small vertical offset creates motion. */
    transform: translateY(8px);
  }
  /* Final state is fully visible and settled. */
  to {
    /* Content reaches full opacity. */
    opacity: 1;
    /* The transform resets to the natural position. */
    transform: translateY(0);
  }
}

/* Fade-in is used by overlays and modal scrims. */
@keyframes fade-in {
  /* The scrim starts invisible. */
  from {
    /* Zero opacity hides the initial layer. */
    opacity: 0;
  }
  /* The scrim reaches full opacity. */
  to {
    /* The overlay becomes visible. */
    opacity: 1;
  }
}

/* The orb floats gently. */
@keyframes orb-float {
  /* The resting state has no vertical offset. */
  0%,
  100% {
    /* The orb sits at baseline. */
    transform: translateY(0) rotate(8deg);
  }
  /* Midpoint floats upward. */
  50% {
    /* A small negative offset creates breathing motion. */
    transform: translateY(-7px) rotate(5deg);
  }
}

/* The orbit rotates continuously. */
@keyframes spin {
  /* The starting angle is zero. */
  from {
    /* Rotation begins at the natural orientation. */
    transform: rotate(0);
  }
  /* The ring completes a full turn. */
  to {
    /* The final angle is a full circle. */
    transform: rotate(360deg);
  }
}

/* The blinking cursor uses an on/off step pattern. */
@keyframes blink {
  /* The caret is visible at the start. */
  0%,
  49% {
    /* Full opacity indicates active streaming. */
    opacity: 1;
  }
  /* The caret disappears in the off phase. */
  50%,
  100% {
    /* Zero opacity creates the blink. */
    opacity: 0;
  }
}

/* Thinking dots pulse smoothly. */
@keyframes pulse {
  /* The dot starts dim and small. */
  0%,
  100% {
    /* Reduced opacity indicates the resting phase. */
    opacity: 0.35;
    /* The dot returns to its base scale. */
    transform: translateY(0) scale(0.9);
  }
  /* The midpoint is bright and lifted. */
  50% {
    /* Full opacity marks activity. */
    opacity: 1;
    /* A small lift creates a wave. */
    transform: translateY(-2px) scale(1);
  }
}

/* Toasts slide in from the inline end. */
@keyframes toast-in {
  /* The toast starts transparent and offset. */
  from {
    /* Zero opacity hides the initial state. */
    opacity: 0;
    /* A small downward offset combines with the entry. */
    transform: translateY(8px);
  }
  /* The toast settles into its resting state. */
  to {
    /* Full opacity reveals the message. */
    opacity: 1;
    /* The transform resets. */
    transform: translateY(0);
  }
}

/* Toasts slide out at the end of their lifetime. */
@keyframes toast-out {
  /* The exit starts visible. */
  from {
    /* The toast is fully visible. */
    opacity: 1;
  }
  /* The exit ends invisible and slightly lower. */
  to {
    /* Fading communicates removal. */
    opacity: 0;
    /* A small downward drift completes the exit. */
    transform: translateY(4px);
  }
}

/* The primary responsive breakpoint converts the sidebar into a drawer. */
@media (max-width: 900px) {
  /* The app shell becomes one column. */
  .app-shell {
    /* Chat takes the full available width. */
    grid-template-columns: minmax(0, 1fr);
  }

  /* The sidebar overlays the workspace on compact screens. */
  .sidebar {
    /* Fixed positioning removes it from the grid. */
    position: fixed;
    /* It anchors to the logical inline start. */
    inset-inline-start: 0;
    /* It spans the viewport height. */
    inset-block: 0;
    /* The footer safe area is respected. */
    padding-block-end: max(var(--space-3), env(safe-area-inset-bottom));
    /* Width leaves a visible scrim. */
    width: min(84vw, 320px);
    /* A high layer sits above the overlay. */
    z-index: 35;
    /* The drawer hides to the physical left in LTR. */
    transform: translateX(-100%);
    /* The transition uses the shared drawer curve. */
    transition: transform var(--transition-base);
  }

  /* RTL sidebars hide to the physical right. */
  [dir="rtl"] .sidebar {
    /* The matching RTL transform preserves mirroring. */
    transform: translateX(100%);
  }

  /* Opening the sidebar slides it into place. */
  body.sidebar-open .sidebar {
    /* Zero transform reveals the drawer. */
    transform: translateX(0);
  }

  /* Mobile-only controls appear at the compact breakpoint. */
  .mobile-only {
    /* Flex display supports icon buttons. */
    display: inline-grid;
  }

  /* The top bar reduces its inline gutter on small screens. */
  .topbar {
    /* Smaller padding uses the viewport more efficiently. */
    padding-inline: var(--space-3);
    /* The minimum height drops slightly. */
    min-height: 64px;
  }

  /* The transcript uses a compact gutter. */
  .chat-main {
    /* Reduced inline padding fits mobile reading. */
    padding-inline: var(--space-3);
  }

  /* The composer aligns with the transcript gutter. */
  .composer-region {
    /* Reduced inline padding preserves field width. */
    padding-inline: var(--space-3);
  }

  /* Error banners align with the mobile gutter. */
  .error-banner {
    /* Reduced margins fit small screens. */
    margin-inline: var(--space-3);
  }

  /* Settings collapse to one column. */
  .settings-layout {
    /* Profile navigation becomes a top section. */
    grid-template-columns: minmax(0, 1fr);
    /* The fields scroll beneath the profile rail. */
    overflow-y: auto;
  }

  /* The profile rail becomes a horizontal band. */
  .profile-panel {
    /* A border separates it from fields vertically. */
    border-inline-end: 0;
    /* The border moves to the block end. */
    border-block-end: 1px solid var(--color-border);
    /* Overflow no longer needs a fixed rail scroll. */
    overflow: visible;
  }

  /* The profile note is hidden to conserve mobile height. */
  .profile-note {
    /* The note is already repeated in help. */
    display: none;
  }

  /* The fields area loses its internal scroll because the layout scrolls. */
  .settings-fields {
    /* The area remains scrollable as a safety net. */
    overflow: visible;
  }

  /* The settings form becomes vertically scrollable. */
  .settings-dialog form {
    /* The body scrolls when the viewport is short. */
    overflow-y: auto;
  }

  /* The settings footer remains readable at compact widths. */
  .settings-footer {
    /* The note can wrap below the actions. */
    flex-wrap: wrap;
  }

  /* The mode badge is hidden to protect header space. */
  .mode-badge {
    /* Operational mode is still visible in the sidebar. */
    display: none;
  }
}

/* The narrow-phone breakpoint simplifies dense compositions. */
@media (max-width: 640px) {
  /* Suggestions stack into a single column. */
  .suggestions {
    /* One column gives each prompt a comfortable target. */
    grid-template-columns: minmax(0, 1fr);
    /* A smaller top margin fits the viewport. */
    margin-block-start: var(--space-4);
  }

  /* Two-column fields stack on phones. */
  .field-grid.two-column {
    /* One column prevents cramped inputs. */
    grid-template-columns: minmax(0, 1fr);
  }

  /* The empty orb shrinks on small screens. */
  .orb {
    /* A 76-pixel core preserves the composition. */
    width: 76px;
    /* Height matches width. */
    height: 76px;
  }

  /* The empty headline uses a more compact fluid size. */
  .empty-state h1 {
    /* The smaller floor prevents awkward breaks. */
    font-size: clamp(25px, 8vw, 34px);
  }

  /* The empty state reduces vertical padding. */
  .empty-state {
    /* Compact spacing preserves room for the composer. */
    padding-block: var(--space-5) var(--space-4);
  }

  /* Feature chips align centrally with tighter spacing. */
  .feature-row {
    /* A smaller gap reduces wrapping height. */
    gap: 5px;
  }

  /* Composer tool labels hide to preserve send space. */
  .tool-label {
    /* Icons remain with accessible labels. */
    display: none;
  }

  /* The hint row hides keyboard-only copy on touch-first screens. */
  .composer-hint {
    /* Shortcut hints remain available in Help. */
    display: none;
  }

  /* Margins inside the empty state are compact. */
  .empty-subtitle {
    /* Fourteen pixels is appropriate on phones. */
    font-size: 14px;
  }

  /* Message avatars shrink slightly. */
  .message-avatar {
    /* A 30-pixel avatar preserves space. */
    width: 30px;
    /* Height matches width. */
    height: 30px;
    /* The radius scales down. */
    border-radius: 9px;
  }

  /* Message bodies use the full available width. */
  .message-body,
  .message-assistant .message-body {
    /* The max width is naturally bounded by the viewport. */
    max-width: 100%;
  }

  /* User bubbles reduce padding on compact screens. */
  .message-body {
    /* Slightly tighter padding preserves line length. */
    padding: 10px 12px;
  }

  /* The settings dialog uses nearly the full viewport. */
  .settings-dialog {
    /* A small inset avoids clipping on rounded screens. */
    width: calc(100vw - 16px);
    /* The maximum height uses nearly all vertical space. */
    max-height: 94dvh;
    /* A smaller radius suits the edge-to-edge surface. */
    border-radius: var(--radius-lg);
  }

  /* The settings header reduces padding. */
  .settings-header {
    /* Compact padding preserves body height. */
    padding: var(--space-4);
  }

  /* The settings title shrinks slightly. */
  .settings-header h2 {
    /* Twenty-one pixels is a good phone modal scale. */
    font-size: 21px;
  }

  /* The fields area uses compact padding. */
  .settings-fields {
    /* Reduced padding maximizes form width. */
    padding: var(--space-4);
  }

  /* The footer uses compact padding. */
  .settings-footer {
    /* Reduced padding keeps actions accessible. */
    padding: var(--space-3) var(--space-4);
  }

  /* The footer note is hidden on the narrowest screens. */
  .settings-footnote {
    /* The information is repeated in the subtitle. */
    display: none;
  }

  /* The drawer takes the full viewport on phones. */
  .help-drawer {
    /* Full width maximizes readable content. */
    width: 100vw;
  }

  /* The drawer header reduces padding. */
  .drawer-header {
    /* Compact padding preserves scroll space. */
    padding: var(--space-4);
  }

  /* The drawer body reduces padding. */
  .drawer-body {
    /* Compact padding supports narrow screens. */
    padding: var(--space-4);
  }

  /* Toasts span a comfortable mobile width. */
  .toast-stack {
    /* The stack sits above the composer with a compact gutter. */
    inset-inline: var(--space-3);
    /* The bottom offset clears the composer. */
    inset-block-end: calc(var(--space-6) + 92px);
    /* The max width follows the viewport. */
    max-width: none;
  }

  /* The topbar context shrinks to the available width. */
  .chat-context {
    /* The model line may truncate gracefully. */
    flex: 1;
    /* Minimum width allows flex shrink. */
    min-width: 0;
  }

  /* The model identifier shrinks on phones. */
  .model-name {
    /* A smaller cap prevents action overflow. */
    max-width: 130px;
  }

  /* The topbar actions gap tightens. */
  .topbar-actions {
    /* A four-pixel gap protects icons. */
    gap: 3px;
  }

  /* The language button shows only the target language label. */
  #langToggle {
    /* Compact padding fits the header. */
    padding: 6px 8px;
  }

  /* The drop overlay matches the compact composer gutter. */
  .drop-overlay {
    /* Reduced horizontal inset aligns with the composer. */
    inset-inline: var(--space-3);
  }

  /* Error banners use a smaller font on phones. */
  .error-banner {
    /* The message stays readable without crowding. */
    font-size: 12px;
  }
}

/* Touch devices should not require hover to access conversation actions. */
@media (hover: none) {
  /* Actions remain visible at a reduced opacity for touch users. */
  .conversation-actions {
    /* Visible actions avoid a hidden secondary menu. */
    opacity: 0.7;
  }

  /* The action row is always interactive on touch. */
  .conversation-item:hover .conversation-actions,
  .conversation-item:focus-within .conversation-actions {
    /* Full opacity confirms focus. */
    opacity: 1;
  }

  /* Hover-only lifts are disabled to prevent sticky states. */
  .suggestion-card:hover,
  .new-chat-button:hover,
  .send-button:hover:not(:disabled),
  .primary-button:hover {
    /* Returning to baseline avoids stuck transforms. */
    transform: none;
  }
}

/* Reduced-motion preferences disable decorative animation. */
@media (prefers-reduced-motion: reduce) {
  /* All authored animations and transitions are collapsed. */
  *,
  *::before,
  *::after {
    /* Durations become tiny but nonzero to preserve state changes. */
    animation-duration: 0.01ms !important;
    /* Animation iterations stop after the immediate state. */
    animation-iteration-count: 1 !important;
    /* Transition durations are effectively instant. */
    transition-duration: 0.01ms !important;
    /* Smooth scrolling is disabled for vestibular safety. */
    scroll-behavior: auto !important;
  }

  /* The orb stops floating. */
  .orb {
    /* The orb remains in its settled orientation. */
    animation: none;
    /* Rotation is retained as a static design feature. */
    transform: rotate(8deg);
  }

  /* The orbit stops spinning. */
  .orb-ring {
    /* The ring remains as a static orbit. */
    animation: none;
  }

  /* Thinking dots remain visible without pulsing. */
  .thinking-dots span {
    /* Full opacity keeps the waiting state legible. */
    opacity: 1;
    /* No transform is applied. */
    transform: none;
  }
}

/* Very wide screens keep the reading measure centered rather than stretched. */
@media (min-width: 1440px) {
  /* The transcript remains within its readable maximum. */
  .empty-state,
  .message-list {
    /* The existing max widths already center content. */
    margin-inline: auto;
  }
}
