.assistant-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  box-shadow: 0 3px 14px rgb(0 0 0 / 18%);
}

.assistant-toggle[aria-expanded="true"] {
  visibility: hidden;
}

.assistant-toggle[data-running="true"]::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: currentColor;
}

.assistant-panel {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: min(420px, calc(100vw - 32px));
  height: min(560px, max(300px, 68vh), calc(100vh - 16px));
  max-height: calc(100vh - 16px);
  overflow: hidden;
  border: 1px solid var(--ui-border-strong);
  border-radius: 6px;
  background: var(--ui-surface);
  color: var(--ui-text);
  box-shadow: 0 10px 34px rgb(0 0 0 / 22%);
}

:root .assistant-panel[data-full-page="true"] {
  border-radius: 0;
}

.assistant-panel[data-full-page="true"] {
  box-shadow: none;
}

/* Keep the panel heading accessible without squeezing floating-window controls. */
.assistant-panel[data-floating="true"] .assistant-header h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.assistant-source-bar {
  flex: none;
  min-width: 0;
  padding: 4px 12px;
  border-bottom: 1px solid var(--ui-border);
}

.assistant-source-chip {
  display: block;
  max-width: 100%;
  min-height: 28px;
  overflow: hidden;
  padding: 2px 8px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface-subtle);
  color: var(--ui-text-soft);
  font: inherit;
  font-size: 12px;
  line-height: 20px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.assistant-source-chip:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 1px;
}

#assistant-options {
  min-width: 32px;
  min-height: 32px;
  padding: 4px;
}

#assistant-management[hidden],
#assistant-status[hidden] {
  display: none;
}

.assistant-connection-summary {
  margin: 8px 0;
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-panel[data-full-page="true"] :is(.assistant-messages, .assistant-results, .assistant-form) {
  box-sizing: border-box;
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
}

.assistant-panel[data-window-interaction] {
  user-select: none;
}

.assistant-header {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  min-width: 0;
  min-height: 44px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--ui-border);
  cursor: move;
  touch-action: none;
  user-select: none;
}

.assistant-header:focus-visible,
.assistant-resize:focus-visible,
.assistant-resize-edge:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: -3px;
}

.assistant-panel[data-full-page="true"] .assistant-header {
  cursor: default;
}

.assistant-header h2 {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.assistant-header-actions {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}

#assistant-history {
  flex: 0 1 132px;
  width: 132px;
  min-width: 72px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--ui-input-border);
  border-radius: 3px;
  background: var(--ui-input-bg);
  color: var(--ui-text);
  font-size: 11px;
}

#assistant-new,
#assistant-clear,
#assistant-full-page {
  min-height: 30px;
  padding: 3px 6px;
  font-size: 11px;
  white-space: nowrap;
}

#assistant-close {
  width: 30px;
  min-height: 30px;
  padding: 2px;
  font-size: 20px;
}

.assistant-management {
  flex: none;
  border-bottom: 1px solid var(--ui-border);
}

