:root {
  --font-heading: "Cinzel", serif;
  --font-body: "EB Garamond", serif;
  --color-bg: #f8f1e0;
  --color-text: #2d2a26;
  --color-header-bg: #2d2a26;
  --color-header-text: #f4e9d8;
  --color-user-bg: #4a5568;
  --color-ai-bg: #e8e2d5;
  --color-ai-text: #2d2a26;
  --color-border: #c9b896;
  --color-accent: #a67c1e;
  --color-accent-text: #7a5c17;
  --color-glass-bg: rgba(45, 42, 38, 0.55);
  --color-glass-panel: rgba(232, 226, 213, 0.6);
}

body.dark-theme {
  --color-bg: #14100d;
  --color-text: #e8dcc3;
  --color-header-bg: #000000;
  --color-user-bg: #4a3f6b;
  --color-ai-bg: #241f1a;
  --color-ai-text: #e8dcc3;
  --color-border: #4a3f2e;
  --color-accent: #d4af37;
  --color-accent-text: #d4af37;
  --color-glass-bg: rgba(0, 0, 0, 0.55);
  --color-glass-panel: rgba(36, 31, 26, 0.6);
  background-image:
    radial-gradient(
      ellipse at top left,
      rgba(212, 175, 55, 0.06),
      transparent 60%
    ),
    radial-gradient(
      ellipse at bottom right,
      rgba(74, 63, 107, 0.15),
      transparent 60%
    ),
    linear-gradient(rgba(20, 16, 13, 0.85), rgba(20, 16, 13, 0.85)),
    url("assets/lotr_map_wallpaper.jpeg");
  background-size:
    auto,
    auto,
    cover,
    cover;
  background-position:
    center,
    center,
    center,
    center;
  background-repeat:
    no-repeat,
    no-repeat,
    no-repeat,
    no-repeat;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Barras de desplazamiento con la paleta del proyecto en vez del scrollbar
   gris por defecto del sistema operativo. scrollbar-color/-width es el
   estándar (Firefox y Chromium recientes); los ::-webkit-scrollbar-* son
   el equivalente para Chrome/Safari/Edge más viejos. Al usar variables de
   tema, cambian solas entre modo claro/oscuro sin reglas extra. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-accent) var(--color-bg);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--color-bg);
}

*::-webkit-scrollbar-thumb {
  background-color: var(--color-accent);
  border-radius: 999px;
  border: 2px solid var(--color-bg);
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-accent-text);
}

/* Transición suave al cambiar de tema: en vez de que los colores salten
   de golpe, estos elementos (los que más cambian entre claro/oscuro)
   interpolan background/color/border al alternar la clase .dark-theme. */
body,
nav,
header,
.chat-toolbar,
.chat-rail,
.chat-lore-panel,
.chat-main,
.message,
.bento-item,
.input-group textarea,
#messages-area {
  transition:
    background-color 0.35s ease,
    background-image 0.35s ease,
    color 0.35s ease,
    border-color 0.35s ease;
}

/* Gradientes en capas: dos radial-gradient decorativos + un overlay
   semitransparente + el mapa de fondo, todos apilados en background-image.
   El primer valor listado queda "arriba" de los demás. */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: var(--font-body);
  background-color: var(--color-bg);
  background-image:
    radial-gradient(
      ellipse at top left,
      rgba(166, 124, 30, 0.08),
      transparent 60%
    ),
    radial-gradient(
      ellipse at bottom right,
      rgba(45, 42, 38, 0.08),
      transparent 60%
    ),
    linear-gradient(rgba(248, 241, 224, 0.91), rgba(248, 241, 224, 0.91)),
    url("assets/lotr_map_wallpaper.jpeg");
  background-size:
    auto,
    auto,
    cover,
    cover;
  background-position:
    center,
    center,
    center,
    center;
  background-repeat:
    no-repeat,
    no-repeat,
    no-repeat,
    no-repeat;
  background-attachment: fixed;
  color: var(--color-text);
}

header {
  padding: 1rem;
  flex-shrink: 0;
  text-align: center;
  font-family: var(--font-heading);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border-bottom: 3px solid var(--color-accent);
}

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

