:root {
  --primary: #00d4c9;
  --dark: #0f0f0f;
  --gray: #1a1a1a;
}

/* Negro forzado en header, mensajes de usuario y botón Enviar */
header h1,
header p.subtitle,
#chat .msg.user,
button#send {
  color: #000 !important;
  -webkit-text-fill-color: #000;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--dark);
  color: #e0e0e0;
  font-family: 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
}

body.modal-open {
  overflow: hidden;
}

dialog {
  border: none;
  padding: 0;
}

dialog.card {
  width: min(720px, calc(100vw - 32px));
  max-height: min(85vh, calc(100vh - 32px));
  overflow: auto;
  padding: 16px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 999;
}

dialog.fallback-open {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  display: block;
}

header {
  text-align: center;
  padding: 2.5rem 1rem;
  background: linear-gradient(135deg, #00d4c9, #007d77);
  color: #0f0f0f;
}

header,
header .subtitle {
  color: #0f0f0f !important;
}

h1 {
  margin: 0;
  font-size: 2.8rem;
  color: #0f0f0f;
}

.subtitle {
  margin: 0.5rem 0 0;
  font-size: 1.2rem;
  color: #0f0f0f;
  opacity: 0.9;
}

main {
  flex: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--dark);
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  background: #141414;
  border: 1px solid #2f2f2f;
  color: #e0e0e0;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}

.btn-secondary {
  background: #2a2a2a;
  color: #e0e0e0 !important;
  border: 1px solid #3b3b3b;
}

.card {
  background: #141414;
  border: 1px solid #2f2f2f;
  border-radius: 16px;
  padding: 16px;
}

.landing-hero {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--dark);
}

.landing-title {
  margin: 0 0 0.5rem;
  font-size: 3.5rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.landing-subtitle {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: #b0e0dd;
}

.landing-desc {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: #9a9a9a;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.landing-cta {
  padding: 0.75rem 1.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #0f0f0f;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.08s ease;
}

.landing-cta:hover {
  background: #00e5d9;
  transform: translateY(-1px);
}

.auth-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}

.auth-copy h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.muted {
  color: #9a9a9a;
  margin: 0;
}

.onboarding {
  margin-top: 10px;
  font-size: 0.85rem;
}

.onboarding ol {
  padding-left: 18px;
  margin: 6px 0 0;
}

.onboarding li {
  margin-bottom: 4px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: #2a2a2a; /* tab inactivo gris discreto */
  border: 1px solid #3b3b3b;
  color: #e0e0e0 !important;
  padding: 10px 12px;
  border-radius: 999px;
  transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.2s ease-out;
}

.tab:hover {
  background: rgba(0, 212, 201, 0.18); /* preview turquesa suave semitransparente */
}

.tab.active {
  background: var(--primary); /* fondo turquesa sólido */
  border-color: var(--primary);
  color: #0f0f0f !important; /* texto oscuro */
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.9rem;
  color: #bdbdbd;
}

select {
  padding: 0.8rem 1rem;
  border-radius: 999px;
  border: 1px solid #3b3b3b;
  background: #2a2a2a;
  color: #e0e0e0;
}

.error {
  background: rgba(255, 78, 78, 0.1);
  border: 1px solid rgba(255, 78, 78, 0.35);
  color: #ffb3b3;
  padding: 10px 12px;
  border-radius: 12px;
}

.history-list {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 9px;
  border-radius: 10px;
  background: #1b1b1b;
  cursor: pointer;
  font-size: 0.85rem;
}

.history-item:hover {
  background: #222;
}

#chatSection {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

#chatSection[hidden] {
  display: none !important;
}

#chat {
  flex: 1;
  overflow-y: auto;
  background: var(--gray);
  border-radius: 15px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Aviso discreto tipo “sistema”, no burbuja Eco/usuario */
.chat-system-nudge {
  align-self: center;
  max-width: 95%;
  margin: 0.35rem 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(200, 220, 215, 0.72);
  text-align: center;
  border: 1px solid rgba(0, 212, 201, 0.12);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
}

.chat-system-nudge-link {
  color: rgba(127, 245, 232, 0.95);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}

.chat-system-nudge-link:hover {
  color: #b8fff6;
}

.chat-eco-plus-nudge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.chat-eco-plus-nudge-text {
  flex: 1 1 200px;
  text-align: center;
}

