/* ============================================================
   POSADA R&D — Living Kandinsky / Crystal design system
   Point & line over curve · organic motion · glass surfaces
   ============================================================ */

:root {
  --paper: #f4f1ea;
  --paper-2: #efe9df;
  --ink: #14161a;
  --muted: #565b63;
  --blue: #1f4fd0;
  --blue-soft: #7aa0ff;
  --cyan: #37c6d0;
  --yellow: #f5c542;
  --orange: #f0872a;
  --red: #d64545;
  --glass: rgba(255, 255, 255, 0.55);
  --glass-line: rgba(255, 255, 255, 0.75);
  --line: rgba(20, 30, 60, 0.12);
  --shadow: 0 20px 60px -24px rgba(20, 30, 60, 0.35);
  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* Living background layers ----------------------------------- */
#living-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(60% 50% at 78% 18%, rgba(122, 160, 255, 0.20), transparent 60%),
    radial-gradient(45% 45% at 15% 80%, rgba(55, 198, 208, 0.16), transparent 60%),
    radial-gradient(35% 35% at 85% 85%, rgba(240, 135, 42, 0.12), transparent 60%),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  pointer-events: none;
}

.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  animation: drift 22s var(--ease) infinite alternate;
}
.blob.b1 { width: 320px; height: 320px; top: -60px; right: 6%; background: radial-gradient(circle at 30% 30%, var(--blue-soft), transparent 70%); }
.blob.b2 { width: 260px; height: 260px; bottom: 4%; left: -40px; background: radial-gradient(circle at 40% 40%, var(--cyan), transparent 70%); animation-duration: 28s; }
.blob.b3 { width: 180px; height: 180px; top: 40%; left: 55%; background: radial-gradient(circle at 40% 40%, var(--yellow), transparent 70%); animation-duration: 34s; }

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(30px, -24px) scale(1.08); }
  100% { transform: translate(-24px, 26px) scale(0.96); }
}

/* Content wrappers ------------------------------------------- */
.wrap { position: relative; z-index: 2; width: min(1120px, 92%); margin: 0 auto; }

.nav-bar {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 26px 0;
}
.mark { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.02em; }
.mark-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(31, 79, 208, 0.15);
  animation: pulse 3.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }
  50%      { transform: scale(1.25); box-shadow: 0 0 0 8px rgba(31,79,208,0.05); }
}

.links { display: flex; gap: 8px; align-items: center; }
.links a {
  padding: 9px 16px; border-radius: 999px; font-size: 0.92rem; color: var(--muted);
  transition: color 0.4s var(--ease), background 0.4s var(--ease);
}
.links a:hover { color: var(--ink); background: var(--glass); backdrop-filter: blur(8px); }

/* Menú de páginas (hamburguer): en móvil, los links del footer se colapsan
   aquí, junto al toggle de idioma. Oculto en escritorio (lo revela el media
   query de móvil). Lo construye app.js clonando .foot-links. */
.nav-menu-wrap { position: relative; display: none; }
.nav-menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 34px; border-radius: 10px; cursor: pointer;
  color: var(--muted); background: var(--glass); border: 1px solid var(--glass-line);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.nav-menu-toggle:hover { color: var(--ink); background: #fff; }
.nav-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40; display: none;
  flex-direction: column; min-width: 190px; padding: 8px;
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--glass-line);
  border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(16px) saturate(140%);
}
.nav-menu a { padding: 10px 12px; border-radius: 8px; color: var(--ink); font-size: 0.92rem; white-space: nowrap; }
.nav-menu a:hover { background: rgba(20, 30, 60, 0.05); }
.nav-menu-wrap.open .nav-menu { display: flex; animation: fade 0.2s var(--ease); }
/* Home affordance lives in the brand mark (replaces the decorative dot) */
.mark-home { display: inline-flex; align-items: center; justify-content: center; color: var(--blue); flex: 0 0 auto; }
.mark-home svg { display: block; }
.mark-home:hover { color: var(--ink); }
.mark-title { color: inherit; text-decoration: none; }
a.mark-title:hover { color: var(--blue); }

/* Hero ------------------------------------------------------- */
.hero {
  position: relative; z-index: 2;
  min-height: 78vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 0 60px;
}
.hero .eyebrow {
  font-size: 0.78rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--blue); margin-bottom: 22px; opacity: 0;
  animation: rise 1s var(--ease) 0.1s forwards;
}
.hero h1 {
  font-size: clamp(2.4rem, 6.4vw, 5rem);
  line-height: 1.02; letter-spacing: -0.02em; font-weight: 600;
  max-width: 14ch; margin: 0; opacity: 0;
  animation: rise 1.1s var(--ease) 0.25s forwards;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--blue), var(--cyan) 60%, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead {
  margin-top: 26px; color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.15rem); max-width: 46ch; opacity: 0;
  animation: rise 1.1s var(--ease) 0.45s forwards;
}
.actions { margin-top: 40px; display: flex; gap: 14px; flex-wrap: wrap; opacity: 0; animation: rise 1.1s var(--ease) 0.65s forwards; }

@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Single-page home: intro next to chat --------------------- */
.home-split {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 1fr; gap: 44px;
  align-items: stretch; min-height: calc(100vh - 172px); min-height: calc(100dvh - 172px); padding: 4px 0 24px;
}
.home-intro { display: flex; flex-direction: column; justify-content: center; }
.home-intro .eyebrow {
  font-size: 0.78rem; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--blue); margin-bottom: 20px; opacity: 0; animation: rise 1s var(--ease) 0.1s forwards;
}
.home-intro h1 {
  font-size: clamp(2.1rem, 4.4vw, 3.9rem); line-height: 1.03; letter-spacing: -0.02em;
  font-weight: 600; max-width: 14ch; margin: 0; opacity: 0; animation: rise 1.1s var(--ease) 0.25s forwards;
}
.home-intro h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--blue), var(--cyan) 60%, var(--orange));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.home-intro .lead {
  margin-top: 22px; color: var(--muted); font-size: clamp(1rem, 1.5vw, 1.12rem);
  max-width: 42ch; opacity: 0; animation: rise 1.1s var(--ease) 0.45s forwards;
}
.home-intro .actions { margin-top: 32px; }
.home-split .chat { height: min(calc(100vh - 172px), 760px); height: min(calc(100dvh - 172px), 760px); opacity: 0; animation: rise 1.1s var(--ease) 0.55s forwards; }

