/* ─── Global ──────────────────────────────────────────────────────────────── */
body {
  background-color: #F9FAFB;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #111827;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Prose (markdown) ───────────────────────────────────────────────────── */
.prose pre {
  background-color: #F3F4F6;
  color: #1F2937;
  padding: 1rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #E5E7EB;
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85em;
  padding: 0.2em 0.4em;
  background: #F3F4F6;
  color: #EB5757;
  border-radius: 4px;
}

.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.prose p {
  margin-bottom: 1rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.prose h1, .prose h2, .prose h3 {
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #111827;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.9em;
}

.prose th, .prose td {
  border: 1px solid #E5E7EB;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.prose th {
  background: #F9FAFB;
  font-weight: 600;
}

/* ─── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #D1D5DB;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #9CA3AF;
}

/* ─── Message animations ─────────────────────────────────────────────────── */
.msg-anim {
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Message surface (AI bubble) ────────────────────────────────────────── */
.message-surface {
  background: #FFFFFF;
  border: 1px solid #F3F4F6;
}

/* ─── User message bubble ────────────────────────────────────────────────── */
.message-user-bubble {
  background: #F3F4F6;
  color: #111827;
  border-radius: 1rem 0 1rem 1rem;
}

/* ── Per-message delete button ───────────────────────────── */
.msg-delete-btn {
  display: none;
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 3px 5px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #9CA3AF;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.msg-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
}
/* Show on parent hover (works for both user & AI rows) */
.group:hover .msg-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── Conversation title editing ───────────────────────────────────────── */
.conversation-title {
  min-height: 20px;
}

.conversation-title-input {
  width: 100%;
  height: 24px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  background: #FFFFFF;
  color: #111827;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
  outline: none;
  padding: 1px 7px;
}

.conversation-title-input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.08);
}

.conversation-title-saving {
  color: #9CA3AF;
  font-size: 11px;
  font-weight: 400;
  margin-left: 6px;
}

.conversation-title-menu {
  position: fixed;
  z-index: 1000;
  min-width: 96px;
  padding: 4px;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  background: #FFFFFF;
  box-shadow: 0 10px 25px rgba(17, 24, 39, 0.12);
}

.conversation-title-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #111827;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.2;
  padding: 7px 10px;
  text-align: left;
}

.conversation-title-menu button:hover {
  background: #F3F4F6;
}

/* ─── Thinking block ─────────────────────────────────────────────────────── */
.thinking-block {
  font-style: italic;
  color: #6B7280;
  border-left: 2px solid #E5E7EB;
  padding-left: 1rem;
  margin-bottom: 0.25rem;
  white-space: pre-wrap;
  font-size: 0.9em;
}

/* ─── Tool calls ─────────────────────────────────────────────────────────── */
.tool-calls-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}

.tool-call-container {
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  overflow: hidden;
  background: #FFFFFF;
}

.tool-call-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease;
  background: #F9FAFB;
}

.tool-call-header:hover {
  background: #F3F4F6;
}

.tool-call-title-row {
  overflow: hidden;
}

.tool-call-title-row svg {
  flex-shrink: 0;
}

.tool-call-name,
.tool-call-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-call-description::before {
  content: "· ";
}

.tool-call-body {
  padding: 12px;
  border-top: 1px solid #F3F4F6;
}

.tool-call-body.hidden {
  display: none;
}

.visualize-widget-action {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px 12px;
}

.visualize-widget-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  background: #FFFFFF;
  color: #374151;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 10px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.visualize-widget-button:hover {
  background: #F3F4F6;
  border-color: #9CA3AF;
  color: #111827;
}

.visualize-widget-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.visualize-widget-button svg {
  flex-shrink: 0;
}

.present-files-actions {
  flex-wrap: wrap;
}

.present-file-button {
  max-width: min(100%, 320px);
}

.present-file-button.is-pending {
  background: #F9FAFB;
  border-color: #E5E7EB;
  color: #9CA3AF;
}

.present-file-button.is-pending .present-file-name {
  color: #9CA3AF;
}

.present-file-name {
  max-width: 180px;
  overflow: hidden;
  color: #6B7280;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Tool block (legacy) ────────────────────────────────────────────────── */
.tool-block {
  font-family: monospace;
  background: #F3F4F6;
  color: #374151;
  padding: 0.5rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.85em;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─── Layout shell ────────────────────────────────────────────────────────── */
.app-shell {
  position: relative;
}

/* ─── Visualize widget sidebar ───────────────────────────────────────────── */
.visualize-widget-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  width: min(720px, 46vw);
  height: 100vh;
  background: #FFFFFF;
  border-left: 1px solid #E5E7EB;
  box-shadow: -16px 0 40px rgba(17, 24, 39, 0.14);
  transform: translateX(100%);
  transition: transform 0.16s ease;
}

.visualize-widget-sidebar.open {
  transform: translateX(0);
}

.visualize-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px 0 16px;
  border-bottom: 1px solid #E5E7EB;
  background: #F9FAFB;
}

.visualize-widget-title {
  min-width: 0;
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visualize-widget-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.visualize-widget-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #6B7280;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.visualize-widget-icon-button:hover {
  background: #FFFFFF;
  border-color: #E5E7EB;
  color: #111827;
}

.visualize-widget-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #FFFFFF;
}

.visualize-widget-loading {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #6B7280;
  font-size: 13px;
  text-align: center;
}

.visualize-widget-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.visualize-widget-frame.ready {
  opacity: 1;
}

.visualize-widget-text-preview {
  height: 100%;
  overflow: auto;
  padding: 16px md:padding-24px;
  color: #111827;
  font-size: 14px;
  line-height: 1.65;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.visualize-widget-text-preview.prose {
  max-width: none;
}

.visualize-widget-text-preview.prose pre {
  white-space: pre-wrap;
}

.visualize-widget-plain-text {
  margin: 0;
  padding: 16px;
  min-height: 100%;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  background: #F9FAFB;
  color: #1F2937;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: env(safe-area-inset-bottom);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .visualize-widget-sidebar {
    width: 100vw;
  }
}

/* ─── Paste confirmation modal ─────────────────────────────────────────── */
.paste-confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.45);
  z-index: 9999;
}

.paste-confirm-overlay.visible {
  display: flex;
}

.paste-confirm-modal {
  width: 100%;
  max-width: 460px;
  background: #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: fadeIn 0.18s ease;
}

.paste-confirm-header {
  padding: 20px 24px 0;
}

.paste-confirm-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
}

.paste-confirm-body {
  padding: 12px 24px 4px;
}

.paste-confirm-message {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #111827;
}

.paste-confirm-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #6B7280;
  line-height: 1.5;
}

.paste-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 20px;
}

.paste-confirm-footer button {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
  color: #111827;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.paste-confirm-footer button:hover {
  background: #F3F4F6;
}

.paste-confirm-ok {
  background: #111827;
  color: #FFFFFF;
  border-color: #111827;
}

.paste-confirm-ok:hover {
  background: #374151;
  border-color: #374151;
}

/* ─── Thinking Block (collapsible) ──────────────────────────────────────── */
details.thinking-block > summary {
  /* Hide the default browser disclosure triangle */
  list-style: none;
}
details.thinking-block > summary::-webkit-details-marker {
  display: none;
}

details.thinking-block[open] > summary .thinking-chevron {
  transform: rotate(180deg);
}
