/* ══ Chat: Messages, Thinking, Exec Cards, Approval Cards, Token Bar ══ */

:root {
  --chat-font-size: 0.9rem;
}

#messages.chat-font-small {
  --chat-font-size: 0.8rem;
}

#messages.chat-font-medium {
  --chat-font-size: 0.9rem;
}

#messages.chat-font-large {
  --chat-font-size: 1.05rem;
}

#messages {
  padding-left: 64px;
  padding-right: 64px;
}

.status-dot {
  background: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  transition: background 0.3s;
}

.status-dot.connected {
  background: var(--ok);
  animation: 1.8s ease-out infinite status-live-pulse;
}

.status-dot.connecting {
  background: var(--warn);
  animation: 1s infinite pulse;
}

.status-text-live {
  color: var(--ok) !important;
  font-weight: 600;
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.45);
}

@keyframes status-live-pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  70% {
    opacity: 0.6;
    transform: scale(1.3);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.msg {
  border-radius: var(--radius);
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  max-width: 80%;
  padding: 10px 14px;
  font-size: var(--chat-font-size);
  line-height: 1.6;
  animation: 0.2s ease-out msg-in;
}

.msg.user {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  color: var(--text);
  align-self: flex-end;
}

.msg.assistant {
  background: var(--assistant-bg);
  border: 1px solid var(--assistant-border);
  color: var(--text);
  align-self: flex-start;
  white-space: normal;
}

.msg p {
  margin: 0;
  white-space: normal;
}

/* ── Markdown block elements inside messages ── */

.msg h1, .msg h2, .msg h3, .msg h4, .msg h5, .msg h6 {
  color: var(--text-strong);
  font-weight: 600;
  margin: 0.6em 0 0.3em;
  line-height: 1.3;
}

.msg h1 { font-size: 1.3em; }
.msg h2 { font-size: 1.15em; }
.msg h3 { font-size: 1.05em; }
.msg h4, .msg h5, .msg h6 { font-size: 1em; }

.msg h1:first-child, .msg h2:first-child, .msg h3:first-child {
  margin-top: 0;
}

.msg ul, .msg ol {
  margin: 0.4em 0;
  padding-left: 1.5em;
}

.msg ul { list-style-type: disc; }
.msg ol { list-style-type: decimal; }

.msg li {
  margin: 0.15em 0;
}

.msg blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 0.4em 0;
  padding: 0.2em 0.8em;
  color: var(--muted);
}

.msg hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.6em 0;
}

.msg em {
  font-style: italic;
}

.msg del {
  text-decoration: line-through;
  opacity: 0.7;
}

.msg a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.msg a:hover {
  color: var(--accent-hover);
}

.msg.system {
  color: var(--muted);
  background: 0 0;
  align-self: center;
  padding: 4px 0;
  font-size: 0.8rem;
}

.msg.system.system-notice {
  background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 85%, transparent);
  border: 1px solid var(--border);
  border-color: color-mix(in srgb, var(--border-strong) 65%, transparent);
  border-radius: 12px;
  align-items: center;
  gap: 6px;
  max-width: min(88%, 640px);
  padding: 6px 14px;
  white-space: normal;
  display: inline-flex;
}

.msg.system.system-notice strong {
  color: var(--text);
  font-weight: 600;
}

.msg.system.system-notice.system-notice-sandbox::before {
  content: "";
  background: var(--muted);
  border-radius: 999px;
  flex-shrink: 0;
  width: 6px;
  height: 6px;
}

.msg.system.system-notice.system-notice-sandbox.is-enabled {
  background: var(--surface2);
  background: color-mix(in srgb, var(--ok) 8%, var(--surface2));
  border-color: color-mix(in srgb, var(--ok) 28%, var(--border));
}

.msg.system.system-notice.system-notice-sandbox.is-enabled::before {
  background: var(--ok);
}

.msg.system.system-notice.system-notice-sandbox.is-disabled {
  background: var(--surface2);
  background: color-mix(in srgb, var(--warn) 8%, var(--surface2));
  border-color: color-mix(in srgb, var(--warn) 24%, var(--border));
}

.msg.system.system-notice.system-notice-sandbox.is-disabled::before {
  background: var(--warn);
}

.msg.error {
  color: var(--error);
  background: 0 0;
  align-self: center;
  padding: 4px 0;
  font-size: 0.8rem;
}

