/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

/* ════════════════════════════════════════════════════════════
   LIGHT MODE  —  soft warm palette  (default / no .dark class)
   Replaces harsh pure whites with warm off-whites & stone tones.
   Colour tokens:
     --lm-canvas   #f0ede8  page background
     --lm-surface  #f7f5f1  panels, sidebar, nav
     --lm-raised   #faf9f6  cards, modals
     --lm-input    #ede9e3  inputs, recessed areas
     --lm-edge     #ddd9d1  borders
     --lm-edge-sm  #e8e4dc  subtle borders
   ════════════════════════════════════════════════════════════ */

/* ── Page canvas ── */
html:not(.dark) body {
  background-color: #f0ede8;
  color: #1c1917;
}

/* ── Nav / header ── */
html:not(.dark) header {
  background: rgba(247,245,241,0.88) !important;
  border-bottom-color: #ddd9d1 !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ── White surfaces → warm off-white ── */
html:not(.dark) .bg-white {
  background-color: #f7f5f1 !important;
}

/* ── Layout area background ── */
html:not(.dark) .bg-zinc-100 {
  background-color: #f0ede8 !important;
}

/* ── Recessed / input areas ── */
html:not(.dark) .bg-zinc-50 {
  background-color: #ede9e3 !important;
}

/* ── Borders: soften the stark zinc-200 ── */
html:not(.dark) .border-zinc-200 { border-color: #ddd9d1 !important; }
html:not(.dark) .border-zinc-100 { border-color: #e8e4dc !important; }
html:not(.dark) .border-zinc-300 { border-color: #c7c3bb !important; }

/* ── Inputs & search ── */
html:not(.dark) input[type="text"],
html:not(.dark) input[type="search"],
html:not(.dark) input[type="number"],
html:not(.dark) input[type="url"],
html:not(.dark) textarea,
html:not(.dark) select {
  background-color: #ede9e3;
  border-color: #d4cfc6;
  color: #1c1917;
}
html:not(.dark) input[type="text"]:focus,
html:not(.dark) input[type="search"]:focus,
html:not(.dark) input[type="number"]:focus,
html:not(.dark) input[type="url"]:focus,
html:not(.dark) textarea:focus,
html:not(.dark) select:focus {
  background-color: #faf9f6;
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(139,92,246,0.1);
  outline: none;
}
html:not(.dark) input::placeholder,
html:not(.dark) textarea::placeholder { color: #a09890; }

/* ── Hover states: warm instead of cold gray ── */
html:not(.dark) .hover\:bg-zinc-100:hover { background-color: #e8e4dc !important; }
html:not(.dark) .hover\:bg-zinc-50:hover  { background-color: #e4e0d8 !important; }
html:not(.dark) .hover\:bg-white:hover    { background-color: #f7f5f1 !important; }
html:not(.dark) .focus\:bg-white:focus    { background-color: #faf9f6 !important; }
html:not(.dark) .focus\:border-zinc-300:focus { border-color: #a78bfa !important; }

/* ── Panel header hover ── */
html:not(.dark) .panel-header:hover { background-color: #e8e4dc !important; }

/* ── Sidebar group count badge ── */
html:not(.dark) span.rounded.bg-zinc-100 {
  background-color: #e4e0d8 !important;
  color: #6b7280 !important;
}

/* ── Scrollbars: warmer thumb ── */
html:not(.dark) ::-webkit-scrollbar-thumb { background: #c7c3bb; }
html:not(.dark) ::-webkit-scrollbar-thumb:hover { background: #a09890; }

/* ── Nav / credits button ── */
html:not(.dark) #creditsBtn {
  background-color: #ede9e3;
  border-color: #d4cfc6;
}
html:not(.dark) #creditsBtn:hover {
  background-color: #e4e0d8;
  border-color: #c7c3bb;
}

/* ── Bulk keyword & response tables ── */
html:not(.dark) .bulk-kw-table th,
html:not(.dark) .response-table th {
  background: #e8e4dc;
  border-color: #d4cfc6;
  color: #6b7280;
}
html:not(.dark) .bulk-kw-table td,
html:not(.dark) .response-table td {
  border-color: #ede9e3;
}
html:not(.dark) .bulk-kw-table tr:hover td,
html:not(.dark) .response-table tr:hover td {
  background: #e8e4dc;
}
html:not(.dark) .opp-bar { background: #ddd9d1; }

/* ── Chat table ── */
html:not(.dark) .chat-table th,
html:not(.dark) .chat-table td { border-color: #ddd9d1; }
html:not(.dark) .chat-table th { background: rgba(0,0,0,0.04); }

/* ── Modals ── */
html:not(.dark) #creditsModal .rounded-2xl,
html:not(.dark) #helpPanel .rounded-2xl {
  background: #f7f5f1 !important;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.06);
}

/* ── Primary CTA (bg-zinc-900) — slightly softer than pure black ── */
html:not(.dark) .bg-zinc-900 {
  background-color: #292524 !important;
}
html:not(.dark) .hover\:bg-zinc-800:hover {
  background-color: #1c1917 !important;
}

/* ── Ambient warmth: very subtle background texture ── */
html:not(.dark) body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 90% 50% at 50% -10%, rgba(245,230,200,0.3) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 100% 110%, rgba(220,210,195,0.2) 0%, transparent 60%);
}

/* ── Line clamp util (fallback for CDN Tailwind) ── */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* ── Backdrop blur fallback ── */
.backdrop-blur-sm { backdrop-filter: blur(4px); }

/* ── Nav button pop animation (triggered when user runs a tool without a key) ── */
@keyframes btn-pop {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.18); }
  40%  { transform: scale(0.93); }
  60%  { transform: scale(1.10); }
  80%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}
.btn-pop {
  animation: btn-pop 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  outline: 2px solid #7c3aed;
  outline-offset: 2px;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* ── Sidebar endpoint list ── */
#endpointList::-webkit-scrollbar { width: 4px; }

/* ── Status pill ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 2px 10px;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Response block ── */
.response {
  position: relative;
  animation: fadeIn 200ms ease-out;
}

.response code {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Loading spinner ── */
.response.loading {
  position: relative;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spinnerRotate 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-text {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.025em;
}

/* ── Token colours (preserved) ── */
.token.key     { color: #8ddb8c; }
.token.string  { color: #8fd0ff; }
.token.number  { color: #6cb6ff; }
.token.boolean { color: #6cb6ff; }
.token.null    { color: #6cb6ff; }

/* ── Collapsible panels ── */
.panel-header {
  cursor: pointer;
  user-select: none;
}
.panel-header:hover {
  background-color: #fafafa;
}
.panel-chevron {
  transition: transform 200ms ease;
  flex-shrink: 0;
}
.panel-root[data-collapsed="true"] .panel-chevron {
  transform: rotate(-90deg);
}
.panel-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 200ms ease;
  overflow: hidden;
}
.panel-root[data-collapsed="true"] .panel-body {
  grid-template-rows: 0fr;
}
.panel-body > .panel-inner {
  min-height: 0;
  overflow: hidden;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes spinnerRotate {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ── Chat panel ── */
#chatPanel {
  position: relative;
  width: 340px;
  min-width: 340px;
}

.chat-resize-handle {
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background-color 150ms;
  z-index: 10;
}

.chat-resize-handle:hover {
  background-color: rgba(139, 92, 246, 0.3);
}

.chat-resize-handle.active {
  background-color: #8b5cf6;
}
  max-width: 100%;
  animation: fadeIn 200ms ease-out;
}

.chat-bubble p {
  margin: 0 0 0.5em;
  line-height: 1.5;
}
.chat-bubble p:last-child { margin-bottom: 0; }

.chat-bubble h2,
.chat-bubble h3,
.chat-bubble h4 {
  margin: 0.75em 0 0.5em;
  font-weight: 700;
  line-height: 1.3;
}

.chat-bubble h2 { font-size: 0.95rem; }
.chat-bubble h3 { font-size: 0.9rem; }
.chat-bubble h4 { font-size: 0.85rem; }
.chat-bubble h5 { font-size: 0.8rem; }

.chat-bubble h2:first-child,
.chat-bubble h3:first-child,
.chat-bubble h4:first-child,
.chat-bubble h5:first-child { margin-top: 0; }

.chat-bubble ul,
.chat-bubble ol { margin: 0.5em 0 0.5em 1.5em; padding: 0; }
.chat-bubble li { margin-bottom: 0.35em; }

.chat-bubble strong { font-weight: 700; }
.chat-bubble em { font-style: italic; }

.chat-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5em 0;
  font-size: 0.8em;
}

.chat-table th,
.chat-table td {
  border: 1px solid #d4d4d8;
  padding: 0.35em 0.6em;
  text-align: left;
}

.chat-table th {
  background: rgba(0, 0, 0, 0.06);
  font-weight: 700;
  font-size: 0.85em;
  white-space: nowrap;
}

.chat-table tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.025);
}

.chat-bubble code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8em;
  background: rgba(0, 0, 0, 0.1);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  color: inherit;
}

.chat-code-block {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  padding: 0.75em;
  margin: 0.5em 0;
  overflow-x: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8em;
  line-height: 1.4;
  color: inherit;
}

.chat-code-block code { background: none; padding: 0; }

.chat-bubble a {
  color: #7c3aed;
  text-decoration: underline;
  transition-colors 150ms;
}
.chat-bubble a:hover { color: #6d28d9; }

/* ── Streamed content blocks ── */
.stream-block {
  animation: fadeIn 400ms ease-out;
}

.stream-block:not(:first-child) {
  margin-top: 0.75em;
}

.chat-typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a78bfa;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

/* ── Chat panel resize ── */
#chatPanel {
  position: relative;
  width: 340px;
  min-width: 340px;
}

.chat-resize-handle {
  position: absolute;
  left: -2px;
  top: 0;
  bottom: 0;
  width: 4px;
  cursor: col-resize;
  background: transparent;
  transition: background-color 150ms;
  z-index: 10;
}

.chat-resize-handle:hover {
  background-color: rgba(139, 92, 246, 0.3);
}

.chat-resize-handle.active {
  background-color: #8b5cf6;
}

/* ── Bulk Keyword Table ── */
.bulk-kw-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6875rem;
}
.bulk-kw-table thead { position: sticky; top: 0; z-index: 1; }
.bulk-kw-table th {
  background: #f4f4f5;
  padding: 0.5em 0.75em;
  text-align: right;
  font-weight: 700;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
  border-bottom: 1px solid #e4e4e7;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.bulk-kw-table th:nth-child(2) { text-align: left; }
.bulk-kw-table th:hover,
.bulk-kw-table th.sort-active { color: #18181b; }
.bulk-kw-table td {
  padding: 0.45em 0.75em;
  border-bottom: 1px solid #f4f4f5;
  white-space: nowrap;
  vertical-align: middle;
  text-align: right;
}
.bulk-kw-table td:nth-child(2) { text-align: left; }
.bulk-kw-table tr:last-child td { border-bottom: none; }
.bulk-kw-table tr:hover td { background: #fafafa; }
.bulk-kw-table td.kw-col {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.opp-bar {
  height: 3px;
  border-radius: 2px;
  background: #e4e4e7;
  overflow: hidden;
  min-width: 60px;
}
.opp-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 500ms ease;
}

/* ── Response Table View ── */
.response-table-wrap {
  overflow: auto;
  max-height: 50vh;
  border-radius: 0 0 16px 16px;
}
.response-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.6875rem;
  font-family: "IBM Plex Mono", monospace;
}
.response-table thead { position: sticky; top: 0; z-index: 1; }
.response-table th {
  background: #f4f4f5;
  padding: 0.5em 0.75em;
  text-align: left;
  font-weight: 700;
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #71717a;
  border-bottom: 1px solid #e4e4e7;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.response-table th:hover,
.response-table th.sort-active { color: #18181b; }
.response-table td {
  padding: 0.4em 0.75em;
  border-bottom: 1px solid #f4f4f5;
  color: #18181b;
  white-space: nowrap;
}
.response-table tr:hover td { background: #fafafa; }
.response-table tr:last-child td { border-bottom: none; }