.assistant-management > summary {
  padding: 6px 12px;
  overflow: hidden;
  color: var(--ui-text-soft);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.assistant-management[open] {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 45%;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.assistant-management-body {
  padding: 0 12px 8px;
}

.assistant-context {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 20%;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 0 8px;
  color: var(--ui-text-soft);
  font-size: 11px;
  line-height: 1.45;
}

.assistant-context-badge {
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  background: var(--ui-surface);
  overflow-wrap: anywhere;
}

.assistant-scroll {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
}

.assistant-scroll > *,
.assistant-turn,
.assistant-proposal {
  min-width: 0;
  max-width: 100%;
}

.assistant-messages {
  padding: 12px;
}

.assistant-empty {
  padding: 18px 6px;
  color: var(--ui-text-muted);
  line-height: 1.6;
  text-align: center;
}

.assistant-turn {
  padding: 0 0 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--ui-border);
}

.assistant-user-message,
.assistant-answer {
  padding: 9px 10px;
  border-radius: 4px;
  line-height: 1.55;
}

.assistant-user-message {
  padding: 6px 9px;
  background: var(--ui-selected);
  font-size: 12px;
}

.assistant-answer {
  margin-top: 6px;
  background: var(--ui-surface-subtle);
  font-size: 14px;
}

.assistant-answer > strong {
  color: var(--ui-text-muted);
  font-size: 11px;
}

.assistant-user-message p {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.assistant-answer,
.assistant-answer-content,
.assistant-answer-table-block {
  min-width: 0;
  max-width: 100%;
}

.assistant-answer-content {
  margin-top: 4px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.assistant-answer-content > :first-child {
  margin-top: 0;
}

.assistant-answer-content > :last-child {
  margin-bottom: 0;
}

.assistant-answer-content p {
  margin: 0 0 10px;
  white-space: normal;
}

.assistant-answer-content :where(h1, h2, h3, h4, h5, h6) {
  margin: 15px 0 7px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.assistant-answer-content h1 { font-size: 1.4em; }
.assistant-answer-content h2 { font-size: 1.3em; }
.assistant-answer-content h3 { font-size: 1.2em; }
.assistant-answer-content h4 { font-size: 1.1em; }
.assistant-answer-content h5,
.assistant-answer-content h6 { font-size: 1em; }

.assistant-answer-content :where(ul, ol) {
  margin: 0 0 10px;
  padding-left: 1.7em;
}

.assistant-answer-content li + li {
  margin-top: 3px;
}

.assistant-answer-content li > :where(ul, ol) {
  margin: 4px 0;
}

.assistant-answer-content blockquote {
  margin: 10px 0;
  padding: 4px 10px;
  border-left: 3px solid var(--ui-border-strong);
  background: var(--ui-surface);
  color: var(--ui-text-soft);
}

.assistant-answer-content blockquote > :last-child {
  margin-bottom: 0;
}

.assistant-answer-content a {
  color: var(--ui-agent-link, var(--ui-primary));
}

.assistant-answer-content .assistant-answer-link-disabled {
  border-bottom: 1px dashed var(--ui-danger);
  color: var(--ui-text-muted);
  text-decoration: none;
  cursor: text;
}

.assistant-answer-content code {
  padding: 1px 3px;
  border-radius: 2px;
  background: var(--ui-agent-pre-bg, var(--ui-surface-muted));
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.assistant-answer-content pre {
  max-width: 100%;
  max-height: 320px;
  margin: 9px 0;
  padding: 9px 10px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ui-agent-code-border, var(--ui-border));
  border-radius: 3px;
  background: var(--ui-agent-pre-bg, var(--ui-surface-muted));
  font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  tab-size: 2;
  white-space: pre;
}

.assistant-answer-content pre code {
  padding: 0;
  background: transparent;
  font: inherit;
}

.assistant-answer-content pre:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}

.assistant-answer-content .assistant-answer-plain {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-answer-content .assistant-rendering-notice {
  margin: 0 0 8px;
  padding: 6px 8px;
  border-left: 3px solid var(--ui-border-strong);
  background: var(--ui-surface);
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-answer-content .katex {
  font-size: 1em;
}

.assistant-answer-content :not(.katex-display) > .katex {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  vertical-align: bottom;
}

.assistant-answer-content .katex-display {
  max-width: 100%;
  max-height: 320px;
  padding: 3px 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.assistant-answer-content .katex-error {
  white-space: normal;
  overflow-wrap: anywhere;
}

.assistant-citation {
  display: inline;
  padding: 0 1px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--ui-agent-link, var(--ui-primary));
  font: inherit;
  line-height: inherit;
  text-decoration: none;
  cursor: pointer;
}

.assistant-citation-unverified {
  border-bottom: 1px dashed var(--ui-danger);
  color: var(--ui-text-muted);
  cursor: help;
}

.assistant-answer-table-block {
  margin: 8px 0 10px;
}

.assistant-answer-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--ui-border-strong);
  border-radius: 3px;
  background: var(--ui-surface);
}

.assistant-answer-table-scroll:focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 2px;
}

.assistant-answer-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.45;
}

.assistant-answer-table th,
.assistant-answer-table td {
  min-width: 6.5rem;
  max-width: 16rem;
  padding: 6px 8px;
  border-right: 1px solid var(--ui-border);
  border-bottom: 1px solid var(--ui-border);
  vertical-align: top;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.assistant-answer-table th:last-child,
.assistant-answer-table td:last-child {
  border-right: 0;
}

.assistant-answer-table tbody tr:last-child td {
  border-bottom: 0;
}

.assistant-answer-table th {
  background: var(--ui-surface-muted);
  color: var(--ui-text);
  font-weight: 650;
}

.assistant-answer-table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.assistant-answer-table-actions .button {
  min-height: 30px;
  padding: 3px 7px;
  font-size: 11px;
}

.assistant-answer-table-status {
  color: var(--ui-text-soft);
  font-size: 11px;
}

.assistant-answer-table-status[data-kind="success"] {
  color: var(--ui-success);
}

.assistant-answer-table-status[data-kind="error"] {
  color: var(--ui-danger);
}

.assistant-turn-status {
  margin-top: 5px;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.assistant-error {
  margin-top: 7px;
  color: var(--ui-danger);
  font-size: 12px;
  line-height: 1.5;
}

.assistant-tools {
  margin-top: 8px;
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-tools summary {
  min-height: 32px;
  padding: 6px 0;
  cursor: pointer;
}

.assistant-tools ol {
  margin: 0;
  padding-left: 22px;
}

.assistant-tools li {
  padding: 5px 0;
}

.assistant-tools li p {
  margin-top: 3px;
  color: var(--ui-text-muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.assistant-results {
  border-top: 1px solid var(--ui-border);
}

.assistant-sources-details[hidden] {
  display: none;
}

.assistant-sources-details > summary {
  padding: 8px 12px;
  color: var(--ui-text-soft);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.assistant-sources,
.assistant-proposals {
  padding: 0 12px;
}

.assistant-sources:empty,
.assistant-proposals:empty {
  padding: 0;
}

.assistant-proposals > h3 {
  padding-top: 10px;
}

.assistant-sources ul {
  margin: 6px 0 10px;
  padding: 0;
  list-style: none;
}

.assistant-sources li {
  padding: 6px 0;
  border-top: 1px solid var(--ui-border);
}

.assistant-source-button {
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  color: var(--ui-agent-link, var(--ui-primary));
  text-align: left;
  cursor: pointer;
}

.assistant-source-link {
  text-decoration: none;
}

.assistant-source-page {
  margin-left: 7px;
  color: var(--ui-text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.assistant-other-sources > summary,
.assistant-source-excerpt > summary {
  padding: 5px 0;
  color: var(--ui-text-soft);
  font-size: 12px;
  cursor: pointer;
}

.assistant-sources li p {
  margin-top: 5px;
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.assistant-proposal {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 4px;
  background: var(--ui-surface-subtle);
}

.assistant-proposal h4 {
  margin: 0;
  font-size: 13px;
}

.assistant-proposal-status {
  margin-top: 5px;
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-proposal > strong {
  display: block;
  margin-top: 10px;
  font-size: 12px;
}

.assistant-proposal-details {
  display: grid;
  grid-template-columns: minmax(72px, auto) minmax(0, 1fr);
  gap: 5px 10px;
  margin: 9px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.assistant-proposal-details dt {
  color: var(--ui-text-muted);
}

.assistant-proposal-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.assistant-proposal-text {
  white-space: pre-wrap;
}

.assistant-analysis-code {
  max-height: 280px;
  margin: 7px 0 0;
  padding: 9px;
  overflow: auto;
  border: 1px solid var(--ui-agent-code-border, var(--ui-border));
  border-radius: 3px;
  background: var(--ui-agent-pre-bg, var(--ui-surface-muted));
  color: var(--ui-agent-code-text, var(--ui-text));
  font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre;
}

.assistant-proposal-source {
  margin-top: 9px;
}

.assistant-proposal-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 7px;
}

.assistant-proposal-images figure {
  min-width: 0;
  margin: 0;
}

.assistant-proposal-image-link {
  display: block;
  color: var(--ui-text-soft);
  text-decoration: none;
}

.assistant-proposal-image-link img {
  display: block;
  width: 100%;
  max-height: 180px;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  background: var(--ui-input-bg);
  object-fit: contain;
}

.assistant-proposal-image-link figcaption {
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.4;
}

.assistant-proposal-receipt,
.assistant-proposal-inactive {
  margin: 5px 0 0;
  color: var(--ui-text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.assistant-proposal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.assistant-status {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 25%;
  overflow: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--ui-border);
  color: var(--ui-text-soft);
  font-size: 12px;
  line-height: 1.5;
}

.assistant-status[data-kind="error"] {
  color: var(--ui-danger);
}

.assistant-status[data-kind="success"] {
  color: var(--ui-success);
}

.assistant-send-row .assistant-reference-add-row {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-right: auto;
  padding: 0;
}

.assistant-form {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
  max-height: 50%;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 10px 12px;
  background: var(--ui-surface);
}

#assistant-note-references {
  display: grid;
  gap: 6px;
  max-height: 224px;
  padding: 8px 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#assistant-note-references:empty {
  display: none;
}

.assistant-reader-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 144px;
  padding: 4px 0 8px;
  overflow-y: auto;
}

.assistant-reader-actions:empty {
  display: none;
}

.assistant-reader-action {
  display: flex;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 7px;
  padding: 5px 7px;
  border: 1px solid var(--ui-border);
  border-radius: 3px;
  background: var(--ui-surface-subtle);
  font-size: 11px;
}

.assistant-reader-action-source {
  min-height: 30px;
  padding: 3px 6px;
  overflow-wrap: anywhere;
  font-size: 11px;
  text-align: left;
}

.assistant-note-reference {
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface-subtle);
}

.assistant-note-reference-summary {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.5;
}

.assistant-note-reference-meta {
  margin-top: 3px;
  color: var(--ui-text-muted);
  font-size: 11px;
}

.assistant-note-reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.assistant-note-reference-actions .button {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 12px;
}

#assistant-message {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 84px;
  padding: 9px 10px;
  resize: vertical;
  border: 1px solid var(--ui-input-border);
  border-radius: 3px;
  background: var(--ui-input-bg);
  color: var(--ui-text);
  line-height: 1.5;
}

.assistant-send-row {
  display: flex;
  flex: none;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 7px;
}

.assistant-settings {
  flex: none;
  margin-top: 4px;
  border-top: 1px solid var(--ui-border);
}

#assistant-settings-toggle {
  display: flex;
  align-items: center;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 0;
  color: var(--ui-text-soft);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.assistant-shared-connection {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.assistant-shared-connection[hidden] {
  display: none;
}

#assistant-shared-use {
  flex: none;
  min-height: 44px;
}

#assistant-shared-help {
  flex: 1 1 180px;
  margin: 0;
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.assistant-settings-form {
  padding: 0 0 8px;
}

#assistant-settings-help {
  margin-bottom: 9px;
  color: var(--ui-text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.assistant-settings-form > label:not(.assistant-vision-option) {
  display: block;
  margin-top: 8px;
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-settings-form > input {
  display: block;
  width: 100%;
  min-height: 36px;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid var(--ui-input-border);
  border-radius: 3px;
  background: var(--ui-input-bg);
  color: var(--ui-text);
}

.assistant-vision-option {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin-top: 8px;
  color: var(--ui-text-soft);
  font-size: 12px;
}

.assistant-settings-status {
  min-height: 22px;
  padding: 5px 0;
  color: var(--ui-text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.assistant-settings-status[data-kind="error"] {
  color: var(--ui-danger);
}

.assistant-settings-status[data-kind="success"] {
  color: var(--ui-success);
}

.assistant-settings[open] {
  max-height: none;
  overflow: visible;
}

.assistant-resize {
  position: absolute;
  right: 1px;
  bottom: 1px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 0;
  padding: 2px;
  border: 0;
  background: transparent;
  color: var(--ui-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: nwse-resize;
  touch-action: none;
}

.assistant-resize:hover {
  color: var(--ui-text);
}

.assistant-resize-edge {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 14px;
  height: 72px;
  min-height: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
}

.assistant-resize-left {
  left: 0;
}

.assistant-resize-right {
  right: 0;
}

.assistant-resize-edge > span {
  width: 2px;
  height: 32px;
  border-radius: 2px;
  background: var(--ui-border-strong);
}

.assistant-resize-edge:hover > span,
.assistant-resize-edge:focus-visible > span {
  background: var(--ui-primary);
}

.assistant-resize-top,
.assistant-resize-bottom {
  left: 50%;
  top: auto;
  width: 72px;
  height: 16px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.assistant-resize-top {
  top: 0;
}

.assistant-resize-bottom {
  bottom: 0;
}

.assistant-resize-top > span,
.assistant-resize-bottom > span {
  width: 32px;
  height: 2px;
}

:root .assistant-panel[data-compact="true"] .assistant-management[open] {
  max-height: 38%;
}

:root .assistant-panel[data-compact="true"] #assistant-message {
  min-height: 64px;
}

.assistant-clear-dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 20px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 6px;
  background: var(--ui-surface);
  color: var(--ui-text);
}

.assistant-clear-dialog::backdrop {
  background: rgb(0 0 0 / 35%);
}

#assistant-clear-form {
  display: grid;
  gap: 12px;
}

#assistant-clear-heading {
  font-size: 17px;
}

.assistant-clear-conversation {
  overflow-wrap: anywhere;
  font-weight: 650;
}

#assistant-clear-help,
.assistant-clear-status {
  color: var(--ui-text-soft);
  font-size: 13px;
  line-height: 1.5;
}

.assistant-clear-status {
  min-height: 20px;
}

.assistant-clear-status[data-kind="error"] {
  color: var(--ui-danger);
}

.assistant-clear-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-height: 480px) {
  .assistant-management[open] {
    max-height: 34%;
  }

  #assistant-message {
    min-height: 56px;
  }
}

@media (max-width: 480px) {
  .assistant-toggle {
    right: 12px;
    bottom: 12px;
  }

  .assistant-panel {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 92vh;
    max-height: 92vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 6px 6px 0 0;
  }

  .assistant-answer-table th,
  .assistant-answer-table td {
    min-width: 5.5rem;
    padding: 5px 6px;
  }

  #assistant-clear,
  .assistant-clear-actions .button {
    min-height: 44px;
  }
}

#assistant-source-preparation {
  margin-top: 8px;
}

.source-preparation {
  max-width: 100%;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface);
  color: var(--ui-text-soft);
  font-size: 12px;
}

.source-preparation > summary {
  padding: 8px;
  color: var(--ui-text);
  font-weight: 600;
  cursor: pointer;
}

.source-preparation-body {
  padding: 0 8px 8px;
}

.source-preparation-help,
.source-preparation-empty,
.source-preparation-count,
.source-preparation-status,
.source-preparation-warning {
  margin: 4px 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.source-preparation-help,
.source-preparation-empty,
.source-preparation-count {
  color: var(--ui-text-muted);
}

.source-preparation-field {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.source-preparation-field > label {
  color: var(--ui-text);
  font-weight: 600;
}

.source-preparation-field select,
.source-preparation-field input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 4px 8px;
  overflow: hidden;
  border: 1px solid var(--ui-border-strong);
  border-radius: 4px;
  background: var(--ui-surface);
  color: var(--ui-text);
  text-overflow: ellipsis;
}

.source-preparation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.source-preparation-actions .button {
  min-height: 32px;
}

.source-preparation-status[data-kind="error"] {
  color: var(--ui-danger);
}

.source-preparation-status[data-kind="success"] {
  color: var(--ui-primary);
}

.source-preparation-pages {
  display: grid;
  gap: 4px;
  padding: 0;
  margin: 8px 0 0;
  list-style: none;
}

.source-preparation-page {
  padding: 4px 8px;
  border: 1px solid var(--ui-border);
  border-radius: 4px;
  background: var(--ui-surface-subtle);
}

.source-preparation-page-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px;
}

.source-preparation-page[data-status="partial"] strong,
.source-preparation-page[data-status="unavailable"] strong,
.source-preparation-page[data-status="missing"] strong {
  color: var(--ui-text-muted);
}

@media (max-width: 480px) {
  .source-preparation-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .source-preparation-actions .button {
    width: 100%;
    min-height: 44px;
  }
}

.assistant-header,
.assistant-header-actions {
  flex-wrap: nowrap;
}

#assistant-history,
#assistant-new,
#assistant-clear,
#assistant-full-page,
#assistant-close {
  min-height: 44px;
}

#assistant-new,
#assistant-clear {
  width: 44px;
  min-width: 44px;
  padding: 10px;
}

#assistant-full-page,
#assistant-close {
  min-width: 44px;
}

#assistant-close {
  width: 44px;
}

#assistant-full-page {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 8px;
}

@media (pointer: coarse), (max-width: 480px) {
  #assistant-full-page {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

.assistant-icon-button {
  display: inline-grid;
  place-items: center;
}

.assistant-icon-button[hidden] {
  display: none;
}

.assistant-icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.assistant-context {
  align-items: center;
  gap: 4px 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--ui-border);
}

.assistant-context-summary {
  flex: 1 1 180px;
  display: -webkit-box;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.assistant-context > .button {
  min-height: 44px;
}

.assistant-advanced > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.source-preparation > summary,
.source-preparation-field select,
.source-preparation-field input,
.source-preparation-actions .button {
  min-height: 44px;
}

.source-preparation-count:empty {
  display: none;
}

@media (max-width: 480px) {
  .assistant-header {
    gap: 4px;
    padding: 4px 6px;
  }

  .assistant-header h2 {
    display: none;
  }

  .assistant-header-actions {
    width: 100%;
    gap: 3px;
  }

  #assistant-history {
    flex: 1 1 auto;
    width: auto;
  }
}
