/* AI Chat Panel */
.panel {
  position: relative;
  width: 500px;
  min-width: 300px;
  max-width: 50%;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden {
  display: none;
}

/* ── Header ─────────────────────────────────────────────── */
.headerActions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.headerBtn {
  background: none;
  border: none;
  color: var(--fg-secondary);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.headerBtn:hover {
  background: var(--bg-highlight);
  color: var(--fg-primary);
}

.headerBtnActive {
  color: var(--accent);
}

.headerBtnDanger {
  color: var(--error);
}

.attachIndicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-sm);
  color: var(--fg-secondary);
}

.statusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.statusDotAttached {
  background: var(--success);
}

.statusDotDetached {
  background: var(--fg-muted);
}

.terminalSelect {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-primary);
  font-size: var(--font-sm);
  font-family: var(--font-ui);
  padding: 1px 4px;
  max-width: 160px;
  outline: none;
}

.terminalSelect:focus {
  border-color: var(--accent);
}

.terminalName {
  font-size: var(--font-xs);
  color: var(--fg-secondary);
  padding: 1px 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frozenBanner {
  padding: 4px 16px;
  font-size: var(--font-xs);
  color: var(--fg-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

/* ── Messages ───────────────────────────────────────────── */
.messageList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.messageList > * {
  flex-shrink: 0;
}

.emptyState {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-muted);
  font-size: var(--font-base);
  text-align: center;
  padding: 40px 20px;
}

.userMsg {
  align-self: flex-end;
  max-width: 85%;
  background: var(--bg-tertiary);
  color: var(--fg-primary);
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: var(--font-base);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistantMsg {
  align-self: flex-start;
  width: 100%;
  font-size: var(--font-base);
  line-height: 1.5;
}

.assistantMsg :global(#markdown-content) {
  padding: 0;
  font-size: inherit;
}

.assistantMsg :global(#markdown-content pre) {
  overflow-x: hidden;
  white-space: pre-wrap;
  word-break: break-all;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.assistantMsg :global(#markdown-content code) {
  border-radius: var(--radius-sm);
}

.assistantMsg :global(#markdown-content p) {
  margin-bottom: 8px;
}

.assistantMsg :global(#markdown-content p:last-child) {
  margin-bottom: 0;
}

.streamingMsg {
  align-self: flex-start;
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--font-sm);
  color: var(--fg-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  padding: 8px 0;
}

/* ── Code block action buttons ──────────────────────────── */
.codeBlockWrapper {
  position: relative;
}

.codeBlockActions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.codeBlockWrapper:hover .codeBlockActions {
  opacity: 1;
}

.codeActionBtn {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.codeActionBtn:hover {
  background: var(--bg-highlight);
  color: var(--fg-primary);
}

.codeActionBtnCopied {
  color: var(--success);
}

/* ── Error banner ───────────────────────────────────────── */
.errorBanner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--error) 30%, transparent);
  color: var(--error);
  font-size: var(--font-sm);
}

.errorText {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retryBtn {
  background: none;
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  color: var(--error);
  font-size: var(--font-sm);
  padding: 2px 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.retryBtn:hover {
  background: color-mix(in srgb, var(--error) 20%, transparent);
}

/* ── Input area ─────────────────────────────────────────── */
.inputArea {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.textarea {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--fg-primary);
  font-size: var(--font-base);
  font-family: var(--font-ui);
  padding: 8px 12px;
  resize: none;
  min-height: 36px;
  max-height: 150px;
  line-height: 1.4;
  box-sizing: border-box;
  overflow-y: auto;
}

.textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.textarea::placeholder {
  color: var(--fg-muted);
  opacity: 0.5;
}

.sendBtn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--text-on-accent);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.sendBtn:hover:not(:disabled) {
  opacity: 0.85;
}

.sendBtn:disabled {
  opacity: 0.3;
  cursor: default;
}

.stopBtn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: var(--text-on-error);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.stopBtn:hover {
  opacity: 0.85;
}

/* ── Agent mode ────────────────────────────────────────── */
.agentBanner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: var(--font-sm);
  color: var(--accent);
}

.agentBannerText {
  flex: 1;
  font-weight: 500;
}

.agentBannerIteration {
  color: var(--fg-secondary);
  font-size: var(--font-xs);
}

.agentBannerBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-size: var(--font-sm);
  padding: 1px 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.agentBannerBtn:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
}

.agentBannerBtnDanger {
  border-color: var(--error);
  color: var(--error);
}

.agentBannerBtnDanger:hover {
  background: color-mix(in srgb, var(--error) 15%, transparent);
}

.agentDoneBanner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: color-mix(in srgb, var(--fg-muted) 10%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--fg-muted) 20%, transparent);
  font-size: var(--font-sm);
  color: var(--fg-secondary);
}

.agentDoneBannerError {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-bottom-color: color-mix(in srgb, var(--error) 25%, transparent);
  color: var(--error);
}

.unrestrictedBanner {
  background: color-mix(in srgb, var(--error) 15%, transparent);
  border-bottom: 1px solid var(--error);
  color: var(--error);
  font-size: var(--font-xs);
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 12px;
  text-align: center;
}

