/* ============================================================
   chat-editorial.css
   Applies the funnel's editorial finance scheme (cream paper, ink
   navy, brand blue + orange, Fraunces serif, JetBrains Mono) to
   the /chat page. Scoped to `body.chat-page` so it never bleeds
   to other pages. Loaded AFTER style-bundle.css so it overrides
   the shared bundle.

   NOTE: !important is used aggressively here because the bundle
   contains ~1,700 !important declarations across the chat surfaces
   (sidebar, message bubbles, send button, welcome cards). Higher
   specificity alone is not enough to win. Limited to visual
   properties (color / background / border / radius / shadow /
   font) — layout properties are left clean.
   ============================================================ */

body.chat-page {
  --ed-ink: #0b1b2b;
  --ed-ink-soft: #1f3a5f;
  --ed-paper: #faf7f2;
  --ed-paper-2: #f3ede2;
  --ed-rule: #c8c0b0;
  --ed-rule-strong: #9c9080;
  --ed-blue: #1a6db5;
  --ed-blue-soft: #4a9ad4;
  --ed-blue-deep: #11507f;
  --ed-orange: #ef7b1d;
  --ed-orange-soft: #f5a04a;
  --ed-orange-deep: #c95f0a;
  --ed-serif: "Fraunces", "Source Serif Pro", Georgia, serif;
  --ed-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  background: var(--ed-paper) !important;
  color: var(--ed-ink) !important;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
}
/* Force the html background to cream so the iOS home-indicator safe
   area (which sits outside body's 100dvh height) doesn't expose a
   dark default. Literal color since CSS vars defined on body don't
   cascade to html. This file is only loaded on /chat, so the rule
   can't leak to other pages. */
html { background: #faf7f2 !important; }
[data-theme="dark"] html { background: #0b1220 !important; }

/* ---- Sidebar ----------------------------------------------- */
body.chat-page .sidebar {
  background: var(--ed-paper-2) !important;
  border-right: 1px solid var(--ed-rule) !important;
  box-shadow: none !important;
}
body.chat-page .sidebar-header {
  border-bottom: 1px solid var(--ed-rule) !important;
  background: transparent !important;
}
body.chat-page .sidebar-section-title {
  font-family: var(--ed-mono) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-blue) !important;
}
body.chat-page .sidebar-item,
body.chat-page .sidebar-item-link {
  color: var(--ed-ink) !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  background: transparent !important;
  border-radius: 6px !important;
  box-shadow: none !important;
  transform: none !important;
}
body.chat-page .sidebar-item:hover,
body.chat-page .sidebar-item-link:hover {
  background: rgba(26, 109, 181, 0.08) !important;
  color: var(--ed-blue-deep) !important;
  transform: none !important;
}
body.chat-page .sidebar-item.active {
  background: var(--ed-ink) !important;
  color: var(--ed-paper) !important;
  box-shadow: 0 8px 20px -10px rgba(11, 27, 43, 0.45) !important;
  position: relative;
}
body.chat-page .sidebar-item.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ed-orange) !important;
  box-shadow: 0 0 0 3px rgba(239, 123, 29, 0.18) !important;
}
body.chat-page .sidebar-item.active .sidebar-icon,
body.chat-page .sidebar-item.active .sidebar-text { color: var(--ed-paper) !important; }
body.chat-page .sidebar-icon {
  color: var(--ed-blue) !important;
  background: transparent !important;
}
body.chat-page .sidebar-item-link .sidebar-icon { color: var(--ed-blue) !important; }
body.chat-page .sidebar-footer {
  border-top: 1px solid var(--ed-rule) !important;
  background: transparent !important;
}

/* User profile in the logged-in sidebar footer. The bundle styles
   .user-name / .user-status with light colors that were designed
   for the old dark sidebar — invisible on cream paper. Restyle for
   the editorial palette. */
