:root {
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition-fast: 0.2s ease;
  --transition-medium: 0.3s ease;
  --container-max: 1120px;
  /* Alturas fijas para layout con header + capa inferior */
  --header-h: 54px;
  /* Altura total estimada de la capa inferior (composer) en desktop */
  --composer-h: 180px;
  /* Separación visible entre el card y el composer */
  --shell-gap: clamp(16px, 2.25vw, 28px);
  /* Separación visible entre composer y footer */
  --footer-gap: clamp(10px, 1.75vw, 20px);
  /* Margen interno del scroll para que el box-shadow del card no se recorte */
  --shell-shadow-bleed: clamp(12px, 1.6vw, 24px);
  --shell-panel-background: var(--surface-strong);
  --accent-gradient: linear-gradient(125deg, var(--accent-strong), var(--accent));
  --accent-gradient-text: linear-gradient(180deg, var(--accent), var(--accent-strong));
  --accent-gradient-callout: linear-gradient(90deg, var(--accent), var(--accent-strong));
}

body {
  margin: 0;
  height: 100vh;
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  transition: background-color var(--transition-medium), color var(--transition-medium);
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Evita scroll de página, sólo scrollea .layout */
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Tema: Aurora violeta */
body.theme-aurora {
  color-scheme: dark;
  --bg: #120928;
  --bg-alt: #111827;
  --surface: rgba(18, 24, 40, 0.78);
  --surface-strong: rgba(12, 17, 33, 0.85);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --text: #f9fafb;
  --text-muted: rgba(226, 232, 240, 0.78);
  --accent: #a855f7;
  --accent-strong: #6366f1;
  --accent-soft: rgba(168, 85, 247, 0.18);
  --accent-soft-strong: rgba(99, 102, 241, 0.26);
  --accent-gradient: linear-gradient(135deg, var(--accent-strong), var(--accent));
  --accent-gradient-text: linear-gradient(180deg, var(--accent), var(--accent-strong));
  --accent-gradient-callout: linear-gradient(90deg, var(--accent), var(--accent-strong));
  --border: #9b58f6;
  --cta-foreground: #0f172a;
  --status-available: #4ade80;
  --header-background: #120928;
  --hero-background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.35), transparent 45%),
    radial-gradient(circle at bottom left, rgba(168, 85, 247, 0.22), transparent 52%);
  --section-alt-background: #111827;
  --preview-card-background: linear-gradient(180deg, rgba(15, 23, 42, 0.9), rgba(24, 34, 68, 0.7));
  --preview-border: #9b58f6;
  --shadow-preview: 0 20px 60px rgba(2, 6, 23, 0.6);
  --shadow-card: 0 12px 30px rgba(2, 6, 23, 0.4);
  --shadow-floating: 0 24px 50px rgba(2, 6, 23, 0.55);
  --plan-highlight-border: #9b58f6;
  --plan-highlight-background: linear-gradient(180deg, rgba(24, 34, 68, 0.92), rgba(124, 58, 237, 0.45));
  --pillars-background: rgba(15, 23, 42, 0.5);
  --chat-window-background: rgba(15, 23, 42, 0.65);
  --chat-form-background: rgba(6, 8, 20, 0.55);
  --chat-input-background: rgba(15, 23, 42, 0.95);
  --chat-message-background: rgba(255, 255, 255, 0.04);
  --chat-message-user-background: rgba(255, 255, 255, 0.06);
  --chat-message-bot-background: rgba(129, 140, 248, 0.25);
  --plan-card-background: rgba(15, 23, 42, 0.55);
  --contact-form-background: rgba(15, 23, 42, 0.55);
  --footer-background: rgba(6, 8, 20, 0.9);
  --form-button-background: rgba(168, 85, 247, 0.18);
  --form-button-color: rgba(248, 250, 252, 0.8);
  --bubble-assistant: rgba(129, 140, 248, 0.25);
  --bubble-user: rgba(255, 255, 255, 0.06);
  --composer-bg: rgba(6, 8, 20, 0.9);
  --shadow-elevated: 0 20px 60px rgba(2, 6, 23, 0.55);
  --shell-panel-background: #160b32;
  --layout-background: #120928;
}

