@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e3e3e6;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --user-bubble: #2563eb;
  --user-bubble-text: #ffffff;
  --assistant-bubble: #f1f1f3;
  --assistant-bubble-text: #1f2328;
  --error-bg: #fee2e2;
  --error-text: #991b1b;
  --guidance-bg: #eff6ff;
  --guidance-text: #1e40af;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

#appShell.hidden,
#loginView.hidden,
.upload-panel.hidden,
.upload-role-notice.hidden,
.view.hidden,
#primaryNav.hidden,
.nav-btn.hidden,
.mic-btn.hidden,
#showContextBtn.hidden,
#modeLabel.hidden,
#chatSidebarPanels.hidden {
  display: none;
}

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
}

.login-form {
  width: 280px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.login-form h2 {
  margin-top: 0;
  font-size: 16px;
  color: var(--text);
}

.login-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  margin-top: 10px;
}

.login-form input {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

#loginSubmitBtn {
  width: 100%;
  margin-top: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}

#loginSubmitBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--error-text);
  min-height: 1em;
}

.upload-role-notice {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}

/* Application shell: the sidebar is a three-region column -- Brand (top),
   the scrollable navigation/operational body (middle), and the Account Area
   (bottom). Only the middle region scrolls, so the product identity and the
   account controls keep a stable location. Sizing stays relative (flex +
   min-height:0) rather than depending on a fixed body height, so the later
   responsive Slice is not designed out. */
.sidebar {
  width: 240px;
  min-width: 200px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 14px;
  overflow: hidden;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

/* Brand area: a restrained product identity anchor, not a branding system.
   No image asset, no gradient, no animation. */
.brand {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.brand-name {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: normal;
  color: var(--text);
}

.brand-subtitle {
  margin: 6px 0 0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--muted);
}

/* Primary navigation between the two application surfaces. Deliberately a
   pair of semantic buttons rather than a routing widget -- there is no URL,
   no history entry, and no router. The active surface is marked with
   aria-current plus a weight/border change, never colour alone. */
.primary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-btn {
  flex: 1 1 auto;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  text-align: center;
}

.nav-btn:hover {
  background: var(--bg);
}

.nav-btn-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

/* Account Area: identity, role, and Logout, pinned to the bottom of the
   shell so Logout is an account action rather than a top-level chat
   control. Identity and role are always rendered as text -- colour is never
   the only carrier of the role. */
.account-area {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-bottom: 0;
}

.sidebar .account-heading {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: none;
}

.account-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  line-height: 1.7;
}

.account-field-label {
  color: var(--muted);
  flex: none;
}

.account-user-id,
.account-role {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
}

.account-role {
  direction: rtl;
  text-align: left;
  font-weight: 600;
}

