:root {
  --app-docs-chat-accent: #1976bd;
  --app-docs-chat-focus: #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 .app-docs-chat-panel button:focus-visible,
.app-docs-chat .app-docs-chat-panel select:focus-visible,
.app-docs-chat .app-docs-chat-panel textarea:focus-visible,
.app-docs-chat .app-docs-chat-panel a:focus-visible {
  outline: 3px solid var(--app-docs-chat-focus);
  outline-offset: 2px;
}

.app-docs-chat,
.app-docs-chat *,
.app-docs-chat *::before,
.app-docs-chat *::after {
  box-sizing: border-box;
}

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

.app-docs-chat {
  --app-shell-side-panel-width: 430px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.app-docs-chat-panel {
  background: #f8fafc;
  box-shadow: -16px 0 48px 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 {
  --app-docs-chat-focus: #8bc9ff;
  align-items: center;
  background: linear-gradient(135deg, #0d3555, #155c8d);
  color: #fff;
  display: flex;
  gap: 12.8px;
  justify-content: space-between;
  min-height: 60px;
  padding: 10.4px 16px;
}

.app-docs-chat-heading {
  align-items: center;
  display: flex;
  gap: 9.6px;
  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: 2.88px;
  min-width: 0;
}

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

.app-docs-chat-heading-copy small {
  color: #c9e5f8;
  font: 650 10.24px/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: 5.6px;
}

.app-docs-chat .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;
  font: 400 16px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  width: 36px;
}

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

.app-docs-chat .app-docs-chat-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.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: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 10.4px 16px;
}

.app-docs-chat-toolbar.is-model-only {
  grid-template-columns: minmax(0, 1fr);
}

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

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

.app-docs-chat select,
.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 12.48px/1.35 Inter, ui-sans-serif, system-ui, sans-serif;
}

.app-docs-chat select {
  min-height: 36px;
  padding: 7.2px 9.6px;
  width: 100%;
}

.app-docs-chat-toolbar select {
  padding-right: 44px;
  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 13.6px center;
  background-size: 16px;
}

.app-docs-chat-main {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 13.6px 16px;
}

.app-docs-chat-empty {
  color: var(--app-docs-chat-muted);
  display: grid;
  font-size: 13.12px;
  gap: 6.4px;
  margin: 10vh auto 0;
  max-width: 304px;
  text-align: center;
}

.app-docs-chat-empty[hidden] {
  display: none;
}

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

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

.app-docs-chat-messages {
  display: grid;
  gap: 12px;
}

.app-docs-chat-message {
  display: grid;
  gap: 5.6px;
}

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

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

.app-docs-chat-message-actions {
  align-items: center;
  display: flex;
  gap: 5.6px;
}

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

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

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

.app-docs-chat .app-docs-chat-copy .app-docs-chat-icon {
  height: 13.6px;
  width: 13.6px;
}

.app-docs-chat .app-docs-chat-copy.is-copied {
  background: #e6f5ec;
  color: #277447;
}

.app-docs-chat .app-docs-chat-copy.is-error {
  background: #fff0f0;
  color: #a13b3b;
}

.app-docs-chat-message-copy {
  background: #f1f6fa;
  border: 1px solid #d8e4ed;
  border-radius: 4px 12px 12px;
  font: 450 13.12px/1.5 Inter, ui-sans-serif, system-ui, sans-serif;
  overflow-wrap: anywhere;
  padding: 10.4px 12px;
  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: 8.8px 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: 15.04px; }
.app-docs-chat-message-copy h4 { font-size: 14.08px; }
.app-docs-chat-message-copy h5 { font-size: 13.44px; }

.app-docs-chat-message-copy ul,
.app-docs-chat-message-copy ol {
  display: grid;
  gap: 4px;
  padding-left: 21.6px;
}

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

.app-docs-chat-message-copy code {
  border-radius: 4.8px;
  background: #e6eef4;
  font: 500 0.84em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  padding: 1.28px 4px;
}

.app-docs-chat-message-copy pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 8.8px;
  background: #102536;
  color: #e7f2fa;
  padding: 12px;
  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-message-copy a {
  color: #126da9;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.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 10.56px/1.25 Inter, ui-sans-serif, system-ui, sans-serif;
  margin: 0 1.28px;
  padding: 1.28px 5.12px;
  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 11.2px/1.4 Inter, ui-sans-serif, system-ui, sans-serif;
  gap: 6.4px;
  margin: 0;
}

.app-docs-chat-citation-warning .app-docs-chat-icon {
  height: 16px;
  margin-top: 0.8px;
  width: 16px;
}

.app-docs-chat-message.is-truncated .app-docs-chat-message-copy {
  background: #fff9ed;
  border-color: #e4bd78;
}

.app-docs-chat-truncation-warning {
  align-items: start;
  background: #fff7e7;
  border: 1px solid #e4bd78;
  border-radius: 8px;
  color: #77470b;
  display: flex;
  font: 600 11.2px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  gap: 6.4px;
  margin: 0;
  padding: 8px 9.6px;
}

.app-docs-chat-truncation-warning .app-docs-chat-icon {
  flex: 0 0 auto;
  height: 16px;
  margin-top: 0.8px;
  width: 16px;
}

.app-docs-chat-truncation-warning a {
  color: #92580b;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.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-actions {
  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: 5.6px;
  margin: 2.4px 0 0;
}

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

.app-docs-chat-sources ol {
  display: grid;
  gap: 5.6px;
  margin: 0;
  padding: 4px 0 0 22.4px;
}

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

.app-docs-chat-annotation-plan {
  display: grid;
  gap: 7px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid #cfdfeb;
}

.app-docs-chat-annotation-plan > p {
  margin: 0;
  color: #42677f;
  font-size: 11.2px;
  font-weight: 700;
  line-height: 1.4;
}

.app-docs-chat-annotation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-docs-chat-annotation-apply {
  position: relative;
}

.app-docs-chat-annotation-color-picker {
  align-items: center;
  background: #fff;
  border: 1px solid #b9cbd8;
  border-radius: 999px;
  bottom: calc(100% + 7px);
  box-shadow: 0 8px 22px rgb(16 42 67 / 18%);
  display: flex;
  gap: 3px;
  inset-inline-start: 0;
  padding: 4px;
  position: absolute;
  width: max-content;
  z-index: 4;
}

.app-docs-chat-annotation-color-picker::after {
  background: #fff;
  border-bottom: 1px solid #b9cbd8;
  border-right: 1px solid #b9cbd8;
  bottom: -4px;
  content: '';
  height: 7px;
  inset-inline-start: 18px;
  position: absolute;
  transform: rotate(45deg);
  width: 7px;
}

.app-docs-chat .app-docs-chat-annotation-color {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  position: relative;
  width: 32px;
  z-index: 1;
}

.app-docs-chat .app-docs-chat-annotation-color:hover,
.app-docs-chat .app-docs-chat-annotation-color:focus-visible {
  background: #eaf3f9;
  outline: 0;
}

.app-docs-chat .app-docs-chat-annotation-color:focus-visible {
  box-shadow: 0 0 0 3px #8bc9ff;
}

.app-docs-chat-annotation-color > span {
  background: #ffe58f;
  border: 1px solid rgb(16 42 67 / 22%);
  border-radius: 50%;
  height: 20px;
  width: 20px;
}

.app-docs-chat-annotation-color[data-color='green'] > span {
  background: #bde7bd;
}

.app-docs-chat-annotation-color[data-color='blue'] > span {
  background: #b7dcff;
}

.app-docs-chat-annotation-color[data-color='pink'] > span {
  background: #ffc7df;
}

.app-docs-chat .app-docs-chat-annotation-actions .app-docs-chat-secondary {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11.2px;
}

.app-docs-chat .app-docs-chat-annotation-actions .app-docs-chat-secondary.is-danger {
  border-color: #e2b1b1;
  background: #fff8f8;
  color: #9b2e2e;
}

.app-docs-chat .app-docs-chat-annotation-actions .app-docs-chat-secondary.is-danger:hover:not(:disabled) {
  border-color: #cc8c8c;
  background: #fff0f0;
  color: #842424;
}

.app-docs-chat-annotation-plan > .app-docs-chat-annotation-feedback.is-error {
  color: #a12626;
}

.app-docs-chat-notice {
  background: #f7fafc;
  border: 1px solid var(--app-docs-chat-line);
  border-radius: 10.4px;
  color: #334e61;
  display: grid;
  font: 500 11.52px/1.45 Inter, ui-sans-serif, system-ui, sans-serif;
  gap: 7.2px;
  padding: 11.2px;
}

.app-docs-chat-notice.is-warning {
  background: #fff8e8;
  border-color: #dfbd72;
  color: #704f14;
}

.app-docs-chat-notice > strong,
.app-docs-chat-notice > p {
  margin: 0;
}

.app-docs-chat-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6.4px;
  justify-content: flex-end;
}

