.chat-page {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.chat-page .nav {
  pointer-events: none;
}

.chat-page .nav-shell,
.chat-page .nav-shell * {
  pointer-events: auto;
}

.chat-main {
  width: min(1540px, calc(100% - 36px));
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 106px 0 16px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  position: relative;
  z-index: 2;
  overflow: hidden;
}

/* Compact context strip: the product is the workspace, not a second hero. */
.chat-intro {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  padding: 0 4px;
}

.chat-intro > div {
  min-width: 0;
}

.chat-intro .eyebrow {
  display: block;
  margin-bottom: 7px;
}

.chat-intro h1 {
  margin: 0;
  font-size: clamp(26px, 2.6vw, 42px);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.chat-intro h1 em {
  color: var(--acid);
  font-style: normal;
}

.chat-intro p {
  width: min(430px, 38vw);
  margin: 0;
  color: #858e98;
  font-size: 11px;
  line-height: 1.55;
  text-align: right;
}

/* The shell owns all remaining viewport height. No page-level chat scrolling. */
.chat-shell {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  border: 1px solid rgba(67, 232, 255, 0.2);
  background:
    radial-gradient(circle at 76% 12%, rgba(67, 232, 255, 0.05), transparent 34%),
    linear-gradient(135deg, rgba(11, 14, 18, 0.96), rgba(6, 8, 10, 0.97));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42);
  overflow: hidden;
  position: relative;
}

.chat-shell:before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.009) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.009) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.58), transparent 68%);
}

.expert-rail,
.chat-console {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
}

/* Expert switcher */
.expert-rail {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(3, 5, 7, 0.72);
  padding: 12px 10px 10px;
  overflow: hidden;
}

.rail-head {
  flex: 0 0 38px;
  padding: 0 7px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.12em;
  color: #707985;
}

.rail-head i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #62ff9b;
  box-shadow: 0 0 8px rgba(98, 255, 155, 0.75);
}

.rail-head em {
  margin-left: auto;
  color: #62d98b;
  font-style: normal;
}

.expert-picker {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 9px 2px 2px 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #252d35 transparent;
  overscroll-behavior: contain;
}

.expert-picker::-webkit-scrollbar {
  width: 4px;
}

.expert-picker::-webkit-scrollbar-track {
  background: transparent;
}

.expert-picker::-webkit-scrollbar-thumb {
  background: #252d35;
  border-radius: 8px;
}

.expert-picker button {
  width: 100%;
  min-height: 51px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: 18px 16px;
  column-gap: 9px;
  align-items: center;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: #9aa3ad;
  padding: 7px 8px;
  cursor: pointer;
  transition: 0.18s ease;
}

.expert-picker button > span {
  grid-row: 1 / 3;
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(67, 232, 255, 0.2);
  border-radius: 50%;
  color: #64cddd;
  font: 9px "DM Mono", monospace;
}