/* Tinte sutil por personaje: un radial-gradient muy transparente con el
   color del personaje activo (--character-accent-rgb, inyectado desde
   app.js), apenas visible detrás de las burbujas. */
#messages-area {
  background-image: radial-gradient(
    ellipse at top,
    rgba(var(--character-accent-rgb, 166, 124, 30), 0.07),
    transparent 65%
  );
}

.message {
  max-width: 80%;
  padding: 0.65rem 1rem;
  border-radius: 1rem;
  line-height: 1.5;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.message__text {
  font-size: 1.1rem;
  line-height: 1.6;
}

/* Pseudo-elemento ::after: dibuja la "colita" del globo de chat con
   bordes transparentes en 3 lados y color solo en uno, sin usar imágenes. */
.message--user::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 0;
  border: 8px solid transparent;
  border-top-color: var(--color-user-bg);
  border-bottom: 0;
  border-right: 0;
}

.message--ai::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 0;
  border: 8px solid transparent;
  border-top-color: var(--color-ai-bg);
  border-bottom: 0;
  border-left: 0;
}

.message--user {
  align-self: flex-end;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.1)),
    linear-gradient(var(--color-user-bg), var(--color-user-bg));
  color: #ffffff;
  border-bottom-right-radius: 0;
}

/* La burbuja de IA suma una tercera capa: un tinte del color del
   personaje activo sobre --color-ai-bg. Al ser una capa más (no un color
   fijo), reacciona sola al cambiar de tema — nunca hay que recalcular
   nada en JS cuando se alterna claro/oscuro. */
.message--ai {
  align-self: flex-start;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.14), rgba(0, 0, 0, 0.05)),
    linear-gradient(
      rgba(var(--character-accent-rgb, 166, 124, 30), 0.16),
      rgba(var(--character-accent-rgb, 166, 124, 30), 0.16)
    ),
    linear-gradient(var(--color-ai-bg), var(--color-ai-bg));
  color: var(--color-ai-text);
  border-bottom-left-radius: 0;
}

.message__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.65;
}

.message__copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 1;
}

.input-group {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.input-group textarea {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--color-border);
  resize: none;
  font-family: inherit;
  font-size: 1rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.input-group button {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-accent);
  border-radius: 0.4rem;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

/* Regla compartida: los 5 tipos de botón "outline" del proyecto (input,
   toolbar, acciones de lore, prompts sugeridos y prompts del acordeón)
   usaban exactamente el mismo hover — agrupados acá en vez de repetidos. */
.input-group button:hover,
.chat-toolbar button:hover,
.lore__actions button:hover,
.lore-section__prompt:hover,
.suggested-prompt:hover {
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.12)),
    linear-gradient(var(--color-accent), var(--color-accent));
  color: var(--color-header-bg);
}

.chat-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.85rem;
  background: var(--color-glass-panel);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.chat-toolbar button {
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-accent);
  border-radius: 0.5rem;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
  cursor: pointer;
  font-size: 0.8rem;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

/* Botón de solo ícono: mismo patrón de tooltip que #theme-toggle (::after
   con attr(aria-label), visible en hover/focus) para no perder la pista
   visual que daba el texto "Borrar historial". */
#clear-history-btn {
  position: relative;
  min-width: 44px;
  padding: 0.5rem;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#clear-history-btn::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.35rem 0.65rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 0.75rem;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  z-index: 60;
}

#clear-history-btn:hover::after,
#clear-history-btn:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.chat-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Fila de columnas (rail + chat + panel de historia). El header vive
   fuera de esto, como barra de ancho completo, para no verse encajonado
   dentro de una sola columna (efecto "frameset" de la web vieja). */
.chat-columns {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  background: var(--color-ai-bg);
}

.chat-rail__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  gap: 1rem;
  padding: 1.25rem 0;
}

.chat-rail__item {
  position: relative;
  display: block;
  border: 3px solid transparent;
  border-radius: 50%;
  padding: 0.2rem;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  transition: transform 0.15s ease;
}

.chat-rail__item:hover {
  transform: scale(1.08);
}

.chat-rail__item--active {
  border-color: var(--character-accent, var(--color-accent));
  background: radial-gradient(
    circle,
    rgba(var(--character-accent-rgb, 166, 124, 30), 0.22),
    transparent 70%
  );
}

.chat-rail__emoji {
  font-size: 2rem;
}