body.chat-page .user-profile {
  background: transparent !important;
  border: 1px solid var(--ed-rule) !important;
  border-radius: 6px !important;
  padding: 10px 12px !important;
}
body.chat-page .user-avatar {
  background: var(--ed-blue) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: none !important;
}
body.chat-page .user-name {
  color: var(--ed-ink) !important;
  font-weight: 700 !important;
  font-size: 14px !important;
}
body.chat-page .user-status {
  color: var(--ed-ink-soft) !important;
  font-family: var(--ed-mono) !important;
  font-size: 10.5px !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  font-weight: 600 !important;
}
body.chat-page .logout-btn {
  color: var(--ed-ink-soft) !important;
  background: transparent !important;
  border: none !important;
}
body.chat-page .logout-btn:hover {
  color: var(--ed-orange-deep) !important;
  background: rgba(239, 123, 29, 0.08) !important;
}

[data-theme="dark"] body.chat-page .user-profile { border-color: rgba(126, 196, 245, 0.18) !important; }
[data-theme="dark"] body.chat-page .user-name { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .user-status { color: #cdd4e0 !important; }
[data-theme="dark"] body.chat-page .user-avatar { background: var(--ed-blue-soft) !important; color: #0b1220 !important; }
[data-theme="dark"] body.chat-page .logout-btn { color: #cdd4e0 !important; }
[data-theme="dark"] body.chat-page .logout-btn:hover { color: var(--ed-orange-soft) !important; background: rgba(245, 160, 74, 0.10) !important; }
body.chat-page .sidebar-badge {
  background: var(--ed-orange) !important;
  color: #fff !important;
  font-family: var(--ed-mono) !important;
  font-weight: 700 !important;
  font-size: 10.5px !important;
  letter-spacing: 0.06em !important;
}

/* ---- Rate widget (sidebar) ---- */
body.chat-page .rate-widget {
  background: transparent !important;
  border: 1px solid var(--ed-rule) !important;
  border-radius: 4px !important;
  box-shadow: none !important;
}
body.chat-page .rate-widget-header,
body.chat-page .rate-widget-header span {
  font-family: var(--ed-mono) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-blue) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
}
body.chat-page .rate-row {
  border-top: 1px solid var(--ed-rule) !important;
  background: transparent !important;
}
body.chat-page .rate-row:first-of-type { border-top: none !important; }
body.chat-page .rate-label {
  font-family: var(--ed-mono) !important;
  font-size: 11px !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: var(--ed-ink-soft) !important;
  font-weight: 600 !important;
}
body.chat-page .rate-value {
  font-family: var(--ed-mono) !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  color: var(--ed-ink) !important;
  font-variant-numeric: tabular-nums !important;
}
body.chat-page .rate-arrow.up   { color: #b04646 !important; }
body.chat-page .rate-arrow.down { color: #2f7a4a !important; }
body.chat-page .rate-arrow.flat { color: var(--ed-rule-strong) !important; }
body.chat-page .rate-widget-footer {
  font-family: var(--ed-mono) !important;
  font-size: 10.5px !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: var(--ed-ink-soft) !important;
  border-top: 1px solid var(--ed-rule) !important;
}

/* ---- Mobile header ----------------------------------------- */
body.chat-page .mobile-header {
  background: var(--ed-paper) !important;
  border-bottom: 1px solid var(--ed-rule) !important;
  box-shadow: none !important;
}
body.chat-page .mobile-menu-btn span { background: var(--ed-ink) !important; }
body.chat-page .mobile-rate-label {
  font-family: var(--ed-mono) !important;
  font-size: 10.5px !important;
  letter-spacing: 0.08em !important;
  color: var(--ed-ink-soft) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
}
body.chat-page .mobile-rate-value {
  font-family: var(--ed-mono) !important;
  font-weight: 700 !important;
  color: var(--ed-ink) !important;
  font-variant-numeric: tabular-nums !important;
}
body.chat-page .mobile-rate-divider { color: var(--ed-rule-strong) !important; }

/* ---- Chat container ---------------------------------------- */
body.chat-page .chat-container,
body.chat-page .main-content { background: var(--ed-paper) !important; }
body.chat-page .chatbox { background: transparent !important; }

/* ---- Welcome banner (pre-message state) -------------------- */
body.chat-page .welcome-banner-v2 {
  background: transparent !important;
  max-width: 720px;
}
body.chat-page .welcome-banner-v2::before {
  content: 'Ask · LoanSpace Intelligence';
  display: block;
  font-family: var(--ed-mono) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-blue) !important;
  text-align: center;
  margin-bottom: 14px;
}
body.chat-page .welcome-title-v2 {
  font-family: var(--ed-serif) !important;
  font-variation-settings: "opsz" 144 !important;
  font-weight: 500 !important;
  font-size: clamp(2rem, 4.5vw, 3.5rem) !important;
  line-height: 1.08 !important;
  letter-spacing: -0.015em !important;
  color: var(--ed-ink) !important;
  text-align: center !important;
  text-wrap: balance;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  margin-bottom: 16px !important;
}
body.chat-page .welcome-title-v2 em,
body.chat-page .welcome-title-v2 .accent {
  font-style: italic !important;
  font-weight: 400 !important;
  color: var(--ed-orange) !important;
}
body.chat-page .welcome-subtitle-v2 {
  font-size: 17px !important;
  line-height: 1.55 !important;
  color: var(--ed-ink-soft) !important;
  font-weight: 500 !important;
  text-align: center !important;
}

/* ---- Welcome cards (suggested prompts) --------------------- */
body.chat-page .welcome-card-v2 {
  background: var(--ed-paper-2) !important;
  border: 1px solid var(--ed-rule) !important;
  border-radius: 4px !important;
  box-shadow: none !important;
  position: relative;
}
body.chat-page .welcome-card-v2:hover {
  border-color: var(--ed-blue) !important;
  background: #ffffff !important;
  box-shadow: 0 10px 24px -16px rgba(11, 27, 43, 0.25) !important;
}
body.chat-page .welcome-card-v2::after {
  content: '';
  position: absolute;
  top: 12px;
  right: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ed-orange) !important;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.chat-page .welcome-card-v2:hover::after { opacity: 1; }

/* Neutralize the per-color gradient icons in the bundle so all cards
   share the editorial blue->orange hover vocabulary. */
body.chat-page .welcome-card-v2 .wc-icon,
body.chat-page .wc-blue .wc-icon,
body.chat-page .wc-teal .wc-icon,
body.chat-page .wc-amber .wc-icon,
body.chat-page .wc-green .wc-icon,
body.chat-page .wc-purple .wc-icon,
body.chat-page .wc-rose .wc-icon {
  background: rgba(26, 109, 181, 0.10) !important;
  color: var(--ed-blue) !important;
  border-radius: 50% !important;
  box-shadow: none !important;
}
body.chat-page .welcome-card-v2:hover .wc-icon {
  background: rgba(239, 123, 29, 0.12) !important;
  color: var(--ed-orange) !important;
}
body.chat-page .wc-label {
  font-weight: 700 !important;
  color: var(--ed-ink) !important;
}
body.chat-page .wc-desc {
  color: var(--ed-ink-soft) !important;
  font-weight: 500 !important;
}
body.chat-page .wc-arrow { color: var(--ed-ink-soft) !important; background: transparent !important; }
body.chat-page .welcome-card-v2:hover .wc-arrow { color: var(--ed-orange) !important; }

/* ---- Chat messages -----------------------------------------
   Bubble-less editorial layout: speaker labels (mono caps) above
   plain text on the cream page. No backgrounds, borders, or
   bubbles — the whole conversation reads like a transcript on
   paper. */
body.chat-page .message {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin-bottom: 28px !important;
}

/* User side — right-aligned, "YOU" label visible in brand-blue
   mono caps, content in ink */
body.chat-page .message.human,
body.chat-page .message.user {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
}
body.chat-page .message.human > strong:first-child,
body.chat-page .message.user > strong:first-child {
  display: block !important;
  font-family: var(--ed-mono) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-blue) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  text-align: right !important;
  margin-bottom: 6px !important;
  padding: 0 !important;
}
body.chat-page .message.human .message-content,
body.chat-page .message.user .message-content {
  background: transparent !important;
  color: var(--ed-ink) !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: 78% !important;
  text-align: right !important;
}
body.chat-page .message.human .message-content p,
body.chat-page .message.user .message-content p {
  color: var(--ed-ink) !important;
  font-weight: 500 !important;
}
body.chat-page .message.human .message-content a,
body.chat-page .message.user .message-content a {
  color: var(--ed-blue) !important;
  text-decoration: underline !important;
}

/* Assistant side — left-aligned, "LOANSPACE.AI" label in brand-
   orange mono caps, content in ink */
body.chat-page .message.assistant {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
}
body.chat-page .message.assistant > strong:first-child {
  font-family: var(--ed-mono) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-orange) !important;
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
  margin-bottom: 6px !important;
  padding: 0 !important;
}
body.chat-page .message.assistant .message-content {
  background: transparent !important;
  border: none !important;
  color: var(--ed-ink) !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  max-width: 100% !important;
}
body.chat-page .message-content p { color: inherit !important; }

/* Strip the soft-blue card outline + hover translate the bundle adds
   to every <li>. The numbered/bulleted marker (::before circle) is
   kept since it reads as editorial. */
body.chat-page .message-content ul li,
body.chat-page .message-content ol li {
  background: transparent !important;
  border: none !important;
  border-left: none !important;
  border-radius: 0 !important;
  padding: 4px 0 4px 36px !important;
  margin-bottom: 4px !important;
  box-shadow: none !important;
}
body.chat-page .message-content ul li:hover,
body.chat-page .message-content ol li:hover {
  background: transparent !important;
  transform: none !important;
  box-shadow: none !important;
}
/* Zero out the browser-default top margin on the first <p> inside an
   <li>, and bottom margin on the last <p>. Without this, the marker
   sits at the top of the row while the text starts 16-20px lower
   (because <p> has default ~1em margin-top). */
body.chat-page .message-content li > p:first-child { margin-top: 0 !important; }
body.chat-page .message-content li > p:last-child { margin-bottom: 0 !important; }
body.chat-page .message-content li > p { margin: 4px 0 !important; }

/* Reposition the marker circle now that the row has tight padding */
body.chat-page .message-content ol li::before,
body.chat-page .message-content ul li::before {
  left: 0 !important;
  top: 6px !important;
  background: var(--ed-blue) !important;
  box-shadow: none !important;
}

/* Tight list spacing — ol/ul themselves shouldn't add huge gaps */
body.chat-page .message-content ol,
body.chat-page .message-content ul {
  margin: 10px 0 !important;
  padding-left: 0 !important;
}

body.chat-page .message-content a {
  color: var(--ed-blue) !important;
  text-decoration: underline !important;
  text-decoration-color: var(--ed-blue) !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  font-weight: 600 !important;
}
body.chat-page .message-content a:hover { text-decoration-color: var(--ed-orange) !important; }

/* Thinking / typing indicator */
body.chat-page .thinking .spinner,
body.chat-page .spinner { border-top-color: var(--ed-blue) !important; }

/* ---- Input area --------------------------------------------
   Floating-button layout: upload/mic sit at the bottom-left and
   send sits at the bottom-right of the textarea. A gradient fade
   under the buttons lets long text dissolve into the paper rather
   than being clipped. */
body.chat-page .input-area {
  /* iMessage-style single-row composer. The textarea reads as one
     rounded pill; borderless icon buttons sit absolute on the left
     inside the pill, and a small circular send button sits absolute
     on the right. position: relative anchors all the absolute
     positioning to the input-area itself. */
  position: relative !important;
  background: var(--ed-paper) !important;
  border-top: 1px solid var(--ed-rule) !important;
  box-shadow: none !important;
  padding: 6px 10px !important;
}
body.chat-page #input,
body.chat-page #userInput,
body.chat-page .input-area textarea {
  position: relative;
  z-index: 0;
  background: #ffffff !important;
  border: 1px solid var(--ed-rule) !important;
  border-radius: 22px !important;
  color: var(--ed-ink) !important;
  font-family: 'DM Sans', sans-serif !important;
  font-size: 16px !important;
  line-height: 1.4 !important;
  /* Left padding clears the upload+mic icons; right padding clears
     the circular send button. Vertical padding gives one comfortable
     line of text. */
  padding: 12px 56px 12px 76px !important;
  min-height: 44px !important;
  box-shadow: none !important;
  resize: none !important;
}
body.chat-page #input::placeholder,
body.chat-page #userInput::placeholder,
body.chat-page .input-area textarea::placeholder { color: #94a3b8 !important; }
body.chat-page #input:focus,
body.chat-page #userInput:focus,
body.chat-page .input-area textarea:focus {
  outline: none !important;
  border-color: var(--ed-blue) !important;
  box-shadow: 0 0 0 3px rgba(26, 109, 181, 0.15) !important;
}

/* Button group sits absolute inside the input-area, anchored to
   both the left and right edges of the textarea pill. Upload + mic
   on the left (with breathing room between), send pushes right via
   margin-left:auto. Container is pointer-events:none so its empty
   middle doesn't block taps on the textarea; children re-enable
   pointer-events. */
body.chat-page .input-area .button-group {
  position: absolute !important;
  left: 18px;
  right: 14px;
  top: 50%;
  bottom: auto !important;
  transform: translateY(-50%);
  display: flex !important;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 2;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}
body.chat-page .input-area .button-group > * { pointer-events: auto; }
body.chat-page .input-area .button-group #sendButton { margin-left: auto !important; }

/* Borderless icon buttons — feel "integrated" with the textarea
   rather than perched on top. Hover gives a soft circular tint
   for affordance. min/max-width are explicit because mobile-fixes.css
   has `padding: 10px 13px !important` on #speechButton inside its
   own !important mobile media query, which would otherwise expand
   the button beyond 30x30. flex-shrink: 0 prevents the parent flex
   container (.button-group) from collapsing them. */
body.chat-page #uploadButton,
body.chat-page #speechButton {
  background: transparent !important;
  border: none !important;
  color: var(--ed-ink-soft) !important;
  border-radius: 999px !important;
  width: 30px !important;
  min-width: 30px !important;
  max-width: 30px !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: none !important;
  font-size: 14px !important;
  line-height: 1 !important;
}
body.chat-page #uploadButton i,
body.chat-page #speechButton i {
  font-size: 14px !important;
  line-height: 1 !important;
}
body.chat-page #uploadButton:hover,
body.chat-page #speechButton:hover {
  background: rgba(26, 109, 181, 0.08) !important;
  color: var(--ed-blue-deep) !important;
}

