/* FMC Console — minimal dark UI with light toggle, RTL/LTR aware.
   Mobile-tuned: drawer sidebar, sticky composer with safe-area, full-screen
   saved sheet on phones, 44px touch targets, no horizontal page scroll. */

:root {
  --bg: #0f1115;
  --bg-2: #161922;
  --bg-3: #1f2330;
  --border: #2a2f3d;
  --fg: #e7eaf2;
  --fg-2: #aab1c2;
  --fg-3: #8089a0;
  --accent: #63b3ed;
  --accent-2: #4a90c2;
  --good: #6ad1a6;
  --warn: #e7b94c;
  --bad:  #ef6b6b;
  --user-bubble: #1f2a3a;
  --asst-bubble: #1a1d29;
  --shadow: 0 6px 20px rgba(0,0,0,.35);
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  /* visualViewport offset; JS updates this when the soft keyboard opens. */
  --kb-offset: 0px;
}

html.light, body.light {
  --bg: #f7f8fb;
  --bg-2: #ffffff;
  --bg-3: #eef0f6;
  --border: #d8dde6;
  --fg: #1c2230;
  --fg-2: #555c70;
  --fg-3: #8089a0;
  --user-bubble: #e3edff;
  --asst-bubble: #ffffff;
  --shadow: 0 6px 20px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
/* The browser default [hidden] { display: none } loses to author rules like
   .modal { display: grid }, which leaves modals/drawers/toasts visible even
   when JS sets element.hidden = true. Force the attribute to win. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: "Segoe UI", "Tahoma", "Cairo", system-ui, -apple-system, sans-serif;
  /* 16px on mobile prevents iOS Safari from zooming on input focus. */
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
}

button, [role="button"], a, input, textarea, select, label {
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; touch-action: manipulation; }
input, textarea {
  font-family: inherit; font-size: inherit; color: inherit;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
a { color: var(--accent); text-decoration: none; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(99,179,237,.10), transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(106,209,166,.08), transparent 55%),
    var(--bg);
}
.login-card {
  width: min(420px, 92vw);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 26px; box-shadow: var(--shadow);
}
.login-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.login-card h1 { margin: 8px 0 18px; font-size: 22px; }
.login-card form label { display: block; margin-bottom: 14px; }
.login-card form span { display: block; color: var(--fg-2); font-size: 13px; margin-bottom: 6px; }
.login-card input { width: 100%; }
.login-card button.primary { width: 100%; min-height: 44px; }
.login-error {
  background: rgba(239,107,107,.10); border: 1px solid rgba(239,107,107,.4);
  color: var(--bad); padding: 8px 10px; border-radius: 8px; margin: 6px 0 12px; font-size: 13px;
}
.login-foot { text-align: center; color: var(--fg-3); font-size: 12px; margin-top: 14px; }

/* ---------- Buttons ---------- */
.primary {
  background: var(--accent); color: #0c1320; font-weight: 600;
  border: none; border-radius: 8px; padding: 10px 14px; cursor: pointer;
  transition: filter .15s ease, transform .08s ease;
}
.primary:hover { filter: brightness(1.08); }
.primary:active { transform: scale(0.97); }
.primary:disabled { opacity: .55; cursor: not-allowed; }
.primary.danger { background: var(--bad); color: #fff; }

.ghost-btn {
  background: transparent; color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 14px;
  min-height: 36px;
  transition: background .12s ease;
}
.ghost-btn:hover { background: var(--bg-3); }
.ghost-btn:active { background: var(--bg); }

.icon-btn {
  background: transparent; color: var(--fg-2); border: none;
  width: 40px; height: 40px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }
.icon-btn:active { background: var(--bg); }

.link-btn {
  background: transparent; color: var(--fg-2); border: none;
  cursor: pointer; padding: 6px 8px; font-size: 14px;
  min-height: 32px;
}
.link-btn:hover { color: var(--fg); text-decoration: underline; }

.lang-toggle {
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 12px; font-weight: 600;
  min-height: 34px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "top top" "side main";
  height: 100vh; height: 100dvh; overflow: hidden;
}

.topbar {
  grid-area: top; background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  padding-inline: 10px;
  padding-block: 0;
  z-index: 5;
  min-width: 0;
}
.topbar-spacer { flex: 1; }

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 auto; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: var(--accent); color: #0c1320;
  font-weight: 800; border-radius: 8px;
  flex: 0 0 auto;
}
.brand-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand-name-short { display: none; font-weight: 600; }

.user-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  min-height: 32px;
}

.topbar-hamburger { display: none; }
.topbar-overflow { display: none; }

/* Top-bar nav links (Admin / Reports / Notifications / New report). Anchors
   styled to read like ghost-btn buttons — no underline, vertically centred. */
