/* Design tokens — Addcontrol brand (see ADR-004). */
:root {
  --c-bg: #0d0c2e;
  --c-surface: #1a1848;
  --c-surface2: #221f5a;
  --c-surface3: #2a2670;
  --c-border: rgba(46, 42, 106, 0.8);
  --c-border2: rgba(46, 42, 106, 1);
  --c-accent: #df5124;
  --c-accent2: #e58925;
  --c-success: #10b981;
  --c-warning: #f59e0b;
  --c-error: #ef4444;
  --c-text: #e2e8f0;
  --c-text-strong: #ffffff;
  --c-muted: #94a3b8;
  --c-muted2: #64748b;

  --font-ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

textarea {
  font-family: inherit;
  resize: none;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--c-muted);
}

.small {
  font-size: 12px;
}

/* ── App layout ─────────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--c-border);
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--c-surface2);
  padding: 4px;
}

/* Full horizontal brand logo (icon + wordmark in one image). Fills
   the sidebar width minus the close button's space; auto-height
   keeps the image's aspect ratio. */
.brand-logo {
  flex: 1;
  min-width: 0;
  max-width: 100%;
  height: auto;
  max-height: 44px;
  object-fit: contain;
  object-position: left center;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--c-text-strong);
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--c-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border2);
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent2) 100%);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.new-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(223, 81, 36, 0.4);
}

.conv-label {
  font-size: 11px;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 4px 0;
  margin-top: 4px;
}

.conv-search {
  margin: 4px 0 6px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border2);
  background: var(--c-surface2);
  color: var(--c-text);
  font-size: 12px;
  font-family: var(--font-ui);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.conv-search::placeholder {
  color: var(--c-muted2);
}

.conv-search:focus {
  border-color: var(--c-accent);
}

.conversations {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.conversations::-webkit-scrollbar {
  width: 6px;
}
.conversations::-webkit-scrollbar-thumb {
  background: var(--c-border2);
  border-radius: 3px;
}

.conv-group-header {
  list-style: none;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-muted2);
  padding: 10px 10px 4px;
}

.conv-group-header:first-child {
  padding-top: 4px;
}

.conv-empty {
  padding: 14px 10px;
  text-align: center;
  line-height: 1.5;
  color: var(--c-muted2);
}

.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  background: transparent;
  position: relative;
}

.conv-item:hover {
  background: var(--c-surface2);
}

.conv-item.active {
  background: var(--c-surface2);
  border-color: var(--c-accent);
}

.conv-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-delete {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--c-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.conv-item:hover .conv-delete,
.conv-item.active .conv-delete {
  opacity: 1;
}

.conv-delete:hover {
  background: rgba(239, 68, 68, 0.18);
  color: var(--c-error);
}

.conv-item-preview {
  font-size: 13px;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-muted);
}

.sidebar-footer {
  padding-top: 10px;
  border-top: 1px solid var(--c-border);
}

.sidebar-legal-links {
  margin-top: 12px;
  text-align: center;
  font-size: 10.5px;
  color: var(--c-muted2);
}

.sidebar-legal-links a {
  color: var(--c-muted);
  text-decoration: none;
  margin: 0 4px;
}

.sidebar-legal-links a:hover {
  color: var(--c-accent2);
  text-decoration: underline;
}

.powered-by {
  margin-top: 6px;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--c-muted2);
  opacity: 0.6;
}

.powered-by strong {
  color: var(--c-accent2);
  font-weight: 600;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-email {
  flex: 1;
  font-size: 11px;
  color: var(--c-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 11px;
}

/* `display: inline-flex` above silently beats the HTML `hidden` attribute. */
.btn-small[hidden] {
  display: none;
}

/* ── Chat area ──────────────────────────────────────────────────────────── */
.chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--c-bg);
}

.chat-header {
  padding: 16px 28px;
  border-bottom: 1px solid var(--c-border);
  background: rgba(26, 24, 72, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kb-status-chip {
  font-size: 11px;
  color: var(--c-muted2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.support-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--c-muted);
  text-decoration: none;
  padding: 5px 0;
  transition: color 0.15s ease;
}
.support-link:hover { color: var(--c-accent); }

.chat-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--c-text-strong);
}

.chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--c-muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 8px;
}
.messages::-webkit-scrollbar-thumb {
  background: var(--c-border2);
  border-radius: 4px;
}

/* ── Welcome screen ─────────────────────────────────────────────────────── */
.welcome {
  margin: auto;
  text-align: center;
  max-width: 560px;
}