/* Circular send button — just an arrow, no "Ask" text. min/max
   dimensions are explicit so mobile-fixes.css `padding: 10px 18px
   !important` can't stretch it into a pill. */
body.chat-page #sendButton {
  background: var(--ed-orange) !important;
  color: #ffffff !important;
  border: 1px solid var(--ed-orange) !important;
  border-radius: 50% !important;
  font-weight: 700 !important;
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  font-size: 14px !important;
  line-height: 1 !important;
  gap: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 12px -4px rgba(239, 123, 29, 0.55) !important;
}
body.chat-page #sendButton i {
  font-size: 14px !important;
  line-height: 1 !important;
}
body.chat-page #sendButton:hover:not(:disabled) {
  background: var(--ed-orange-deep) !important;
  border-color: var(--ed-orange-deep) !important;
  box-shadow: 0 6px 14px -4px rgba(201, 95, 10, 0.6) !important;
}
body.chat-page #sendButton span { display: none !important; }
body.chat-page #sendButton:hover:not(:disabled) {
  background: var(--ed-orange-deep) !important;
  border-color: var(--ed-orange-deep) !important;
  box-shadow: 0 10px 22px -8px rgba(201, 95, 10, 0.55) !important;
}
body.chat-page #sendButton:disabled { opacity: 0.55 !important; box-shadow: none !important; }
body.chat-page #sendButton i { color: #ffffff !important; }