.expert-picker button b {
  align-self: end;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.expert-picker button small {
  align-self: start;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #5e6873;
  font: 9px "DM Mono", monospace;
}

.expert-picker button:hover {
  border-color: rgba(67, 232, 255, 0.14);
  background: rgba(67, 232, 255, 0.025);
  color: #d2d8de;
}

.expert-picker button.active {
  border-color: rgba(98, 255, 155, 0.26);
  background: linear-gradient(90deg, rgba(98, 255, 155, 0.09), rgba(98, 255, 155, 0.015));
  color: #ebfff1;
}

.expert-picker button.active > span {
  border-color: rgba(98, 255, 155, 0.44);
  color: #9fffc0;
  background: rgba(98, 255, 155, 0.035);
}

/* Conversation workspace */
.chat-console {
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-console-head {
  min-height: 69px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  background: rgba(7, 9, 11, 0.72);
}

.active-expert {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.active-expert > span {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 1px solid rgba(67, 232, 255, 0.3);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 9px "DM Mono", monospace;
  color: var(--cyan);
  background: radial-gradient(circle, rgba(67, 232, 255, 0.08), transparent 70%);
}

.active-expert small {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #69737d;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.11em;
}

.active-expert small i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #62ff9b;
  box-shadow: 0 0 6px rgba(98, 255, 155, 0.75);
}

.active-expert h2 {
  margin: 3px 0 1px;
  font-size: 17px;
  line-height: 1;
}

.active-expert p {
  margin: 0;
  color: #a9b0b7;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.035em;
}

.chat-head-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.daily-cap {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.012);
  color: #727c86;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.1em;
}

.chat-actions-wrap {
  position: relative;
}

.chat-actions-toggle {
  width: 32px;
  height: 29px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: transparent;
  color: #69747e;
  padding: 0;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.chat-actions-toggle:hover,
.chat-actions-toggle[aria-expanded="true"] {
  border-color: rgba(67, 232, 255, 0.3);
  color: var(--cyan);
}

.chat-actions-menu {
  position: absolute;
  z-index: 12;
  top: calc(100% + 7px);
  right: 0;
  width: 178px;
  padding: 6px;
  border: 1px solid rgba(67, 232, 255, 0.16);
  background: #090c0f;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.5);
}

.chat-actions-menu[hidden] {
  display: none;
}

.chat-actions-menu button {
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: #89939c;
  text-align: left;
  padding: 0 10px;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.chat-actions-menu button:hover:not(:disabled) {
  background: rgba(255, 184, 0, 0.055);
  color: var(--acid);
}

.chat-actions-menu .danger-action {
  color: #d99a9a;
  border-top: 1px solid rgba(255, 107, 107, 0.1);
}

.chat-actions-menu .danger-action:hover:not(:disabled) {
  color: #ffabab;
  background: rgba(255, 87, 87, 0.07);
}

.chat-actions-menu button:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Client chats read as tabs, not cards. */
.conversation-bar {
  min-height: 43px;
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px 10px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(4, 6, 8, 0.9);
}

.conversation-tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.conversation-tabs::-webkit-scrollbar {
  display: none;
}

.conversation-tab {
  flex: 0 1 164px;
  min-width: 104px;
  max-width: 184px;
  min-height: 37px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 25px;
  align-items: stretch;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  background: transparent;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.conversation-tab:hover {
  background: rgba(255, 255, 255, 0.02);
}

.conversation-tab.active {
  border-color: rgba(67, 232, 255, 0.18);
  background: rgba(14, 18, 22, 0.94);
  box-shadow: inset 0 2px 0 rgba(67, 232, 255, 0.7);
}

.conversation-tab.pending {
  box-shadow: inset 0 2px 0 rgba(255, 184, 0, 0.65);
}

.conversation-select,
.conversation-close,
.new-chat {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.conversation-select {
  min-width: 0;
  padding: 0 5px 0 9px;
  color: #838d97;
  text-align: left;
}

.conversation-select span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font: 10px/1.2 "DM Mono", monospace;
}

.conversation-select small {
  display: none;
}

.conversation-tab.active .conversation-select span {
  color: #dce4e9;
}

.conversation-tab.pending .conversation-select span:after {
  content: " ···";
  color: var(--acid);
}

.conversation-close {
  width: 25px;
  color: #515c66;
  font: 14px/1 "DM Mono", monospace;
}

.conversation-close:hover:not(:disabled) {
  color: #ff9797;
  background: rgba(255, 105, 105, 0.035);
}

.conversation-close:disabled {
  opacity: 0.22;
  cursor: wait;
}

.new-chat {
  flex: 0 0 auto;
  align-self: center;
  height: 29px;
  margin: 0 2px 5px 5px;
  padding: 0 9px;
  border: 1px solid rgba(98, 255, 155, 0.16);
  border-radius: 2px;
  color: #79ca95;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.new-chat span {
  margin-right: 3px;
  color: #62ff9b;
  font-size: 11px;
}

.new-chat:hover {
  border-color: rgba(98, 255, 155, 0.38);
  background: rgba(98, 255, 155, 0.035);
  color: #aef2c5;
}

/* This is the only main vertical scroll region in the conversation workspace. */
.chat-messages {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #293139 transparent;
  padding: 22px clamp(18px, 3.5vw, 48px) 26px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #293139;
  border-radius: 8px;
}

.chat-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px 16px;
}

.chat-empty .empty-core {
  max-width: 520px;
}

.chat-empty .empty-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 17px;
  border: 1px solid rgba(67, 232, 255, 0.28);
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--cyan);
  font: 14px "DM Mono", monospace;
  box-shadow: inset 0 0 28px rgba(67, 232, 255, 0.045);
}

.chat-empty small {
  color: #65707a;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.13em;
}

.chat-empty h3 {
  margin: 8px 0 9px;
  font-size: clamp(20px, 2vw, 28px);
}

.chat-empty p {
  margin: 0;
  color: #8e98a2;
  font-size: 11px;
  line-height: 1.65;
}

.chat-empty .starter-prompts {
  margin-top: 17px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.starter-prompts button {
  border: 1px solid rgba(255, 255, 255, 0.075);
  background: rgba(255, 255, 255, 0.014);
  color: #808a94;
  padding: 8px 10px;
  font: 10px "DM Mono", monospace;
  cursor: pointer;
}

.starter-prompts button:hover {
  border-color: rgba(67, 232, 255, 0.3);
  color: var(--cyan);
}

.chat-message {
  display: flex;
  gap: 9px;
  margin: 0 auto 18px;
  width: min(100%, 960px);
}

.chat-message.user {
  justify-content: flex-end;
}

.message-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(67, 232, 255, 0.24);
  color: var(--cyan);
  font: 9px "DM Mono", monospace;
}

.message-body {
  max-width: min(820px, 84%);
}

.message-meta {
  margin-bottom: 5px;
  color: #5f6974;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.chat-message.user .message-meta {
  text-align: right;
}

.message-card {
  padding: 12px 14px;
  border: 1px solid rgba(67, 232, 255, 0.11);
  border-radius: 3px;
  background: rgba(14, 18, 22, 0.8);
  color: #d4dae0;
  font-size: 12px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.chat-message.user .message-card {
  border-color: rgba(255, 184, 0, 0.2);
  background: rgba(255, 184, 0, 0.055);
  color: #e1e3df;
  white-space: pre-wrap;
}

.message-card strong {
  color: #f3f6f7;
  font-weight: 650;
}

.message-card .ai-heading {
  display: block;
  margin: 12px 0 4px;
  color: var(--acid);
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.07em;
}

.message-card .ai-heading:first-child {
  margin-top: 0;
}

.message-card .ai-bullet {
  display: block;
  padding-left: 3px;
}

.message-tools {
  margin-top: 6px;
}

.copy-message {
  border: 0;
  background: transparent;
  color: #65717b;
  padding: 0;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.07em;
  cursor: pointer;
}

.copy-message:hover {
  color: var(--cyan);
}

.chat-message.error .message-card {
  border-color: rgba(255, 102, 102, 0.3);
  color: #ffb2b2;
  background: rgba(255, 70, 70, 0.045);
}

.thinking-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  height: 17px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  opacity: 0.25;
  animation: chatPulse 1s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatPulse {
  50% { opacity: 1; transform: translateY(-2px); }
}

/* Composer stays visible while the history scrolls above it. */
.chat-composer {
  min-width: 0;
  padding: 11px 18px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(5, 7, 9, 0.97);
}

.chat-composer > label {
  display: block;
  margin-bottom: 6px;
  color: #68727c;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.11em;
}

.composer-box {
  min-height: 50px;
  display: flex;
  align-items: end;
  gap: 9px;
  border: 1px solid rgba(67, 232, 255, 0.18);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.014);
  padding: 6px 7px 6px 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.composer-box:focus-within {
  border-color: rgba(67, 232, 255, 0.44);
  box-shadow: inset 0 0 28px rgba(67, 232, 255, 0.022);
}

.composer-box textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  max-height: 132px;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: #e1e4e6;
  font: 12px/1.5 Inter, Arial, sans-serif;
  padding: 7px 0 5px;
}

.composer-box textarea::placeholder {
  color: #5d6670;
}

.send-chat {
  height: 37px;
  min-width: 82px;
  border: 1px solid var(--acid);
  border-radius: 2px;
  background: var(--acid);
  color: #080808;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
}

.send-chat:disabled {
  cursor: wait;
  opacity: 0.55;
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 6px;
  color: #57616b;
  font: 9px "DM Mono", monospace;
  letter-spacing: 0.035em;
}

#quotaStatus.limit-hit {
  color: #ff9b9b;
}

