/* Scoped to the public chat: the owner cabinet keeps its existing layout. */
.chat-page {
  overflow-anchor: none;
}
.chat-page .shell {
  max-width: 1024px;
}
.chat-page header {
  padding: 18px 0;
}
.chat-page #chat-main {
  max-width: 760px;
  padding: 18px 0 20px;
}
.chat-page #intro .eyebrow {
  font-size: 12px;
}
.chat-page #intro {
  padding: 6px 0;
}
.chat-page #intro h1 {
  font-size: clamp(26px, 3.4vw, 34px);
  line-height: 1.15;
  margin: 4px 0 8px;
}
.chat-page #intro p {
  font-size: 14px;
  line-height: 1.45;
  margin: 0 0 8px;
}
.chat-page .question-examples {
  margin: 8px 0 14px;
}
.chat-page .question-examples button {
  padding: 7px 11px;
}
.chat-page #mode {
  margin: 0 0 12px;
}

#chat-card {
  --chat-card-height: clamp(320px, 65dvh, 640px);
  display: flex;
  flex-direction: column;
  position: relative;
  height: var(--chat-card-height);
  min-width: 0;
  width: 100%;
  border: 1px solid #ccd8e4;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 8px 32px #1736520b;
}
#chat-history {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  overflow-anchor: none;
  scroll-behavior: auto;
  scrollbar-width: thin;
  scrollbar-color: #9cabb9 #f1f5f9;
  border-radius: 19px 19px 0 0;
  padding: 20px;
  background: #f8fafc;
}
#chat-history::-webkit-scrollbar {
  width: 7px;
}
#chat-history::-webkit-scrollbar-track {
  background: #f1f5f9;
}
#chat-history::-webkit-scrollbar-thumb {
  background: #9cabb9;
  border: 2px solid #f1f5f9;
  border-radius: 8px;
}
#chat-history:focus-visible {
  outline: 2px solid #5688ba;
  outline-offset: -3px;
}
#chat-history .messages {
  gap: 14px;
}
#chat-history .message {
  padding: 15px 17px;
  font-size: 15px;
  line-height: 1.65;
  border-radius: 14px;
}
#chat-history .message.user {
  max-width: 88%;
}
#chat-history .message-label {
  font-size: 11px;
  margin-bottom: 6px;
}
#chat-history .message-content {
  min-width: 0;
  overflow-wrap: anywhere;
}
#history-jump {
  position: relative;
  flex: 0 0 0;
  z-index: 3;
}
#chat-card #latest-answer {
  position: absolute;
  inset: auto 14px 12px auto;
  transform: none;
  max-width: calc(100% - 28px);
  border-radius: 22px;
  min-height: 44px;
  font-size: 13px;
  padding: 9px 14px;
  background: #fff;
  border-color: #c4d2de;
  box-shadow: 0 3px 14px #1736521a;
}
#chat-card #composer-dock {
  display: flex;
  flex-direction: column;
  position: relative;
  inset: auto;
  z-index: auto;
  flex: 0 0 auto;
  min-height: 0;
  max-height: calc(var(--chat-card-height) - 40px);
  min-width: 0;
  background: #fff;
  padding: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 19px 19px;
  box-shadow: none;
}
#chat-card #composer-context {
  flex: 0 1 auto;
  min-height: 0;
  max-height: min(120px, calc(var(--chat-card-height) * 0.25));
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
#chat-card #composer-context #files,
#chat-card #composer-context #error,
#chat-card #composer-context #recording,
#chat-card #composer-context #voice-retry {
  max-height: none;
  overflow: visible;
}
#chat-card [hidden] {
  display: none;
}
#chat-card #composer {
  flex: 0 0 auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  overflow: visible;
}
#chat-card #composer:focus-within {
  outline: 0;
}
#chat-card #question {
  display: block;
  min-height: 60px;
  height: 60px;
  max-height: var(--question-max-height, 112px);
  padding: 14px 17px 8px;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
  font-size: 16px;
}
#chat-card #question:focus-visible {
  box-shadow: inset 3px 0 #5688ba;
}
#chat-card .composer-bottom {
  padding: 0 12px 10px;
  gap: 8px;
  flex-wrap: wrap;
}
#chat-card .composer-bottom .tool {
  min-height: 44px;
  min-width: 44px;
  font-size: 13px;
}
#chat-card #send {
  min-height: 44px;
  padding: 9px 14px;
  font-size: 14px;
  margin-left: auto;
}
#chat-card #stop {
  min-height: 44px;
  font-size: 13px;
  padding: 8px 10px;
}
#chat-card #conversation-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 14px;
  min-width: 0;
  padding: 7px 14px;
  border-top: 1px solid #dce5ee;
  border-radius: 0 0 19px 19px;
  background: #eef3f8;
}
#chat-card #consent-panel {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  flex: 0 1 auto;
  min-width: min(260px, 100%);
  gap: 0 4px;
  margin: 0;
  color: #405569;
}
#chat-card #consent-panel input {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin: 0 4px 0 0;
}
#chat-card #consent-panel label {
  min-height: 44px;
  margin: 0;
  line-height: 1.4;
  font-size: 12px;
  font-weight: 400;
}
#chat-card .terms-link {
  min-height: 44px;
  font-size: 12px;
  line-height: 1.4;
  padding: 0 1px;
}
#chat-card .terms-compact {
  display: none;
}
#conversation-credit {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  margin: 0;
}
#conversation-credit .conversation-credit {
  min-width: 0;
  gap: 7px;
}
#conversation-credit .conversation-credit > span:not(.credit-ring) {
  max-width: 93px;
  font-size: 11px;
  line-height: 1.35;
}
#conversation-credit .credit-ring {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  font-size: 11px;
}
#conversation-credit .credit-help summary {
  width: 40px;
  min-width: 40px;
  height: 44px;
  min-height: 44px;
}
#conversation-credit .credit-refill {
  min-height: 44px;
  font-size: 12px;
  padding: 8px 11px;
  background: #fff;
  border-color: #bccbd9;
}
#conversation-credit .credit-refill:hover {
  background: #e2ebf4;
}
#conversation-credit .paid-credit {
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.4;
}
#conversation-credit > p,
#conversation-credit > button:not(.credit-refill) {
  font-size: 12px;
  overflow-wrap: anywhere;
}
#conversation-credit > button:not(.credit-refill) {
  min-height: 44px;
  padding: 7px 10px;
}
#chat-card .credit-help-content {
  width: min(290px, calc(100vw - 44px));
  max-height: min(280px, 55dvh);
  overflow-y: auto;
}
#chat-card #files {
  max-height: 100px;
  overflow-y: auto;
  overscroll-behavior: contain;
  gap: 6px;
  margin: 0;
  padding: 8px 12px 0;
}
#chat-card #files:empty {
  display: none;
}
#chat-card .file {
  padding: 7px 10px;
  font-size: 13px;
  gap: 8px;
}
#chat-card .file-actions button {
  min-height: 44px;
  font-size: 12px;
  padding: 5px 8px;
}
#chat-card #error {
  max-height: 92px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 13px;
  padding: 9px 12px;
  margin: 8px 12px 0;
}
#chat-card #recording {
  margin: 8px 12px 0;
  padding: 7px 10px;
  gap: 4px 8px;
  max-height: 100px;
  overflow-y: auto;
  font-size: 13px;
}
#chat-card #recording button {
  min-height: 44px;
  padding: 7px 9px;
  font-size: 12px;
}
#chat-card #voice-retry {
  padding: 8px 12px 0;
  max-height: 80px;
  overflow-y: auto;
  font-size: 13px;
  gap: 4px 8px;
}
#chat-card #voice-retry button {
  min-height: 44px;
  padding: 7px 10px;
  font-size: 12px;
}
.chat-page #channel-switch {
  margin: 14px 0 10px;
}
.chat-page .consultation-launch {
  margin: 10px 0;
}
.chat-page #document-help {
  margin: 6px 0 4px;
}
.chat-page .disclaimer {
  font-size: 12px;
  margin: 12px 0 8px;
}
.chat-page #status {
  font-size: 12px;
  margin: 8px 0;
}
.chat-page .conversation-actions {
  margin-top: 12px;
}