/* Tema: Nocturno */
body.theme-void {
  color-scheme: dark;
  --bg: #050505;
  --bg-alt: #0b0b0f;
  --surface: rgba(18, 18, 21, 0.85);
  --surface-strong: rgba(10, 10, 12, 0.9);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --text: #f4f4f5;
  --text-muted: rgba(212, 212, 216, 0.72);
  --accent: #0ea97c;
  --accent-strong: #1fd6a3;
  --accent-soft: rgba(31, 214, 163, 0.28);
  --accent-soft-strong: rgba(24, 131, 109, 0.36);
  --accent-cool: #1e3a8a;
  --accent-cool-soft: rgba(30, 64, 175, 0.22);
  --accent-gradient: linear-gradient(
    135deg,
    #0ea97c 0%,
    #1cc191 16%,
    #28d6a5 32%,
    #39ddc0 48%,
    #d44f93 64%,
    #c1326e 82%,
    #a90e3b 100%
  );
  --accent-gradient-text: linear-gradient(
    180deg,
    #0ea97c 0%,
    #1cc191 16%,
    #28d6a5 32%,
    #39ddc0 48%,
    #d44f93 64%,
    #c1326e 82%,
    #a90e3b 100%
  );
  --accent-gradient-callout: linear-gradient(
    90deg,
    #0ea97c 0%,
    #1cc191 16%,
    #28d6a5 32%,
    #39ddc0 48%,
    #d44f93 64%,
    #c1326e 82%,
    #a90e3b 100%
  );
  --border: #0ea97c;
  --cta-foreground: #041b11;
  --status-available: #22c55e;
  --header-background: linear-gradient(180deg, rgba(6, 6, 8, 0.95), rgba(6, 6, 8, 0.72));
  --hero-background: radial-gradient(circle at top right, rgba(31, 214, 163, 0.32), transparent 42%),
    radial-gradient(circle at center, rgba(14, 116, 144, 0.28), transparent 60%),
    radial-gradient(circle at bottom left, var(--accent-cool-soft), transparent 58%);
  --section-alt-background: #0b0b0f;
  --preview-card-background: linear-gradient(180deg, rgba(12, 12, 15, 0.92), rgba(20, 20, 24, 0.78));
  --preview-border: #0ea97c;
  --shadow-preview: 0 20px 60px rgba(0, 0, 0, 0.65);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.55);
  --shadow-floating: 0 26px 48px rgba(0, 0, 0, 0.6);
  --plan-highlight-border: #0ea97c;
  --plan-highlight-background: linear-gradient(
      180deg,
      rgba(4, 27, 17, 0.92),
      rgba(14, 169, 124, 0.45) 55%,
      var(--accent-cool-soft)
    );
  --pillars-background: rgba(14, 14, 18, 0.78);
  --chat-window-background: rgba(12, 12, 15, 0.8);
  --chat-form-background: rgba(5, 5, 7, 0.65);
  --chat-input-background: rgba(18, 18, 23, 0.9);
  --chat-message-background: rgba(255, 255, 255, 0.04);
  --chat-message-user-background: rgba(255, 255, 255, 0.06);
  --chat-message-bot-background: rgba(14, 169, 124, 0.2);
  --plan-card-background: rgba(12, 12, 15, 0.8);
  --contact-form-background: rgba(12, 12, 15, 0.8);
  --footer-background: rgba(5, 5, 7, 0.92);
  --form-button-background: rgba(14, 169, 124, 0.18);
  --form-button-color: rgba(244, 244, 245, 0.8);
  --bubble-assistant: rgba(14, 169, 124, 0.2);
  --bubble-user: rgba(255, 255, 255, 0.06);
  --composer-bg: rgba(5, 5, 7, 0.9);
  --shadow-elevated: 0 20px 55px rgba(0, 0, 0, 0.55);
  --layout-background: #050505;
}