/* Readability pass for the dense conversation workspace. */
.chat-intro p {
  color: #b5bec8;
  font-size: 13px;
}

.rail-head,
.active-expert small,
.daily-cap,
.chat-actions-menu button,
.conversation-select span,
.new-chat,
.chat-empty small,
.message-meta,
.message-card .ai-heading,
.copy-message,
.chat-composer > label,
.composer-meta,
.send-chat {
  font-size: 11px;
}

.rail-head,
.active-expert small,
.daily-cap,
.conversation-select,
.chat-empty small,
.message-meta,
.copy-message,
.chat-composer > label,
.composer-meta {
  color: #aab4be;
}

.expert-picker button {
  color: #b7c0c9;
}

.expert-picker button > span,
.expert-picker button small {
  font-size: 11px;
}

.expert-picker button small {
  color: #9faab5;
}

.expert-picker button b,
.active-expert p {
  font-size: 12px;
}

.active-expert p {
  color: #c1c8cf;
}

.chat-empty p,
.starter-prompts button {
  font-size: 12px;
  color: #aeb7c1;
}

.message-avatar {
  font-size: 11px;
}

.message-card {
  color: #e0e5e9;
  font-size: 14px;
  line-height: 1.68;
}

.composer-box textarea {
  color: #f0f2f4;
  font-size: 14px;
}