/* Retratos "en pergamino" por defecto (desaturados + un toque sepia) y a
   full color en :hover/:focus-visible/activo — mismo filtro para la
   imagen real y el emoji de respaldo, así el efecto es igual en ambos. */
.chat-rail__avatar,
.chat-rail__emoji {
  filter: grayscale(0.85) sepia(0.35) contrast(0.95);
  transition: filter 0.25s ease;
}

.chat-rail__item:hover .chat-rail__avatar,
.chat-rail__item:hover .chat-rail__emoji,
.chat-rail__item:focus-visible .chat-rail__avatar,
.chat-rail__item:focus-visible .chat-rail__emoji,
.chat-rail__item--active .chat-rail__avatar,
.chat-rail__item--active .chat-rail__emoji {
  filter: none;
}

/* Tooltip dinámico: en vez de un ::after posicionado dentro del riel
   (quedaba recortado por el overflow del contenedor scrolleable), un
   único elemento con position:fixed se reposiciona por JS según el
   avatar activo. Al ser fixed, ignora cualquier overflow ancestro. */
.chat-rail__tooltip {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 200px;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  white-space: normal;
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(0);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  z-index: 50;
}

.chat-rail__tooltip strong {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.chat-rail__tooltip span {
  font-family: var(--font-body);
  font-size: 0.75rem;
  line-height: 1.3;
  opacity: 0.85;
}

.chat-rail__tooltip--visible {
  opacity: 1;
  transform: translateY(-50%) translateX(6px);
}

.chat-lore-panel {
  display: none;
  background: var(--color-ai-bg);
  flex-direction: column;
  padding: 1rem;
  overflow-y: auto;
}

.chat-lore-panel__header {
  text-align: center;
  padding-bottom: 1rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--character-accent, var(--color-accent));
}

/* Retrato tipo "cuadro enmarcado": cuadrado con esquinas suaves en vez
   de círculo, y un marco en degradado (mismo truco de capas: un fondo
   sólido para el contenido + un degradado detrás, recortados distinto
   con background-clip) en vez de border-image. */
.chat-lore-panel__avatar {
  width: 100%;
  max-width: 7rem;
  height: 7rem;
  border-radius: 0.75rem;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  display: block;
  border: 4px solid transparent;
  background-image:
    linear-gradient(var(--color-ai-bg), var(--color-ai-bg)),
    linear-gradient(
      135deg,
      var(--character-accent, var(--color-accent)),
      var(--color-accent-text)
    );
  background-origin: border-box;
  background-clip: content-box, border-box;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.chat-lore-panel__emoji {
  width: 100%;
  max-width: 7rem;
  height: 7rem;
  border-radius: 0.75rem;
  margin: 0 auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  border: 4px solid transparent;
  background-image:
    linear-gradient(var(--color-ai-bg), var(--color-ai-bg)),
    linear-gradient(
      135deg,
      var(--character-accent, var(--color-accent)),
      var(--color-accent-text)
    );
  background-origin: border-box;
  background-clip: content-box, border-box;
}

.chat-lore-panel__header h2 {
  font-family: var(--font-heading);
  font-size: 1rem;
}

.chat-lore-panel__tagline {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

/* Acordeón: patrón de disclosure (botón con aria-expanded/aria-controls +
   contenido con atributo hidden), sin librería. */
.lore-section {
  border-bottom: 1px solid var(--color-border);
}

.lore-section__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  padding: 0.75rem 0.25rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  min-height: 44px;
}

.lore-section__icon {
  transition: transform 0.2s ease;
}

.lore-section__trigger[aria-expanded="true"] .lore-section__icon {
  transform: rotate(180deg);
}

.lore-section__content {
  padding: 0 0.25rem 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.lore-section__prompts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lore-section__prompt {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid var(--color-accent-text);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--color-text);
  cursor: pointer;
  min-height: 44px;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.chat-lore-panel__link {
  display: block;
  text-align: center;
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--color-accent-text);
}

.chat-header__lore-link {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-header-text);
  border-bottom: 1px solid currentColor;
  text-decoration: none;
  opacity: 0.85;
}