.chat-eco-plus-nudge-btn {
  flex-shrink: 0;
  padding: 6px 14px !important;
  font-size: 0.85rem !important;
}

#chat[hidden],
#input-area[hidden] {
  display: none !important;
}

.msg {
  position: relative;
  padding: 0.75rem 1rem;
  border-radius: 18px;
  max-width: 80%;
  line-height: 1.5;
  word-wrap: break-word;
  font-size: 0.97rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #0f0f0f !important;
  border-bottom-right-radius: 4px;
}

.msg.eco {
  align-self: flex-start;
  background: #202020;
  color: #e4fff7;
  border: 1px solid rgba(0, 212, 201, 0.5);
  border-bottom-left-radius: 4px;
}

.msg.eco.typing {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  font-style: italic;
  opacity: 0.8;
}

.typing-dots {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  margin-left: 4px;
}

.typing-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a8e6cf;
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.feedback-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-left: 4px;
  font-size: 0.8rem;
  opacity: 0.75;
}

.feedback-row button {
  padding: 2px 7px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e0e0 !important;
  font-size: 0.75rem;
  min-width: auto;
}

.feedback-row button:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  transform: none;
}

.feedback-row button.selected {
  border-color: var(--primary);
  color: var(--primary) !important;
}

.feedback-row button:disabled {
  opacity: 0.45;
  cursor: default;
}

.feedback-comment {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  margin-left: 4px;
}

.feedback-comment input {
  flex: 1;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #2a2a2a;
  color: #e0e0e0;
  font-size: 0.8rem;
}

.feedback-comment button {
  padding: 2px 9px;
  font-size: 0.75rem;
  border-radius: 999px;
  background: var(--primary);
  color: #0f0f0f !important;
  border: none;
}

#input-area {
  display: flex;
  gap: 12px;
}

input, textarea {
  flex: 1;
  padding: 1.1rem;
  border: none;
  border-radius: 30px;
  background: #2a2a2a;
  color: white;
  font-size: 1.1rem;
}

input:focus, textarea:focus {
  outline: 2px solid var(--primary);
}

#send,
button {
  padding: 0 2rem;
  border: none;
  border-radius: 30px;
  background: var(--primary);
  color: #0f0f0f !important;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

footer {
  text-align: center;
  padding: 1.5rem;
  color: #666;
  font-size: 0.9rem;
  background: var(--dark);
}

.footer-link {
  background: none;
  border: none;
  padding: 0;
  color: #00d4c9;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.footer-link:hover {
  color: #00f5e9;
}

.footer-link-privacy {
  color: #5ebfb8;
  text-decoration: underline;
}

.footer-link-privacy:hover {
  color: #7dccc6;
}

.footer-link-support {
  color: #5ff5ec;
  font-size: 0.92em;
  text-decoration: underline;
  opacity: 1;
}

.footer-link-support:hover {
  color: #8ffdf6;
}

.eco-plus-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}

.btn-primary {
  display: inline-block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  padding: 0.9rem 1rem;
  border-radius: 30px;
  background: var(--primary);
  color: #0f0f0f !important;
  text-decoration: none;
  font-weight: bold;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.step {
  margin-top: 12px;
  border: 1px solid rgba(0, 212, 201, 0.2);
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
  border-radius: 14px;
}

.step p {
  margin: 8px 0 0;
}

.note {
  margin-top: 10px;
  color: rgba(200, 220, 215, 0.78);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* Modal Eco Plus */
#ecoPlusModal {
  color: var(--text);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}

#ecoPlusModal .eco-plus-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
  font-size: 1.2rem;
}

.note-warning {
  font-size: 13px;
  opacity: 0.8;
  margin-top: 10px;
}

.eco-option {
  margin-top: 15px;
}

.eco-plus-col {
  background: #1b1b1b;
  border: 1px solid #2f2f2f;
  border-radius: 14px;
  padding: 12px;
}

.eco-plus-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eco-plus-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.eco-plus-submit-inline {
  width: 100%;
  padding: 0.9rem 1rem;
}

.upgrade-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 780px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

  .eco-plus-grid {
    grid-template-columns: 1fr;
  }
}

.eco-logo-img {
  width: 200px;
  height: auto;
  display: block;
  margin: 0 auto;
}


/* Textarea auto-resize */

#userInput {
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
  height: 50px;
  max-height: 150px;
  line-height: 1.4;
  font-family: 'Segoe UI', sans-serif;
}
