/* Chat view — scoped to .chat-view / .chat-dock. Warm ivory + plum identity. */
.chat-view, .chat-dock {
  --chat-ivory: #fbf7ef;
  --chat-paper: #fffdf8;
  --chat-line: #e7dccb;
  --chat-ink: #2d2230;
  --chat-muted: #7a6c74;
  --chat-plum: #6b2f5b;
  --chat-plum-soft: #f3e6ee;
  --chat-error: #a3263a;
}
.chat-view {
  display: flex; flex-direction: column;
  min-height: calc(100dvh - 120px); height: 100%;
  background: var(--chat-ivory); color: var(--chat-ink);
  border-radius: 14px; overflow: hidden;
}
.chat-view [hidden] { display: none !important; }
.chat-view .chat-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chat-view .chat-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; background: color-mix(in srgb, var(--chat-ivory) 92%, transparent);
  border-bottom: 1px solid var(--chat-line); backdrop-filter: blur(6px);
}
.chat-view .chat-header-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chat-view .chat-header-actions { display: flex; flex: none; gap: 6px; flex-wrap: wrap; }
.chat-view .chat-model-btn {
  min-width: 0; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 600; color: var(--chat-plum); background: transparent; border-color: transparent;
}
.chat-view .chat-model-btn:hover, .chat-view .chat-icon-btn:hover { background: var(--chat-plum-soft); }
.chat-view .chat-icon-btn { padding: 4px 10px; font-size: 0.9em; }
.chat-view .chat-header .shell-menu-toggle { padding: 4px 8px; font-size: 0.9em; }

.chat-view [hidden], .chat-dock [hidden] { display: none !important; }
.chat-view .chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 12px; }
.chat-view .chat-bubble-text pre.chat-code {
  white-space: pre; overflow-x: auto; margin: 8px 0; padding: 10px 12px;
  background: #f4eee4; border: 1px solid var(--chat-line); border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; line-height: 1.5;
}
.chat-view .chat-bubble-text pre.chat-code code { white-space: inherit; font: inherit; background: none; }
.chat-view .chat-model-opt[aria-pressed="true"] { color: var(--chat-plum); font-weight: 600; }
.chat-view .chat-menu-item[aria-pressed="true"]::before { content: '✓ '; color: var(--chat-plum); }
.chat-view .chat-transcript { max-width: 760px; min-height: 0; max-height: none; overflow: visible; padding: 0; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.chat-view .chat-empty { text-align: center; padding: 18vh 12px 0; }
.chat-view .chat-empty h2 { color: var(--chat-plum); font-weight: 600; margin: 0 0 6px; }
.chat-view .chat-msg { max-width: 100%; min-width: 0; line-height: 1.6; }
.chat-view .chat-msg.user {
  align-self: flex-end; max-width: 85%;
  background: var(--chat-plum-soft); border: 1px solid #e6d0dd;
  padding: 8px 12px; border-radius: 16px 16px 4px 16px;
}
.chat-view .chat-msg.assistant { align-self: stretch; padding: 2px 4px; }
.chat-view .chat-msg.pending .chat-bubble-text:empty::after { content: '…'; color: var(--chat-muted); }
.chat-view .chat-bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Request-scoped stage line: 思考中…（持续 X 秒） / 图片生成中… */
.chat-view .chat-activity {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 4px;
  color: var(--chat-muted); font-size: 0.85em; font-variant-numeric: tabular-nums;
}
.chat-view .chat-activity-dot {
  flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--chat-plum);
  animation: chat-activity-pulse 1.2s ease-in-out infinite;
}
@keyframes chat-activity-pulse { 50% { opacity: 0.3; transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) { .chat-view .chat-activity-dot { animation: none; opacity: 0.6; } }
.chat-view .chat-msg.pending:has(.chat-activity:not([hidden])) .chat-bubble-text:empty::after { content: none; }
/* Provider-disclosed public reasoning summary (推理摘要), shown before the answer */
.chat-view .chat-reasoning {
  margin: 0 0 8px; padding: 0 0 0 10px; border: 0; border-left: 2px solid var(--chat-line);
  background: transparent; color: var(--chat-muted); font-size: 0.86em;
}
.chat-view .chat-reasoning > summary {
  width: fit-content; cursor: pointer; font-weight: 500; color: var(--chat-muted); border-radius: 6px; padding: 1px 4px;
}
.chat-view .chat-reasoning > summary:hover { color: var(--chat-plum); }
.chat-view .chat-reasoning > summary:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 1px; }
.chat-view .chat-reasoning-text {
  white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; margin-top: 4px;
  max-height: 18rem; overflow-y: auto; overscroll-behavior: contain;
}
.chat-view .chat-result:empty { display: none; }
.chat-view .chat-response-details { align-self: flex-start; max-width: 100%; background: transparent; border: 0; padding: 0; }
.chat-view .chat-response-details > summary { color: var(--chat-muted); font-size: .82rem; font-weight: 500; }
.chat-view .chat-response-details[open] { align-self: stretch; }
.chat-view .chat-response-details > details { margin-block: .35rem; }
.chat-view .chat-msg pre, .chat-view .chat-msg code, .chat-view .chat-result pre {
  max-width: 100%; overflow-x: auto; white-space: pre; font-size: 0.88em;
}
.chat-view .chat-result img { max-width: 100%; height: auto; border-radius: 10px; }