/* Avatar del header: solo en mobile. En desktop el panel de historia ya
   muestra un retrato grande del personaje — repetirlo acá volvería a la
   redundancia de 3 avatares que se corrigió antes (ver sección 9 de la
   guía en Notion, Error de layout). */
.chat-header__avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.chat-header__emoji {
  font-size: 1.25rem;
  vertical-align: middle;
  margin-right: 0.4rem;
}

.chat-layout > header {
  position: relative;
}

section {
  padding: 1.5rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

/* transition + transform: anima el estado :hover (más abajo) y también
   el fin del scroll-reveal que maneja IntersectionObserver en app.js. */
.character-card {
  cursor: pointer;
  background: var(--color-ai-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    opacity 0.4s ease;
}

.character-card:hover {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
  border-color: var(--color-accent);
}

.character-card.reveal-pending {
  opacity: 0;
  transform: translateY(24px);
}

.character-card__emoji {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.character-card__avatar {
  display: block;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  border: 2px solid var(--color-accent);
}

.chat-rail__avatar {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
}

.lore__avatar {
  display: block;
  width: 6rem;
  height: 6rem;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.5rem;
  border: 3px solid var(--color-accent);
}

.character-card p {
  font-size: 0.85rem;
  opacity: 0.75;
}

.character-card__lore-link {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-accent-text);
  text-decoration: none;
  border-top: 1px solid var(--color-border);
  padding-top: 0.5rem;
  width: 100%;
}

.character-card__lore-link:hover {
  text-decoration: underline;
}

.hero {
  text-align: center;
  padding-bottom: 0;
}

.hero__title {
  font-size: 2rem;
  background-image: linear-gradient(135deg, var(--color-accent), var(--color-accent-text));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__subtitle {
  max-width: 500px;
  margin: 0.75rem auto 0;
  font-style: italic;
  opacity: 0.8;
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--color-accent);
  max-width: 300px;
  margin: 1.25rem auto;
  font-size: 1.1rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-accent);
  opacity: 0.6;
}

.gallery {
  padding-top: 0.5rem;
}

.gallery h2 {
  font-family: var(--font-heading);
  text-align: center;
}

.lore {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

.lore__emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
}

.lore__text {
  line-height: 1.7;
  text-align: left;
}

.lore__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.lore__actions button {
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--color-accent);
  border-radius: 0.4rem;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

.lore__actions a {
  color: var(--color-accent-text);
  text-decoration: none;
}

.lore__actions a:hover {
  text-decoration: underline;
}

@media (min-width: 768px) {
  body {
    max-width: 700px;
    margin: 0 auto;
  }

  .message {
    max-width: 65%;
  }
}

@media (min-width: 1024px) {
  body {
    max-width: 1600px;
  }

  header {
    padding: 1.5rem;
  }

  .chat-layout {
    gap: 1rem;
    padding: 1rem;
  }

  .chat-layout > header {
    border-radius: 0.75rem;
  }

  .chat-columns {
    flex-direction: row;
    gap: 1rem;
  }

  .chat-rail {
    display: flex;
    width: 7rem;
    flex-shrink: 0;
    overflow-y: auto;
    border-radius: 0.75rem;
  }

  .chat-lore-panel {
    display: flex;
    width: 300px;
    flex-shrink: 0;
    border-radius: 0.75rem;
  }

  .chat-main {
    background: var(--color-ai-bg);
    border-radius: 0.75rem;
    overflow: hidden;
  }

  .chat-header__lore-link {
    display: none;
  }

  .chat-header__avatar,
  .chat-header__emoji {
    display: none;
  }
}

/* Glassmorphism: fondo semitransparente (--color-glass-bg) + backdrop-filter
   desenfoca lo que queda detrás (el mapa), en vez de taparlo con un color
   sólido. -webkit- es el prefijo que necesita Safari para lo mismo. */
/* Ya no es una "barra": con solo 2 botones adentro (menú y tema), la caja de
   fondo glassmorphism sobraba. Quedan los dos íconos flotando directo sobre
   el mapa, sin fondo ni blur detrás. */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  flex-shrink: 0;
}

/* El menú de navegación (Inicio/Chat/Acerca de) vive detrás de un botón de
   hamburguesa a todos los anchos: antes los 3 links + separadores "❖"
   competían por espacio con el toggle de tema y se partían en mobile (ver
   Error 8 en la guía de Notion). */
