:root {
  --bg-primary: #0a0f1d;
  --bg-card: #151e32;
  --bg-card-hover: #1c2742;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent: #0284c7;
  --accent-light: #38bdf8;
  --accent-glow: rgba(2, 132, 199, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #24324f;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none; /* Firefox: oculta barras de rolagem mantendo o scroll touch */
  -ms-overflow-style: none; /* IE e Edge */
}

*::-webkit-scrollbar {
  display: none; /* WebKit / Chrome / Android WebView: oculta barras de rolagem */
  width: 0;
  height: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header com suporte total a Safe Area (Notch e Status Bar) */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(10, 15, 29, 0.95);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding-top: max(2.75rem, calc(1rem + env(safe-area-inset-top, 0px)));
  padding-bottom: 0.85rem;
  padding-left: max(1.25rem, calc(0.75rem + env(safe-area-inset-left, 0px)));
  padding-right: max(1.25rem, calc(0.75rem + env(safe-area-inset-right, 0px)));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.brand:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: linear-gradient(to right, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  background-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.status-badge.connected {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Main Container */
main {
  flex: 1;
  padding: 1.25rem;
  padding-bottom: max(2.5rem, calc(2rem + env(safe-area-inset-bottom, 24px)));
  padding-left: max(1.25rem, calc(0.5rem + env(safe-area-inset-left, 0px)));
  padding-right: max(1.25rem, calc(0.5rem + env(safe-area-inset-right, 0px)));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* PIN Screen */
#pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  text-align: center;
}

.pin-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 1.5rem;
  color: var(--accent-light);
}

.pin-screen h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.pin-screen p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.pin-input {
  width: 100%;
  max-width: 280px;
  background-color: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  text-align: center;
  outline: none;
  margin-bottom: 1rem;
}

.pin-input:focus {
  border-color: var(--accent-light);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  max-width: 280px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  touch-action: manipulation;
  user-select: none;
  position: relative;
  z-index: 10;
  transition: transform 0.1s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  opacity: 0.85;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Active Screen */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}

/* Push Banner */
.push-banner {
  background: linear-gradient(to right, rgba(2, 132, 199, 0.15), rgba(99, 102, 241, 0.15));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 0.75rem;
}

.push-banner p {
  font-size: 0.85rem;
  font-weight: 500;
}

.btn-sm {
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

/* Agents Row */
.agents-list {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  scrollbar-width: none;
}
.agents-list::-webkit-scrollbar { display: none; }

.agent-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.agent-pill.shell-idle {
  background-color: rgba(30, 41, 59, 0.45);
  border-color: rgba(148, 163, 184, 0.25);
  color: #94a3b8;
}

.agent-pill.shell-idle:hover {
  border-color: rgba(148, 163, 184, 0.45);
}

.agent-pill.ai-active {
  border-color: rgba(52, 211, 153, 0.35);
}

.status-dot.shell-idle {
  background-color: #94a3b8 !important;
}

.status-dot.ai-active {
  background-color: #34d399 !important;
}

.status-dot.self {
  background-color: #38bdf8 !important;
}

/* Action Cards */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-state {
  background-color: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.action-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.25s ease-out;
}

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-agent {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.card-prompt {
  font-size: 1rem;
  line-height: 1.5;
  color: #f1f5f9;
  white-space: pre-wrap;
  word-break: break-word;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-option {
  flex: 1 1 calc(50% - 0.25rem);
  background-color: var(--bg-card-hover);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 0.75rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.btn-option:active {
  background-color: var(--accent);
}

.card-custom-input {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.card-custom-input input {
  flex: 1;
  background-color: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.card-custom-input button {
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* Multi-Estação: Barra de Controle & Estações Agrupadas */
.stations-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(21, 30, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.stations-bar-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stations-count-badge {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  font-weight: 700;
}

/* Container de Estações Agrupadas */
.stations-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Card Agrupado de Cada Estação */
.station-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.station-group-card.online {
  border-color: rgba(56, 189, 248, 0.35);
}

.station-group-card.offline {
  border-color: rgba(239, 68, 68, 0.25);
  opacity: 0.88;
}

/* Header do Grupo de Estação */
.station-group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.station-group-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.station-group-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
}

.station-group-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.station-pin-tag {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-family: monospace;
  font-weight: 600;
}

.station-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.station-status-pill.online {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.station-status-pill.offline {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.station-status-pill.connecting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-station-remove {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-station-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* Seções Internas da Estação */
.station-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.station-section-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.station-section-hint {
  font-size: 0.7rem;
  color: #38bdf8;
  text-transform: none;
  font-weight: normal;
}

.station-agents-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.station-empty-prompts {
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.75rem;
  text-align: center;
  font-size: 0.8rem;
  color: #64748b;
}

.station-prompts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.station-card {
  margin-bottom: 1.25rem;
  padding: 0.85rem 1rem;
  background: rgba(21, 30, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.station-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.station-title-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.station-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.btn-station-action {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-station-action.btn-add {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.btn-station-action.btn-add:active {
  background: rgba(56, 189, 248, 0.28);
}

.btn-station-action.btn-logout {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-station-action.btn-logout:active {
  background: rgba(239, 68, 68, 0.28);
}

.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.station-select {
  width: 100%;
  background: var(--bg-primary);
  color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 2.2rem 0.55rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.station-select:focus {
  border-color: #38bdf8;
}

.select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: #94a3b8;
  display: flex;
  align-items: center;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 1000;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 360px;
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.modal-header h3 {
  font-size: 1.1rem;
  color: var(--text-primary);
}

.modal-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent-light);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-icon:hover, .btn-icon:focus {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.btn-icon:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.15);
}

/* Modal de Versão e Informações */
.version-info-box {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.version-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.version-label {
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.version-value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.version-value.highlight {
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.version-value.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #a5f3fc;
}

.version-value.code-small {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  color: #94a3b8;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Agent Chip interativo */
.agent-chip {
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.2s ease, background 0.2s ease;
  user-select: none;
  touch-action: manipulation;
}

.agent-chip:active {
  transform: scale(0.95);
  border-color: var(--accent-light);
  background: var(--bg-card-hover);
}

/* Bottom Sheet / Drawer de Chat */
.chat-drawer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-top: max(1.2rem, calc(0.5rem + env(safe-area-inset-top, 0px)));
}

.chat-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.chat-content {
  position: relative;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  height: 93vh;
  height: 93dvh;
  max-height: 95vh;
  max-height: 95dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10;
  overflow: hidden;
}

.chat-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 15, 29, 0.6);
  flex-shrink: 0;
}

.chat-agent-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.chat-messages {
  flex: 1;
  padding: 0.85rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.chat-messages::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.chat-scroll-bottom-btn {
  position: absolute;
  right: 1.1rem;
  bottom: 5.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), 0 0 10px rgba(56, 189, 248, 0.2);
  cursor: pointer;
  z-index: 45;
  transition: all 0.2s ease-in-out;
  backdrop-filter: blur(8px);
}

.chat-scroll-bottom-btn:active {
  transform: scale(0.92);
  background: rgba(56, 189, 248, 0.25);
}

.chat-bubble {
  max-width: 92%;
  padding: 0.75rem 0.9rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #059669, #0d9488);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.chat-bubble.agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
  font-family: var(--font-sans);
}

.chat-bubble.typing {
  align-self: flex-start;
  font-style: italic;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
}

.terminal-snapshot {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  width: 100%;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}

.terminal-snapshot-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.35rem;
  word-break: break-word;
}

/* Indicadores de Agente Pensando / Atividade */
.status-dot.thinking {
  background-color: #f59e0b !important;
  box-shadow: 0 0 8px #f59e0b;
  animation: pulse-dot 1.2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

.agent-state-pill {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

.agent-state-pill.thinking {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.2);
  animation: pulse-border 1.4s infinite alternate;
}

.agent-state-pill.idle {
  background: rgba(34, 197, 94, 0.12);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

@keyframes pulse-border {
  from { border-color: rgba(245, 158, 11, 0.3); }
  to { border-color: rgba(245, 158, 11, 0.85); }
}

.chat-thinking-banner {
  padding: 0.5rem 0.9rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(245, 158, 11, 0.35);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.25);
}

.typing-wave {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.typing-wave span {
  width: 5px;
  height: 5px;
  background: #fbbf24;
  border-radius: 50%;
  animation: wave 1.2s infinite ease-in-out;
}

.typing-wave span:nth-child(2) { animation-delay: 0.2s; }
.typing-wave span:nth-child(3) { animation-delay: 0.4s; }

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

/* Card Dinâmico no Final do Chat: Agente Pensando / Executando */
.chat-bubble.thinking-card {
  align-self: flex-start;
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.15), 0 2px 8px rgba(0, 0, 0, 0.5);
  color: #f1f5f9;
  border-bottom-left-radius: 4px;
  width: auto;
  min-width: 240px;
  max-width: 95%;
  padding: 0.75rem 0.95rem;
  margin-top: 0.4rem;
  animation: fadeInThinking 0.25s ease-out;
}

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

.thinking-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.thinking-header-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.82rem;
  color: #fbbf24;
}

.thinking-timer {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.75rem;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.25);
  letter-spacing: 0.04em;
}

.thinking-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.thinking-status-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow: hidden;
}

.thinking-action-badge {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.8rem;
  color: #fef08a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 250px;
}

.terminal-snapshot-body {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-height: none;
  overflow-y: visible;
  margin: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.terminal-snapshot-body::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Barra de input com respiro generoso para barra de navegação/gestos do Android */
.chat-input-bar {
  padding-top: 0.65rem;
  padding-left: max(0.65rem, calc(0.4rem + env(safe-area-inset-left, 0px)));
  padding-right: max(0.65rem, calc(0.4rem + env(safe-area-inset-right, 0px)));
  padding-bottom: max(1.8rem, calc(0.6rem + env(safe-area-inset-bottom, 0px)));
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  display: flex;
  gap: 0.4rem;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  min-width: 0; /* CRUCIAL para evitar overflow horizontal do input em telas mobile */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

.chat-input-bar input:focus {
  border-color: var(--accent-light);
}

.btn-send {
  background: var(--accent);
  color: white;
  border: none;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s ease;
}

.btn-send:active {
  transform: scale(0.92);
}

/* Botões de Ação na Entrada (Anexo e Microfone) */
.btn-input-action {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  transition: all 0.2s ease;
}

.btn-input-action:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.12);
}

.btn-input-action.recording {
  background: #ef4444 !important;
  color: white !important;
  border-color: #f87171 !important;
  animation: pulse-mic 1s infinite alternate;
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  100% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Backdrop e Menu Flutuante de Ação para Anexo (Câmera / Galeria / Arquivos) */
.attach-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.attach-menu-popover {
  position: absolute;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  z-index: 100;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  padding: 6px;
  min-width: 230px;
  animation: attachMenuPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes attachMenuPop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: #f1f5f9;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, transform 0.1s ease;
  touch-action: manipulation;
}

.attach-menu-item:active {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(0.98);
}

.attach-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
}

.attach-item-icon.camera {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.attach-item-icon.gallery {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.attach-item-icon.file {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.attach-item-label {
  flex: 1;
  white-space: nowrap;
}

/* Barra de Pré-visualização de Anexo */
.attachment-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.attachment-thumb-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.attachment-thumb-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.attachment-name {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-size {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.btn-remove-attachment {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  line-height: 1;
}

.btn-remove-attachment:hover {
  color: #ef4444;
}

/* Balão com Anexo no Histórico */
.chat-attachment-bubble {
  margin-top: 0.5rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-attachment-bubble img {
  display: block;
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 6px;
}

.chat-attachment-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #38bdf8;
}
