/* Chat-specific reading surfaces. Keep the dashboard's existing theme intact. */
.app.is-chat-page .main, .app.is-chat-page .chats-page { background: var(--surface); }
.app.is-chat-page .side { background: var(--surface-2); border-color: var(--hairline); backdrop-filter: none; }
.app.is-chat-page .topbar { background: var(--surface); backdrop-filter: none; border-color: var(--hairline); }
.chats-page { position: relative; justify-content: center; min-width: 0; }
.chat-context { display: flex; align-items: center; gap: 10px; padding: 12px 28px; color: var(--text-soft); font-size: 13px; flex-shrink: 0; }
.chat-context__brand { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-context__privacy { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.chats-page:not(.is-conversing) .chat-context { position: absolute; top: 0; }
.chatpg__body { flex: 0 1 auto; width: 100%; min-height: 0; padding: 32px 24px 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--hairline) transparent; overflow-anchor: none; }
.chats-page.is-conversing .chatpg__body { flex: 1 1 0; justify-content: flex-start; padding: 20px 28px 0; overflow-y: auto; }
.chatpg__greet { margin: 0 0 24px; }
.chatpg__greet-hi { font-size: 13px; color: var(--text-soft); }
.chatpg__greet-q { font-size: clamp(26px, 3vw, 32px); font-weight: 600; letter-spacing: -.035em; }
.chatpg__greet-sub { color: var(--text-soft); font-size: 14px; max-width: 450px; }
.chatpg__footer { flex: 0 0 auto; position: relative; width: 100%; padding: 0 28px max(16px, env(safe-area-inset-bottom)); background: var(--surface); }
.chats-page.is-conversing .chatpg__footer { padding-top: 12px; }
.chatpg__composer-wrap { margin: 0 auto; max-width: 740px; }
.chatpg__sugcards { gap: 8px; margin-bottom: 16px; }
.sugcard { background: var(--surface); border-radius: 10px; padding: 12px 14px; box-shadow: none; }
.sugcard:hover { background: var(--surface-2); box-shadow: none; }
.sugcard__s { color: var(--text-soft); font-size: 12px; }
.chats-page .c2 { border-radius: 20px; box-shadow: none; background: var(--surface-2); padding: 12px; border-color: var(--hairline); }
.chats-page .c2:focus-within { border-color: var(--text-muted); box-shadow: none; }
.chats-page .c2::after { display: none; }
.chats-page .c2__input { font-size: 16px; line-height: 1.5; min-height: 48px; max-height: 150px; }
.chats-page .c2__bar { gap: 6px; flex-wrap: nowrap; }
.chats-page .c2__btn { background: transparent; border-color: transparent; min-height: 36px; font-weight: 500; }
.chats-page .c2__btn:hover { background: var(--surface-3); }
.chats-page .c2__send { background: var(--text); color: var(--surface); width: 36px; height: 36px; box-shadow: none; }
.chats-page .c2__send:disabled { background: var(--surface-3); color: var(--text-muted); opacity: .65; cursor: default; transform: none; }
.chats-page .c2__send::after { display: none; }
.chat-keyboard-hint { font-size: 11px; line-height: 1.5; color: var(--text-muted); text-align: center; margin-top: 8px; }
.chatpg__feed { max-width: 740px; gap: 32px; padding: 0 0 20px; min-width: 0; }
.chatpg__feed .msg--bot { display: grid; grid-template-columns: 26px minmax(0, 1fr); column-gap: 12px; }
.chatpg__feed .msg__avatar { width: 26px; height: 26px; margin-top: 2px; background: var(--surface-2); }
.chatpg__feed .msg__avatar-ps { font-size: 10px; color: var(--accent-ink); }
.chatpg__feed .msg__avatar.is-thinking::before { display: none; }
.chatpg__feed .msg--bot .msg__body { font-size: 16px; line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.chatpg__feed .msg--bot .msg__body p { margin: 0 0 16px; }
.chatpg__feed .msg--bot .msg__body p:last-child { margin-bottom: 0; }
.chatpg__feed .msg--bot .msg__body li { font-size: inherit; }
.chatpg__feed .msg--bot .msg__body h1 { font-size: 24px; }
.chatpg__feed .msg--bot .msg__body h2 { font-size: 21px; }
.chatpg__feed .msg--bot .msg__body h3 { font-size: 18px; }
.chatpg__feed .msg--bot .msg__body :is(h1,h2,h3) { margin: 24px 0 12px; font-weight: 600; }
.chatpg__feed .msg--bot .msg__body > :first-child { margin-top: 0; }
.chatpg__feed .msg--user .msg__role { display: none; }
.chatpg__feed .msg--user .msg__body { font-size: 15px; line-height: 1.6; max-width: 85%; padding: 12px 18px; border-radius: 20px; background: var(--surface-2); border: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chatpg__feed .msg__actions { opacity: 1; margin-top: 12px; gap: 2px; }
.msg--user .msg__actions { display: flex; opacity: 1; margin-top: 4px; }
.msg__action-btn { min-width: 32px; min-height: 32px; border: 0; background: transparent; border-radius: 7px; }
.chats-page button:focus-visible, .msg__action-btn:focus-visible, .chat-block-btn:focus-visible, .chat-jump:focus-visible, .chat-context button:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 3px; }
.chatpg__feed .lr-receipt { border: 0; background: transparent; padding: 0; margin: 0 0 14px; font-size: 12px; color: var(--text-soft); }
.lr-receipt button { border: 0; background: transparent; color: var(--accent-ink); font: inherit; cursor: pointer; padding: 8px; margin-left: auto; white-space: nowrap; }
.chatpg__feed .lr-steps.lr-running::before { background: var(--hairline); animation: none; }
.chatpg__feed .lr-working::before { background: var(--accent-ink); }
.chat-jump { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); border: 1px solid var(--hairline); border-radius: 24px; padding: 9px 16px; font: inherit; font-size: 12px; background: var(--surface); color: var(--text); cursor: pointer; z-index: 2; }
.chat-jump[hidden] { display: none; }
.chat-review-note { display: flex; gap: 12px; align-items: center; justify-content: space-between; font-size: 12px; line-height: 1.5; color: var(--text-soft); background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.chat-review-note[hidden] { display: none; }
.chat-review-note button { background: none; border: 0; color: var(--text-soft); font: inherit; cursor: pointer; padding: 6px; }
.chat-error { padding: 14px 16px; margin-top: 14px; border: 1px solid var(--hairline); border-radius: 12px; background: var(--surface-2); font-size: 14px; line-height: 1.6; }
.chat-error strong { display: block; font-weight: 600; margin-bottom: 4px; }
.chat-error p { margin: 0 0 8px; }
.chat-block { margin: 16px 0; min-width: 0; max-width: 100%; border: 1px solid var(--hairline); border-radius: 12px; overflow: hidden; }
.chat-block-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--surface-2); font-size: 12px; color: var(--text-soft); }
.chat-block-bar span:first-child { margin-right: auto; }
.chat-block-btn { border: 0; border-radius: 6px; padding: 6px 8px; background: transparent; color: var(--text-soft); font: inherit; font-size: 12px; cursor: pointer; }
.chat-block-btn:hover { color: var(--text); background: var(--surface-3); }
.chat-table-scroll { overflow-x: auto; max-width: 100%; }
.msg--bot .msg__body .chat-block table { width: 100%; margin: 0; font-size: 14px; border: 0; }
.msg--bot .msg__body .chat-block :is(td,th) { padding: 10px 14px; border: 0; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
.msg--bot .msg__body .chat-block tr:last-child td { border-bottom: 0; }
.msg--bot .msg__body .chat-block th { font-weight: 600; background: var(--surface); }
.msg--bot .msg__body .chat-block pre { margin: 0; padding: 16px; border: 0; border-radius: 0; font-size: 13px; }
.msg--bot .msg__body .chat-block pre code { font-size: 13px; line-height: 1.6; }
.chat-sent-files { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; max-width: 85%; }
.chat-sent-file { border: 1px solid var(--hairline); border-radius: 10px; padding: 6px 10px; font-size: 12px; color: var(--text-soft); overflow-wrap: anywhere; }
.chat-live-status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .app-shell:has(.app.is-chat-page) { height: var(--chat-viewport-height, 100dvh); }
  .app.is-chat-page { height: auto; }
  .chat-context { padding: 10px 16px; font-size: 12px; }
  .chat-context__privacy { font-size: 11px; }
  .chatpg__body { padding: 24px 16px 0; }
  .chats-page.is-conversing .chatpg__body { padding: 16px 16px 0; }
  .chatpg__footer { padding: 0 12px max(10px, env(safe-area-inset-bottom)); }
  .chatpg__greet-q { font-size: 26px; }
  .chatpg__greet-sub { font-size: 13px; }
  .chatpg__sugcards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .sugcard { padding: 10px; }
  .sugcard__t { font-size: 12px; }
  .sugcard__s { display: none; }
  .chatpg__feed { gap: 28px; }
  .chatpg__feed .msg--bot { grid-template-columns: minmax(0, 1fr); }
  .chatpg__feed .msg__avatar { display: none; }
  .chatpg__feed .msg--user .msg__body { max-width: 92%; }
  .chatpg__feed .msg--bot .msg__body { font-size: 16px; }
  .chat-keyboard-hint { display: none; }
  .chats-page .c2__btn { min-height: 40px; padding: 6px 8px; }
  .chats-page .c2__plus, .chats-page .c2__send { width: 40px; height: 40px; }
  .msg__action-btn { min-width: 40px; min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  .chats-page *, .chats-page *::before, .chats-page *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* The expanded model catalog remains usable in short/mobile viewports. */
.model-pop {
  max-height: min(420px, calc(100dvh - 16px));
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Keep the answer, its controls and its receipt in one reading column. */
.chatpg__feed .msg--bot > :not(.msg__avatar) { grid-column: 2; min-width: 0; }
.chatpg__feed .msg__used { color: var(--text-soft); margin-top: 6px; font-size: 12px; }
.chatpg__feed .msg__actions { color: var(--text-soft); }
.chats-page .c2 { background: var(--surface); border-color: var(--hairline); box-shadow: 0 2px 12px rgba(0,0,0,.04); }
.chats-page .c2:focus-within { border-color: var(--accent-ink); }
.chats-page .c2__input::placeholder { color: var(--text-soft); }
.chat-context { border-bottom: 1px solid var(--hairline); }
@media (max-width: 640px) {
  .chatpg__feed .msg--bot > :not(.msg__avatar) { grid-column: 1; }
}