.app-docs-chat-pending-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-docs-chat-pending-list li {
  border-top: 1px solid rgb(112 79 20 / 18%);
  display: grid;
  gap: 5.6px;
  padding-top: 8px;
}

.app-docs-chat-pending-list li > span {
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

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

.app-docs-chat-status a {
  color: inherit;
  font-weight: 750;
}

/* Inline action inside the status line (e.g. confirming an additional
   credit-unit activation) — reads like a link, works like a button. */
.app-docs-chat-inline-action {
  background: none;
  border: none;
  color: #174f7e;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  padding: 0;
  text-decoration: underline;
}

.app-docs-chat-inline-action:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* /study wraps this shared widget inside .external-study-main, whose own
   "every <button> looks like a button" reset (globals.css) has higher
   specificity (a class + an element vs. this single class) and otherwise
   wins per property, turning "Ativar e continuar" into a filled blue pill
   instead of the plain inline text action the Library surface shows for
   the same class. Scope under .app-docs-chat's own top-level class so the
   widget keeps full control of its own button styling everywhere it is
   embedded, matching every property that reset sets.
*/
.app-docs-chat .app-docs-chat-inline-action {
  display: inline;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  color: #174f7e;
  font: inherit;
  font-weight: 750;
  text-decoration: underline;
}

.app-docs-chat .app-docs-chat-inline-action:hover {
  background: none;
  border-color: transparent;
}

.app-docs-chat .app-docs-chat-inline-action:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.app-docs-chat-composer {
  background: #fff;
  border-top: 1px solid var(--app-docs-chat-line);
  display: grid;
  column-gap: 7.2px;
  grid-template-columns: minmax(0, 1fr) 44px;
  row-gap: 6.4px;
  padding: 10.4px 16px max(10.4px, env(safe-area-inset-bottom));
}

.app-docs-chat-compose-row {
  display: grid;
  gap: 7.2px;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1fr) 44px;
}