/* Tema: Espectro vibrante */
body.theme-ice {
  color-scheme: light;
  --bg: #eff1f5;
  --bg-alt: #fdf4ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: rgba(250, 245, 255, 0.95);
  --surface-soft: rgba(253, 244, 255, 0.6);
  --text: #1f2937;
  --text-muted: rgba(31, 41, 55, 0.68);
  --accent: #b458ffff;
  --accent-strong: #4400e3ff;
  --accent-soft: rgba(168, 65, 255, 0.18);
  --accent-soft-strong: rgba(123, 68, 255, 0.26);
  --accent-gradient: linear-gradient(
    135deg,
    #4400e3ff 0%,
    #8144ff 14%,
    #8843ff 28%,
    #8e43ff 42%,
    #9242ff 50%,
    #9542ff 58%,
    #9b42ff 72%,
    #a241ff 86%,
    #b458ffff 100%
  );
  --accent-gradient-text: linear-gradient(
    180deg,
    #4400e3ff 0%,
    #8144ff 14%,
    #8843ff 28%,
    #8e43ff 42%,
    #9242ff 50%,
    #9542ff 58%,
    #9b42ff 72%,
    #a241ff 86%,
    #b458ffff 100%
  );
  --accent-gradient-callout: linear-gradient(
    90deg,
    #4400e3ff 0%,
    #8144ff 14%,
    #8843ff 28%,
    #8e43ff 42%,
    #9242ff 50%,
    #9542ff 58%,
    #9b42ff 72%,
    #a241ff 86%,
    #b458ffff 100%
  );
  --border: #b96bfd;
  --cta-foreground: #f9f7ff;
  --status-available: #4400e3ff;
  --header-background: #eff1f5;
  --hero-background: radial-gradient(circle at top right, rgba(123, 68, 255, 0.28), transparent 38%),
    radial-gradient(circle at bottom left, rgba(168, 65, 255, 0.24), transparent 52%),
    radial-gradient(circle at center, rgba(129, 230, 255, 0.18), transparent 62%);
  --section-alt-background: #fdf4ff;
  --preview-card-background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(253, 244, 255, 0.94));
  --preview-border: rgba(185, 107, 253, 0.22);
  --shadow-preview: 0 16px 46px rgba(123, 68, 255, 0.12);
  --shadow-card: 0 12px 32px rgba(123, 68, 255, 0.16);
  --shadow-floating: 0 18px 40px rgba(168, 65, 255, 0.18);
  --plan-highlight-border: rgba(185, 107, 253, 0.45);
  --plan-highlight-background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.97),
      rgba(168, 65, 255, 0.28)
    );
  --pillars-background: rgba(255, 255, 255, 0.87);
  --chat-window-background: rgba(255, 255, 255, 0.96);
  --chat-form-background: rgba(253, 244, 255, 0.82);
  --chat-input-background: rgba(255, 255, 255, 0.95);
  --chat-message-background: rgba(244, 243, 255, 0.65);
  --chat-message-user-background: rgba(168, 65, 255, 0.18);
  --chat-message-bot-background: rgba(123, 68, 255, 0.22);
  --plan-card-background: rgba(255, 255, 255, 0.95);
  --contact-form-background: rgba(255, 255, 255, 0.95);
  --footer-background: #eff1f5;
  --form-button-background: rgba(123, 68, 255, 0.16);
  --form-button-color: rgba(31, 41, 55, 0.78);
  --bubble-assistant: rgba(123, 68, 255, 0.22);
  --bubble-user: rgba(168, 65, 255, 0.18);
  --composer-bg: rgba(255, 255, 255, 0.94);
  --shadow-elevated: 0 20px 55px rgba(123, 68, 255, 0.18);
  --layout-background: #eff1f5;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity var(--transition-fast);
}

a:hover,
button:hover {
  opacity: 0.9;
}

.container {
  width: min(760px, 92vw);
  margin: 0 auto;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--header-background);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.20rem;
  padding: 0.65rem 0;
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  font-weight: 700;
  color: var(--text);
}

.brand-icon {
  width: 34px;
  height: 34px;
  display: block;
  object-fit: contain;
}

.brand-text {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  letter-spacing: 0.03em;
}

.brand-text .logo {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1;
}