.welcome h2 {
  font-size: 26px;
  font-weight: 600;
  color: var(--c-text-strong);
  margin: 0 0 8px;
  background: linear-gradient(90deg, var(--c-accent) 0%, var(--c-accent2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.welcome-sub {
  color: var(--c-muted);
  margin: 0 0 24px;
}

.examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.example {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 13px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.example:hover {
  border-color: var(--c-accent);
  transform: translateY(-1px);
}

.welcome-tip {
  margin-top: 22px;
  font-size: 11px;
  color: var(--c-muted2);
  letter-spacing: 0.02em;
}

.welcome-tip kbd {
  background: var(--c-surface2);
  border: 1px solid var(--c-border2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--c-text);
  margin: 0 2px;
}

/* ── Password visibility toggle ─────────────────────────────────────────── */
.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input {
  padding-right: 42px !important;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle:hover {
  color: var(--c-text);
  background: rgba(255, 255, 255, 0.04);
}
.password-toggle:focus { outline: none; }

/* ── Onboarding modal ───────────────────────────────────────────────────── */
.ob-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ob-modal[hidden] { display: none; }

.ob-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 12, 46, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.ob-card {
  position: relative;
  background: #121130;
  border: 1px solid rgba(46, 42, 106, 0.9);
  border-radius: 20px;
  padding: 36px 32px 28px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55);
  animation: ob-in 0.25s ease;
}

@keyframes ob-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.ob-logo {
  margin-bottom: 20px;
}
.ob-logo img {
  height: 28px;
  opacity: 0.9;
}

.ob-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 10px;
}

.ob-desc {
  font-size: 13.5px;
  color: var(--c-muted);
  margin: 0 0 20px;
  line-height: 1.6;
}

.ob-hint {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--c-muted2);
  margin: 0 0 10px;
}

.ob-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
  text-align: left;
}

.ob-chip {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 11px 14px;
  color: var(--c-text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  line-height: 1.45;
}
.ob-chip:hover {
  background: var(--c-surface2);
  border-color: var(--c-accent);
  transform: translateY(-1px);
  color: #fff;
}

.ob-start-btn {
  background: linear-gradient(135deg, var(--c-accent), #E58925);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 11px 24px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
  font-family: inherit;
}
.ob-start-btn:hover { opacity: 0.88; }

/* ── Bubbles ────────────────────────────────────────────────────────────── */
.bubble-row {
  display: flex;
  flex-direction: column;
  max-width: 720px;
  width: 100%;
  align-self: flex-start;
}

.bubble-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  font-size: 14px;
  line-height: 1.65;
  box-shadow: var(--shadow-sm);
}

.bubble-row.user .bubble {
  background: var(--c-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
  max-width: 80%;
}

/* Edit-button row sits below the user bubble and aligns to the right.
   The button only fades in on hover (or focus-within) so it doesn't
   compete visually with the message itself. */
.bubble-row.user .bubble-meta {
  margin-left: auto;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.bubble-row.user:hover .bubble-meta,
.bubble-row.user:focus-within .bubble-meta {
  opacity: 1;
}

.bubble-row.bot {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}

.bot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  margin-top: 2px;
}

.bubble-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.bubble-row.bot .bubble {
  background: var(--c-surface2);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-top-left-radius: 4px;
}

.bubble-row.bot .bubble.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--c-muted);
  font-style: italic;
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--c-accent);
  border-radius: 50%;
  animation: dot-pulse 1.4s infinite both;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dot-pulse {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Markdown inside bot bubble */
.bubble p {
  margin: 0 0 8px;
}
.bubble p:last-child {
  margin-bottom: 0;
}
.bubble ul,
.bubble ol {
  margin: 6px 0 8px;
  padding-left: 22px;
}
.bubble li {
  margin: 2px 0;
}
.bubble strong {
  color: var(--c-text-strong);
}
.bubble code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 6px;
  border-radius: 4px;
}
.bubble pre {
  background: rgba(0, 0, 0, 0.4);
  padding: 12px;
  border-radius: var(--r-sm);
  overflow-x: auto;
}

/* ── Sources + feedback bar ─────────────────────────────────────────────── */
.bubble-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  align-items: center;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--c-border);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--c-muted);
}

.source-chip strong {
  color: var(--c-accent2);
  font-weight: 500;
}

.bubble-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.fb-bar {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.fb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.fb-btn:hover {
  background: var(--c-surface2);
  color: var(--c-text);
}

.fb-btn.active.up {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--c-success);
  color: var(--c-success);
}

.fb-btn.active.down {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--c-error);
  color: var(--c-error);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.action-btn:hover {
  background: var(--c-surface2);
  color: var(--c-text);
}

.action-btn.copied {
  color: var(--c-success);
  border-color: var(--c-success);
}

/* ── Composer ───────────────────────────────────────────────────────────── */
.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px 28px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
  align-items: flex-end;
}

#user-input {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--c-border2);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#user-input:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(223, 81, 36, 0.15);
}

#send-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  border: none;
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent2) 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(223, 81, 36, 0.4);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* `display: flex` above silently beats the HTML `hidden` attribute — restore it. */
.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border2);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow-md);
}

.modal-content h3 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--c-text-strong);
}

.modal-content .muted {
  margin: 0 0 16px;
  font-size: 13px;
}

.reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.reason-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--c-border2);
  background: var(--c-surface2);
  color: var(--c-text);
  font-size: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.reason-btn.active {
  border-color: var(--c-accent);
  background: rgba(223, 81, 36, 0.18);
  color: var(--c-accent2);
}

#feedback-comment {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border2);
  background: var(--c-surface2);
  color: var(--c-text);
  font-size: 13px;
  outline: none;
  margin-top: 6px;
}

#feedback-comment:focus {
  border-color: var(--c-accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.btn-ghost {
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border2);
  background: transparent;
  color: var(--c-muted);
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--c-text);
  border-color: var(--c-border2);
}

.btn-primary {
  padding: 8px 16px;
  border-radius: var(--r-sm);
  border: none;
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent2) 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(223, 81, 36, 0.4);
}

/* ── Toast / tiny inline status ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-surface2);
  border: 1px solid var(--c-border2);
  color: var(--c-text);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  animation: toast-in 0.18s ease;
}

.toast.ok {
  border-color: rgba(74, 222, 128, 0.45);
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
}
.toast.err {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ── Mobile top bar + sidebar drawer ─────────────────────────────────── */
.mobile-topbar {
  display: none;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.mobile-brand-logo {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border2);
  background: var(--c-surface);
  color: var(--c-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: var(--c-surface2);
}

.sidebar-close {
  display: none;
  margin-left: auto;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  z-index: 49;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    grid-column: 1 / -1;
  }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 80%;
    max-width: 320px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .chat {
    height: auto;
    min-height: 0;
  }

  .chat-header {
    padding: 12px 16px;
  }

  .messages {
    padding: 16px;
  }

  .chat-form {
    padding: 12px 16px 16px;
  }
}