/* ── Tool call cards ───────────────────────────────────── */
.toolCallCard {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 4px 0;
  font-size: var(--font-sm);
  overflow: hidden;
}

.toolCallHeader {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  cursor: pointer;
  user-select: none;
}

.toolCallHeader:hover {
  background: var(--bg-highlight);
}

.toolCallName {
  font-weight: 500;
  color: var(--fg-primary);
}

.toolCallDuration {
  color: var(--fg-muted);
  font-size: var(--font-xs);
  margin-left: auto;
}

.toolCallStatusDot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toolCallSuccess {
  background: var(--success);
}

.toolCallFailure {
  background: var(--error);
}

.toolCallPending {
  background: var(--warning);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.toolCallBody {
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--font-xs);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg-secondary);
  max-height: 300px;
  overflow-y: auto;
}

.toolCallResultHeader {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 2px;
}

.toolCallOutput {
  white-space: pre-wrap;
  word-break: break-word;
}

.toolCallCopyBtn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: var(--font-xs);
  font-family: var(--font-ui);
  padding: 0 4px;
  cursor: pointer;
  line-height: 1.4;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.toolCallCopyBtn:hover {
  color: var(--fg-primary);
  border-color: var(--fg-secondary);
}

.toolCallCopyBtnCopied {
  color: var(--success);
  border-color: var(--success);
}

.toolCallExpandBtn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: var(--font-xs);
  font-family: var(--font-mono);
  padding: 2px 0;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Approval prompt ───────────────────────────────────── */
.approvalCard {
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 4px 0;
  background: color-mix(in srgb, var(--warning) 8%, transparent);
}

.approvalText {
  font-size: var(--font-sm);
  color: var(--fg-primary);
  margin-bottom: 6px;
}

.approvalActions {
  display: flex;
  gap: 8px;
}

.approvalBtn {
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  padding: 3px 12px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.approvalBtn:hover {
  opacity: 0.85;
}

.approveBtn {
  background: var(--success);
  color: var(--text-on-accent);
}

.denyBtn {
  background: var(--error);
  color: var(--text-on-error);
}

.alwaysAllowBtn {
  background: var(--fg-tertiary, #888);
  color: var(--bg-primary, #fff);
}

/* ── Model picker ──────────────────────────────────────── */
.modelPicker {
  font-size: var(--font-xs);
  background: var(--bg-secondary);
  color: var(--fg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1px 4px;
  cursor: pointer;
  max-width: 120px;
}

.modelPicker:hover {
  color: var(--fg-primary);
}

/* ── Step count input ──────────────────────────────────── */
.stepInput {
  font-size: var(--font-xs);
  background: var(--bg-secondary);
  color: var(--fg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1px 4px;
  width: 48px;
  text-align: center;
}

/* ── Thinking pulse animation ──────────────────────────── */
.thinkingPulse {
  animation: thinkingPulse 1.2s ease-in-out infinite;
}

@keyframes thinkingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Input queue badge ─────────────────────────────────── */
.queueBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--text-on-accent);
  font-size: 10px;
  font-weight: 600;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
}

/* ── History panel ──────────────────────────────────── */
.historyPanel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 0;
  background: var(--bg-primary);
}

.historyHeader {
  padding: 4px 16px 8px;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--fg-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.historyEmpty {
  padding: 16px;
  text-align: center;
  color: var(--fg-muted);
  font-size: var(--font-sm);
}

.historyItem {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--fg-primary);
  font-family: var(--font-ui);
  font-size: var(--font-sm);
}

.historyItem:hover {
  background: var(--bg-hover);
}

.historyTitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.historyMeta {
  display: flex;
  gap: 8px;
  font-size: var(--font-xs);
  color: var(--fg-secondary);
}

.historySession {
  color: var(--accent);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.historyCount {
  color: var(--fg-muted);
}

.historyModel {
  color: var(--fg-accent, #7cb8ff);
  font-size: 10px;
  opacity: 0.8;
}

.historyDate {
  color: var(--fg-muted);
  margin-left: auto;
}

/* ── Usage footer ───────────────────────────────────────── */
.usageFooter {
  padding: 3px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--fg-muted);
  display: flex;
  gap: 6px;
  align-items: center;
  font-family: var(--font-mono);
  line-height: 1.4;
}


/* Extended-thinking disclosure (Opus 4.7+ reasoning) */
.reasoningDisclosure {
  margin: 4px 0;
  border-left: 2px solid var(--border);
  padding-left: 8px;
}

.reasoningSummary {
  cursor: pointer;
  font-size: var(--font-sm);
  color: var(--fg-secondary);
  user-select: none;
  list-style: none;
}

.reasoningSummary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform var(--t-norm, 0.15s);
}

.reasoningDisclosure[open] > .reasoningSummary::before {
  transform: rotate(90deg);
}

.reasoningBody {
  margin-top: 4px;
  font-size: var(--font-sm);
  color: var(--fg-muted);
  opacity: 0.85;
}