.logo {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Ensure image logo scales nicely in header */
.logo img {
  display: block;
  height: 28px;
  width: auto;
}

.nav {
  display: flex;
  gap: 1.5rem;
  font-size: 0.95rem;
}

.nav a {
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.nav a:hover {
  color: var(--text);
}

.theme-switcher {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  justify-content: flex-end;
}

.theme-button-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0;
  margin: 0;
  align-items: flex-end;
}

.theme-button {
  --theme-button-border: var(--border);
  --theme-button-color: var(--text);
  --theme-button-active-bg: var(--accent-soft);
  --theme-button-active-border: var(--accent);
  --theme-button-active-color: var(--accent-strong);
  min-width: 28px;
  height: 56px;
  border-radius: 32px 0 0 32px;
  border: 1px solid var(--theme-button-border);
  border-right: 0;
  background: var(--surface-strong);
  color: var(--theme-button-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast),
    color var(--transition-fast);
  margin-right: -1px;
  padding: 0;
}

.theme-button-group .theme-button {
  display: none;
}

.theme-button-group .theme-button[aria-pressed='true'] {
  display: inline-flex;
}

.theme-switcher.is-expanded .theme-button-group .theme-button {
  display: inline-flex;
}

.theme-switcher.is-expanded .theme-button-group {
  padding: 0.35rem 0.25rem 0.35rem 0;
  border-radius: 36px 0 0 36px;
  align-items: stretch;
}

.theme-switcher.is-expanded .theme-button {
  margin-right: 0;
}

.theme-switcher:not(.is-expanded) .theme-button[aria-pressed='true'] {
  box-shadow: var(--shadow-floating);
}

.theme-button svg {
  width: 20px;
  height: 20px;
}

.theme-button svg circle,
.theme-button svg line {
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.theme-button svg path {
  fill: currentColor;
}

.theme-button.theme-button--ice {
  --theme-button-border: rgba(130, 87, 255, 0.55);
  --theme-button-color: #5524e5;
  --theme-button-active-bg: rgba(149, 102, 255, 0.25);
  --theme-button-active-border: #5524e5;
  --theme-button-active-color: #5524e5;
}

.theme-button.theme-button--aurora {
  --theme-button-border: rgba(168, 85, 247, 0.5);
  --theme-button-color: #a855f7;
  --theme-button-active-bg: rgba(99, 102, 241, 0.22);
  --theme-button-active-border: #7c3aed;
  --theme-button-active-color: #7c3aed;
}

.theme-button.theme-button--void {
  --theme-button-border: rgba(14, 169, 124, 0.45);
  --theme-button-color: #0ea97c;
  --theme-button-active-bg: rgba(14, 169, 124, 0.22);
  --theme-button-active-border: #0ea97c;
  --theme-button-active-color: #0ea97c;
}

.theme-button:hover {
  border-color: var(--theme-button-active-border);
}

.theme-button:focus-visible {
  outline: 2px solid var(--theme-button-active-border);
  outline-offset: 4px;
}

.theme-button[aria-pressed='true'] {
  background: var(--theme-button-active-bg);
  border-color: var(--theme-button-active-border);
  color: var(--theme-button-active-color);
}

.theme-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.cta {
  padding: 0.5rem 1.05rem;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: var(--cta-foreground);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast);
  border: none;
}

.cta:hover {
  transform: translateY(-2px);
}

/* Botón hamburger (oculto por defecto) */
.hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.hamburger-box {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.hamburger-line {
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* Menú móvil (oculto por defecto) */
.mobile-menu {
  position: fixed;
  left: 0;
  right: 0;
  top: 0; /* se ajusta en JS al abrir */
  z-index: 40;
}

.mobile-menu-panel {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-elevated);
  border-radius: 16px;
  margin-top: 0.5rem;
  padding: 0.9rem;
}

.mobile-menu-list,
.mobile-menu-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.mobile-menu-links a {
  color: var(--text-muted);
}

.mobile-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0;
}

/* Estilo del CTA dentro del menú móvil */
.mobile-menu .cta {
  width: 100%;
  text-align: center;
  padding: 0.6rem 0.9rem;
}

/* Evitar duplicado del selector dentro del menú móvil */
.mobile-menu .theme-switcher {
  display: none;
}

/* Centrar la CTA en el header */
.site-header .cta {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Mantener el efecto hover sin perder el centrado */
.site-header .cta:hover {
  transform: translate(-50%, -2px);
}

.layout {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  background: var(--layout-background, var(--bg));
  /* Reservar sólo la altura del composer; el gap se agrega como padding interno */
  bottom: calc(var(--composer-h) + var(--composer-b, 0px));
  overflow-y: auto; /* Scrollbar a nivel viewport */
  -webkit-overflow-scrolling: touch;
  /* Evitar recorte del box-shadow: espacio arriba y abajo dentro del scroll */
  padding-top: var(--shell-shadow-bleed);
  padding-bottom: var(--shell-gap);
}

/* Card centrado dentro del contenedor scrolleable full-width */
.layout > .chat-shell {
  width: min(760px, 92vw);
  margin: 0 auto; /* el espaciado vertical lo maneja el padding de .layout */
  background: var(--shell-panel-background);
  border-radius: 22px;
  padding: clamp(1.5rem, 4vw, 3rem);
  box-shadow: var(--shadow-elevated);
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* (El bloque .layout duplicado se unifica en el bloque fijo superior) */

.intro h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  text-align: center;
  background-image: var(--accent-gradient-text);
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro p {
  margin: 1.4rem auto 1.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 34rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.intro p span + span {
  margin-left: 0;
  margin-top: 0.4rem;
}

.intro p .callout {
  font-weight: 600;
  font-size: 1.15em;
  background-image: var(--accent-gradient-callout);
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

body.theme-aurora .intro {
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.theme-aurora .intro h1,
body.theme-aurora .intro p span {
  font-family: 'Inter', serif;
  display: inline-block;
  overflow: hidden;
  max-width: 100%;
  white-space: nowrap;
  clip-path: inset(0 100% 0 0);
  -webkit-clip-path: inset(0 100% 0 0);
}

@keyframes introAuroraTyping {
  0% {
    clip-path: inset(0 100% 0 0);
    -webkit-clip-path: inset(0 100% 0 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
  }
}

body.theme-aurora .intro h1 {
  margin-inline: auto;
  animation: introAuroraTyping 1.4s steps(22, end) 0.3s forwards;
}

body.theme-aurora .intro p span:nth-of-type(1) {
  animation: introAuroraTyping 1.6s steps(24, end) 2s forwards;
}

body.theme-aurora .intro p span:nth-of-type(2) {
  animation: introAuroraTyping 1.6s steps(23, end) 3.9s forwards;
}

body.theme-aurora .intro p .callout {
  animation: introAuroraTyping 1.4s steps(20, end) 5.6s forwards;
}

body.theme-void .intro {
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.theme-void .intro h1,
body.theme-void .intro p span {
  font-family: 'Inter', serif;
  display: inline-block;
  overflow: hidden;
  max-width: 100%;
  white-space: nowrap;
  clip-path: inset(0 100% 0 0);
  -webkit-clip-path: inset(0 100% 0 0);
}

@keyframes introVoidTyping {
  0% {
    clip-path: inset(0 100% 0 0);
    -webkit-clip-path: inset(0 100% 0 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
  }
}

body.theme-void .intro h1 {
  margin-inline: auto;
  animation: introVoidTyping 1.4s steps(22, end) 0.3s forwards;
}

body.theme-void .intro p span:nth-of-type(1) {
  animation: introVoidTyping 1.6s steps(24, end) 2s forwards;
}

body.theme-void .intro p span:nth-of-type(2) {
  animation: introVoidTyping 1.6s steps(23, end) 3.9s forwards;
}

body.theme-void .intro p .callout {
  animation: introVoidTyping 1.4s steps(20, end) 5.6s forwards;
}

body.theme-ice .intro {
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.theme-ice .intro h1,
body.theme-ice .intro p span {
  font-family: 'Inter', serif;
  display: inline-block;
  overflow: hidden;
  max-width: 100%;
  white-space: nowrap;
  clip-path: inset(0 100% 0 0);
  -webkit-clip-path: inset(0 100% 0 0);
}

@keyframes introIceTyping {
  0% {
    clip-path: inset(0 100% 0 0);
    -webkit-clip-path: inset(0 100% 0 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
  }
}

body.theme-ice .intro h1 {
  margin-inline: auto;
  animation: introIceTyping 1.4s steps(22, end) 0.3s forwards;
}

body.theme-ice .intro p span:nth-of-type(1) {
  animation: introIceTyping 1.6s steps(24, end) 2s forwards;
}

body.theme-ice .intro p span:nth-of-type(2) {
  animation: introIceTyping 1.6s steps(23, end) 3.9s forwards;
}

body.theme-ice .intro p .callout {
  animation: introIceTyping 1.4s steps(20, end) 5.6s forwards;
}

@media (max-width: 540px) {
  body.theme-aurora .intro h1,
  body.theme-aurora .intro p span {
    white-space: normal;
  }

  body.theme-void .intro h1,
  body.theme-void .intro p span {
    white-space: normal;
  }

  body.theme-ice .intro h1,
  body.theme-ice .intro p span {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.theme-aurora .intro h1,
  body.theme-aurora .intro p span {
    clip-path: none !important;
    -webkit-clip-path: none !important;
    animation: none !important;
  }

  body.theme-void .intro h1,
  body.theme-void .intro p span {
    clip-path: none !important;
    -webkit-clip-path: none !important;
    animation: none !important;
  }

  body.theme-ice .intro h1,
  body.theme-ice .intro p span {
    clip-path: none !important;
    -webkit-clip-path: none !important;
    animation: none !important;
  }
}


.chat-log {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  /* Evita saltos de anclaje cuando se insertan mensajes */
  overflow-anchor: none;
}

.chat-log::-webkit-scrollbar {
  width: 6px;
}

.chat-log::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 999px;
}

.message {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 90%;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  font-size: 0.98rem;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.message--assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
}

.message--human {
  align-self: flex-start;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid var(--border);
}

.message--user {
  align-self: flex-end;
  background: var(--bubble-user);
}

.message__label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.message__body {
  white-space: pre-wrap;
}

.message__attachments {
  margin-top: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.message__attachment {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.05);
  color: inherit;
  font-size: 0.78rem;
  text-decoration: none;
}

.message__attachment:hover {
  text-decoration: underline;
}

.message__attachment-size {
  font-size: 0.7rem;
  color: var(--muted-text, #475569);
}

.message strong {
  color: var(--accent);
  font-weight: 600;
}

.typing-indicator {
  width: 44px;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1s infinite ease-in-out;
}

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

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

@keyframes typing {
  0%,
  80%,
  100% {
    transform: scale(0.6);
    opacity: 0.3;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.composer {
  width: min(760px, 92vw);
  margin: 0 auto 0.65rem;
  background: var(--shell-panel-background);
  border-radius: 22px;
  border: 0.8px solid var(--border);
  box-shadow: var(--shadow-elevated);
  padding: 1.25rem 1.25rem 0.25rem;
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateZ(0);
  bottom: calc(var(--footer-h, 0px) + var(--footer-gap, 12px));
  z-index: 20;
}

/* Promover a capa propia para evitar parpadeos durante repaints/reflows */
.site-footer {
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform;
}

.composer-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.composer-disclaimer {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.composer-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--surface);
  border-radius: 1.25rem;
  padding: 0.6rem 0.75rem;
  border: 0.8px solid var(--border);
}

.composer-input-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.composer-input-row input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
  padding: 0.75rem 1rem;
}

.composer-input-row input:focus {
  outline: none;
}

.composer-input-row button {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

#chat-submit {
  background: var(--accent-gradient);
  color: #0f172a;
}

#chat-submit:hover {
  transform: translateY(-1px);
}

.composer-attach {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #d24d91;
  color: #fff;
}

.composer-attach:hover {
  transform: translateY(-1px);
}

.composer-attach svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  stroke-width: 1.6;
  fill: none;
}

.composer-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.composer-attachments__list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.composer-attachments__item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.04);
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  color: var(--muted-text, #475569);
}

.composer-attachments__item span {
  max-width: 140px;
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-attachments__size {
  font-size: 0.68rem;
  color: var(--muted-text, #475569);
}

.composer-attachments__remove {
  border: none;
  background: transparent;
  color: var(--muted-text, #475569);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.1rem;
}

.composer-attachments__remove:hover {
  color: var(--text);
}

.composer-attachments__error,
.composer-attachments__uploading {
  width: 100%;
  font-size: 0.75rem;
}

.composer-attachments__error {
  color: var(--destructive, #dc2626);
}

.composer-attachments__uploading {
  color: var(--muted-text, #475569);
}

.site-footer {
  border-top: 1px solid var(--border);
  background-color: var(--footer-background);
  padding: 0.6rem 0;
  width: 100%;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 12;
  /* Evitar solape con el indicador de iOS */
  padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
}

/* Footer incrustado dentro del composer: estilo integrado, sin fondo pleno */
.composer .site-footer {
  background: transparent;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
  padding-bottom: 0.2rem;
}
.composer .site-footer .container {
  width: min(760px, 92vw);
  margin: 0 auto;
}


.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.footer-content .logo {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
  font-size: 0.85rem;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-muted);
}

@media (max-width: 1080px) {
  .header-content {
    flex-wrap: wrap;
    justify-content: center;
  }

  .nav {
    order: 3;
  }

  .cta {
    order: 1;
  }
}

@media (max-width: 960px) {
  .nav {
    display: none;
  }

  .header-content {
    justify-content: space-between;
  }

  /* Mostrar botón hamburger en tablet/móvil */
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Ocultar footer también en tablets pequeñas */
  .site-footer {
    display: none;
  }

  /* Compactar CTA hasta 960px */
  .site-header .cta {
    font-size: 0.95rem;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    line-height: 1.1;
  }
}

@media (max-width: 720px) {
  body {
    gap: 1rem;
  }

  .site-header .brand {
    display: none;
  }

  .site-header .cta {
    position: static;
    transform: none;
    margin-left: auto;
    margin-right: clamp(0.4rem, 2.5vw, 1rem);
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.90rem;
    line-height: 1.1;
  }

  .theme-button {
    min-width: 24px;
    height: 50px;
  }

  .theme-button svg {
    width: 18px;
    height: 18px;
  }

  /* Mostrar botón hamburger en móvil */
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .layout > .chat-shell {
    background: transparent;
    box-shadow: none;
    padding: 1.25rem;
  }

  /* Compactar la CTA para igualar altura visual al logo */
  .site-header .cta {
    font-size: 0.95rem;
    padding: 0.2rem 0.6rem;
    border-radius: 8px;
    line-height: 1.1;
  }

  /* Composer fijo y más esbelto en móviles */
  .composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom);
    margin: 0;
    width: 100%;
    border-radius: 12px 12px 0 0;
    padding: 0.5rem 0.75rem 0.25rem;
    z-index: 30;
    /* Anular centrado horizontal de escritorio */
    transform: translateZ(0);
  }

  .composer-content {
    width: min(760px, 92vw);
    margin: 0 auto;
    gap: 0.5rem;
  }

  .composer-disclaimer {
    display: none;
  }

  .composer-form {
    border-radius: 1rem;
    padding: 0.4rem 0.6rem;
    gap: 0.45rem;
  }

  .composer-input-row {
    gap: 0.55rem;
  }

  .composer-input-row input {
    padding: 0.6rem 0.8rem;
  }

  .composer-input-row button {
    width: auto;
    padding: 0.6rem 1rem;
  }

  .composer-attachments__item {
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
  }

  /* En móvil, el área legal se oculta y el alto efectivo del composer es menor */
  :root {
    --composer-h: 100px;
  }

  /* Ocultar el footer del sitio en móviles */
  .site-footer {
    display: none;
  }

  .footer-content {
    flex-direction: column;
    gap: 0.6rem;
    text-align: center;
  }

  .footer-left,
  .footer-links {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Aún más compacto en móviles pequeños */
@media (max-width: 480px) {
  .site-header .cta {
    font-size: 0.82rem;
    padding: 0.52rem 0.8rem;
    border-radius: 8px;
    line-height: 1.05;
    white-space: nowrap;
    margin-left: auto;
    margin-right: clamp(0.35rem, 4vw, 0.75rem);
  }

  .theme-button {
    min-width: 22px;
    height: 46px;
  }

  .theme-button svg {
    width: 16px;
    height: 16px;
  }
}

@media (max-width: 1024px) {
  /* Ocultar footer en iPads vertical y similares */
  .site-footer {
    display: none;
  }

  /* En resoluciones medias, llevar el composer al borde seguro */
  .composer {
    bottom: env(safe-area-inset-bottom);
  }

  /* Mostrar hamburger y ocultar acciones del header hasta 1024px */
  .hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}