/* Modal ---------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  padding: 20px; background: rgba(20, 30, 60, 0.28); backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; animation: fade 0.3s var(--ease); }
.modal {
  position: relative; width: min(480px, 100%); max-height: 90vh; max-height: 90dvh; overflow: auto; padding: 30px;
  border-radius: var(--radius); background: rgba(255, 255, 255, 0.75); border: 1px solid var(--glass-line);
  backdrop-filter: blur(20px) saturate(150%); box-shadow: var(--shadow); animation: rise 0.4s var(--ease);
}
.modal-close {
  position: absolute; top: 12px; right: 16px; border: 0; background: transparent;
  font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted);
}
.modal-close:hover { color: var(--ink); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Contact modal greeting (JP saying hi) */
.modal-greet { display: flex; align-items: center; gap: 12px; margin: 4px 0 22px; }
.greet-avatar {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(31, 79, 208, 0.25), 0 6px 16px -6px rgba(20, 30, 60, 0.4);
  animation: greet-bob 3s var(--ease) infinite;
}
.greet-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.greet-bubble {
  position: relative; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; border-bottom-left-radius: 5px; padding: 10px 14px;
  font-size: 0.92rem; color: var(--ink); box-shadow: var(--shadow);
  transform-origin: left center; opacity: 0;
  animation: greet-pop 0.55s var(--ease) 0.15s forwards;
}
.greet-bubble::before {
  content: ""; position: absolute; left: -7px; bottom: 8px;
  width: 12px; height: 12px; background: #fff;
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}
@keyframes greet-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-4px) rotate(-3deg); }
}
@keyframes greet-pop {
  0%   { opacity: 0; transform: scale(0.85) translateX(-6px); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

/* Buttons ---------------------------------------------------- */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-radius: 999px; font-size: 0.95rem; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease); overflow: hidden;
}
.btn:hover { transform: translateY(-2px); }
.btn.primary { background: linear-gradient(120deg, var(--blue), var(--cyan)); color: #fff; box-shadow: 0 16px 40px -16px rgba(31, 79, 208, 0.7); }
.btn.ghost, .btn.secondary { background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(10px); color: var(--ink); }
.btn .arrow { transition: transform 0.4s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

/* Organic "Let's talk" crystal pill (JP avatar + message icon) */
.talk-pill {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 7px 20px 7px 7px; border-radius: 999px; cursor: pointer;
  background: linear-gradient(120deg, var(--blue), var(--cyan)); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 16px 40px -16px rgba(31, 79, 208, 0.7);
  font-size: 1rem; font-weight: 600; letter-spacing: 0.01em;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease);
}
.talk-pill:hover { transform: translateY(-2px); box-shadow: 0 26px 54px -18px rgba(31, 79, 208, 0.8); }
.talk-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 4px 12px -4px rgba(20, 30, 60, 0.35);
  animation: greet-bob 3.4s var(--ease) infinite;
}
.talk-text { white-space: nowrap; }
.talk-icon { color: #fff; flex: 0 0 auto; transition: transform 0.4s var(--ease); }
.talk-pill:hover .talk-icon { transform: translateX(3px) translateY(-2px); }

/* Circular send button in the chat composer */
.chat-send {
  flex: 0 0 auto; width: 48px; height: 48px; padding: 0;
  justify-content: center; border-radius: 50%;
}

/* Crystal cards ---------------------------------------------- */
.crystal {
  position: relative; padding: 26px 24px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease);
}
.crystal::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(140deg, rgba(255,255,255,0.6), transparent 40%);
  opacity: 0.7; pointer-events: none;
}
.crystal::after {
  content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%;
  top: -50px; right: -40px;
  background: radial-gradient(circle, var(--accent, var(--blue-soft)), transparent 70%);
  opacity: 0.35; filter: blur(6px);
}
.crystal:hover { transform: translateY(-6px); box-shadow: 0 30px 70px -26px rgba(20, 30, 60, 0.45); }
.crystal .glyph { width: 40px; height: 40px; margin-bottom: 16px; }
.crystal h3 { margin: 0 0 6px; font-size: 1.05rem; font-weight: 600; }
.crystal p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.c1 { --accent: var(--blue-soft); }
.c2 { --accent: var(--cyan); }
.c3 { --accent: var(--orange); }

.mini-title {
  position: relative; z-index: 2;
  font-size: 0.76rem; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 20px;
}

/* Chat / FAQ ------------------------------------------------- */
.stage { position: relative; z-index: 2; padding: 30px 0 90px; }
.split { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 18px; }


.chat {
  border-radius: var(--radius); background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; min-height: 420px; overflow: hidden;
}
.chat .log { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 6px 4px 12px; display: flex; flex-direction: column; gap: 12px; }
.bubble { max-width: 82%; padding: 11px 14px; border-radius: 16px; font-size: 0.92rem; line-height: 1.45; animation: rise 0.5s var(--ease); }
.msg { display: flex; align-items: flex-end; gap: 10px; }
.msg.assistant { flex-direction: row; }
.msg.user { flex-direction: row; justify-content: flex-end; }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.user .bubble { background: linear-gradient(120deg, var(--blue), var(--cyan)); color: #fff; border-bottom-right-radius: 6px; }

.avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--paper-2); border: 1px solid var(--glass-line);
  box-shadow: 0 4px 12px -4px rgba(20, 30, 60, 0.35);
}
.msg.assistant .avatar { box-shadow: 0 0 0 2px rgba(31, 79, 208, 0.25), 0 4px 12px -4px rgba(20, 30, 60, 0.35); }
.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.composer { display: flex; gap: 10px; margin-top: 10px; }
.composer input {
  flex: 1; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.7);
  border-radius: 999px; padding: 13px 18px; font-size: 0.95rem; outline: none;
  transition: box-shadow 0.4s var(--ease);
}
.composer input:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }

.chat-disclaimer {
  margin: 10px 4px 2px; font-size: 0.72rem; line-height: 1.5; color: var(--muted);
  opacity: 0.8; text-align: left;
}
.chat-disclaimer::before {
  content: "AI"; display: inline-block; vertical-align: middle; margin-right: 6px;
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 6px; color: var(--blue);
  background: rgba(31, 79, 208, 0.10); border: 1px solid rgba(31, 79, 208, 0.20);
}
.disclaimer-link {
  border: 0; background: transparent; padding: 0; cursor: pointer; font: inherit;
  color: var(--blue); font-weight: 600; text-decoration: underline;
  text-underline-offset: 2px; transition: color 0.3s var(--ease);
}
.disclaimer-link:hover { color: var(--cyan); }

/* Chat toolbar + maximize ------------------------------------ */
.debug-toggle {
  display: inline-flex; align-items: center; gap: 10px; cursor: pointer;
  font-size: 0.9rem; color: var(--ink); user-select: none;
}
.debug-toggle input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--blue); }
.debug-toggle-nav {
  gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(10px); font-size: 0.82rem; color: var(--muted);
}
.debug-toggle-nav:hover { color: var(--ink); }
.debug-toggle-nav input { width: 16px; height: 16px; }

.chat-head { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -2px 2px 8px; }
.chat-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; cursor: pointer;
  color: var(--muted); background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--glass-line); transition: color 0.3s var(--ease), background 0.3s var(--ease), transform 0.3s var(--ease);
}
.chat-icon-btn:hover { color: var(--ink); background: #fff; transform: translateY(-1px); }
.chat-icon-btn .ic-collapse { display: none; }

/* Modo voz de la IA (chat-voice): micrófono + botón 🔊 por mensaje */
/* Borde e icono azules, coherentes con el botón de enviar. */
.cv-mic { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--blue); border-color: var(--blue); }
.cv-mic--dictate {
  flex: 0 0 auto; width: 44px; min-height: 44px; border-radius: 12px;
  background: rgba(31, 79, 208, 0.08); border: 1px solid var(--blue);
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}
.cv-mic--dictate:hover { color: #fff; background: var(--blue); }
.cv-mic.cv-on { color: #fff; background: var(--blue); border-color: var(--blue); }         /* modo voz activo */
.cv-mic.cv-listening { color: #fff; background: var(--rojo-k, #d93a2b); border-color: transparent; } /* escuchando */
@media (prefers-reduced-motion: no-preference) {
  .cv-mic.cv-listening { animation: cvPulse 1.2s ease-in-out infinite; }
}
@keyframes cvPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(217, 58, 43, 0.45); } 50% { box-shadow: 0 0 0 6px rgba(217, 58, 43, 0); } }
/* Botón 🔊 en la burbuja de la IA: burbuja propia para que el icono resalte */
.cv-say {
  flex: 0 0 auto; align-self: flex-end; margin-left: 2px; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; padding: 0; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem;
  color: var(--blue); background: rgba(31, 79, 208, 0.10); border: 1px solid var(--blue);
  box-shadow: 0 1px 3px rgba(20, 30, 60, 0.12);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.cv-say:hover, .cv-say:focus-visible { color: #fff; background: var(--blue); transform: translateY(-1px); }
.chat-mini-btn {
  display: none; align-items: center; gap: 8px; cursor: pointer;
  margin-right: auto; padding: 7px 14px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; color: #fff;
  background: linear-gradient(120deg, var(--blue), var(--cyan));
  border: 0; box-shadow: 0 12px 30px -14px rgba(31, 79, 208, 0.7);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.chat-mini-btn:hover { transform: translateY(-1px); box-shadow: 0 16px 36px -14px rgba(31, 79, 208, 0.8); }

.chat.maximized {
  position: fixed; top: 88px; right: 14px; bottom: 84px; left: 14px;
  z-index: 60; width: auto; height: auto;
  max-height: none; min-height: 0; margin: 0; opacity: 1;
  animation: rise 0.35s var(--ease) forwards;
}
.home-split .chat.maximized { height: auto; opacity: 1; }
.chat.maximized .chat-mini-btn { display: inline-flex; }
.chat.maximized .chat-head .ic-expand { display: none; }
.chat.maximized .chat-head .ic-collapse { display: block; }
body.chat-maxed { overflow: hidden; }

/* Forms ------------------------------------------------------ */
.form-card {
  position: relative; z-index: 2; max-width: 560px; padding: 30px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--shadow);
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.7);
  border-radius: 14px; padding: 12px 14px; font-size: 0.95rem; outline: none;
  transition: box-shadow 0.4s var(--ease);
}
.field input:focus, .field textarea:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }
.field textarea { min-height: 120px; resize: vertical; }

/* Footer ----------------------------------------------------- */
.foot {
  position: relative; z-index: 2; padding: 16px 0 22px; color: var(--muted); font-size: 0.82rem;
  display: flex; justify-content: flex-start; align-items: center; gap: 8px 18px; flex-wrap: wrap;
}
.foot-copy { white-space: nowrap; }
.foot-links { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.foot-links a { color: var(--muted); text-decoration: none; transition: color 0.3s var(--ease); }
.foot-links a:hover { color: var(--ink); }
.lang-toggle { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--glass-line); }
.lang-toggle button { border: 0; background: transparent; cursor: pointer; padding: 6px 12px; border-radius: 999px; font-size: 0.8rem; color: var(--muted); transition: background 0.3s var(--ease), color 0.3s var(--ease); }
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle button.active { background: var(--ink); color: #fff; }

/* Hidden admin access — a subtle dot next to the copyright */
.admin-access {
  display: inline-block;
  width: 7px; height: 7px;
  margin-left: 9px;
  border-radius: 50%;
  background: rgba(20, 30, 60, 0.18);
  vertical-align: middle;
  transition: background 0.4s var(--ease), transform 0.4s var(--ease);
}
.admin-access:hover { background: var(--blue); transform: scale(1.3); }

.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* Admin (crystal variant) ------------------------------------ */
.admin-grid { position: relative; z-index: 2; display: grid; grid-template-columns: 240px 1fr; gap: 18px; padding: 20px 0 60px; }
.sidebar, .panel {
  border-radius: var(--radius); background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(16px) saturate(140%); box-shadow: var(--shadow); padding: 16px;
}
.tab-btn { width: 100%; text-align: left; margin-bottom: 8px; }
.hidden { display: none; }

/* Admin full-screen layout: use the whole viewport, scroll inside panels */
body.admin-body { height: 100vh; height: 100dvh; overflow: hidden; }
body.admin-body .wrap {
  width: 98%; max-width: 2200px; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}
body.admin-body .nav-bar { padding: 12px 0; flex: 0 0 auto; }
body.admin-body .admin-grid {
  flex: 1 1 auto; min-height: 0; padding: 0 0 12px;
  grid-template-columns: 210px 1fr; gap: 12px;
}
body.admin-body .sidebar {
  align-self: stretch; overflow-y: auto; padding: 12px;
}
body.admin-body .panel {
  min-height: 0; overflow-y: auto; padding: 18px 22px;
}
body.admin-body .panel label { margin: 9px 0 4px; }
body.admin-body .panel input,
body.admin-body .panel textarea,
body.admin-body .panel select { padding: 8px 12px; border-radius: 11px; }
body.admin-body .panel textarea { min-height: 84px; }
body.admin-body .cta-row { margin-top: 12px; }
.small { color: var(--muted); font-size: 0.9rem; }

/* Bare form elements inside admin panel */
.panel label { display: block; font-size: 0.82rem; color: var(--muted); margin: 12px 0 6px; }
.panel input, .panel textarea, .panel select {
  width: 100%; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.7);
  border-radius: 14px; padding: 11px 14px; font-size: 0.95rem; outline: none;
  transition: box-shadow 0.4s var(--ease);
}
.panel input:focus, .panel textarea:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }
.panel textarea { min-height: 110px; resize: vertical; }
.panel h2 { margin-top: 0; font-weight: 600; }
.panel ul { list-style: none; padding: 0; margin: 0; }
.cta-row { margin-top: 18px; display: flex; gap: 12px; flex-wrap: wrap; }