.msg.error-card {
  background: var(--surface);
  border: 1px solid var(--error);
  border-radius: 8px;
  align-self: center;
  align-items: flex-start;
  gap: 10px;
  max-width: 420px;
  padding: 12px 16px;
  display: flex;
}

.error-icon {
  flex-shrink: 0;
  font-size: 1.4rem;
  line-height: 1;
}

.error-body {
  flex: 1;
  min-width: 0;
}

.error-title {
  color: var(--error);
  margin-bottom: 2px;
  font-size: 0.85rem;
  font-weight: 600;
}

.error-detail {
  color: var(--fg);
  opacity: 0.85;
  font-size: 0.8rem;
}

.error-continue-btn {
  margin-top: 8px;
  font-size: 0.8rem;
  padding: 4px 16px;
}

.error-countdown {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
  font-size: 0.75rem;
}

.error-countdown.reset-ready {
  color: var(--success, #22c55e);
  font-weight: 600;
}

/* ── Thinking ── */

.msg.thinking {
  background: var(--assistant-bg);
  border: 1px solid var(--assistant-border);
  align-items: center;
  padding: 14px 18px;
  display: flex;
}

.msg.thinking.session-loading {
  gap: 10px;
  align-self: center;
}

.session-loading-label {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.thinking-dots {
  align-items: center;
  gap: 5px;
  display: flex;
}

.thinking-dots span {
  background: var(--muted);
  border-radius: 50%;
  width: 7px;
  height: 7px;
  animation: 1.2s ease-in-out infinite dot-bounce;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }

.thinking-text {
  color: var(--muted);
  white-space: pre-wrap;
  text-overflow: ellipsis;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.4;
  animation: 2s ease-in-out infinite thinking-pulse;
  display: -webkit-box;
  overflow: hidden;
}

@keyframes thinking-pulse {
  0%, to { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ── Tool events ── */

.msg.tool-event {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.msg.tool-ok { color: var(--ok); }
.msg.tool-err { color: var(--error); }

/* ── Exec cards ── */

.msg.exec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: normal;
  flex-direction: column;
  align-self: flex-start;
  gap: 4px;
  max-width: 70%;
  padding: 8px 12px;
  display: flex;
}
.msg.exec-card:not(:has(.exec-body.open)) {
  padding-bottom: 4px;
  gap: 0;
}
.msg.exec-card:not(:has(.exec-body.open)) .exec-status {
  display: none;
}

.msg.exec-card.exec-ok { border-color: var(--border); }
.msg.exec-card.exec-err { border-color: var(--error); }

.exec-prompt {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.4;
}

.exec-prompt-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exec-expand-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 4px 6px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.exec-expand-btn::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.3s ease;
}
.exec-expand-btn.open::before {
  transform: rotate(180deg);
}
.exec-expand-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ── Collapsible body ─────────────────────────────── */
.exec-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}
.exec-body.open {
  max-height: 2000px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.25s ease 0.05s;
}
.exec-body > * {
  min-height: 0;
  overflow: hidden;
}

.exec-card.exec-err .exec-prompt-char { color: var(--error); }

.exec-status {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: italic;
}

.exec-output {
  font-family: var(--font-mono);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  white-space: pre;
  border-radius: 4px;
  max-height: 200px;
  margin: 0;
  padding: 6px 8px;
  font-size: 0.78rem;
  line-height: 1.45;
  overflow: auto;
}

.exec-output.exec-stderr { color: var(--warn); }

.exec-exit {
  font-family: var(--font-mono);
  color: var(--error);
  font-size: 0.72rem;
}

.exec-error-detail {
  color: var(--error);
  font-size: 0.78rem;
}

.skill-hint {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

.skill-hint a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.skill-hint a:hover {
  color: var(--text);
}

/* ── Tool card collapsible body (legacy) ────────────────── */

/* ── Collapsible chat footer / model info ────────────────── */
.msg-model-footer {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin 0.2s ease;
  margin: 0;
  height: 0;
}
.msg-model-footer.visible {
  max-height: 200px;
  opacity: 1;
  margin-top: 2px;
}

/* ── Action bar ───────────────────────────────────── */
.msg-action-bar {
  max-height: 80px;
  opacity: 1;
  margin-top: 2px;
  display: flex;
  gap: 2px;
  align-items: center;
}
.msg-action-bar.visible {
  max-height: 80px;
  opacity: 1;
  margin-top: 2px;
}

.map-link-row {
  width: 100%;
  align-items: baseline;
  gap: 8px;
  display: flex;
}

.map-link-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-link-meta {
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.msg-table-wrap {
  max-width: 100%;
  margin: 6px 0;
  overflow-x: auto;
}

.msg-table {
  border: 1px solid var(--border);
  border-collapse: collapse;
  min-width: 100%;
  background: var(--surface);
  white-space: normal;
}

.msg-table th,
.msg-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  vertical-align: top;
}

.msg-table th {
  background: var(--surface2);
  color: var(--text-strong);
  font-weight: 600;
}
/* ── Message inline elements ── */

.msg code {
  background: var(--surface2);
  font-family: var(--font-mono);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
}

.msg pre {
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 6px 0;
  padding: 10px 12px;
  overflow-x: auto;
}

.msg pre code {
  background: 0 0;
  padding: 0;
}

/* ── Syntax highlighting (Shiki) ── */

.code-block {
  position: relative;
}

.code-lang-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.7em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
  pointer-events: none;
  font-family: var(--font-mono);
}

/* Shiki dual-theme: dark mode uses --shiki-dark colors */
[data-theme="dark"] .shiki,
[data-theme="dark"] .shiki span {
  color: var(--shiki-dark) !important;
  background-color: transparent !important;
}

/* Light mode uses Shiki's inline default theme colors. */
[data-theme="light"] .shiki,
[data-theme="light"] .shiki span {
  background-color: transparent !important;
}

/* Reset Shiki container to match existing pre styling */
.msg pre .shiki {
  background: transparent !important;
  margin: 0;
  padding: 0;
}

.msg strong {
  color: var(--text-strong);
  font-weight: 600;
}

.msg-channel-footer {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.voice-icon {
  width: 12px;
  height: 12px;
  display: inline-block;
  opacity: 0.85;
  background-color: currentColor;
  -webkit-mask-image: url("../icons/masks/mask-706201b58364b1d8.svg");
  mask-image: url("../icons/masks/mask-706201b58364b1d8.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

/* ── Theme Toggle ── */

.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: center;
  gap: 2px;
  padding: 2px;
  display: flex;
}

.theme-btn {
  width: 28px;
  height: 28px;
  color: var(--muted);
  cursor: pointer;
  background: 0 0;
  border: none;
  border-radius: 4px;
  justify-content: center;
  align-items: center;
  transition: all 0.15s;
  display: flex;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.theme-btn.active {
  color: var(--text-strong);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

.theme-btn svg,
.theme-btn .icon {
  width: 16px;
  height: 16px;
}

/* ── Approval Cards ── */

.approval-card {
  background: var(--surface2);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  flex-direction: column;
  align-self: center;
  gap: 8px;
  max-width: 90%;
  padding: 12px 16px;
  display: flex;
}

.approval-label {
  color: var(--warn);
  font-size: 0.8rem;
  font-weight: 600;
}

.approval-cmd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
  padding: 6px 10px;
  font-size: 0.82rem;
  display: block;
}

.approval-btns {
  gap: 8px;
  display: flex;
}

.approval-btn {
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  padding: 5px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: opacity 0.15s;
}

.approval-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.approval-allow { background: var(--ok); color: #fff; }
.approval-deny { background: var(--error); color: #fff; }

.approval-countdown {
  color: var(--muted);
  text-align: right;
  font-size: 0.72rem;
}

.approval-status {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

.approval-resolved { opacity: 0.6; }
.approval-expired { opacity: 0.4; }

/* ── Question Cards ── */

.question-card {
  background: var(--bg-elevated, var(--surface2));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  flex-direction: column;
  align-self: center;
  gap: 0;
  max-width: 90%;
  min-width: min(320px, calc(100vw - 32px));
  padding: 0;
  display: flex;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 767px) {
  .question-card {
    max-width: calc(100vw - 16px);
    min-width: 0;
  }

  .question-title-row {
    padding: 8px 10px;
  }

  .question-body-inner {
    padding: 0 10px 10px;
    gap: 8px;
  }

  .question-option-card {
    padding: 12px 10px;
    min-height: 44px;
  }

  .question-custom-answer {
    padding: 12px 10px;
    min-height: 44px;
  }

  .question-text-input {
    min-height: 44px;
    font-size: 16px;
    padding: 10px;
  }

  .question-submit-btn {
    min-height: 44px;
    min-width: 44px;
  }
}

.question-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 8px;
  cursor: default;
}

.question-header {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  flex-shrink: 0;
}

.question-collapsed-preview {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.question-collapsed-preview.visible {
  display: flex;
}

.question-collapsed-preview .question-summary-prompt {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
}

.question-collapsed-preview .question-summary-answer {
  color: var(--ok);
  font-weight: 500;
  font-size: 0.82rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.question-awaiting {
  color: var(--muted);
  font-style: italic;
  font-size: 0.78rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.question-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  transition: background 0.15s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.question-toggle-btn:hover {
  background: var(--border);
  border-radius: 4px;
}

.question-toggle-btn .icon-chevron-down {
  transition: transform 0.3s ease;
  display: inline-block;
  font-size: 0.65em;
  transform: rotate(180deg);
}

.question-toggle-btn.closed .icon-chevron-down {
  transform: rotate(0deg);
}

.question-body {
  overflow: hidden;
}

.question-body-inner {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

.question-body.closed .question-body-inner {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.question-prompt {
  color: var(--text);
  font-size: 0.88rem;
  white-space: pre-wrap;
  line-height: 1.45;
}

.question-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.question-option-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.84rem;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  width: 100%;
}

.question-option-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
}

.question-option-card:active {
	background: var(--accent);
	color: #fff;
	border-color: var(--accent);
}

.question-option-card.selected {
	border-color: var(--accent);
	background: var(--accent);
	color: #fff;
}

.question-option-card:disabled {
	cursor: default;
	opacity: 0.5;
}

.question-option-card:disabled:hover {
	border-color: var(--border);
	background: var(--surface);
}

.question-option-card.selected:disabled {
	opacity: 1;
	border-color: var(--accent);
	background: var(--accent);
	color: #fff;
}

.question-checkmark {
	margin-left: 6px;
	font-weight: 600;
}

.question-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.question-text-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.84rem;
  color: var(--text);
  outline: none;
  font-family: inherit;
}

.question-text-input:focus {
  border-color: var(--accent);
}

.question-text-input::placeholder {
  color: var(--muted);
}

.question-submit-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.question-submit-btn:hover {
  opacity: 0.85;
}

.question-resolved {
	/* Card stays fully visible after resolution. */
}

.question-resolved .question-text-input,
.question-resolved .question-submit-btn {
	pointer-events: none;
}

.question-resolved .question-text-input {
	opacity: 0.5;
}

.question-resolved .question-card:hover {
	border-color: var(--accent);
}

.question-summary {
  display: none;
}

.question-custom-answer {
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.84rem;
  color: #fff;
  background: var(--accent);
  width: 100%;
  text-align: left;
}

.question-custom-answer .question-checkmark {
  margin-left: 6px;
  font-weight: 600;
}

.question-resolved .question-text-input,
.question-resolved .question-submit-btn {
  pointer-events: none;
}

.question-resolved .question-text-input {
	opacity: 0.5;
}

.question-resolved .question-card:hover {
	border-color: var(--accent);
}

.question-summary-prompt {
	color: var(--text);
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.question-summary-answer {
	color: var(--ok);
	font-weight: 500;
}

.question-collapsed .question-toggle-btn {
  display: none;
}

.question-response-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
  margin-top: 4px;
}

/* ── Token bar ── */

.token-bar {
  color: var(--muted);
  text-align: left;
  border: 0;
  background: transparent;
  padding: 0 2px;
  font-size: 0.8em;
  line-height: 1.35;
  min-width: 0;
  max-width: 180px;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.token-bar:empty { display: none; }

.chat-command-prompt {
  min-width: 20px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.chat-command-prompt-hidden {
  display: none;
}

.chat-input-row {
  border-top: 0;
  background: var(--bg);
  min-width: 0;
  padding: 16px 24px 18px;
}

.chat-composer {
  width: min(100%, 980px);
  min-width: 0;
  box-sizing: border-box;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
  padding: 14px 16px 12px;
}

.chat-composer:focus-within {
  border-color: var(--border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.08);
}

.chat-composer-input-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.chat-composer-textarea {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  max-height: 140px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 4px 2px;
  overflow-x: hidden;
  overflow-wrap: anywhere;
}

.chat-composer-textarea::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

.chat-composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.chat-composer-tools,
.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-composer-tools {
  flex: 0 1 auto;
}

.chat-composer-footer .token-bar {
  flex: 0 0 auto;
  margin-right: auto;
}

.chat-composer-footer .model-dropdown {
  top: auto;
  bottom: calc(100% + 6px);
}

.chat-composer-footer #modelDropdown {
  width: clamp(280px, 85vw, 640px);
  min-width: 280px;
  max-width: calc(100vw - 32px);
  overflow: hidden;
}

.chat-composer-footer .model-combo-btn {
  min-height: 36px;
  border-radius: 14px;
  padding: 6px 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
}

.chat-composer-footer #modelComboBtn {
  max-width: min(56vw, 360px);
}

#modelComboLabel {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-composer-icon-btn,
.chat-composer-send-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
}

.chat-composer-icon-btn {
  background: var(--surface);
  color: var(--muted);
}

.chat-composer-icon-btn:hover:not(:disabled),
.chat-composer-icon-btn:focus-visible:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--text);
  outline: none;
}

.chat-composer-send-btn {
  border-color: transparent;
  background: var(--text);
  color: var(--surface);
}

.chat-composer-send-btn:hover:not(:disabled),
.chat-composer-send-btn:focus-visible:not(:disabled) {
  background: var(--accent);
  outline: none;
}

.chat-composer-send-btn.is-stop {
  background: #ef4444;
  color: #fff;
}

.chat-composer-send-btn.is-stop:hover:not(:disabled),
.chat-composer-send-btn.is-stop:focus-visible:not(:disabled) {
  background: #dc2626;
}

.chat-composer-icon-btn:disabled,
.chat-composer-send-btn:disabled {
  cursor: default;
  opacity: 0.4;
}

.chat-input-row.command-mode {
  border-top-color: var(--accent-subtle);
}

.chat-input-row.command-mode #chatInput {
  font-family: var(--font-mono);
}

.msg-model-footer {
  color: var(--muted);
  text-align: right;
  margin-top: 4px;
  font-size: 0.68rem;
}

.msg-token-speed {
  font-variant-numeric: tabular-nums;
}

.msg-token-speed-fast {
  color: var(--ok);
}

.msg-token-speed-slow {
  color: var(--error);
}

.reply-medium-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.msg-voice-action {
  margin-left: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
}

.msg-voice-action:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.msg-voice-action:disabled {
  opacity: 0.55;
  cursor: default;
}

.msg-voice-player-slot {
  margin-top: 6px;
}

.msg-voice-warning {
  margin-top: 6px;
  max-width: 320px;
}

/* ── Message action bar (copy, retry, fork) ── */

.msg-action-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 2px;
  position: relative;
}

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s, background 0.15s;
}

.msg-action-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.msg-action-btn-active {
  color: var(--accent);
  opacity: 0.7;
  pointer-events: none;
}

/* Retry popover */

.msg-action-popover {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 24px;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  z-index: 50;
  padding: 4px;
  animation: msg-action-pop-in 0.12s ease-out;
}

@keyframes msg-action-pop-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-action-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.msg-action-popover-item:hover {
  background: var(--bg-hover);
}

.msg-action-popover-item .icon {
  color: var(--muted);
  flex-shrink: 0;
}

/* ── Waveform Audio Player ── */

.waveform-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 320px;
}

.waveform-play-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.waveform-play-btn:hover {
  background: var(--accent-hover);
}

.waveform-play-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

.waveform-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 1.5px;
  height: 28px;
  cursor: pointer;
}

.waveform-bar {
  flex: 1;
  min-width: 2px;
  background: var(--border-strong);
  border-radius: 1px;
}

.waveform-bar.played {
  background: var(--accent);
}

.waveform-duration {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  min-width: 2.5em;
  text-align: right;
}

/* ── New content indicator (smart auto-scroll) ── */

.new-content-indicator {
  position: sticky;
  bottom: 8px;
  z-index: 10;
  align-self: flex-end;
  margin-top: -36px;
  margin-right: 8px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 4px 12px;
  font-size: 0.78rem;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s;
  animation: 0.2s ease-out msg-in;
}

.new-content-indicator:hover {
  background: var(--surface2);
  border-color: var(--accent-hover);
}

/* Font size presets */
.chat-font-small { --chat-font-size: 0.8rem; }
.chat-font-medium { --chat-font-size: 0.9rem; }
.chat-font-large { --chat-font-size: 1.05rem; }

/* Welcome card respects font size setting */
#messages #welcomeCard {
  font-size: var(--chat-font-size);
}
#messages #welcomeCard h2 {
  font-size: calc(var(--chat-font-size) * 1.4);
}
#messages #welcomeCard p,
#messages #welcomeCard li {
  font-size: calc(var(--chat-font-size) * 0.95);
}