a.topbar-link { display: inline-flex; align-items: center; text-decoration: none; }
a.topbar-link:hover { text-decoration: none; }

/* ---------- Overflow menu (mobile) ---------- */
.overflow-menu {
  position: absolute;
  top: 56px;
  inset-inline-end: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 35;
  min-width: 200px;
  display: flex; flex-direction: column;
  gap: 2px;
}
.overflow-item {
  background: transparent;
  color: var(--fg);
  border: none;
  text-align: start;
  font-size: 15px;
  padding: 12px 14px;
  border-radius: 6px;
  min-height: 44px;
  cursor: pointer;
}
.overflow-item:hover { background: var(--bg-3); }
.overflow-item:active { background: var(--bg); }
.overflow-item.danger { color: var(--bad); }
.overflow-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}
.overflow-user {
  font-size: 12px;
  color: var(--fg-3);
  padding: 6px 14px 0;
  word-break: break-word;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: side; background: var(--bg-2);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-mobile-head {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-mobile-head h3 { margin: 0; font-size: 15px; }

.new-chat {
  margin: 12px; padding: 12px;
  background: var(--bg-3); color: var(--fg); border: 1px dashed var(--border);
  border-radius: 8px; cursor: pointer; text-align: center; font-weight: 600;
  font-size: 15px; min-height: 44px;
}
.new-chat:hover { background: var(--bg); border-color: var(--accent); }
.new-chat:active { transform: scale(0.99); }

.sessions-wrap {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 8px;
}
.sessions { list-style: none; padding: 0; margin: 0; }
.session-row {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 8px; margin: 2px 0; border-radius: 8px;
  cursor: pointer; color: var(--fg);
  min-height: 44px;
}
.session-row:hover { background: var(--bg-3); }
.session-row:active { background: var(--bg); }
.session-row.active { background: var(--bg-3); border: 1px solid var(--border); }
.session-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 14px;
}
/* Desktop: row actions appear on hover. Mobile: always visible (no hover). */
.session-row .row-actions { display: none; gap: 4px; }
.session-row:hover .row-actions { display: inline-flex; }
.session-row .row-actions .icon-btn { width: 36px; height: 36px; }

/* ---------- Chat ---------- */
.chat {
  grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--bg);
}
.chat-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px 12px;
  scroll-behavior: smooth;
}

.empty-state {
  max-width: 760px; margin: 8vh auto 0; padding: 0 8px;
}
.empty-state h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.3; }
.empty-sub { color: var(--fg-2); margin: 0 0 18px; font-size: 15px; }
.suggestion-chips { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.suggestion-chips button {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 10px; cursor: pointer; text-align: start;
  font-size: 14px; min-height: 44px;
  min-width: 0; width: 100%;
  word-break: break-word;
  /* Cap to 2 lines max on phones; ellipsis the rest. */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; line-height: 1.35;
  transition: border-color .12s ease, background .12s ease;
}
.suggestion-chips button:hover { border-color: var(--accent); background: var(--bg-3); }
.suggestion-chips button:active { background: var(--bg); }

.messages { list-style: none; padding: 0; margin: 0 auto; max-width: 880px; }
.msg { display: flex; gap: 10px; margin: 14px 0; }
.msg.user { justify-content: flex-end; }
.msg.assistant { justify-content: flex-start; }
.bubble {
  max-width: min(720px, 88%);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: anywhere;
  position: relative;
  min-width: 0;
}
.msg.user .bubble {
  background: var(--user-bubble);
  border-color: rgba(99,179,237,.25);
}
.msg.assistant .bubble {
  background: var(--asst-bubble);
  box-shadow: var(--shadow);
}
.bubble .meta {
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; color: var(--fg-3); margin-bottom: 6px;
}
.bubble .star-btn {
  position: absolute; top: 4px; inset-inline-end: 4px;
  background: transparent; border: none; color: var(--fg-3);
  cursor: pointer; opacity: 0; transition: opacity .12s ease;
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-grid; place-items: center;
}
.msg.assistant:hover .star-btn { opacity: 1; }
.bubble .star-btn:hover { background: var(--bg-3); color: var(--fg); }
.bubble .star-btn.starred { color: var(--warn); opacity: 1; }

/* B-2c: report button — sits next to the star, same hover-reveal treatment. */
.bubble .report-btn {
  position: absolute; top: 4px; inset-inline-end: 44px;
  background: transparent; border: none; color: var(--fg-3);
  cursor: pointer; opacity: 0; transition: opacity .12s ease;
  font-size: 14px;
  width: 36px; height: 36px;
  border-radius: 8px;
  display: inline-grid; place-items: center;
}
.msg.assistant:hover .report-btn { opacity: 1; }
.bubble .report-btn:hover { background: var(--bg-3); color: var(--fg); }

/* Report modal form fields */
#reportModal .form-label {
  font-size: 12px; color: var(--fg-2); margin-bottom: 4px;
}
#reportModal input[type="text"],
#reportModal select,
#reportModal textarea {
  background: var(--bg-2); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