.app-docs-chat-prompt-template {
  display: grid;
  gap: 4px;
  grid-column: 1;
  min-width: 0;
}

.app-docs-chat-prompt-template > span {
  color: var(--app-docs-chat-muted);
  font: 700 10.4px/1.25 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-docs-chat-prompt-template select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #55748a 50%) right 15px center / 5px 5px no-repeat,
    linear-gradient(135deg, #55748a 50%, transparent 50%) right 10px center / 5px 5px no-repeat,
    #fff;
  border: 1px solid var(--app-docs-chat-line);
  border-radius: 8.8px;
  color: var(--app-docs-chat-ink);
  font: 600 12px/1.25 Inter, ui-sans-serif, system-ui, sans-serif;
  min-height: 36px;
  min-width: 0;
  padding: 7px 30px 7px 10px;
  width: 100%;
}

.app-docs-chat-compose-row .app-docs-chat-primary {
  min-width: 44px;
}

.app-docs-chat-compose-actions {
  align-self: stretch;
  display: grid;
  gap: 7.2px;
  grid-auto-rows: minmax(36px, 1fr);
  grid-column: 2;
}

.app-docs-chat-compose-actions > button {
  min-width: 44px;
  padding-inline: 8px;
}

.app-docs-chat-clear-question {
  color: var(--app-docs-chat-ink);
}

.app-docs-chat textarea {
  max-height: 144px;
  min-height: 72px;
  padding: 8.8px 10.4px;
  resize: vertical;
  width: 100%;
}

.app-docs-chat textarea::placeholder {
  color: var(--app-docs-chat-muted);
  opacity: 1;
}

.app-docs-chat-status {
  grid-column: 1;
}

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

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

.app-docs-chat .app-docs-chat-primary:hover:not(:disabled) {
  background: #145f93;
  border-color: #145f93;
}

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

.app-docs-chat .app-docs-chat-primary.is-stop:hover:not(:disabled) {
  background: #87302d;
  border-color: #87302d;
}

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

.app-docs-chat .app-docs-chat-secondary:hover:not(:disabled) {
  background: #edf5fb;
  border-color: #9ebed3;
  color: #174765;
}

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

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

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

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