.account-logout-btn {
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

.account-logout-btn:hover {
  background: var(--bg);
}

.runtime-indicator {
  display: inline-block;
  margin-bottom: 6px;
  padding: 3px 8px;
  font-size: 10px;
  color: #166534;
  background: #dcfce7;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
}

.api-status-indicator {
  display: block;
  margin-bottom: 14px;
  font-size: 10px;
  color: var(--muted);
}

.api-status-indicator.api-status-error {
  color: #b91c1c;
}

.runtime-indicator.runtime-indicator-network {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.panel {
  margin-bottom: 16px;
}

.panel h3 {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.panel label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.panel input,
.panel select {
  width: 100%;
  padding: 6px 8px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}

.active-index-panel > label {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.custom-path-wrapper {
  margin-top: 8px;
}

.custom-path-wrapper.hidden {
  display: none;
}

.active-index-summary {
  margin-top: 10px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.6;
}

.advanced-settings summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}

.advanced-settings[open] summary {
  margin-bottom: 8px;
}

.sessions-panel .compact-panel-header {
  margin-bottom: 8px;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}

/* One row per persisted Conversation: the select control and its delete
   control are always sibling buttons, never nested. */
.session-row {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.session-item {
  text-align: right;
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-item:hover {
  background: var(--bg);
}

.session-item-active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Transient Conversation-list states. Deliberately not `.session-item`: no
   border, no button affordance, no hover, and not selectable -- so a loading
   or empty placeholder can never read as a Conversation the user could open. */
.session-list-placeholder {
  padding: 6px 8px;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  cursor: default;
  user-select: none;
}

.session-list-loading {
  opacity: 0.85;
}

.session-list-empty {
  font-style: normal;
}

.session-delete-btn {
  flex: 0 0 auto;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: #b91c1c;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

.session-delete-btn:hover {
  background: var(--bg);
}

.session-delete-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.upload-panel h3 {
  margin-bottom: 8px;
  color: var(--text);
  font-weight: 600;
}

.upload-constraints {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.upload-file-info {
  font-size: 11px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.6;
  word-break: break-word;
  unicode-bidi: isolate;
}

.upload-file-info.hidden {
  display: none;
}

.upload-file-warning {
  color: #92400e;
}

.upload-summary {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  line-height: 1.6;
}

.upload-summary.hidden {
  display: none;
}

.upload-panel input[type="file"] {
  width: 100%;
  font-size: 11px;
  margin-bottom: 8px;
}

.upload-force-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}

.upload-force-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

#uploadIndexBtn {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}

#uploadIndexBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.upload-status {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.upload-status.upload-status-error {
  color: #b91c1c;
}

.upload-status.upload-status-success {
  color: #166534;
}

.compact-panel {
  margin-bottom: 12px;
}

.compact-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  width: auto;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

.link-btn:hover {
  text-decoration: underline;
}

.panel-output {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-output.compact {
  max-height: 110px;
  font-size: 11px;
}

.doc-summary-line {
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
  unicode-bidi: isolate;
}

.doc-summary-line:last-child {
  border-bottom: none;
}

/* The shared main region hosts exactly one visible view at a time, plus the
   one shared error banner above them (a single showError authority serving
   both surfaces, rather than a second banner per view). */
.main-region {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* Management surface: a real page in the main region rather than a stack of
   narrow sidebar panels, so the operator workflow is visibly a different
   place from Chat. Relative units and a min-width-based auto-fill grid, so
   the later responsive Slice is not designed out. */
.management-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 24px;
  flex: none;
}

.management-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.management-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
  gap: 16px;
  align-content: start;
}

.management-body > .panel {
  margin-bottom: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.management-body > .upload-role-notice {
  margin-bottom: 0;
}

.management-body .panel h3 {
  margin-bottom: 8px;
}

/* Current-conversation header: the main region's stable top anchor. It shows
   the authoritative title of the selected Conversation, or a bounded draft
   label when New Chat is active -- never invented metadata. */
.conversation-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 24px;
  flex: none;
}

.conversation-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-header-draft .conversation-title {
  color: var(--muted);
  font-weight: 500;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  display: flex;
}

.message.user {
  justify-content: flex-start;
}

.message.assistant {
  justify-content: flex-end;
}

.message-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 70%;
}

.bubble {
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.8;
  font-size: 15px;
}

.message.user .bubble {
  background: var(--user-bubble);
  color: var(--user-bubble-text);
  font-weight: 500;
  padding: 9px 14px;
}

.message.assistant .bubble {
  background: var(--assistant-bubble);
  color: var(--assistant-bubble-text);
}

.answer-line {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Bullet marker is CSS-only (::before), never a DOM node built from model
   text. text-indent pulls the marker into the padding-right gutter on the
   first line only, so a wrapped bullet item's continuation lines align
   under the text (hanging indent) instead of under the marker. */
.answer-line-bullet {
  padding-right: 18px;
  text-indent: -18px;
}

.answer-line-bullet::before {
  content: "•";
  display: inline-block;
  width: 18px;
  text-align: center;
}

.answer-line-heading {
  font-weight: bold;
  margin-top: 6px;
}

.answer-line-citation {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  unicode-bidi: isolate;
}

.message.assistant .answer-line-citation {
  color: #52575c;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Transient Message-pane states (Detail loading, blank Draft hint).
   Deliberately NOT `.message` and NOT a bubble: centered, muted, borderless
   plain text with no role styling, so neither can be mistaken for persisted
   Conversation content. Symmetric padding only, so both read correctly in
   RTL. */
.conversation-placeholder {
  align-self: center;
  max-width: 70%;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
  user-select: none;
}

.conversation-placeholder-loading {
  font-style: italic;
  animation: conversation-placeholder-pulse 1.4s ease-in-out infinite;
}

.conversation-placeholder-draft {
  font-style: normal;
}

/* The pending Ask indicator. It reuses the `.message assistant` layout hook
   that already exists in the DOM, but is styled to a visibly LOWER authority
   than a confirmed Assistant answer: no solid answer background, a dashed
   outline that marks it as provisional, muted italic text, and a CSS-only
   pulse. Persisted Assistant rendering above is untouched. Specificity is
   raised past `.message.assistant .bubble` on purpose so the override is
   unambiguous rather than source-order dependent. */
.message.assistant.conversation-pending .bubble {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border);
  font-style: italic;
  font-size: 13px;
  animation: conversation-placeholder-pulse 1.4s ease-in-out infinite;
}

@keyframes conversation-placeholder-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .conversation-placeholder-loading,
  .message.assistant.conversation-pending .bubble {
    animation: none;
  }
}

.copy-btn {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

.copy-btn:hover {
  background: var(--bg);
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.source-chips:empty {
  display: none;
}

.source-chips-label {
  font-size: 11px;
  color: var(--muted);
}

.source-chip {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  unicode-bidi: isolate;
}

.source-chip:hover {
  background: var(--bg);
}

.copy-all-sources-btn {
  font-size: 11px;
  padding: 3px 10px;
  border: 1px dashed var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

.copy-all-sources-btn:hover {
  background: var(--bg);
}

.grounding-warning {
  margin-top: 6px;
  font-size: 11px;
  color: var(--guidance-text);
  background: var(--guidance-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
}

.grounding-warning.hidden {
  display: none;
}

/* RAG Inspection Visibility Slice: Source chips/metadata below an answer are
   an ADMIN-oriented technical-review detail, toggled by applyRolePresentation()
   -- a normal user's answer stays limited to the question and the answer
   text itself. */
.hide-rag-technical-details .source-chips,
.hide-rag-technical-details .grounding-warning {
  display: none;
}

.context-panel {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 24px;
  max-height: 260px;
  overflow-y: auto;
}

.context-panel.hidden,
.error-banner.hidden {
  display: none;
}

.context-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.context-panel-header h3 {
  margin: 0;
  font-size: 14px;
}

.context-panel-header button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  min-height: 24px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
}

.context-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--bg);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.context-item-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
}

.context-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  direction: ltr;
  text-align: start;
  unicode-bidi: isolate;
}

.copy-source-btn {
  margin-top: 6px;
  font-size: 11px;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
}

.copy-source-btn:hover {
  background: var(--bg);
}

.context-text {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* The one shared banner element, with two mutually-exclusive presentations:
   an actual error (red) and non-error user guidance (neutral blue). Neither
   color carries meaning on its own -- the banner text always states plainly
   which one it is; the color only reinforces the distinction. */
.error-banner {
  padding: 8px 24px;
  font-size: 13px;
}

.error-banner.banner-error {
  background: var(--error-bg);
  color: var(--error-text);
}

.error-banner.banner-guidance {
  background: var(--guidance-bg);
  color: var(--guidance-text);
}

.composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 24px 20px;
}

.composer textarea {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.composer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-label {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-label select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.composer-buttons {
  display: flex;
  gap: 8px;
  /* VOICE-SLICE-B: the Dictation controls are additional actions in this same
     row, so at ~320-480px the row must wrap rather than overflow. Additive
     only -- the existing Send/Context controls keep their own styling and are
     visually unchanged at every width where they already fitted. */
  flex-wrap: wrap;
}

.composer-buttons button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
}

#askBtn {
  background: var(--accent);
  color: white;
  border: none;
}

#showContextBtn {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 8px 12px;
}

#showContextBtn:hover {
  background: var(--bg);
  color: var(--text);
}

#askBtn:disabled,
#showContextBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* VOICE-SLICE-B -- Dictation controls.

   Deliberately built on the existing `.composer-buttons button` base rather
   than as a new button family: the microphone and cancel controls are two more
   ordinary Composer actions, not a separate Voice surface. The 40px floor is a
   touch-target minimum applied to these two controls ONLY, so Send and Show
   Context keep exactly the sizing they already had. Logical layout only (flex
   + gap), so RTL is inherited from <html dir="rtl"> with no left/right
   dependency, and no absolute overlay is placed over the textarea. */
.composer-buttons .mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  min-height: 40px;
  padding: 8px 12px;
}

.mic-glyph {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Recording is signalled by THREE independent channels -- the glyph shape
   (microphone vs. stop square), the button's own label/accessible name, and
   the live status line below -- so the state is never carried by color alone.
   The glyph swap is pure CSS: both glyphs ship in the markup and no JavaScript
   builds or replaces an icon. */
.mic-glyph-stop {
  display: none;
}

.mic-btn-recording .mic-glyph-idle {
  display: none;
}

.mic-btn-recording .mic-glyph-stop {
  display: inline-block;
}

.mic-btn-recording {
  border-color: var(--error-text);
  color: var(--error-text);
}

#micBtn:disabled,
#micCancelBtn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Composer-local, ownership-gated Voice feedback. Deliberately NOT the shared
   page-level #errorBanner: that banner already carries Ask/Conversation
   errors, has no live-region role, and sits at the top of the main region --
   far from the Composer at narrow widths. `min-height` reserves the line so
   status text never reflows the composer. */
.voice-status {
  margin-top: 8px;
  min-height: 1em;
  font-size: 13px;
  color: var(--muted);
}

.voice-status.voice-status-error {
  color: var(--error-text);
}

/* Keyboard focus must stay visible on every interactive control, including
   the Account Area's Logout button. :focus-visible only, so pointer users
   are unaffected. */
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-left: none;
    border-bottom: 1px solid var(--border);
    max-height: 240px;
  }
}

/* Narrow-screen padding/width relief: the 24px horizontal rhythm used
   throughout at wider viewports wastes a large share of a ~320-480px
   screen. Bounded to the surfaces where that padding is most costly --
   plain CSS values only, no new navigation architecture and no JS. */
@media (max-width: 480px) {
  .messages {
    padding: 14px;
  }
  .composer {
    padding: 12px 14px 20px;
  }
  .conversation-header,
  .management-header,
  .context-panel {
    padding: 12px 14px;
  }
  .management-body {
    padding: 20px 14px;
  }
  .error-banner {
    padding: 8px 14px;
  }
  .message-column,
  .conversation-placeholder {
    max-width: 88%;
  }
}