@media (max-width: 650px) {
  .chat-page .shell {
    padding: 0 12px;
  }
  .chat-page header {
    align-items: center;
    padding: 12px 0;
  }
  .chat-page #chat-main {
    padding-top: 12px;
  }
  .chat-page #intro h1 {
    font-size: 26px;
  }
  .chat-page .question-examples {
    margin-bottom: 10px;
  }
  #chat-card {
    --chat-card-height: clamp(300px, 65dvh, 640px);
    border-radius: 16px;
  }
  #chat-history {
    padding: 12px;
    border-radius: 15px 15px 0 0;
  }
  #chat-history .message {
    font-size: 14px;
    padding: 12px 13px;
  }
  #chat-history .message.user {
    max-width: 94%;
  }
  #chat-card #question {
    padding: 12px 13px 7px;
    min-height: 54px;
    height: 54px;
    max-height: var(--question-max-height, 90px);
  }
  #chat-card #composer-dock {
    position: relative;
    bottom: auto;
    padding: 0;
    background: #fff;
    box-shadow: none;
    border-radius: 0 0 15px 15px;
  }
  #chat-card .composer-bottom {
    padding: 0 8px 8px;
    gap: 4px;
  }
  #chat-card #send {
    padding: 9px 12px;
  }
  #chat-card #conversation-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 3px 10px 7px;
    border-radius: 0 0 15px 15px;
  }
  #chat-card #consent-panel {
    flex-shrink: 0;
    justify-content: flex-start;
  }
  #chat-card #consent-panel label,
  #chat-card .terms-link {
    min-height: 44px;
    font-size: 12px;
  }
  #conversation-credit {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-content: flex-start;
    gap: 3px 8px;
  }
  #conversation-credit .conversation-credit {
    grid-column: 1;
    grid-row: 1;
    justify-content: flex-start;
    margin-right: 0;
    gap: 6px;
  }
  #conversation-credit > span,
  #conversation-credit > p,
  #conversation-credit > button:not(.credit-refill) {
    grid-column: 1 / -1;
  }
  #conversation-credit .credit-refill {
    grid-column: 2;
    grid-row: 1;
    margin-left: auto;
    padding: 8px 10px;
  }
  #conversation-credit .paid-credit {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    margin-top: 4px;
  }
  #chat-card #files,
  #chat-card #recording {
    max-height: 86px;
  }
  #chat-card #files {
    padding: 7px 8px 0;
  }
  #chat-card #error,
  #chat-card #recording {
    margin: 6px 8px 0;
  }
  #chat-card #latest-answer {
    right: 10px;
    bottom: 9px;
  }
  .chat-page #channel-switch {
    gap: 8px;
    margin: 12px 0 8px;
  }
  .chat-page .channel-button {
    font-size: 13px;
    padding: 10px 8px;
  }
}
@media (max-height: 480px) {
  .chat-page header {
    padding: 8px 0;
  }
  .chat-page #chat-main {
    padding-top: 8px;
  }
  .chat-page #intro .eyebrow,
  .chat-page #intro p,
  .chat-page .question-examples {
    display: none;
  }
  .chat-page #intro h1 {
    font-size: 23px;
    margin: 0 0 8px;
  }
  #chat-card #question {
    min-height: 42px;
    height: 42px;
    max-height: var(--question-max-height, 68px);
    padding-top: 9px;
  }
  #chat-card #files,
  #chat-card #error,
  #chat-card #recording,
  #chat-card #voice-retry {
    max-height: 64px;
  }
}
.chat-page.keyboard-open #chat-card #question {
  min-height: 34px;
  height: 34px;
  padding-top: 6px;
  padding-bottom: 5px;
}
.chat-page.keyboard-open #chat-main {
  padding-top: 6px;
}
.chat-page.keyboard-open header {
  padding: 6px 0;
}
.chat-page.keyboard-open #chat-card .composer-bottom {
  padding-bottom: 4px;
}
.chat-page.keyboard-open #chat-card #conversation-toolbar {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 4px;
  padding-top: 0;
  padding-bottom: 4px;
}
.chat-page.keyboard-open #chat-card #consent-panel {
  min-width: 0;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 0 3px;
}
.chat-page.keyboard-open #chat-card .terms-full {
  display: none;
}
.chat-page.keyboard-open #chat-card .terms-compact {
  display: inline;
}
.chat-page.keyboard-open #conversation-credit {
  width: auto;
  flex: 1 1 auto;
  gap: 4px;
}
.chat-page.keyboard-open #conversation-credit .conversation-credit {
  margin: 0;
  gap: 0;
}
.chat-page.keyboard-open #conversation-credit .credit-ring {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}
.chat-page.keyboard-open
  #conversation-credit
  .conversation-credit
  > span:not(.credit-ring),
.chat-page.keyboard-open #conversation-credit .credit-help {
  display: none;
}
.chat-page.keyboard-open #conversation-credit .credit-refill {
  margin-left: auto;
  padding-right: 9px;
  padding-left: 9px;
}
.chat-page.keyboard-open #chat-card #consent-panel label,
.chat-page.keyboard-open #chat-card .terms-link {
  min-height: 44px;
}