.composer-box textarea::placeholder {
  color: #99a4ae;
}

@media (max-width: 650px) {
  .rail-head,
  .active-expert small,
  .daily-cap,
  .chat-actions-menu button,
  .conversation-select span,
  .new-chat,
  .chat-empty small,
  .message-meta,
  .message-card .ai-heading,
  .copy-message,
  .chat-composer > label,
  .composer-meta,
  .send-chat {
    font-size: 10px;
  }

  .message-card,
  .composer-box textarea {
    font-size: 14px;
  }
}

/* Deliberate destructive-action confirmation. */
.chat-confirm-dialog {
  width: min(440px, calc(100% - 28px));
  max-width: 440px;
  border: 1px solid rgba(67, 232, 255, 0.2);
  background: #080b0e;
  color: #d9dfe4;
  padding: 0;
  overflow: visible;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.68);
}

.chat-confirm-dialog .dialog-cursor-orb,
.chat-confirm-dialog .dialog-cursor-dot {
  position: fixed;
  pointer-events: none;
  z-index: 2147483647 !important;
}

.chat-confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(3px);
}

.chat-confirm-card { padding: 26px; }
.chat-confirm-card h3 { margin: 12px 0 8px; font-size: 22px; }
.chat-confirm-card p { margin: 0; color: #8e98a2; font-size: 12px; line-height: 1.65; }

.chat-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}