/* ---- Powered-by footer ------------------------------------- */
body.chat-page .powered-by {
  font-family: var(--ed-mono) !important;
  font-size: 9.5px !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--ed-ink-soft) !important;
  background: transparent !important;
  padding: 4px 0 6px !important;
  font-style: normal !important;
}

/* ---- Document status + question warning ------------------- */
body.chat-page .document-status {
  background: var(--ed-paper-2) !important;
  border: 1px solid var(--ed-rule) !important;
  color: var(--ed-ink) !important;
  border-radius: 4px !important;
  box-shadow: none !important;
}
body.chat-page .document-status .doc-icon { color: var(--ed-blue) !important; }
body.chat-page .clear-doc-btn { color: var(--ed-ink-soft) !important; }
body.chat-page .clear-doc-btn:hover { color: var(--ed-orange-deep) !important; }
body.chat-page .question-warning {
  background: rgba(239, 123, 29, 0.10) !important;
  border: 1px solid var(--ed-orange-soft) !important;
  color: var(--ed-orange-deep) !important;
  border-radius: 4px !important;
  /* Bundle rule defines only margin-bottom; add breathing room above
     so the banner doesn't sit flush under the sticky header. */
  margin-top: 16px !important;
}

/* ============================================================
   Dark mode
   ============================================================ */
