/* ── DEBUG PANEL INTERNALS ───────────────────────────────────── */
.debug-header {
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-shrink: 0;
  height: 40px;
}

.debug-tabs {
  display: flex;
  flex: 1;
  gap: 0;
}

.debug-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s;
  padding: 0 6px;
}
.debug-tab:hover  { color: var(--text-dim); }
.debug-tab.active { color: var(--gold); border-bottom-color: var(--gold-dim); }

.debug-clear {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  align-self: center;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.debug-clear:hover { color: var(--text-dim); border-color: var(--border2); }

/* ── PANEL CONTENT (shared for sources + memory) ─────────────── */
.panel-content {
  height: calc(100vh - 100px); /* Ajustado para dar respiro no bottom */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: block; /* Removido important para o JS poder alternar abas */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.panel-content > * {
  margin-bottom: 14px; /* Substitui o gap do flex */
}

.panel-content > *:last-child {
  margin-bottom: 0;
}

.debug-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* ── DEBUG TURN ──────────────────────────────────────────────── */
.debug-turn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  animation: fadeUp 0.25s ease both;
}

.debug-turn-header {
  padding: 6px 10px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.turn-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  flex-shrink: 0;
}

.turn-query {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.debug-section {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.debug-section:last-child { border-bottom: none; }

.rewritten-query {
  font-size: 12px;
  color: var(--text);
  font-style: italic;
  line-height: 1.5;
  padding: 6px 10px;
  background: var(--gold-glow);
  border-left: 2px solid var(--gold-dim);
  border-radius: 0 2px 2px 0;
}

/* ── CHUNK ───────────────────────────────────────────────────── */
.chunk {
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
  transition: border-color 0.2s;
}
.chunk:last-child { margin-bottom: 0; }
.chunk:hover { border-color: var(--border2); }

.chunk-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--surface2);
}

.chunk-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 18px;
}

.chunk-ref {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--gold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-bar-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.score-bar {
  width: 48px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.score-fill {
  height: 100%;
  background: var(--gold-dim);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.score-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text-muted);
  min-width: 28px;
  text-align: right;
}

.chunk-text {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
  background: rgba(0,0,0,0.15);
  max-height: 280px; /* Limite de tamanho restaurado */
  overflow-y: auto;
  scrollbar-width: thin;
  position: relative;
}

[data-theme="light"] .chunk-text { background: rgba(255,255,255,0.4); }

.chunk-actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(0,0,0,0.25);
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.chunk-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.2s;
}
.chunk-btn:hover { color: var(--gold); border-color: var(--gold-dim); }
.chunk-btn.del:hover { color: var(--red); border-color: var(--red); }

.memory-edit-area {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--gold-dim);
  color: var(--text);
  font-family: 'Crimson Pro', serif;
  font-size: 13px;
  padding: 8px;
  border-radius: 2px;
  resize: vertical;
  min-height: 60px;
  outline: none;
}