.chat-confirm-actions button {
  min-height: 38px;
  padding: 0 14px;
  font: 10px "DM Mono", monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.confirm-cancel { border: 1px solid var(--line); background: transparent; color: #88929c; }
.confirm-action { border: 1px solid rgba(255, 107, 107, 0.42); background: rgba(255, 87, 87, 0.08); color: #ffabab; }

/* Tablet: experts become a compact horizontal switcher. */
@media (max-width: 900px) {
  .chat-main {
    width: min(calc(100% - 20px), 880px);
    padding-top: 96px;
    padding-bottom: 10px;
    gap: 9px;
  }

  .chat-intro {
    min-height: 54px;
    gap: 20px;
  }

  .chat-intro h1 {
    font-size: clamp(24px, 5vw, 34px);
  }

  .chat-intro p {
    width: min(360px, 45vw);
    font-size: 10px;
  }

  .chat-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 63px minmax(0, 1fr);
  }

  .expert-rail {
    display: block;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    padding: 7px 9px;
    overflow: hidden;
  }

  .rail-head { display: none; }

  .expert-picker {
    height: 49px;
    display: flex;
    gap: 4px;
    padding: 0 0 3px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .expert-picker::-webkit-scrollbar { display: none; }

  .expert-picker button {
    flex: 0 0 132px;
    min-height: 46px;
  }
}

/* Small screens keep the same mental model but spend pixels on conversation. */
@media (max-width: 640px) {
  .chat-page .nav { padding: 7px; }

  .chat-main {
    width: calc(100% - 12px);
    padding-top: 76px;
    padding-bottom: 6px;
    gap: 6px;
  }

  .chat-intro {
    min-height: 47px;
    padding: 0 2px;
  }

  .chat-intro .eyebrow { display: none; }

  .chat-intro h1 {
    font-size: clamp(22px, 8vw, 28px);
  }

  .chat-intro p { display: none; }

  .chat-shell {
    grid-template-rows: 55px minmax(0, 1fr);
  }

  .expert-rail { padding: 5px 7px; }

  .expert-picker { height: 44px; }

  .expert-picker button {
    flex-basis: 112px;
    min-height: 42px;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: 28px;
    column-gap: 7px;
    padding: 5px 7px;
  }

  .expert-picker button > span {
    grid-row: 1;
    width: 27px;
    height: 27px;
  }

  .expert-picker button b { align-self: center; }
  .expert-picker button small { display: none; }

  .chat-console-head {
    min-height: 58px;
    padding: 8px 10px;
  }

  .active-expert { gap: 8px; }

  .active-expert > span {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    font-size: 8px;
  }

  .active-expert small { display: none; }
  .active-expert h2 { margin-top: 0; font-size: 15px; }
  .active-expert p { margin-top: 3px; font-size: 9px; }
  .daily-cap { display: none; }

  .conversation-bar {
    min-height: 40px;
    padding: 5px 6px 0 7px;
  }

  .conversation-tab {
    flex-basis: 120px;
    min-width: 92px;
    min-height: 35px;
  }

  .new-chat {
    width: 34px;
    height: 28px;
    margin-left: 3px;
    padding: 0;
    font-size: 0;
  }

  .new-chat span {
    margin: 0;
    font-size: 14px;
  }

  .chat-messages {
    padding: 15px 8px 18px;
    scrollbar-gutter: auto;
  }

  .chat-empty { padding: 18px 10px; }
  .chat-empty .empty-mark { width: 48px; height: 48px; margin-bottom: 12px; }
  .chat-empty h3 { font-size: 19px; }
  .chat-empty p { font-size: 10px; }
  .starter-prompts button { padding: 7px 8px; }

  .chat-message { margin-bottom: 14px; gap: 6px; }
  .message-avatar { width: 24px; height: 24px; flex-basis: 24px; font-size: 8px; }
  .message-body { max-width: 91%; }
  .message-card { padding: 10px 11px; font-size: 11px; line-height: 1.6; }

  .chat-composer { padding: 8px; }
  .chat-composer > label { display: none; }

  .composer-box {
    min-height: 45px;
    gap: 6px;
    padding: 5px 5px 5px 9px;
  }

  .composer-box textarea {
    min-height: 33px;
    max-height: 100px;
    font-size: 11px;
  }

  .send-chat {
    width: 40px;
    min-width: 40px;
    height: 34px;
    padding: 0;
  }

  .send-chat span { display: none; }

  .composer-meta {
    display: block;
    margin-top: 5px;
  }

  .composer-meta span:first-child { display: none; }
  #quotaStatus { display: block; text-align: right; }
}

/* Short laptops get an even tighter chrome without reducing message scroll area. */
@media (max-height: 760px) and (min-width: 641px) {
  .chat-main {
    padding-top: 91px;
    padding-bottom: 9px;
    gap: 7px;
  }

  .chat-intro { min-height: 42px; }
  .chat-intro .eyebrow { display: none; }
  .chat-intro h1 { font-size: 25px; }
  .chat-intro p { font-size: 9px; line-height: 1.35; }

  .chat-console-head { min-height: 60px; padding-top: 7px; padding-bottom: 7px; }
  .active-expert > span { width: 34px; height: 34px; flex-basis: 34px; }
  .active-expert small { display: none; }

  .conversation-bar { min-height: 39px; }
  .conversation-tab { min-height: 33px; }

  .chat-composer { padding-top: 8px; padding-bottom: 8px; }
  .chat-composer > label { display: none; }
  .composer-meta { margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-messages { scroll-behavior: auto; }
  .thinking-dots i { animation: none; opacity: 0.65; }
}

/* Readability pass: preserve the compact workspace while lifting the labels
   that tested too small on a 1363x936 desktop viewport. */
@media (min-width: 641px) {
  .chat-intro p { font-size: 12px; }
  .rail-head { font-size: 10px; }
  .expert-picker button > span { font-size: 10px; }
  .expert-picker button b { font-size: 11px; }
  .expert-picker button small { font-size: 10px; }
  .active-expert small { font-size: 10px; }
  .active-expert p { font-size: 11px; }
  .daily-cap { font-size: 10px; }
  .conversation-select { font-size: 11px; }
  .message-meta { font-size: 10px; }
  .message-card { font-size: 13px; }
  .chat-composer > label { font-size: 10px; }
  .composer-box textarea { font-size: 13px; }
  .composer-meta { font-size: 10px; }
}

@media (max-width: 640px) {
  .active-expert p { font-size: 10px; }
  .chat-empty p { font-size: 11px; }
  .message-card { font-size: 12px; }
  .composer-box textarea { font-size: 13px; }
}

@media (max-height: 760px) and (min-width: 641px) {
  .chat-intro p { font-size: 10px; }
}

/* Final cascade guard: these values intentionally come last so compact
   breakpoint rules never make functional chat text hard to read. */
@media (min-width: 641px) {
  .chat-intro p { font-size: 13px; color: #b5bec8; }
  .rail-head,
  .expert-picker button > span,
  .expert-picker button small,
  .active-expert small,
  .daily-cap,
  .message-meta,
  .chat-composer > label,
  .composer-meta { font-size: 11px; color: #aab4be; }
  .expert-picker button b,
  .active-expert > span,
  .active-expert p,
  .conversation-select span,
  .new-chat,
  .starter-prompts button,
  .copy-message,
  .send-chat { font-size: 12px; }
  .expert-picker button small { color: #9faab5; }
  .active-expert p { color: #c1c8cf; }
  .chat-empty p { font-size: 13px; color: #aeb7c1; }
  .message-avatar { font-size: 11px; }
  .message-card { font-size: 14px; color: #e0e5e9; }
  .composer-box textarea { font-size: 14px; color: #f0f2f4; }
  .composer-box textarea::placeholder { color: #99a4ae; }
}

@media (max-width: 640px) {
  .active-expert p { font-size: 11px; color: #c1c8cf; }
  .chat-empty p { font-size: 12px; color: #aeb7c1; }
  .message-card { font-size: 14px; color: #e0e5e9; }
  .composer-box textarea { font-size: 14px; color: #f0f2f4; }
  .composer-box textarea::placeholder { color: #99a4ae; }
  #quotaStatus { font-size: 10px; color: #aab4be; }
}