[data-theme="dark"] body.chat-page {
  --ed-paper: #0b1220;
  --ed-paper-2: #0f1a2b;
  --ed-ink: #f5efe2;
  --ed-ink-soft: #cdd4e0;
  --ed-rule: rgba(126, 196, 245, 0.18);
  --ed-rule-strong: rgba(126, 196, 245, 0.32);
}
[data-theme="dark"] body.chat-page,
[data-theme="dark"] body.chat-page .chat-container,
[data-theme="dark"] body.chat-page .main-content,
[data-theme="dark"] body.chat-page #chatbox,
[data-theme="dark"] body.chat-page .chat-area,
[data-theme="dark"] body.chat-page .main-chat { background: #0b1220 !important; color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .sidebar { background: #0f1a2b !important; }
[data-theme="dark"] body.chat-page .sidebar-item,
[data-theme="dark"] body.chat-page .sidebar-item-link { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .sidebar-item:hover,
[data-theme="dark"] body.chat-page .sidebar-item-link:hover {
  background: rgba(74, 154, 212, 0.10) !important;
  color: #7ec4f5 !important;
}
[data-theme="dark"] body.chat-page .sidebar-icon { color: var(--ed-blue-soft) !important; }
[data-theme="dark"] body.chat-page .sidebar-item.active { background: #f5efe2 !important; color: #0b1220 !important; }
[data-theme="dark"] body.chat-page .sidebar-item.active .sidebar-icon,
[data-theme="dark"] body.chat-page .sidebar-item.active .sidebar-text { color: #0b1220 !important; }
[data-theme="dark"] body.chat-page .welcome-title-v2 { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .welcome-subtitle-v2 { color: #cdd4e0 !important; }
[data-theme="dark"] body.chat-page .welcome-card-v2 {
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(126, 196, 245, 0.18) !important;
}
[data-theme="dark"] body.chat-page .welcome-card-v2:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: var(--ed-blue-soft) !important;
}
[data-theme="dark"] body.chat-page .welcome-card-v2 .wc-icon,
[data-theme="dark"] body.chat-page .wc-blue .wc-icon,
[data-theme="dark"] body.chat-page .wc-teal .wc-icon,
[data-theme="dark"] body.chat-page .wc-amber .wc-icon,
[data-theme="dark"] body.chat-page .wc-green .wc-icon,
[data-theme="dark"] body.chat-page .wc-purple .wc-icon,
[data-theme="dark"] body.chat-page .wc-rose .wc-icon {
  background: rgba(74, 154, 212, 0.14) !important;
  color: var(--ed-blue-soft) !important;
}
[data-theme="dark"] body.chat-page .welcome-card-v2:hover .wc-icon {
  background: rgba(245, 160, 74, 0.16) !important;
  color: var(--ed-orange-soft) !important;
}
[data-theme="dark"] body.chat-page .wc-label { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .wc-desc { color: #cdd4e0 !important; }
[data-theme="dark"] body.chat-page .message.assistant .message-content {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(126, 196, 245, 0.18) !important;
  color: #f5efe2 !important;
}
[data-theme="dark"] body.chat-page .message.human .message-content,
[data-theme="dark"] body.chat-page .message.user .message-content {
  background: transparent !important;
  color: #f5efe2 !important;
}
[data-theme="dark"] body.chat-page .message.human .message-content p,
[data-theme="dark"] body.chat-page .message.user .message-content p { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .message.human > strong:first-child,
[data-theme="dark"] body.chat-page .message.user > strong:first-child { color: var(--ed-blue-soft) !important; }
[data-theme="dark"] body.chat-page .message.assistant > strong:first-child { color: var(--ed-orange-soft) !important; }
[data-theme="dark"] body.chat-page .message.assistant .message-content { color: #f5efe2 !important; }
[data-theme="dark"] body.chat-page .input-area {
  background: #0b1220 !important;
  border-top-color: rgba(126, 196, 245, 0.18) !important;
}
[data-theme="dark"] body.chat-page #input,
[data-theme="dark"] body.chat-page #userInput,
[data-theme="dark"] body.chat-page .input-area textarea {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(126, 196, 245, 0.20) !important;
  color: #f5efe2 !important;
}
/* Dark mode fade target matches the dark textarea fill so the
   gradient blends seamlessly. */
[data-theme="dark"] body.chat-page .input-area::after {
  background: linear-gradient(to bottom, rgba(15, 26, 43, 0), #0f1a2b 65%);
}
[data-theme="dark"] body.chat-page #uploadButton,
[data-theme="dark"] body.chat-page #speechButton {
  border-color: rgba(126, 196, 245, 0.25) !important;
  color: var(--ed-ink-soft) !important;
}
[data-theme="dark"] body.chat-page #uploadButton:hover,
[data-theme="dark"] body.chat-page #speechButton:hover {
  border-color: var(--ed-blue-soft) !important;
  color: var(--ed-blue-soft) !important;
  background: rgba(74, 154, 212, 0.10) !important;
}

/* ---- Tablet --------------------------------------------------
   iPad portrait + landscape (768-1199px) renders the mobile-header
   layout (no sidebar). Keeps the welcome cards in a single-column
   stack (matches mobile) but with a contained title size and
   slightly wider banner so the editorial feel is preserved on the
   bigger screen. */
@media (min-width: 768px) and (max-width: 1199px) {
  body.chat-page .welcome-banner-v2 {
    max-width: 720px !important;
  }
  body.chat-page .welcome-title-v2 {
    font-size: 2rem !important;       /* flat 32px, no vw scaling */
    line-height: 1.15 !important;
  }
  body.chat-page .welcome-subtitle-v2 {
    font-size: 15px !important;
  }
  body.chat-page .welcome-banner-v2::before {
    font-size: 11px !important;
  }
  /* Single-column stacked cards (default behavior — no grid override). */

  /* Bigger tap targets on iPad — the 30/36px sizes from the desktop
     base feel undersized at iPad's viewing distance. Bump upload/mic
     to 40 and send to 48 while keeping the same icon-only composition.
     Textarea side padding widens to clear the larger buttons. */
  body.chat-page #uploadButton,
  body.chat-page #speechButton {
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    font-size: 18px !important;
  }
  body.chat-page #uploadButton i,
  body.chat-page #speechButton i { font-size: 18px !important; }
  body.chat-page #sendButton {
    width: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    font-size: 18px !important;
  }
  body.chat-page #sendButton i { font-size: 18px !important; }
  body.chat-page #input,
  body.chat-page #userInput,
  body.chat-page .input-area textarea {
    /* Left padding clears the upload(40) + gap(6) + mic(40) + 18px
       left anchor + a comfortable 16px gap before placeholder text.
       The #input / #userInput selectors are required because the
       base rule on the same property uses #input (specificity 111)
       — a class-only selector would lose even with !important. */
    padding: 14px 70px 14px 120px !important;
    min-height: 52px !important;
    font-size: 17px !important;
  }
}

/* ---- Mobile -------------------------------------------------- */
@media (max-width: 767px) {
  body.chat-page .welcome-title-v2 { font-size: clamp(1.75rem, 8vw, 2.5rem) !important; }
  body.chat-page .welcome-subtitle-v2 { font-size: 16px !important; }
  body.chat-page .welcome-banner-v2::before { font-size: 11px !important; }

  /* Mobile keeps the iMessage-style inline composer — same layout
     as desktop, with three small tweaks for narrow viewports:
       1. .input-area horizontal padding drops 10 → 4 so the pill
          extends nearly to the screen edges (more room for both
          the placeholder text AND the buttons inside).
       2. Send button's `right` offset bumps 14 → 18 so it sits
          comfortably inside the pill border instead of brushing it.
       3. Textarea side padding adjusts to match the new button
          positions on the new wider pill. */
  body.chat-page .input-area {
    padding-left: 4px !important;
    padding-right: 4px !important;
  }
  body.chat-page #input,
  body.chat-page #userInput,
  body.chat-page .input-area textarea {
    padding: 12px 60px 12px 76px !important;
    min-height: 44px !important;
  }
  body.chat-page .input-area .button-group {
    left: 14px;
    right: 18px;
  }
}