.admin-search {
  width: 100%; margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--glass-line); background: rgba(255,255,255,0.75);
  font-size: 0.95rem; outline: none; transition: box-shadow 0.4s var(--ease);
}
.admin-search:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }

/* Contacts messaging ----------------------------------------- */
.btn.danger { background: rgba(214,69,69,0.12); border: 1px solid rgba(214,69,69,0.35); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; margin-left: 6px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 700; line-height: 1;
  color: #fff; background: var(--red); vertical-align: middle;
}

.contacts-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; align-items: start; }
.contacts-layout.notes-open:not(.context-open) { grid-template-columns: 240px minmax(0, 1fr) 320px; }
.contacts-layout.context-open:not(.notes-open) { grid-template-columns: 240px minmax(0, 1fr) 340px; }
.contacts-layout.notes-open.context-open { grid-template-columns: 240px minmax(0, 1fr) 320px 340px; }
.contacts-list { max-height: 72vh; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 8px; }
.contact-item {
  padding: 11px 13px; border-radius: 14px; cursor: pointer; min-width: 0;
  background: rgba(255,255,255,0.55); border: 1px solid var(--glass-line);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease);
}
.contact-item:hover { background: #fff; transform: translateY(-1px); }
.contact-item.is-active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,79,208,0.14); }
.contact-item.is-unread { border-left: 3px solid var(--blue); }
.contact-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.contact-item-top > strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-item-preview { color: var(--muted); font-size: 0.82rem; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-item-date { margin-top: 4px; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-chip { font-size: 0.66rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status-new { color: var(--blue); background: rgba(31,79,208,0.12); }
.status-read { color: var(--muted); background: rgba(20,22,26,0.08); }
.status-replied { color: #1a7f4b; background: rgba(26,127,75,0.12); }
.status-archived { color: var(--orange); background: rgba(240,135,42,0.14); }

.contact-chips { display: inline-flex; align-items: center; gap: 6px; }
.lang-chip {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 6px; color: var(--cyan);
  background: rgba(55,198,208,0.14); border: 1px solid rgba(55,198,208,0.3);
}
.lang-chip-lg { font-size: 0.72rem; padding: 4px 10px; border-radius: 999px; }
.reply-right-head { display: flex; align-items: center; gap: 10px; }
.thread-unread {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  font-size: 0.66rem; font-weight: 700; color: #fff; background: var(--red);
}
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg-card {
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255,255,255,0.6); border: 1px solid var(--glass-line);
}
.msg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.msg-row { display: flex; align-items: flex-start; gap: 12px; }
.msg-row .contact-message { flex: 1; min-width: 0; background: var(--paper); margin: 0; }
.msg-icons { display: flex; flex-direction: row; gap: 6px; flex: 0 0 auto; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer;
  background: rgba(255,255,255,0.7); border: 1px solid var(--glass-line);
  color: var(--muted); transition: color 0.25s var(--ease), background 0.25s var(--ease), transform 0.25s var(--ease);
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn.icon-reply:hover { color: #fff; background: var(--blue); border-color: var(--blue); }
.icon-btn.icon-archive:hover { color: var(--orange); border-color: rgba(240,135,42,0.4); }
.icon-btn.icon-trash:hover { color: #fff; background: var(--red); border-color: var(--red); }
.msg-card .contact-history { margin-top: 12px; padding-top: 10px; }

.contact-detail {
  min-height: 200px; max-height: 72vh; overflow-y: auto; padding: 18px; border-radius: 16px;
  background: rgba(255,255,255,0.55); border: 1px solid var(--glass-line);
}
.contact-empty { margin: 0; }
.contact-detail-head h3 { margin: 0 0 4px; }
.contact-detail-head p { margin: 0 0 14px; }
.detail-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.context-toggle { padding: 7px 14px; font-size: 0.85rem; flex: 0 0 auto; }

/* AI context: right-hand pane (three-pane inbox layout) */
.context-pane { display: none; min-width: 0; }
.contacts-layout.context-open .context-pane { display: block; }

/* Notes / journal side pane */
.notes-pane {
  display: none; min-width: 0; max-height: 72vh; overflow-y: auto;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(55,198,208,0.06); border: 1px solid rgba(55,198,208,0.25);
}
.contacts-layout.notes-open .notes-pane { display: block; }
.notes-pane .journal { margin-top: 0; border-top: 0; padding-top: 0; }
.detail-toggles { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.context-pane .context-box {
  margin: 0; max-height: 72vh; overflow-y: auto;
  background: rgba(31,79,208,0.06); border: 1px solid rgba(31,79,208,0.2);
}
.context-pane .context-body { max-height: none; }
.context-head-right { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.context-refresh { width: 34px; height: 34px; }
.context-refresh:hover { color: #fff; background: var(--blue); border-color: var(--blue); }
.context-refresh.is-loading { opacity: 0.7; cursor: wait; }
.context-refresh.is-loading svg { animation: ctx-spin 0.8s linear infinite; transform-origin: center; }
@keyframes ctx-spin { to { transform: rotate(360deg); } }
.context-close {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 1.3rem; line-height: 1; padding: 0 2px;
}
.context-close:hover { color: var(--ink); }

/* AI context memory box */
.context-box {
  margin: 0 0 16px; padding: 12px 14px; border-radius: 14px;
  background: rgba(31,79,208,0.06); border: 1px solid rgba(31,79,208,0.2);
}
.context-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.context-btns { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.context-btn { padding: 7px 14px; font-size: 0.85rem; }
.context-btn.is-loading { opacity: 0.5; cursor: wait; }
.context-meta { margin-bottom: 8px; }
.context-body { white-space: pre-wrap; word-break: break-word; font-size: 0.9rem; line-height: 1.5; max-height: 34vh; overflow-y: auto; }
.contact-message {
  white-space: pre-wrap; word-break: break-word; line-height: 1.5;
  padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.7);
  border: 1px solid var(--glass-line);
}
.contact-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.contact-reply { margin-top: 18px; border-top: 1px solid var(--glass-line); padding-top: 16px; }
.contact-reply h4 { margin: 0 0 10px; font-weight: 600; }
.reply-send { margin-top: 12px; }

.contact-history { margin-top: 12px; border-top: 1px solid var(--glass-line); padding-top: 10px; }
.contact-history h4 { margin: 0 0 12px; font-weight: 600; }
.history-toggle {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 0; background: transparent; padding: 0; margin: 0 0 4px;
  font: inherit; font-weight: 600; color: var(--ink);
}
.history-toggle:hover { color: var(--blue); }
.history-arrow { color: var(--blue); font-size: 0.8rem; }
.history-list { margin-top: 12px; }

/* Reply modal form fields (outside .panel, need their own styling) */
.reply-modal { width: min(560px, 100%); text-align: left; }
.reply-modal-wide { width: min(980px, 100%); }
.reply-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
.reply-col-left {
  border-right: 1px solid var(--glass-line); padding-right: 26px;
  display: flex; flex-direction: column; min-width: 0;
}
.reply-col-left .contact-message { flex: 1; overflow-y: auto; max-height: 55vh; margin: 0; }
.conv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conv-summary {
  margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; white-space: pre-wrap;
  background: rgba(245,197,66,0.12); border: 1px solid rgba(245,197,66,0.4);
  font-size: 0.9rem; line-height: 1.5; max-height: 30vh; overflow-y: auto;
}
.conv-history { flex: 1; overflow-y: auto; max-height: 55vh; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.conv-item { padding: 9px 11px; border-radius: 10px; border: 1px solid var(--glass-line); }
.conv-in { background: rgba(255,255,255,0.6); border-left: 3px solid var(--muted); }
.conv-out { background: rgba(31,79,208,0.06); border-left: 3px solid var(--blue); }
.conv-out.conv-failed { border-left-color: var(--red); }
.conv-item-head { font-weight: 600; margin-bottom: 4px; }
.conv-item-text { white-space: pre-wrap; word-break: break-word; font-size: 0.88rem; line-height: 1.45; }
.reply-col-right { min-width: 0; }
.reply-modal label { display: block; font-size: 0.82rem; color: var(--muted); margin: 12px 0 6px; }
.reply-modal input, .reply-modal textarea, .reply-modal select {
  width: 100%; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.8);
  border-radius: 12px; padding: 10px 13px; font-size: 0.95rem; outline: none;
  transition: box-shadow 0.4s var(--ease);
}
.reply-modal input:focus, .reply-modal textarea:focus, .reply-modal select:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }
.reply-modal textarea { min-height: 150px; resize: vertical; }

/* AI polish assistant inside reply modal */
.ai-assist { margin-top: 14px; border-top: 1px dashed var(--glass-line); padding-top: 14px; }
.ai-assist-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: nowrap; }
.ai-assist-row select { flex: 1; min-width: 120px; }
.ai-assist-row .btn { white-space: nowrap; }
.ai-icon-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; border-radius: 12px; cursor: pointer; font-size: 1.05rem;
  background: rgba(255,255,255,0.8); border: 1px solid var(--glass-line);
  transition: background 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.ai-icon-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -12px rgba(31,79,208,0.6); }
.ai-icon-btn.is-loading { opacity: 0.5; cursor: wait; }
.ai-icon-btn:disabled { cursor: wait; }
.ai-suggestion {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: rgba(55,198,208,0.08); border: 1px solid rgba(55,198,208,0.3);
}
.ai-suggestion-label { font-weight: 700; color: var(--cyan); margin-bottom: 6px; }
.ai-suggestion-text { white-space: pre-wrap; word-break: break-word; line-height: 1.55; font-size: 0.95rem; }
.ai-suggestion .cta-row { margin-top: 12px; }

/* Chat session AI verdict (keep vs delete) */
.verdict {
  margin: 14px 0 0; padding: 12px 14px; border-radius: 12px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.5; font-size: 0.92rem;
  background: rgba(20,22,26,0.05); border: 1px solid var(--glass-line); color: var(--ink);
}
.verdict.verdict-keep { background: rgba(26,127,75,0.10); border-color: rgba(26,127,75,0.4); color: #14603a; }
.verdict.verdict-delete { background: rgba(214,69,69,0.10); border-color: rgba(214,69,69,0.4); color: #a02a2a; }

/* Journal / interaction notes */
.journal { margin-top: 18px; border-top: 1px solid var(--glass-line); padding-top: 14px; }
.journal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.journal-head h4 { margin: 0; font-weight: 600; }
.journal-head-right { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.journal-list { display: flex; flex-direction: column; gap: 10px; }
.journal-item {
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.6); border: 1px solid var(--glass-line); border-left: 3px solid var(--cyan);
}
.journal-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.journal-when { flex: 1; min-width: 0; }
.journal-item-actions { display: inline-flex; gap: 6px; flex: 0 0 auto; }
.journal-item-actions .icon-btn { width: 28px; height: 28px; }
.journal-item-title { font-weight: 600; margin-bottom: 4px; }
.journal-item-body { white-space: normal; word-break: break-word; font-size: 0.9rem; line-height: 1.5; }
.journal-item-body code { background: rgba(20,22,26,0.08); padding: 1px 5px; border-radius: 5px; font-size: 0.85em; }
.journal-item-body a { color: var(--blue); text-decoration: underline; }

.note-type {
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  color: var(--blue); background: rgba(31,79,208,0.12);
}
.note-type-call { color: #1a7f4b; background: rgba(26,127,75,0.12); }
.note-type-meeting { color: var(--orange); background: rgba(240,135,42,0.14); }
.note-type-document { color: var(--muted); background: rgba(20,22,26,0.08); }

.note-form {
  margin-bottom: 12px; padding: 12px 14px; border-radius: 12px;
  background: rgba(31,79,208,0.05); border: 1px solid rgba(31,79,208,0.2);
}
.note-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.note-fields .note-field { flex: 1; min-width: 140px; }
.note-field { display: block; margin-bottom: 8px; }
.note-label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.note-form input, .note-form select, .note-form textarea {
  width: 100%; border: 1px solid var(--glass-line); background: rgba(255,255,255,0.8);
  border-radius: 10px; padding: 8px 11px; font-size: 0.92rem; outline: none;
}
.note-form textarea { resize: vertical; min-height: 90px; }
.note-form input:focus, .note-form select:focus, .note-form textarea:focus { box-shadow: 0 0 0 4px rgba(31,79,208,0.15); }
.history-item {
  padding: 9px 11px; margin-bottom: 8px; border-radius: 10px;
  background: rgba(255,255,255,0.6); border: 1px solid var(--glass-line);
  border-left: 3px solid #1a7f4b;
}
.history-item.history-failed { border-left-color: var(--red); }
.history-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.history-body { white-space: pre-wrap; word-break: break-word; font-size: 0.86rem; line-height: 1.45; color: var(--muted); }

@media (max-width: 1200px) {
  /* Below 1200 the extra columns get too tight: stack notes/context
     full-width under the messages (in-flow, no fixed positioning). */
  .contacts-layout.notes-open:not(.context-open),
  .contacts-layout.context-open:not(.notes-open),
  .contacts-layout.notes-open.context-open { grid-template-columns: 240px minmax(0, 1fr); }
  .contacts-layout.context-open .context-pane,
  .contacts-layout.notes-open .notes-pane { grid-column: 1 / -1; }
  .context-pane .context-box { max-height: 46vh; }
  .notes-pane { max-height: 50vh; }
}

@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .home-split { grid-template-columns: 1fr; min-height: 0; gap: 28px; }
  .home-split .chat { height: 56vh; height: 56dvh; min-height: 0; }
  .contacts-layout, .contacts-layout.context-open { grid-template-columns: 1fr; }
  .contacts-layout.notes-open, .contacts-layout.notes-open.context-open { grid-template-columns: 1fr; }
  .contacts-list { max-height: 40vh; }
  .contact-detail { max-height: none; overflow: visible; }
  .reply-cols { grid-template-columns: 1fr; gap: 16px; }
  .reply-col-left { border-right: 0; padding-right: 0; border-bottom: 1px solid var(--glass-line); padding-bottom: 16px; }
  .reply-col-left .contact-message { max-height: 28vh; }
  body.admin-body { height: auto; overflow: auto; }
  body.admin-body .wrap { height: auto; }
  body.admin-body .admin-grid { grid-template-columns: 1fr; }
  body.admin-body .panel, body.admin-body .sidebar { overflow: visible; }
  /* Admin tabs as a horizontal scrollable row */
  .sidebar { display: flex; flex-direction: row; overflow-x: auto; gap: 8px; padding: 10px; -webkit-overflow-scrolling: touch; }
  .tab-btn { width: auto; white-space: nowrap; margin-bottom: 0; flex: 0 0 auto; }
}

@media (max-width: 600px) {
  /* Prevent iOS auto-zoom: form fields must be >= 16px */
  .composer input,
  .modal input, .modal textarea, .modal select,
  .reply-modal input, .reply-modal textarea, .reply-modal select,
  .panel input, .panel textarea, .panel select { font-size: 16px; }

  /* Comfortable touch targets (>= 44px) */
  .icon-btn, .chat-icon-btn { width: 44px; height: 44px; }
  .ai-icon-btn { width: 44px; height: 44px; }
  .msg-icons { gap: 8px; }

  /* Lighten GPU load on phones: drop the animated canvas and blobs */
  #living-canvas { display: none; }
  .blob { display: none; }

  /* Los links del footer se colapsan en el hamburguer del nav (junto al toggle).
     Scoped a has-nav-menu: páginas sin nav conservan sus links en el footer. */
  .nav-menu-wrap { display: inline-flex; }
  body.has-nav-menu .foot-links { display: none; }

  /* Roomier chat on phones; cap to the visible viewport so the keyboard
     never hides the composer or the messages. */
  .home-split .chat { height: min(68dvh, calc(var(--vvh, 100dvh) - 96px)); }

  /* Mobile stacking order: eyebrow -> chat -> h1 -> lead -> actions */
  .home-split { display: flex; flex-direction: column; gap: 18px; }
  .home-intro { display: contents; }
  .home-intro .eyebrow { order: 1; margin-bottom: 0; font-size: 0.68rem; letter-spacing: 0.2em; }
  .home-split .chat { order: 2; }
  .home-intro h1 { order: 3; font-size: 1.45rem; line-height: 1.22; font-weight: 600; max-width: none; }
  .home-intro .lead { order: 4; margin-top: 10px; font-size: 0.95rem; }
  .home-intro .actions { order: 5; margin-top: 6px; }

  /* Compact modals + kill nested scroll areas inside the reply modal */
  .modal { padding: 18px; }
  .reply-modal-wide { width: 100%; }
  .conv-history, .conv-summary { max-height: none; }
  .reply-col-left .contact-message { max-height: none; }
  .ai-assist-row { flex-wrap: wrap; }
  .ai-assist-row select { min-width: 100%; }

  /* Maximized chat: full-screen app-like takeover (ChatGPT/Claude style),
     height bound to the visible viewport so the composer stays above the keyboard */
  body.chat-maxed .foot,
  body.chat-maxed .nav-bar { display: none; }
  .home-split .chat.maximized {
    top: 0; bottom: auto; left: 0; right: 0; height: var(--vvh, 100dvh); border-radius: 0;
    padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 10px);
    animation: none;
  }
  .chat.maximized .chat-head { margin: 0 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .chat.maximized .log { gap: 14px; padding: 4px 2px 14px; }
  .chat.maximized .bubble { max-width: 88%; font-size: 0.98rem; }
  .chat.maximized .composer { margin-top: 12px; }
  .chat.maximized .chat-disclaimer { display: none; }

  /* Contacts master-detail: show one pane at a time */
  .contacts-layout .contact-detail { display: none; }
  .contacts-layout.has-detail .contacts-list { display: none; }
  .contacts-layout.has-detail .contact-detail { display: block; }
  .detail-back { display: inline-flex; margin-bottom: 12px; }
}

.detail-back { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================ */
/* Free course                                                  */
/* ============================================================ */

/* Home CTA pill (secondary to talk-pill) */
.course-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-radius: 999px; cursor: pointer; text-decoration: none;
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(10px);
  color: var(--ink); font-size: 1rem; font-weight: 600;
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), background 0.4s var(--ease);
}
.course-pill:hover { transform: translateY(-2px); background: #fff; box-shadow: var(--shadow); }
.course-icon { color: var(--blue); flex: 0 0 auto; }
.course-pill-badge {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: linear-gradient(120deg, var(--orange), var(--yellow)); color: #3a2a06;
  padding: 2px 8px; border-radius: 999px;
}

/* Landing */
.course-hero { position: relative; z-index: 2; max-width: 820px; margin: 20px 0 40px; }
.course-hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.05; margin: 8px 0 0; letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--blue), var(--cyan) 60%, var(--orange));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.course-hero .course-subtitle { margin: 6px 0 0; color: var(--blue); font-weight: 600; font-size: clamp(1.05rem, 2vw, 1.35rem); letter-spacing: -0.01em; }
.course-hero .lead { margin-top: 16px; color: var(--muted); max-width: none; font-size: clamp(0.85rem, 1.05vw, 0.98rem); line-height: 1.65; }
.course-stats { list-style: none; display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0 0; padding: 0; }
.course-stats li {
  display: flex; flex-direction: column; gap: 3px; padding: 12px 18px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--glass-line); min-width: 92px;
}
.cs-num {
  font-size: 1.5rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--blue), var(--cyan));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.cs-lbl { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.course-progress { display: flex; align-items: center; gap: 12px; margin-top: 24px; max-width: 460px; }
.course-progress-bar { flex: 1; height: 8px; border-radius: 999px; background: rgba(20,30,60,0.1); overflow: hidden; }
.course-progress-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(120deg, var(--blue), var(--cyan)); transition: width 0.6s var(--ease); }

/* Completed-topic checkmark (shared by the reader sidebar and sitemap) */
.rn-topic.is-done .rn-check { background: var(--blue); border-color: var(--blue); }
.rn-topic.is-done .rn-check::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.course-empty { position: relative; z-index: 2; color: var(--muted); padding: 40px 0; }

/* Course library (catalog of courses shown as cards) */
.course-library {
  position: relative; z-index: 2; display: grid; gap: 18px; padding-bottom: 40px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.course-card {
  --card-accent: var(--blue);
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: var(--ink);
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(8px);
  border-radius: 18px; padding: 22px 22px 20px; position: relative; overflow: hidden;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), background 0.3s var(--ease);
}
.course-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--card-accent);
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); background: #fff; }
.course-card-title { font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em; }
.course-card-summary { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.course-card-meta { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.course-card-cta { margin-top: auto; padding-top: 8px; font-weight: 600; color: var(--card-accent); font-size: 0.9rem; }

/* Hero + save-progress side by side at the top of a course page */
.course-top {
  position: relative; z-index: 2; display: grid; align-items: start; gap: 28px;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); margin: 20px 0 40px; /* ~60 / 40 */
}
.course-top .course-hero { margin: 0; max-width: none; }
.course-enroll-side { margin: 0; max-width: none; position: sticky; top: 20px; }
@media (max-width: 820px) {
  .course-top { grid-template-columns: 1fr; }
  .course-enroll-side { position: static; }
}

/* Single-screen course page: everything fits the viewport, no page scroll */
.course-fit .wrap {
  width: min(1360px, 96%); height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
}
.course-fit .nav-bar { flex: 0 0 auto; }
.course-fit .course-top { flex: 0 0 auto; margin: 8px 0 10px; gap: 24px; }
.course-fit .course-hero h1 { font-size: clamp(1.5rem, 3vw, 2.15rem); }
.course-fit .course-hero .lead { margin-top: 8px; font-size: 0.92rem; }
.course-fit .course-stats { margin-top: 16px; gap: 10px; }
.course-fit .course-stats li { padding: 9px 15px; min-width: 80px; }
.course-fit .cs-num { font-size: 1.3rem; }
.course-fit .course-progress { margin-top: 14px; }
.course-fit .course-hero .actions { margin-top: 14px; }
.course-fit .course-enroll-side { padding: 16px 18px; position: static; }
.course-fit .course-enroll-side h2 { font-size: 1.05rem; }
.course-fit .course-enroll-side > p.small { font-size: 0.82rem; }
.course-fit .course-enroll-side .enroll-form { margin-top: 10px; gap: 8px; }
.course-fit .foot { flex: 0 0 auto; padding: 8px 0; }
@media (max-width: 820px) {
  /* On small screens, fall back to normal flow (a phone can't fit 27 topics). */
  .course-fit .wrap { height: auto; overflow: visible; display: block; }
}

.course-enroll {
  position: relative; z-index: 2; margin: 20px 0 50px; padding: 24px; border-radius: var(--radius);
  background: var(--glass); border: 1px solid var(--glass-line); backdrop-filter: blur(12px); max-width: 720px;
}
.course-enroll h2 { margin: 0 0 6px; font-size: 1.2rem; }
.enroll-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.enroll-form input[type=email], .enroll-form input:not([type]) {
  flex: 1 1 200px; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit;
}
.enroll-news { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.enroll-status { min-height: 1.2em; color: var(--blue); }

/* Reader layout: sidebar | content | tutor */
.reader-grid { position: relative; z-index: 2; display: grid; grid-template-columns: 250px minmax(0, 1fr) 320px; gap: 24px; align-items: start; padding-bottom: 40px; }
.reader-nav { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
.reader-nav-toggle { display: none; }
/* Light "chat-like" panel around the collapsible module list */
.reader-nav-inner { background: var(--glass); border: 1px solid var(--glass-line); border-radius: 14px; padding: 8px; backdrop-filter: blur(10px); }
.rn-module { margin-bottom: 2px; }
.rn-module:last-child { margin-bottom: 0; }
/* Module header = collapsible accordion summary */
summary.rn-module-title {
  cursor: pointer; user-select: none; list-style: none;
  display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 8px;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
summary.rn-module-title::-webkit-details-marker { display: none; }
summary.rn-module-title:hover { color: var(--ink); background: #fff; }
summary.rn-module-title::after {
  content: ""; margin-left: auto; flex: 0 0 auto; width: 6px; height: 6px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform 0.25s var(--ease);
}
details.rn-module[open] > summary.rn-module-title { color: var(--ink); }
details.rn-module[open] > summary.rn-module-title::after { transform: rotate(45deg); }
.rn-module ul { list-style: none; margin: 3px 0 6px; padding: 0 0 0 4px; display: grid; gap: 2px; }
.rn-topic { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--muted); padding: 6px 8px; border-radius: 8px; font-size: 0.9rem; }
.rn-topic:hover { background: #fff; color: var(--ink); }
.rn-topic.current { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.rn-check { flex: 0 0 auto; width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--line); position: relative; }

.reader-main { min-width: 0; }
.reader-head h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.1; margin: 6px 0; letter-spacing: -0.02em; }
.reader-content {
  background: rgba(255,255,255,0.6); border: 1px solid var(--glass-line); backdrop-filter: blur(8px);
  border-radius: var(--radius); padding: clamp(20px, 3vw, 44px); box-shadow: var(--shadow);
  font-size: clamp(1.12rem, 1.05vw, 1.28rem); line-height: 1.78; color: #1c2027; overflow-wrap: break-word;
}
.reader-content h2 { font-size: 1.75rem; margin: 1.6em 0 0.5em; letter-spacing: -0.01em; }
.reader-content h3 { font-size: 1.35rem; margin: 1.3em 0 0.4em; color: #2a2f38; }
.reader-content p { margin: 0.7em 0; }
.reader-content a { color: var(--blue); }
.reader-content .course-example {
  margin: 1em 0; padding: 10px 16px; border-left: 3px solid var(--cyan); background: rgba(55,198,208,0.08);
  font-style: italic; color: #2b545a; border-radius: 0 10px 10px 0;
}
.reader-content .callout { margin: 1.2em 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.reader-content .callout-head { padding: 8px 14px; font-weight: 700; color: #fff; }
.reader-content .callout-body { padding: 12px 16px; }
.reader-content .callout-body p:first-child { margin-top: 0; }
.reader-content .callout-body p:last-child { margin-bottom: 0; }
.reader-content .callout--concept .callout-head { background: #0f6b74; }
.reader-content .callout--concept { background: rgba(15,107,116,0.06); }
.reader-content .callout--exercise .callout-head { background: var(--orange); }
.reader-content .callout--exercise { background: rgba(240,135,42,0.07); }
.reader-content .callout--reflect .callout-head { background: #2f7d86; }
.reader-content .callout--reflect { background: rgba(47,125,134,0.07); }
.reader-content .course-table { width: 100%; border-collapse: collapse; margin: 1.2em 0; font-size: 1rem; }
.reader-content .course-table td { border: 1px solid var(--line); padding: 8px 12px; vertical-align: top; }
.reader-content .course-table.glossary td:first-child { font-weight: 600; width: 30%; }

/* Collapsible "How to use this book" intro (collapsed by default) */
.reader-content .course-howto {
  margin: 0.4em 0 1.4em; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(20,30,60,0.03); overflow: hidden;
}
.reader-content .course-howto > summary {
  cursor: pointer; list-style: none; padding: 12px 16px; font-size: 1.05rem; font-weight: 600;
  color: #2a2f38; display: flex; align-items: center; gap: 10px; user-select: none;
}
.reader-content .course-howto > summary::-webkit-details-marker { display: none; }
.reader-content .course-howto > summary::before {
  content: "▸"; color: var(--blue); transition: transform 0.2s var(--ease); flex: 0 0 auto;
}
.reader-content .course-howto[open] > summary::before { transform: rotate(90deg); }
.reader-content .course-howto > summary:hover { background: rgba(31,79,208,0.05); }
.reader-content .course-howto .howto-body { padding: 0 16px 8px; }
.reader-content .course-howto .howto-body > *:first-child { margin-top: 0; }

.reflect-cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 26px 0;
  padding: 18px 20px; border-radius: var(--radius); background: var(--glass); border: 1px solid var(--glass-line);
}
.reflect-cta .small { color: var(--muted); }
.reflect-modal { width: min(560px, 100%); }
.reflect-modal h2 { margin: 0 24px 4px 0; font-size: 1.25rem; }
.reflect-modal > p.small { color: var(--muted); margin: 0 0 6px; }
.reflect-q { display: block; margin: 14px 0; }
.reflect-q span { display: block; font-weight: 600; margin-bottom: 6px; }
.reflect-q textarea, #reflectForm textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: inherit; resize: vertical;
}
.reflect-result { margin-top: 16px; padding: 16px; border-radius: 14px; background: #fff; border: 1px solid var(--line); white-space: pre-wrap; }
.reflect-result.hidden { display: none; }
.reflect-score { font-size: 1.1rem; margin-bottom: 8px; }
.reflect-feedback { white-space: pre-wrap; }

.reader-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0; flex-wrap: wrap; }
.reader-controls .btn { max-width: 44%; }
#markComplete.is-done { background: linear-gradient(120deg, #0f6b74, var(--cyan)); }

.reader-tutor {
  position: sticky; top: 20px; display: flex; flex-direction: column;
  height: calc(100vh - 40px); max-height: 760px;
  background: rgba(255,255,255,0.55); border: 1px solid var(--glass-line); backdrop-filter: blur(14px);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.tutor-head { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.tutor-head .greet-avatar { width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex: 0 0 auto; }
.tutor-head .greet-avatar img { width: 100%; height: 100%; object-fit: cover; }
.reader-tutor .log { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 4px; display: flex; flex-direction: column; gap: 12px; }

/* Responsive */
@media (max-width: 1080px) {
  .reader-grid { grid-template-columns: minmax(0, 1fr); }
  .reader-nav { position: static; max-height: none; }
  .reader-nav-inner { display: none; }
  .reader-nav.open .reader-nav-inner { display: block; }
  .reader-nav-toggle {
    display: inline-block; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--glass-line);
    background: var(--glass); backdrop-filter: blur(8px); font: inherit; font-weight: 600; cursor: pointer; margin-bottom: 10px;
  }
  .reader-tutor { position: static; height: 60vh; height: 60dvh; margin-top: 20px; }
}

/* Desktop reader: full-width, full-height 3-pane app layout with independent
   scrolling panes. Scoped to the reader so home/landing/mobile are unaffected. */
@media (min-width: 1081px) {
  body.course-reader { overflow: hidden; }
  body.course-reader .wrap {
    width: 96%; max-width: 1800px; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
  }
  body.course-reader .reader-grid {
    flex: 1; min-height: 0; align-items: stretch; padding-bottom: 0;
    grid-template-columns: 260px minmax(0, 1fr) 360px;
  }
  body.course-reader .reader-nav {
    position: static; top: auto; height: 100%; max-height: none; overflow-y: auto; padding-right: 6px;
  }
  body.course-reader .reader-main {
    height: 100%; overflow-y: auto; padding-right: 12px;
  }
  body.course-reader .reader-tutor {
    position: static; top: auto; height: 100%; max-height: none;
  }
  body.course-reader .foot { flex: 0 0 auto; margin-top: 10px; }
}

/* Slim, discreet scrollbars for the reader panes */
.reader-nav, .reader-main, .reader-tutor .log { scrollbar-width: thin; scrollbar-color: rgba(20,30,60,0.28) transparent; }
.reader-nav::-webkit-scrollbar, .reader-main::-webkit-scrollbar, .reader-tutor .log::-webkit-scrollbar { width: 10px; }
.reader-nav::-webkit-scrollbar-thumb, .reader-main::-webkit-scrollbar-thumb, .reader-tutor .log::-webkit-scrollbar-thumb {
  background: rgba(20,30,60,0.22); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
.reader-nav::-webkit-scrollbar-thumb:hover, .reader-main::-webkit-scrollbar-thumb:hover, .reader-tutor .log::-webkit-scrollbar-thumb:hover {
  background: rgba(20,30,60,0.4); background-clip: padding-box;
}
.reader-nav::-webkit-scrollbar-track, .reader-main::-webkit-scrollbar-track, .reader-tutor .log::-webkit-scrollbar-track { background: transparent; }

/* ============================================================ */
/* Kandinsky hybrid layer — course pages only (scoped .course-body) */
/* "El lienzo es neutro; Kandinsky habla solo donde comunica algo."  */
/* Flatter Bauhaus discipline over the existing Crystal identity.    */
/* ============================================================ */
.course-body {
  /* Strict color roles (guide §2) */
  --rojo-k: #D93A2B;      /* acción: CTA, "estás aquí" */
  --azul-k: #2B5DA8;      /* navegación: enlaces, hover, foco */
  --amarillo-k: #F2B705;  /* progreso: línea que avanza */
  --verde-check: #2E7D4F; /* completado */
  --linea-k: #D8D4CB;     /* bordes/divisores (gris cálido) */
  --radio-k: 10px;        /* forma plana (guide: 10px, no 22px) */
  --lienzo-hover: #F3F0E9;
  --f-display: 'Jost', 'Futura', system-ui, sans-serif;
  --t-rapido: 150ms ease;
  --t-recompensa: 400ms ease-out;
}

/* Bauhaus display type on course titles/headings */
.course-body .course-hero h1,
.course-body .course-card-title,
.course-body .reader-head h1,
.course-body .k-mod-title {
  font-family: var(--f-display);
  letter-spacing: 0.005em;
  font-weight: 600;
}

/* Híbrido: atenuar (no eliminar) la decoración ambiental en cursos */
.course-body #living-canvas { opacity: 0.32; }
.course-body .blob { opacity: 0.22; }

/* Focus visible (guide §8): contorno 2px azul con offset */
.course-body a:focus-visible,
.course-body button:focus-visible,
.course-body input:focus-visible,
.course-body textarea:focus-visible,
.course-body .k-pt:focus-visible {
  outline: 2px solid var(--azul-k); outline-offset: 2px; border-radius: 4px;
}

/* ---------- Componente firma: mapa de puntos-y-líneas (.k-map) ---------- */
.k-map {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 4px; margin: 18px 0 6px; padding: 12px 6px;
}
.k-map .k-line {
  position: absolute; left: 10px; right: 10px; top: 50%; height: 2px;
  transform: translateY(-50%); background: var(--linea-k); border-radius: 2px;
}
.k-map .k-line-fill {
  display: block; height: 100%; width: 0; border-radius: 2px;
  background: var(--amarillo-k); transition: width var(--t-recompensa, 400ms) ease-out;
}
.k-pt {
  position: relative; z-index: 1; flex: 0 0 auto;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--linea-k);
  box-shadow: 0 0 0 3px var(--paper); /* corta la línea detrás del punto */
  transition: transform 150ms var(--ease), border-color 150ms var(--ease), background 150ms var(--ease);
}
.k-pt:hover { border-color: var(--azul-k); transform: scale(1.18); }
.k-pt.is-done { background: var(--ink); border-color: var(--ink); }
.k-pt.is-done::after { /* check (forma, no solo color) */
  content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid var(--paper); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.k-pt.current { background: var(--rojo-k); border-color: var(--rojo-k); box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px rgba(217,58,43,0.18); }
.k-map--compact { margin: 0 0 14px; padding: 8px 6px; }
/* En el lector, el mapa compacto queda fijo arriba de la columna de contenido */
body.course-reader .reader-main > .k-map--compact { position: sticky; top: 0; z-index: 3; background: var(--paper); }
.k-map--compact .k-pt { width: 12px; height: 12px; }
.k-map--compact .k-pt.is-done::after { left: 2.5px; top: 0.5px; width: 3px; height: 6px; }

/* Barra sticky del lector: k-map + fila de controles (pager superior + read-aloud).
   Se mueve el sticky del k-map a este contenedor, así los controles nunca se pierden
   al hacer scroll. Mínimo espacio: 2 filas finas; eyebrow y h1 quedan fuera. */
body.course-reader .reader-main > .reader-toolbar {
  position: sticky; top: 0; z-index: 3; background: var(--paper);
  padding-top: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--linea-k);
}
.reader-toolbar .k-map--compact { margin: 0; }
.reader-toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.reader-toolbar-row:empty { display: none; }
/* read-aloud dentro de la barra: sin caja glass, más compacto, alineado a la izquierda */
.reader-toolbar .read-aloud { order: 1; margin: 0; padding: 0; background: none; border: none; backdrop-filter: none; gap: 8px; }
.reader-toolbar .read-aloud .ra-btn { min-height: 34px; padding: 6px 12px; }
.reader-toolbar .read-aloud .ra-speed { margin-left: 0; }
.reader-toolbar .read-aloud .ra-hint { display: none; }
@media (min-width: 1100px) { .reader-toolbar .read-aloud .ra-hint { display: inline; } }
/* pager superior empujado a la derecha de la fila */
.reader-toolbar .reader-pager--top { order: 2; margin-left: auto; }

/* ---------- Vista 1 · Catálogo (tarjeta plana Bauhaus) ---------- */
.course-body .course-card {
  background: var(--plano, #fff); border: 1px solid var(--linea-k);
  border-radius: var(--radio-k); backdrop-filter: none; box-shadow: none;
  transition: border-color 150ms var(--ease), transform 150ms var(--ease);
}
.course-body .course-card:hover {
  transform: none; background: #fff; box-shadow: none; border-color: var(--azul-k);
}
.course-body .course-card:hover .course-card-glyph { transform: translate(3px, -2px) rotate(4deg); }
.course-card-glyph { width: 44px; height: 44px; display: block; }
.course-card-glyph svg { width: 100%; height: 100%; overflow: visible; transition: transform 150ms var(--ease); }
.course-body .course-card-cta { color: var(--azul-k); }
.course-card-progress {
  display: none; align-items: center; gap: 8px; margin-top: 4px;
}
.course-card.has-progress .course-card-progress { display: flex; }
.course-card-progress .ccp-bar { flex: 1; height: 6px; border-radius: 999px; background: rgba(20,30,60,0.1); overflow: hidden; }
.course-card-progress .ccp-fill { display: block; height: 100%; width: 0; background: var(--amarillo-k); border-radius: 999px; transition: width 0.6s var(--ease); }
.course-card-progress .ccp-lbl { font-size: 0.72rem; color: var(--tinta-suave, var(--muted)); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Vista 2 · Temario (módulos en columnas, flat Kandinsky) ---------- */
/* Columnas responsivas para aprovechar el ancho y caber sin scroll (como antes) */
/* Temario = mapa de contenido tipo sitemap: columnas limpias, sin paneles,
   sin minutos, sin scroll. La estructura la dan la línea divisora y las columnas. */
.course-modules-k {
  position: relative; z-index: 2; display: grid; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px 28px; padding-bottom: 24px;
}
.k-module { break-inside: avoid; }
.k-mod-head { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--linea-k); }
.k-mod-roman { font-family: var(--f-display); font-weight: 700; font-size: 0.85rem; color: var(--rojo-k); letter-spacing: 0.04em; }
.k-mod-title { font-size: 0.95rem; margin: 0; line-height: 1.2; }
.k-topics { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.k-topic {
  display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--muted);
  padding: 3px 0; font-size: 0.9rem; line-height: 1.3;
  transition: color 150ms var(--ease);
}
.k-topic:hover { color: var(--azul-k); }
.k-topic-label { flex: 1 1 auto; min-width: 0; }
.k-topic-check { flex: 0 0 auto; width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--linea-k); position: relative; }
.k-topic.is-done .k-topic-check { background: var(--verde-check); border-color: var(--verde-check); }
.k-topic.is-done .k-topic-check::after { content: ""; position: absolute; left: 3px; top: 0.5px; width: 3px; height: 6px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.k-topic.is-done .k-topic-label { opacity: 0.7; }
/* Vista course-fit (una sola pantalla): sin scroll; el sitemap denso cabe. */
.course-fit .course-modules-k { flex: 1 1 auto; min-height: 0; gap: 4px 26px; }
@media (max-width: 820px) {
  /* Teléfono: una columna y filas táctiles cómodas. */
  .course-fit .course-modules-k { grid-template-columns: 1fr; }
  .k-topic { padding: 8px 0; }
}

/* ---------- Vista 3 · Lección (aplanado + extras) ---------- */
.course-body .reader-content {
  background: #fff; border: 1px solid var(--linea-k); box-shadow: none;
  border-radius: var(--radio-k); backdrop-filter: none;
}
.course-body .reader-nav-inner,
.course-body .reader-tutor { border-radius: var(--radio-k); }
/* Prev/next: "Siguiente" en rojo (única acción roja), "Anterior" enlace azul */
.reader-controls .rc-next {
  display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px;
  background: var(--rojo-k); color: #fff; border: none; border-radius: var(--radio-k);
  padding: 10px 16px; text-decoration: none; max-width: 48%;
}
.reader-controls .rc-next .rc-kicker { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.reader-controls .rc-next .rc-title { font-weight: 600; font-size: 0.95rem; }
.reader-controls .rc-prev {
  color: var(--azul-k); background: none; border: none; text-decoration: none;
  font-weight: 500; max-width: 40%;
}
.reader-controls .rc-prev:hover { text-decoration: underline; }
.course-body #markComplete.is-done { background: var(--verde-check); }
/* Paginación del lector: una sección <h2> por "página" */
.reader-page[hidden] { display: none; }
.course-body .reflect-cta[hidden],
.course-body .reader-controls[hidden] { display: none !important; }
.reader-page { animation: kFade 220ms var(--ease); }
@keyframes kFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.reader-pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 22px 0 4px; flex-wrap: wrap;
}
.reader-pager .rp-prev {
  background: none; border: none; color: var(--azul-k); font: inherit; font-weight: 500;
  cursor: pointer; padding: 10px 4px; min-height: 44px;
}
.reader-pager .rp-prev:hover { text-decoration: underline; }
.reader-pager .rp-prev[hidden] { visibility: hidden; display: inline-block; } /* keep layout */
.reader-pager .rp-next {
  background: var(--rojo-k); color: #fff; border: none; border-radius: var(--radio-k);
  font: inherit; font-weight: 600; cursor: pointer; padding: 11px 20px; min-height: 44px;
}
.reader-pager .rp-next[hidden] { display: none; }
.reader-pager .rp-ind { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); }
.reader-pager .rp-count { font-size: 0.78rem; letter-spacing: 0.04em; }
.reader-pager .rp-dots { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; }
/* Dots = clickable buttons that jump to a page. Small visual disc in ::before,
   larger transparent hit area around it for touch. */
.reader-pager .rp-dot {
  appearance: none; -webkit-appearance: none; border: none; background: none;
  padding: 5px 3px; margin: 0; cursor: pointer; line-height: 0; display: inline-flex;
}
.reader-pager .rp-dot::before {
  content: ""; display: block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--linea-k); transition: background 150ms var(--ease), transform 150ms var(--ease);
}
.reader-pager .rp-dot.seen::before { background: var(--amarillo-k); }
.reader-pager .rp-dot.current::before { background: var(--ink); transform: scale(1.3); }
.reader-pager .rp-dot:hover::before { background: var(--azul-k); }

/* Top mini-pager next to the eyebrow: flat arrows, no red block, compact. */
.rh-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.reader-pager--top { margin: 0; gap: 8px; flex: 0 0 auto; }
.reader-pager--top .rp-txt { display: none; }
.reader-pager--top .rp-prev,
.reader-pager--top .rp-next {
  background: none; color: var(--azul-k); border: none; border-radius: 6px;
  padding: 4px 6px; min-height: 0; font-size: 1.05rem; font-weight: 600;
}
.reader-pager--top .rp-prev:hover, .reader-pager--top .rp-next:hover { text-decoration: none; color: var(--ink); }
.reader-pager--top .rp-next[hidden], .reader-pager--top .rp-prev[hidden] { visibility: hidden; }
.reader-pager--top .rp-count { font-size: 0.72rem; }

/* Modo lectura en voz alta (read-aloud): barra de controles + resaltado karaoke */
.read-aloud {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 10px 0 4px; padding: 8px 10px;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: var(--radio-k);
  backdrop-filter: blur(8px);
}
.read-aloud .ra-btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-weight: 600;
  cursor: pointer; min-height: 40px; padding: 8px 16px; border-radius: var(--radio-k);
  border: 1px solid var(--azul-k); background: none; color: var(--azul-k);
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.read-aloud .ra-btn:hover { background: var(--azul-k); color: #fff; }
.read-aloud .ra-btn:focus-visible { outline: 2px solid var(--azul-k); outline-offset: 2px; }
.read-aloud .ra-play[aria-pressed="true"] { background: var(--azul-k); color: #fff; }
.read-aloud .ra-play .ra-ico { font-size: 0.9rem; line-height: 1; }
.read-aloud .ra-restart { padding: 8px 12px; font-size: 1.05rem; }
.read-aloud .ra-hint { color: var(--muted); font-size: 0.8rem; }
.read-aloud .ra-speed { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 0.85rem; }
.read-aloud .ra-speed select {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--linea-k);
  border-radius: 8px; padding: 6px 8px; min-height: 36px; cursor: pointer;
}
/* Palabras clicables: el alumno toca una para empezar la lectura desde ahí */
.reader-content .ra-word { cursor: pointer; border-radius: 3px; }
.reader-content .ra-word:hover { background: rgba(242, 183, 5, 0.28); }
/* Palabra que se está pronunciando */
.ra-word.ra-active {
  background: var(--amarillo-k); color: #1c2027; border-radius: 3px;
  box-shadow: 0 0 0 2px var(--amarillo-k);
}
@media (prefers-reduced-motion: no-preference) {
  .ra-word { transition: background 0.12s var(--ease); }
}

@media (prefers-reduced-motion: reduce) { .reader-page { animation: none; } .reader-pager .rp-dot::before { transition: none; } }

/* Pantalla de fin de curso ("el plano completo") */
.k-done-screen {
  position: relative; z-index: 2; margin: 30px 0; padding: 40px 28px; text-align: center;
  border: 1px solid var(--linea-k); border-radius: var(--radio-k); background: #fff;
}
.k-done-screen.hidden { display: none; }
.k-done-screen h2 { font-family: var(--f-display); font-size: 1.6rem; margin: 0 0 6px; }
.k-done-screen p { color: var(--muted); max-width: 46ch; margin: 0 auto 20px; }
.k-done-screen .k-map { justify-content: center; gap: 6px; max-width: 520px; margin: 0 auto 24px; }
.k-done-cta {
  display: inline-block; background: var(--rojo-k); color: #fff; font-weight: 600;
  padding: 12px 22px; border-radius: var(--radio-k); text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  .course-body .k-line-fill, .course-body .k-pt,
  .course-body .course-card, .course-body .course-card-glyph svg { transition: none !important; }
}