#reportModal input[type="text"]:focus,
#reportModal select:focus,
#reportModal textarea:focus {
  outline: none; border-color: var(--accent);
}

.thinking {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--fg-2); font-style: italic; font-size: 13px;
}
.thinking .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-2); animation: blink 1.2s infinite;
}
.thinking .dot:nth-child(2) { animation-delay: .2s; }
.thinking .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 12px; font-size: 13px;
  cursor: pointer; color: var(--fg);
  min-height: 36px;
  max-width: 100%;
}
.file-chip span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.file-chip:hover { border-color: var(--accent); }

/* Markdown content inside bubbles */
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { padding-inline-start: 22px; margin: 6px 0; }
/* Wrap tables/code so long content scrolls inside the bubble, not the page. */
.md .table-wrap, .md .pre-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 8px 0;
  border-radius: 8px;
}
.md table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 13px; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 8px; text-align: start; white-space: normal; }
.md th { background: var(--bg-3); font-weight: 600; }
.md code {
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 4px; font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12.5px;
  word-break: break-word;
}
.md pre {
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 8px;
  font-family: ui-monospace, "SFMono-Regular", "Menlo", monospace;
  font-size: 12.5px; line-height: 1.45;
  margin: 0;
  white-space: pre;
  width: max-content; min-width: 100%;
}
.md strong { font-weight: 700; }
.md em { font-style: italic; }

/* ---------- Composer ---------- */
.composer {
  border-top: 1px solid var(--border);
  background: var(--bg-2);
  padding: 10px 14px;
  padding-bottom: calc(10px + var(--safe-bottom));
  display: flex; gap: 8px; align-items: end;
}
.composer textarea {
  flex: 1; resize: none;
  min-height: 44px; max-height: 168px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; line-height: 1.45;
  font-size: 16px; /* prevent iOS zoom-on-focus */
}
.composer textarea:focus { border-color: var(--accent); }
.send-btn {
  height: 44px; width: 48px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: 12px;
}
/* Send arrow points "forward" — flip the icon for RTL. */
html[dir="rtl"] .send-ico { transform: scaleX(-1); }

.composer-hint {
  text-align: center;
  font-size: 11px;
  color: var(--fg-3);
  padding: 0 14px 6px;
  background: var(--bg-2);
}

/* ---------- Drawer (Saved) ---------- */
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0;
  width: min(440px, 92vw); background: var(--bg-2);
  border-inline-start: 1px solid var(--border);
  z-index: 30; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.saved-list {
  flex: 1; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: calc(12px + var(--safe-bottom));
}
.saved-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.saved-card .saved-meta {
  font-size: 11px; color: var(--fg-3); margin-bottom: 6px;
  display: flex; justify-content: space-between; gap: 8px;
}
.saved-card .saved-meta > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.saved-card .saved-preview {
  font-size: 13px; color: var(--fg); margin-bottom: 8px;
  max-height: 6em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical;
  word-break: break-word;
}
.saved-card .saved-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.saved-card .saved-actions .ghost-btn { flex: 1 1 auto; min-height: 40px; }

/* ---------- Sidebar drawer backdrop (mobile only) ---------- */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 19;
  opacity: 0;
  transition: opacity .2s ease;
}
.sidebar-backdrop.show { opacity: 1; }

/* ---------- Modal & toast ---------- */
.modal {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 40;
  background: rgba(0,0,0,.5);
  padding: 16px;
}
.modal-body {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; min-width: 280px; max-width: 92vw;
  width: min(420px, 92vw);
  box-shadow: var(--shadow);
}
.modal-body p { margin: 0 0 4px; line-height: 1.5; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px;
}
.modal-actions .ghost-btn,
.modal-actions .primary {
  min-height: 44px; padding: 10px 18px; font-size: 15px;
}

.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  inset-inline-start: 50%; transform: translateX(-50%);
  background: var(--bg-2); color: var(--fg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; box-shadow: var(--shadow);
  z-index: 50;
  max-width: 90vw;
}
html[dir="rtl"] .toast { transform: translateX(50%); }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 25;
}