.nav-menu {
  position: relative;
}

#nav-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  /* var(--color-text), no un cream fijo: el botón ya no vive sobre una barra
     oscura, sino directo sobre el fondo del body, que cambia con el tema. */
  color: var(--color-text);
  font-size: 1.1rem;
  cursor: pointer;
}

/* [hidden] tiene que ir después y explícito: si .nav-menu__panel ya trae
   display:flex, esa regla de autor le gana al display:none que el navegador
   aplica por el atributo hidden, y el panel queda visible siempre. */
.nav-menu__panel[hidden] {
  display: none;
}

.nav-menu__panel {
  position: absolute;
  top: calc(100% + 0.6rem);
  left: 0;
  display: flex;
  flex-direction: column;
  width: max-content;
  min-width: 170px;
  background: var(--color-header-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.6rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  z-index: 70;
}

.nav-menu__panel a {
  padding: 0.8rem 1.1rem;
  color: var(--color-header-text);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.nav-menu__panel a:last-child {
  border-bottom: none;
}

.nav-menu__panel a:hover,
.nav-menu__panel a:focus-visible {
  background: var(--color-accent);
  color: var(--color-header-bg);
}

#theme-toggle {
  position: relative;
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: 50%;
  width: 2.75rem;
  height: 2.75rem;
  cursor: pointer;
  font-size: 1rem;
}

/* Tooltip del botón de tema: el aria-label ya lo anuncia a lectores de
   pantalla, pero un botón de solo ícono también necesita una pista
   visible al pasar el cursor o el foco por teclado. Usa attr(aria-label)
   para no repetir el texto en dos lugares. */
#theme-toggle::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.35rem 0.65rem;
  border-radius: 0.4rem;
  border: 1px solid var(--color-border);
  font-family: var(--font-body);
  font-size: 0.75rem;
  white-space: nowrap;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  z-index: 60;
}

#theme-toggle:hover::after,
#theme-toggle:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* Toast genérico: confirma acciones (cambio de tema, borrar historial...)
   con un mensaje que aparece y se desvanece solo. role="status" +
   aria-live="polite" en el HTML hace que los lectores de pantalla lo
   anuncien apenas cambia su texto. */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--color-accent);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  /* Sin esto, en pantallas angostas el texto puede partirse en dos líneas y
     la píldora (border-radius: 999px) queda deformada — mismo bug que tenía
     el panel del menú. max-width + ellipsis es la red de seguridad si algún
     mensaje futuro fuera más largo de lo que cabe. */
  white-space: nowrap;
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  z-index: 100;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: opacity 0.15s ease;
}

#app.is-transitioning {
  opacity: 0;
}

/* Bento grid: grid-template-areas nombra cada bloque y decide su
   posición dibujando el layout como texto. "characters" se repite en
   dos filas, por eso ocupa una card grande y desigual (asimetría típica
   de un bento grid) en vez de una grilla pareja. */
.about-bento {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-areas:
    "what what"
    "stack characters"
    "credits characters";
  gap: 1rem;
  margin-top: 1.5rem;
}

.bento-item {
  background: var(--color-ai-bg);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.bento-item--what {
  grid-area: what;
}

.bento-item--stack {
  grid-area: stack;
}

.bento-item--characters {
  grid-area: characters;
}

.bento-item--credits {
  grid-area: credits;
}

.bento-disclaimer {
  font-size: 0.8rem;
  opacity: 0.75;
  margin-top: 0.5rem;
}

.bento-item h2,
.bento-item h3 {
  font-family: var(--font-heading);
  margin-bottom: 0.5rem;
}

.bento-item ul {
  list-style: none;
  line-height: 1.8;
}

@media (max-width: 767px) {
  .about-bento {
    grid-template-columns: 1fr;
    grid-template-areas:
      "what"
      "stack"
      "characters"
      "credits";
  }

  /* En desktop los prompts sugeridos van en fila y hacen wrap (quedan 2 y
     luego 1 suelto abajo, disparejo). En mobile, uno debajo del otro. */
  .suggested-prompts {
    flex-direction: column;
    align-items: flex-start;
  }
}

.suggested-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.suggested-prompt {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}

h1,
h3 {
  font-family: var(--font-heading);
}