.chat-view .chat-header, .chat-view .chat-bottom { flex-shrink: 0; }
.chat-view .chat-bottom {
  position: sticky; bottom: 0; z-index: 2;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--chat-ivory) 80%, transparent);
}
.chat-view .chat-composer {
  max-width: 760px; margin: 0 auto;
  background: var(--chat-paper); border: 1px solid var(--chat-line); border-radius: 20px;
  padding: 6px 8px; box-shadow: 0 2px 10px rgba(80, 40, 70, 0.08);
}
.chat-view .chat-composer:focus-within { border-color: var(--chat-plum); }
.chat-view .chat-input {
  display: block; width: 100%; box-sizing: border-box; min-width: 0; min-height: 2.4rem;
  resize: none; border: 0; outline: none; background: transparent;
  font: inherit; color: inherit; padding: 8px 6px 4px; margin: 0; max-height: 240px;
}
/* Composer action strip below the textarea */
.chat-view .chat-composer-tools {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 2px;
}
.chat-view .chat-tools-end { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chat-view .chat-plus-wrap { position: relative; }
.chat-view .chat-plus { width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 1.2em; }
.chat-view .chat-send, .chat-view .chat-stop { border-radius: 16px; min-height: 34px; }

.chat-view .chat-effort {
  display: inline-flex; align-items: center; gap: 2px; min-width: 0; height: 32px; box-sizing: border-box;
  padding: 0 2px 0 10px; border: 1px solid var(--chat-line); border-radius: 999px;
  font-size: 0.85em; color: var(--chat-muted); background: transparent;
}
.chat-view .chat-effort:focus-within { border-color: var(--chat-plum); }
.chat-view .chat-effort-label { margin: 0; font-weight: 500; white-space: nowrap; cursor: pointer; }
.chat-view .chat-effort-select {
  width: auto; min-width: 0; max-width: 8.5em; height: 28px; margin: 0; padding: 0 4px;
  border: 0; border-radius: 999px; background: transparent; box-shadow: none;
  font: inherit; font-weight: 600; color: var(--chat-plum); cursor: pointer;
}
.chat-view .chat-effort-select:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 1px; }
/* One focus ring around the whole 推理 pill instead of a second outline on the select half. */
@supports selector(:has(*)) {
  .chat-view .chat-effort-select:focus, .chat-view .chat-effort-select:focus-visible { outline: none; box-shadow: none; }
  .chat-view .chat-effort:has(.chat-effort-select:focus-visible) { outline: 2px solid var(--chat-plum); outline-offset: 2px; }
}
.chat-view .chat-effort-select:disabled { color: var(--chat-muted); font-weight: 500; cursor: not-allowed; }
.chat-view .chat-effort:has(.chat-effort-select:disabled) { border-style: dashed; }