/* ---------- Mobile (≤ 720px) ---------- */
@media (max-width: 720px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "top" "main";
  }

  /* Sidebar becomes a slide-in drawer. In RTL it docks to the right
     edge (inline-start in RTL = visual right) and slides off to the
     right when closed; in LTR it docks to the left and slides off
     to the left. translateX is a physical axis, so the hide
     direction must be set per-direction. */
  .sidebar {
    position: fixed;
    top: 56px;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: auto;
    width: min(320px, 86vw);
    z-index: 22;
    transition: transform .2s ease;
    border-inline-end: 1px solid var(--border);
    border-inline-start: none;
    box-shadow: var(--shadow);
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  html[dir="rtl"] .sidebar.open,
  html[dir="ltr"] .sidebar.open { transform: translateX(0); }

  .sidebar-mobile-head { display: flex; }

  .topbar-hamburger { display: inline-flex; }

  /* On mobile, hide the inline header buttons and use the 3-dot overflow
     menu instead. The hamburger stays (primary nav). Saved button moves
     into overflow + sidebar foot. */
  .topbar-saved,
  .topbar-link,
  .topbar-lang,
  .topbar-user {
    display: none;
  }
  .topbar-overflow { display: inline-flex; }

  /* Brand: hide the long form, show short. */
  .brand-name { display: none; }
  .brand-name-short { display: inline; font-size: 15px; }

  /* Suggestion chips: full-row, comfortable tap target. */
  .suggestion-chips { grid-template-columns: 1fr; gap: 10px; }
  .suggestion-chips button {
    min-height: 56px;
    padding: 14px 16px;
    font-size: 15px;
    -webkit-line-clamp: 2;
  }

  .empty-state { margin-top: 4vh; padding: 0; }
  .empty-state h2 { font-size: 20px; }

  /* Bubbles: more screen real estate, slightly tighter padding. */
  .bubble {
    max-width: 90%;
    padding: 11px 12px;
    font-size: 15px;
  }
  /* Star + report are always visible on touch (no hover). */
  .msg.assistant .star-btn { opacity: .55; width: 44px; height: 44px; font-size: 20px; }
  .msg.assistant .star-btn.starred { opacity: 1; }
  .msg.assistant .report-btn { opacity: .55; width: 44px; height: 44px; font-size: 18px; inset-inline-end: 52px; }

  .chat-scroll { padding: 14px 12px 12px; }
  .messages { padding: 0; }

  /* Composer: sticky at the bottom safe-area, lifted above the keyboard
     by the visualViewport-driven --kb-offset. */
  .composer {
    position: sticky;
    bottom: 0;
    padding: 8px 10px;
    padding-bottom: calc(8px + var(--safe-bottom) + var(--kb-offset));
    transition: padding-bottom .15s ease;
  }
  .composer textarea {
    min-height: 44px;
    border-radius: 14px;
    padding: 10px 14px;
  }
  .send-btn { width: 52px; height: 48px; border-radius: 14px; }

  /* Hide the desktop-only Enter/Shift-Enter hint on touch. */
  .composer-hint { display: none; }

  /* Saved drawer becomes a full-screen sheet on phones. */
  .drawer {
    width: 100vw;
    inset-inline-end: 0;
    inset-inline-start: 0;
    border-inline-start: none;
    box-shadow: none;
  }
  .saved-card .saved-actions { flex-direction: row; }

  /* Modal sizing on phones — buttons full-width side-by-side. */
  .modal-body { width: min(420px, 92vw); padding: 16px; }
  .modal-actions { gap: 10px; }
  .modal-actions .ghost-btn,
  .modal-actions .primary { flex: 1 1 0; min-height: 48px; }

  /* Row actions visible on tap (no hover available). */
  .session-row .row-actions { display: inline-flex; }
}

/* ---------- Tiny phones (≤ 380px) ---------- */
@media (max-width: 380px) {
  .topbar { gap: 4px; padding-inline: 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-name-short { font-size: 14px; }
  .empty-state h2 { font-size: 18px; }
  .empty-sub { font-size: 14px; }
}

/* ---------- Rate limit bubble ---------- */
.rate-limit-bubble {
  background: rgba(231, 185, 76, .10);
  border: 1px solid rgba(231, 185, 76, .45);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--fg);
  max-width: 720px;
}
.rate-limit-bubble .rl-title {
  color: var(--warn);
  font-weight: 700;
  margin-bottom: 6px;
}
.rate-limit-bubble .rl-body { color: var(--fg-2); white-space: pre-wrap; }
.rate-limit-bubble .rl-countdown {
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--fg-3);
}
.rate-limit-bubble .rl-action {
  margin-top: 12px;
  padding: 9px 16px;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--accent); border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: 14px; min-height: 40px;
}
.rate-limit-bubble .rl-action:hover { background: var(--bg); }
.rate-limit-bubble .rl-action:active { transform: scale(0.99); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
  .chat-scroll { scroll-behavior: auto; }
}

