:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e7eaf0;
  --muted: #8b93a3;
  --accent: #6f8cff;
  --accent-2: #4f6ef7;
  --danger: #ff6b6b;
  --ok: #3ddc97;
  --radius: 12px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, #1b2340 0%, var(--bg) 45%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

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

.small {
  font-size: 12px;
}

/* ---------------------------- Login ---------------------------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 20px;
}

form {
  display: grid;
  gap: 6px;
}

label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

input,
textarea,
select,
button {
  font: inherit;
  color: inherit;
}

input,
textarea,
select {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(111, 140, 255, 0.18);
}

button {
  cursor: pointer;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  transition: filter 0.15s ease, transform 0.05s ease;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#login-button {
  margin-top: 18px;
}

button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px;
}

button.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: #3a414f;
  filter: none;
}

.error {
  margin: 8px 0 0;
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

/* --------------------------- Dashboard -------------------------- */

.dashboard {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(23, 26, 33, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.logo {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  font-size: 13px;
  letter-spacing: 0.5px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(139, 147, 163, 0.15);
}

.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.18);
}

.dot.bad {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.18);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar select {
  width: auto;
  max-width: 260px;
  padding: 7px 10px;
  font-size: 13px;
}

/* --------------------------- Mensajes --------------------------- */

.messages {
  overflow-y: auto;
  padding: 8px 2px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.empty {
  margin: auto;
  max-width: 420px;
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
}

.row {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  gap: 4px;
}

.row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.row.assistant {
  align-self: flex-start;
}

.bubble {
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row.user .bubble {
  background: linear-gradient(180deg, #2a3760, #232c4c);
  border-color: #334066;
  border-bottom-right-radius: 4px;
}

.row.assistant .bubble {
  border-bottom-left-radius: 4px;
}

.role {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0 4px;
}

.tools {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.tool {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  overflow-wrap: anywhere;
}

.tool b {
  color: #b8c2dc;
  font-weight: 600;
}

.working {
  align-self: flex-start;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.working::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* --------------------------- Composer --------------------------- */

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  background: rgba(23, 26, 33, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.composer textarea {
  resize: none;
  max-height: 220px;
  min-height: 46px;
  border: none;
  background: transparent;
  padding: 8px;
}

.composer textarea:focus {
  box-shadow: none;
}

.composer button {
  height: 44px;
  min-width: 92px;
}

@media (max-width: 640px) {
  .dashboard {
    padding: 10px;
    gap: 8px;
  }

  .row {
    max-width: 96%;
  }

  .toolbar select {
    max-width: 150px;
  }
}
