:root {
  --app-docs-chat-accent: #1976bd;
  --app-docs-chat-ink: #102f49;
  --app-docs-chat-muted: #64788c;
  --app-docs-chat-line: #cbdbe8;
  --app-docs-chat-surface: #f7fbff;
  --app-docs-chat-panel: #fff;
}

.app-docs-chat button:focus-visible,
.app-docs-chat select:focus-visible,
.app-docs-chat input:focus-visible,
.app-docs-chat textarea:focus-visible,
.app-docs-chat a:focus-visible {
  outline: 3px solid #63b8f3;
  outline-offset: 2px;
}

.app-docs-chat-icon {
  fill: none;
  flex: 0 0 auto;
  height: 1.25rem;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 1.25rem;
}

.app-docs-chat {
  --app-shell-side-panel-width: 430px;
}

.app-docs-chat-panel {
  background: #f8fafc;
  box-shadow: -1rem 0 3rem rgb(7 26 44 / 18%);
  color: var(--app-docs-chat-ink);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100%;
  overflow: hidden;
}

.app-docs-chat-header {
  align-items: center;
  background: linear-gradient(135deg, #0d3555, #155c8d);
  color: #fff;
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  min-height: 60px;
  padding: 0.65rem 1rem;
}

.app-docs-chat-heading {
  align-items: center;
  display: flex;
  gap: 0.6rem;
  min-width: 0;
}

.app-docs-chat-heading-mark {
  align-items: center;
  background: rgb(255 255 255 / 14%);
  border-radius: 10px;
  display: flex;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.app-docs-chat-heading-copy {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.app-docs-chat-heading-copy strong {
  font: 750 0.92rem/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-heading-copy small {
  color: #c9e5f8;
  font: 650 0.64rem/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-docs-chat-header-actions {
  display: flex;
  gap: 0.35rem;
}

.app-docs-chat-icon-button {
  align-items: center;
  background: rgb(255 255 255 / 10%);
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 10px;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  padding: 0;
  width: 36px;
}

.app-docs-chat-icon-button:hover {
  background: rgb(255 255 255 / 18%);
}

.app-docs-chat-toolbar {
  align-items: end;
  background: var(--app-docs-chat-surface);
  border-bottom: 1px solid var(--app-docs-chat-line);
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 0.65rem 1rem;
}

.app-docs-chat-scope-help {
  grid-column: 1 / -1;
  margin: -0.1rem 0 0;
  color: var(--app-docs-chat-muted);
  font: 500 0.68rem/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-field {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.app-docs-chat-field > span,
.app-docs-chat-setup label > span {
  color: var(--app-docs-chat-muted);
  font: 700 0.64rem/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-docs-chat select,
.app-docs-chat input,
.app-docs-chat textarea {
  background: #fff;
  border: 1px solid var(--app-docs-chat-line);
  border-radius: 10px;
  color: var(--app-docs-chat-ink);
  font: 500 0.78rem/1.35 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat select,
.app-docs-chat input {
  min-height: 36px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

.app-docs-chat-toolbar select {
  padding-right: 2.75rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23213f5b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem;
}

.app-docs-chat-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.85rem 1rem;
}

.app-docs-chat-empty {
  color: var(--app-docs-chat-muted);
  display: grid;
  font-size: 0.82rem;
  gap: 0.4rem;
  margin: 10vh auto 0;
  max-width: 19rem;
  text-align: center;
}

.app-docs-chat-empty strong {
  color: var(--app-docs-chat-ink);
  font-size: 0.95rem;
}

.app-docs-chat-empty p {
  line-height: 1.45;
  margin: 0;
}

.app-docs-chat-messages {
  display: grid;
  gap: 0.75rem;
}

.app-docs-chat-message {
  display: grid;
  gap: 0.35rem;
}

.app-docs-chat-message-meta {
  align-items: center;
  display: flex;
  gap: 0.35rem;
}

.app-docs-chat-message-meta > span {
  color: var(--app-docs-chat-muted);
  font: 700 0.64rem/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.app-docs-chat-retry {
  display: inline-grid;
  width: 1.45rem;
  height: 1.45rem;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #557087;
  cursor: pointer;
  font: 750 1rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-retry:hover,
.app-docs-chat-retry:focus-visible {
  background: #e3edf5;
  color: #145f93;
}

.app-docs-chat-retry:disabled {
  cursor: default;
  opacity: 0.45;
}

.app-docs-chat-message-copy {
  background: #f1f6fa;
  border: 1px solid #d8e4ed;
  border-radius: 4px 12px 12px;
  font: 450 0.82rem/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  overflow-wrap: anywhere;
  padding: 0.65rem 0.75rem;
  white-space: pre-wrap;
}

.app-docs-chat-message.is-assistant .app-docs-chat-message-copy {
  white-space: normal;
}

.app-docs-chat-message-copy > :first-child {
  margin-top: 0;
}

.app-docs-chat-message-copy > :last-child {
  margin-bottom: 0;
}

.app-docs-chat-message-copy p,
.app-docs-chat-message-copy blockquote,
.app-docs-chat-message-copy ul,
.app-docs-chat-message-copy ol,
.app-docs-chat-message-copy pre,
.app-docs-chat-message-copy hr,
.app-docs-chat-message-copy h3,
.app-docs-chat-message-copy h4,
.app-docs-chat-message-copy h5 {
  margin: 0.55rem 0;
}

.app-docs-chat-message-copy h3,
.app-docs-chat-message-copy h4,
.app-docs-chat-message-copy h5 {
  color: #123a58;
  line-height: 1.3;
}

.app-docs-chat-message-copy h3 { font-size: 0.94rem; }
.app-docs-chat-message-copy h4 { font-size: 0.88rem; }
.app-docs-chat-message-copy h5 { font-size: 0.84rem; }

.app-docs-chat-message-copy ul,
.app-docs-chat-message-copy ol {
  display: grid;
  gap: 0.25rem;
  padding-left: 1.35rem;
}

.app-docs-chat-message-copy blockquote {
  padding-left: 0.75rem;
  border-left: 3px solid #9dc7e2;
  color: #3d5e74;
}

.app-docs-chat-message-copy code {
  border-radius: 0.3rem;
  background: #e6eef4;
  font: 500 0.84em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  padding: 0.08rem 0.25rem;
}

.app-docs-chat-message-copy pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 0.55rem;
  background: #102536;
  color: #e7f2fa;
  padding: 0.75rem;
  white-space: pre;
}

.app-docs-chat-message-copy pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.app-docs-chat-message-copy hr {
  border: 0;
  border-top: 1px solid #cbdbe8;
}

.app-docs-chat-waiting {
  display: inline-block;
  color: #567287;
  animation: app-docs-chat-waiting 1.2s ease-in-out infinite alternate;
  font-style: italic;
}

@keyframes app-docs-chat-waiting {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.app-docs-chat-citation {
  background: #dceffc;
  border: 1px solid #a9d3ee;
  border-radius: 999px;
  color: #125f95;
  display: inline-block;
  font: 750 0.66rem/1.25 Inter, ui-sans-serif, system-ui, sans-serif;
  margin: 0 0.08rem;
  padding: 0.08rem 0.32rem;
  text-decoration: none;
  white-space: nowrap;
}

.app-docs-chat-citation:hover {
  background: #c9e7fa;
  color: #0a4d7c;
}

.app-docs-chat-citation-warning {
  align-items: start;
  color: #8a5512;
  display: flex;
  font: 600 0.7rem/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
  gap: 0.4rem;
  margin: 0;
}

.app-docs-chat-citation-warning .app-docs-chat-icon {
  height: 1rem;
  margin-top: 0.05rem;
  width: 1rem;
}

.app-docs-chat-message.is-user {
  justify-items: end;
}

.app-docs-chat-message.is-user .app-docs-chat-message-meta {
  justify-content: flex-end;
}

.app-docs-chat-message.is-user .app-docs-chat-message-copy {
  background: #e3f2fd;
  border-color: #badcf3;
  border-radius: 12px 4px 12px 12px;
  max-width: 88%;
}

.app-docs-chat-sources {
  display: grid;
  gap: 0.35rem;
  margin: 0.15rem 0 0;
}

.app-docs-chat-sources summary {
  color: #245f89;
  cursor: pointer;
  font: 700 0.72rem/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-sources ol {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0.25rem 0 0 1.4rem;
}

.app-docs-chat-sources a {
  color: #176ba7;
  font: 600 0.72rem/1.35 Inter, ui-sans-serif, system-ui, sans-serif;
  overflow-wrap: anywhere;
}

.app-docs-chat-status {
  color: var(--app-docs-chat-muted);
  font: 600 0.7rem/1.35 Inter, ui-sans-serif, system-ui, sans-serif;
  margin: 0;
  min-height: 1rem;
}

.app-docs-chat-status.is-error {
  color: #a12622;
}

.app-docs-chat-composer {
  background: #fff;
  border-top: 1px solid var(--app-docs-chat-line);
  display: grid;
  gap: 0.4rem;
  padding: 0.65rem 1rem max(0.65rem, env(safe-area-inset-bottom));
}

.app-docs-chat-compose-row {
  align-items: end;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: minmax(0, 1fr) auto;
}

.app-docs-chat textarea {
  max-height: 9rem;
  min-height: 42px;
  padding: 0.55rem 0.65rem;
  resize: vertical;
  width: 100%;
}

.app-docs-chat-primary,
.app-docs-chat-secondary {
  align-items: center;
  border-radius: 0.55rem;
  cursor: pointer;
  display: inline-flex;
  font: 700 0.76rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  gap: 0.45rem;
  justify-content: center;
  min-height: 36px;
  padding: 0.55rem 0.7rem;
}

.app-docs-chat-primary {
  background: var(--app-docs-chat-accent);
  border: 1px solid var(--app-docs-chat-accent);
  color: #fff;
}

.app-docs-chat-primary.is-stop {
  border-color: #a43b37;
  background: #a43b37;
}

.app-docs-chat-secondary {
  background: #fff;
  border: 1px solid var(--app-docs-chat-line);
  color: #245574;
}

.app-docs-chat-primary:disabled,
.app-docs-chat-secondary:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-docs-chat-setup {
  background: #f7fbff;
  border-top: 1px solid var(--app-docs-chat-line);
  display: grid;
  gap: 0.6rem;
  max-height: min(65dvh, 38rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.85rem 1rem;
}

.app-docs-chat-setup[hidden],
.app-docs-chat-composer[hidden] {
  display: none;
}

.app-docs-chat-setup h3,
.app-docs-chat-setup p {
  margin: 0;
}

.app-docs-chat-setup h3 {
  font-size: 0.9rem;
}

.app-docs-chat-setup p {
  color: #506a7e;
  font: 450 0.76rem/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-key-state {
  background: #e9f4fc;
  border-left: 3px solid #2a84c3;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

.app-docs-chat-account-key {
  align-items: center;
  background: #fff;
  border: 1px solid var(--app-docs-chat-line);
  border-radius: 0.65rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 0.65rem;
}

.app-docs-chat-account-key[hidden],
.app-docs-chat-key-divider[hidden],
.app-docs-chat-key-state[hidden],
.app-docs-chat-setup-actions button[hidden],
.app-docs-chat-account-actions > [hidden] {
  display: none;
}

.app-docs-chat-account-key > div:first-child {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.app-docs-chat-account-key strong {
  font: 700 0.78rem/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-account-key span {
  color: #60768a;
  font: 500 0.7rem/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat-account-actions {
  align-items: stretch;
  display: grid;
  gap: 0.35rem;
}

.app-docs-chat-account-actions .app-docs-chat-secondary {
  min-height: 34px;
  white-space: nowrap;
}

.app-docs-chat-profile-link {
  color: #176ba7;
  font: 650 0.68rem/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: center;
}

.app-docs-chat-key-divider {
  align-items: center;
  display: flex;
  gap: 0.6rem;
  text-transform: uppercase;
}

.app-docs-chat-key-divider::before,
.app-docs-chat-key-divider::after {
  background: var(--app-docs-chat-line);
  content: '';
  flex: 1;
  height: 1px;
}

.app-docs-chat-setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.app-docs-chat-consent {
  align-items: start;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: auto minmax(0, 1fr);
}

.app-docs-chat-consent input {
  margin-top: 0.12rem;
  min-height: 1rem;
  width: 1rem;
}

.app-docs-chat-consent span {
  color: #3f5e74;
  font: 550 0.72rem/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: normal;
  text-transform: none;
}

@media screen and (max-width: 640px) {
  .app-docs-chat-panel {
    box-shadow: none;
  }

  .app-docs-chat-header {
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }

  .app-docs-chat-account-key {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-docs-chat-account-actions {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-docs-chat-panel { scroll-behavior: auto; }
  .app-docs-chat-waiting { animation: none; }
}