.chat-view .chat-context-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; box-sizing: border-box; padding: 0 10px;
  border: 1px solid var(--chat-line); border-radius: 999px; background: transparent;
  color: var(--chat-muted); font: inherit; font-size: 0.85em; white-space: nowrap; cursor: pointer;
}
.chat-view .chat-context-btn:hover, .chat-view .chat-context-btn[aria-expanded="true"] { background: var(--chat-plum-soft); }
.chat-view .chat-context-btn:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 2px; }
.chat-view .chat-context-value { color: var(--chat-plum); font-weight: 600; font-variant-numeric: tabular-nums; }
.chat-view .chat-context-value:empty { display: none; }
.chat-view .chat-ring { flex: none; display: block; }
.chat-view .chat-ring-track { stroke: var(--chat-line); }
.chat-view .chat-ring-value { stroke: var(--chat-plum); }
/* Neutral ring for every state without an exact count */
.chat-view .chat-context-btn:is([data-state="none"], [data-state="idle"], [data-state="pending"], [data-state="error"]) .chat-ring-track {
  stroke-dasharray: 2.2 2.2; stroke: #cdbfae;
}
.chat-view .chat-context-btn[data-state="pending"] .chat-ring { animation: chat-ring-spin 1.2s linear infinite; }
@keyframes chat-ring-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .chat-view .chat-context-btn[data-state="pending"] .chat-ring { animation: none; opacity: 0.6; }
}
.chat-view .chat-context-btn[data-level="high"] .chat-ring-value,
.chat-view .chat-context-btn[data-level="high"] .chat-context-value { stroke: var(--chat-error); color: var(--chat-error); }
.chat-view .chat-context-pop {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 6;
  width: min(300px, 100%); box-sizing: border-box; padding: 10px 12px;
  background: var(--chat-paper); color: var(--chat-ink); border: 1px solid var(--chat-line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(60, 30, 55, 0.16); font-size: 0.85em; line-height: 1.5;
}
.chat-view .chat-context-pop:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 2px; }
.chat-view .chat-context-pop strong { display: block; color: var(--chat-plum); margin-bottom: 4px; }
.chat-view .chat-context-body p { margin: 0 0 4px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.chat-view .chat-context-body .chat-context-note { margin: 6px 0 0; color: var(--chat-muted); }
.chat-view .chat-context-refresh { padding: 2px 10px; font-size: 0.95em; border-radius: 999px; }

/* Drag-and-drop target highlight on the composer */
.chat-view .chat-composer.chat-dropping {
  border-color: var(--chat-plum); background: color-mix(in srgb, var(--chat-plum-soft) 55%, var(--chat-paper));
  outline: 2px dashed var(--chat-plum); outline-offset: 2px;
}

/* Separate, clearly labelled model refusal */
.chat-view .chat-refusal {
  margin: 6px 0 2px; padding: 8px 12px; border: 1px solid #ecc9cf; border-left: 3px solid var(--chat-error);
  border-radius: 10px; background: #fdf3f4; color: var(--chat-ink); font-size: 0.92em;
}
.chat-view .chat-refusal-label { display: block; color: var(--chat-error); font-size: 0.85em; font-weight: 600; margin-bottom: 2px; }
.chat-view .chat-refusal-text { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Rich reply formatting (class assigned by rich-reply.js). Scroll only inside code, tables and display math. */
.chat-view .chat-msg .chat-markdown { white-space: normal; overflow-wrap: anywhere; min-width: 0; max-width: 100%; }
.chat-view .chat-markdown > :first-child { margin-top: 0; }
.chat-view .chat-markdown > :last-child { margin-bottom: 0; }
.chat-view .chat-markdown :is(p, ul, ol, blockquote, pre, table, hr, .katex-display) { margin: 0.6em 0; }
.chat-view .chat-markdown :is(h1, h2, h3, h4, h5, h6) { margin: 1em 0 0.4em; line-height: 1.35; font-weight: 650; color: var(--chat-ink); }
.chat-view .chat-markdown h1 { font-size: 1.3em; }
.chat-view .chat-markdown h2 { font-size: 1.18em; }
.chat-view .chat-markdown h3 { font-size: 1.06em; }
.chat-view .chat-markdown :is(h4, h5, h6) { font-size: 1em; }
.chat-view .chat-markdown :is(ul, ol) { padding-left: 1.5em; }
.chat-view .chat-markdown li + li, .chat-view .chat-markdown li > :is(ul, ol) { margin-top: 0.2em; }
.chat-view .chat-markdown li > p { margin: 0.2em 0; }
.chat-view .chat-markdown blockquote {
  padding: 0.1em 0 0.1em 0.9em; border-left: 3px solid var(--chat-line); color: var(--chat-muted);
}
.chat-view .chat-markdown hr { border: 0; border-top: 1px solid var(--chat-line); }
.chat-view .chat-markdown a { color: var(--chat-plum); text-decoration: underline; text-underline-offset: 2px; }
.chat-view .chat-markdown img { max-width: 100%; height: auto; }
.chat-view .chat-markdown :not(pre) > code {
  white-space: pre-wrap; overflow-wrap: anywhere; overflow: visible;
  padding: 0.1em 0.35em; border-radius: 5px; background: #f4eee4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.chat-view .chat-markdown pre {
  max-width: 100%; box-sizing: border-box; overflow-x: auto; white-space: pre; overflow-wrap: normal;
  padding: 10px 12px; background: #f4eee4; border: 1px solid var(--chat-line); border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; line-height: 1.5;
}
.chat-view .chat-markdown pre code { white-space: inherit; font: inherit; background: none; padding: 0; overflow: visible; }
.chat-view .chat-markdown table {
  display: block; max-width: 100%; width: max-content; overflow-x: auto; border-collapse: collapse; font-size: 0.92em;
  overflow-wrap: normal;
}
.chat-view .chat-markdown :is(th, td) { padding: 5px 10px; border: 1px solid var(--chat-line); text-align: left; vertical-align: top; }
.chat-view .chat-markdown th { background: #f6efe6; font-weight: 600; }
.chat-view .chat-markdown .katex-display { max-width: 100%; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.chat-view .chat-markdown .katex { overflow-wrap: normal; }
.chat-view .chat-markdown .chat-citation { font-size: 0.78em; vertical-align: super; line-height: 0; margin-left: 1px; }
.chat-view .chat-markdown .chat-sources, .chat-view .chat-msg .chat-sources {
  margin: 0.8em 0 0; padding: 6px 0 0; border-top: 1px dashed var(--chat-line); font-size: 0.85em; color: var(--chat-muted);
}
.chat-view .chat-sources :is(ol, ul) { margin: 0.2em 0; padding-left: 1.4em; }
.chat-view .chat-sources a { color: var(--chat-plum); overflow-wrap: anywhere; }
.chat-view .chat-reasoning-text.chat-markdown, .chat-view .chat-reasoning-text .chat-markdown { font-size: 1em; }
.chat-view .chat-send { background: var(--chat-plum); border-color: var(--chat-plum); color: #fff; }
.chat-view .chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
/* Local attachment preparation: 正在加载附件… XX% */
.chat-view .chat-prep {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 0;
  color: var(--chat-muted); font-size: 0.82em; font-variant-numeric: tabular-nums;
}
.chat-view .chat-prep-text { flex: none; white-space: nowrap; }
.chat-view .chat-prep-bar { flex: 1 1 auto; min-width: 60px; height: 6px; accent-color: var(--chat-plum); }
/* Delete confirmation */
.chat-view .chat-delete-dlg { width: min(420px, calc(100vw - 24px)); }
.chat-view .chat-delete-dlg h3 { margin: 0 0 8px; color: var(--chat-plum); }
.chat-view .chat-delete-dlg p { margin: 0 0 10px; overflow-wrap: anywhere; }
.chat-view .chat-delete-dlg .chat-delete-error { margin: 0 0 10px; }
.chat-view .chat-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.chat-view .chat-delete-confirm { background: var(--chat-error); border-color: var(--chat-error); color: #fff; }
.chat-view .chat-delete-dlg button:disabled { opacity: 0.6; cursor: not-allowed; }
.chat-view .chat-menu {
  position: absolute; bottom: 44px; left: 0; z-index: 5; min-width: 200px;
  background: var(--chat-paper); border: 1px solid var(--chat-line); border-radius: 12px;
  padding: 4px; box-shadow: 0 8px 24px rgba(60, 30, 55, 0.16);
}
.chat-view .chat-menu hr { border: 0; border-top: 1px solid var(--chat-line); margin: 4px 0; }
.chat-view .chat-menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: inherit; font: inherit; cursor: pointer;
}
.chat-view .chat-menu-item:hover { background: var(--chat-plum-soft); }
.chat-view .chat-menu-item:focus-visible { outline-offset: -3px; }
.chat-view .chat-menu-item[aria-checked="true"]::before { content: '✓ '; color: var(--chat-plum); }
.chat-view .chat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 4px 2px; }
.chat-view .chat-chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 220px;
  background: var(--chat-plum-soft); color: var(--chat-plum); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 0.85em;
}
.chat-view .chat-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-view .chat-chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 6px; font-size: 1.1em; }
.chat-view .chat-chip-clear { padding: 2px 8px; font-size: 0.8em; }
.chat-view .chat-error { color: var(--chat-error); max-width: 760px; margin: 4px auto; }
.chat-view .chat-status { color: var(--chat-muted); font-size: 0.8em; max-width: 760px; margin: 4px auto 0; min-height: 1em; }

.chat-view .chat-dialog {
  width: min(560px, calc(100vw - 24px)); max-height: min(80dvh, 720px);
  border: 1px solid var(--chat-line); border-radius: 16px; padding: 16px;
  background: var(--chat-paper); color: var(--chat-ink);
}
.chat-view .chat-dialog::backdrop { background: rgba(45, 34, 48, 0.35); }
.chat-view .chat-dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chat-view .chat-dialog-head h3 { margin: 0; color: var(--chat-plum); }
.chat-view .chat-dialog textarea, .chat-view .chat-dialog input { width: 100%; box-sizing: border-box; }
.chat-view .chat-dialog .field { margin-bottom: 12px; }
.chat-view .chat-model-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; max-height: 50dvh; overflow-y: auto; }
.chat-view .chat-model-opt {
  display: flex; justify-content: space-between; gap: 8px; text-align: left; width: 100%;
  border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; color: inherit; font: inherit; cursor: pointer;
}
.chat-view .chat-model-opt:hover { background: var(--chat-plum-soft); }
.chat-view .chat-model-opt:focus-visible { outline-offset: -3px; }
.chat-view .chat-model-opt[aria-pressed="true"] { color: var(--chat-plum); font-weight: 600; }
.chat-view .chat-model-id { overflow-wrap: anywhere; }
.chat-view .chat-model-manual { color: var(--chat-plum); font-style: italic; }

.chat-dock { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.chat-dock .chat-dock-item {
  text-align: left; border: 0; background: transparent; color: inherit; font: inherit; font-size: 0.9em;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-dock .chat-dock-item:hover { background: var(--chat-plum-soft); }
.chat-dock .chat-dock-item[aria-current="true"] { background: var(--chat-plum-soft); color: var(--chat-plum); font-weight: 600; }
.chat-dock .chat-dock-item:disabled { opacity: 0.5; cursor: not-allowed; }
/* Row = title button + ⋯ button; the menu sits in flow below the row so the scrolling dock never clips it. */
.chat-dock .chat-dock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; border-radius: 8px; }
.chat-dock .chat-dock-row .chat-dock-item { flex: 1 1 0; min-width: 0; }
.chat-dock .chat-dock-more {
  flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--chat-muted); font: inherit; line-height: 1; cursor: pointer; opacity: 0.55;
}
.chat-dock .chat-dock-row:hover .chat-dock-more, .chat-dock .chat-dock-more:focus-visible,
.chat-dock .chat-dock-more[aria-expanded="true"] { opacity: 1; }
.chat-dock .chat-dock-more:hover, .chat-dock .chat-dock-more[aria-expanded="true"] { background: var(--chat-plum-soft); color: var(--chat-plum); }
.chat-dock .chat-dock-more:focus-visible, .chat-dock .chat-dock-menu-item:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: -2px; }
.chat-dock .chat-dock-more:disabled { opacity: 0.3; cursor: not-allowed; }
.chat-dock .chat-dock-menu {
  flex: 0 0 100%; box-sizing: border-box; margin: 2px 0 4px; padding: 4px;
  background: var(--chat-paper); border: 1px solid var(--chat-line); border-radius: 10px;
  box-shadow: 0 4px 14px rgba(60, 30, 55, 0.12);
}
.chat-dock .chat-dock-menu-item {
  display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--chat-error); font: inherit; font-size: 0.9em; cursor: pointer;
}
.chat-dock .chat-dock-menu-item:hover { background: #fdf3f4; }

/* Copy-answer control under finalized assistant replies (always visible; tooltip on hover/keyboard focus only) */
.chat-view .chat-copy { display: flex; align-items: center; gap: 6px; margin-top: 6px; min-height: 28px; }
.chat-view .chat-copy-btn {
  position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 7px; background: transparent; color: var(--chat-muted); cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.chat-view .chat-copy-icon { position: relative; display: block; width: 14px; height: 14px; }
.chat-view .chat-copy-icon::before, .chat-view .chat-copy-icon::after {
  content: ''; position: absolute; width: 9px; height: 10px; box-sizing: border-box;
  border: 1.5px solid currentColor; border-radius: 2.5px;
}
.chat-view .chat-copy-icon::before { left: 0; top: 0; opacity: 0.7; }
.chat-view .chat-copy-icon::after { right: 0; bottom: 0; background: var(--chat-ivory); }
.chat-view .chat-copy-btn:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 1px; color: var(--chat-plum); }
.chat-view .chat-copy-tip {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 3; padding: 3px 8px; border-radius: 6px;
  background: var(--chat-ink); color: var(--chat-ivory); font-size: 0.75rem; line-height: 1.4; white-space: nowrap;
  pointer-events: none; opacity: 0; visibility: hidden; transition: opacity 0.12s ease;
}
.chat-view .chat-copy-btn:focus-visible:not([data-tipoff]) .chat-copy-tip { opacity: 1; visibility: visible; }
@media (hover: hover) and (pointer: fine) {
  .chat-view .chat-copy-btn:hover { background: var(--chat-plum-soft); color: var(--chat-plum); }
  .chat-view .chat-copy-btn:hover:not([data-tipoff]) .chat-copy-tip { opacity: 1; visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { .chat-view .chat-copy-tip { transition: none; } }
.chat-view .chat-copy-msg { color: var(--chat-muted); font-size: 0.78rem; }
.chat-view .chat-copy-msg[data-state="error"] { color: var(--chat-error); }

@media (max-width: 600px) {
  .chat-view { border-radius: 0; min-height: calc(100dvh - 60px); }
  .chat-view .chat-msg.user { max-width: 92%; }
  .chat-view .chat-header-actions .chat-icon-btn { padding: 4px 8px; }
  .chat-view .chat-model-btn { max-width: 45vw; }
  .chat-view .chat-bottom { padding-inline: 8px; }
  .chat-view .chat-composer { padding: 6px; }
  .chat-view .chat-composer-tools { gap: 4px; }
  .chat-view .chat-tools-end { gap: 4px; }
  .chat-view .chat-effort-select { max-width: 6.5em; }
  .chat-view .chat-context-btn { padding: 0 8px; }
  .chat-view .chat-send, .chat-view .chat-stop { padding-inline: 12px; }
}
/* Anchored mobile chat: the shell height is the measured visual viewport, so no minimum may push the composer out. */
html.vv-chat .chat-view { min-height: 0; }
@media (max-width: 380px) {
  /* Percentage/count stays in the ring, accessible name and popover. */
  .chat-view .chat-context-value { display: none; }
  .chat-view .chat-effort { padding-left: 8px; }
  .chat-view .chat-effort-select { max-width: 5.5em; }
}

/* Reply visuals (interactive-reply.js): static SVG drawings and studio-ui widgets */
.chat-view .chat-visual {
  margin: 0.7em 0; padding: 0; max-width: 100%; min-width: 0;
  background: var(--chat-paper); border: 1px solid var(--chat-line); border-radius: 12px; overflow: hidden;
}
.chat-view .chat-visual-title {
  padding: 8px 12px 0; color: var(--chat-plum); font-weight: 600; font-size: 0.92em; overflow-wrap: anywhere;
}
.chat-view .chat-visual-stage { padding: 10px; display: flex; justify-content: center; }
.chat-view .chat-visual-stage > svg {
  display: block; width: 100%; max-width: 100%; height: auto; max-height: min(60dvh, 480px); overflow: hidden;
}
.chat-view .chat-visual-stage.is-grabbable > svg { cursor: grab; }
.chat-view .chat-visual-stage.is-dragging > svg { cursor: grabbing; }
.chat-view .chat-visual-drag-target { touch-action: none; }
.chat-view .chat-visual-stage.has-drag { box-shadow: inset 0 0 0 0 transparent; transition: box-shadow 0.15s ease; }
.chat-view .chat-visual-stage.is-dragging,
.chat-view .chat-visual-stage.is-focus { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--chat-plum) 35%, transparent); }
.chat-view .chat-visual-controls {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px;
  border-top: 1px solid var(--chat-line); background: color-mix(in srgb, var(--chat-ivory) 70%, var(--chat-paper));
  font-size: 0.9em;
}
.chat-view .chat-visual-control {
  display: grid; grid-template-columns: minmax(4.5em, max-content) minmax(0, 1fr) auto; align-items: center; gap: 10px;
}
.chat-view .chat-visual-label { color: var(--chat-muted); font-weight: 500; overflow-wrap: anywhere; }
.chat-view .chat-visual-range {
  width: 100%; min-width: 0; margin: 0; min-height: 28px; accent-color: var(--chat-plum); cursor: pointer;
}
.chat-view .chat-visual-value {
  min-width: 3.5em; text-align: right; color: var(--chat-plum); font-weight: 600; font-variant-numeric: tabular-nums;
}
.chat-view .chat-visual-select {
  grid-column: 2 / -1; justify-self: start; max-width: 100%; min-height: 32px; padding: 0 10px;
  border: 1px solid var(--chat-line); border-radius: 999px; background: var(--chat-paper);
  font: inherit; color: var(--chat-plum); font-weight: 600; cursor: pointer;
}
.chat-view .chat-visual-select:hover { background: var(--chat-plum-soft); }
.chat-view .chat-visual-drags { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-view .chat-visual-drag {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 32px; padding: 4px 12px;
  border: 1px dashed #d8c7d2; border-radius: 999px; background: transparent;
  font: inherit; color: var(--chat-ink); cursor: move; touch-action: manipulation;
}
.chat-view .chat-visual-drag:hover, .chat-view .chat-visual-drag.is-active {
  border-style: solid; border-color: var(--chat-plum); background: var(--chat-plum-soft);
}
.chat-view .chat-visual-coords { color: var(--chat-muted); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.chat-view .chat-visual-reset {
  align-self: flex-end; min-height: 30px; padding: 2px 14px; border-radius: 999px;
  border: 1px solid var(--chat-line); background: transparent; color: var(--chat-muted); font: inherit; cursor: pointer;
}
.chat-view .chat-visual-reset:hover { color: var(--chat-plum); background: var(--chat-plum-soft); }
.chat-view .chat-visual-reset:active, .chat-view .chat-visual-drag:active { transform: translateY(1px); }
.chat-view :is(.chat-visual-range, .chat-visual-select, .chat-visual-drag, .chat-visual-reset):focus-visible {
  outline: 2px solid var(--chat-plum); outline-offset: 2px;
}
@media (max-width: 480px) {
  .chat-view .chat-visual-stage { padding: 6px; }
  .chat-view .chat-visual-control { grid-template-columns: minmax(0, 1fr) auto; row-gap: 2px; }
  .chat-view .chat-visual-label { grid-column: 1 / -1; }
  .chat-view .chat-visual-select { grid-column: 1 / -1; width: 100%; }
  .chat-view .chat-visual-reset { align-self: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-view .chat-visual-stage.has-drag { transition: none; }
  .chat-view .chat-visual-reset:active, .chat-view .chat-visual-drag:active { transform: none; }
}

/* Generated file cards below a reply (markup from Codex) */
.chat-view .chat-files { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-width: 100%; }
.chat-view .chat-file-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
  padding: 8px 10px; background: var(--chat-paper); border: 1px solid var(--chat-line); border-radius: 10px;
}
.chat-view .chat-file-kind {
  min-width: 2.6em; padding: 2px 6px; box-sizing: border-box; text-align: center; border-radius: 6px;
  background: var(--chat-plum-soft); color: var(--chat-plum); font-size: 0.72em; font-weight: 650;
  letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;
}
.chat-view .chat-file-name { min-width: 0; overflow-wrap: anywhere; word-break: break-word; font-size: 0.9em; line-height: 1.4; }
.chat-view .chat-file-download {
  min-height: 30px; padding: 2px 12px; border-radius: 999px; border: 1px solid var(--chat-line);
  background: transparent; color: var(--chat-plum); font: inherit; font-size: 0.85em; font-weight: 600; cursor: pointer;
}
.chat-view .chat-file-download:hover { background: var(--chat-plum-soft); border-color: #e6d0dd; }
.chat-view .chat-file-download:focus-visible { outline: 2px solid var(--chat-plum); outline-offset: 2px; }
.chat-view .chat-file-download:disabled { opacity: 0.55; cursor: not-allowed; }
.chat-view .chat-file-status { grid-column: 1 / -1; color: var(--chat-muted); font-size: 0.78em; }
.chat-view .chat-file-inline {
  padding: 0; border: 0; background: none; color: var(--chat-plum);
  font: inherit; text-decoration: underline; text-align: left; cursor: pointer;
}
@media (max-width: 420px) {
  .chat-view .chat-file-card { grid-template-columns: auto minmax(0, 1fr); }
  .chat-view .chat-file-download { grid-column: 1 / -1; justify-self: stretch; }
}
