/* ───────────────────────────────────────────────────────────
 * Lurpio — design system
 * Sans (Inter) para UI · serif (Iowan/Palatino) para contenido legal.
 * ─────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Paleta */
  --c-primary:        #1e3a5f;
  --c-primary-hover:  #2c4f7c;
  --c-primary-active: #152a44;
  --c-primary-soft:   #e8eef5;

  --c-bg:           #fafaf7;
  --c-surface:      #ffffff;
  --c-surface-alt:  #f5f4ef;

  --c-text:         #1a1a1a;
  --c-text-muted:   #5a5a52;
  --c-text-subtle:  #8a8a82;

  --c-border:       #e2e0d8;
  --c-border-strong:#cdcbc0;
  --c-border-focus: var(--c-primary);

  --c-success-bg:   #e6f4ea;
  --c-success-fg:   #1a7430;
  --c-danger-bg:    #fce8e8;
  --c-danger-fg:    #9b1c1c;
  --c-warning-bg:   #fef3c7;
  --c-warning-fg:   #92400e;

  /* Tipografía */
  --font-ui:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif:  'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, 'Source Serif Pro', serif;

  /* Sombras (en capas, suaves) */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.04), 0 2px 4px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 20px rgba(15, 23, 42, 0.06), 0 3px 6px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 24px 48px rgba(15, 23, 42, 0.08), 0 8px 16px rgba(15, 23, 42, 0.06);
  --ring-focus: 0 0 0 3px rgba(30, 58, 95, 0.18);

  /* Radio */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-full: 999px;

  /* Transiciones */
  --t-fast: 120ms ease;
  --t-base: 200ms ease;
}

/* ── Reset suave ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
h1 { font-size: 1.75rem; margin: 0 0 1rem; line-height: 1.2; }
h2 { font-size: 1.35rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
h4 { font-size: 0.95rem; margin: 1rem 0 0.4rem; }

a { color: var(--c-primary); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--c-primary-hover); }

p { margin: 0 0 0.9rem; }
hr { border: 0; border-top: 1px solid var(--c-border); margin: 1.5rem 0; }
code {
  background: var(--c-surface-alt);
  padding: 0.1rem 0.4rem;
  border-radius: var(--r-sm);
  font-size: 0.88em;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
::selection { background: rgba(30, 58, 95, 0.18); }

/* ── Scrollbar discreta ──────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--c-border-strong); border-radius: var(--r-full);
  border: 2px solid var(--c-bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--c-text-subtle); }

/* ───────────────────────────────────────────────────────────
 * Layout: sidebar + main
 * ─────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  padding: 1.25rem 0.85rem;
  position: sticky; top: 0; height: 100vh;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.brand {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--c-primary);
  letter-spacing: -0.01em;
  padding: 0.5rem 0.7rem;
  margin-bottom: 1rem;
  display: block;
}
.brand:hover { color: var(--c-primary); }

.side-nav {
  display: flex; flex-direction: column; gap: 0.15rem;
  margin-bottom: 0.5rem;
}
.side-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  color: var(--c-text);
  border-radius: var(--r-md);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.side-link:hover { background: var(--c-surface-alt); color: var(--c-text); }
.side-link.active {
  background: var(--c-primary-soft); color: var(--c-primary);
  font-weight: 600;
}

.sidebar-section {
  margin-top: 0.6rem; padding-top: 0.75rem;
  border-top: 1px solid var(--c-border);
}
.sidebar-docs-wrap {
  flex: 1; min-height: 0; overflow-y: auto;
  margin-top: 0.4rem;
}

/* Compactar barra-caso y panel-docs en sidebar */
.sidebar .barra-caso {
  flex-direction: column; align-items: flex-start;
  padding: 0.4rem 0.2rem; gap: 0.3rem;
  background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
.sidebar .barra-caso-titulo { font-size: 0.92rem; font-weight: 600; }
.sidebar .barra-caso-meta { font-size: 0.78rem; }
.sidebar .barra-caso-switch select { width: 100%; max-width: 100%; }

.sidebar .panel-docs > details {
  padding: 0; background: transparent; border: 0; box-shadow: none;
}
.sidebar .panel-docs > details > summary {
  padding: 0.2rem 0; font-size: 0.85rem; font-weight: 500;
}
.sidebar .panel-docs-grupo h4 { font-size: 0.7rem; }
.sidebar .panel-docs-grupo li { font-size: 0.78rem; word-break: break-word; }
.sidebar .panel-docs-tag { font-size: 0.66rem; }

.sidebar-footer {
  font-size: 0.7rem; color: var(--c-text-subtle);
  padding: 0.7rem 0.5rem;
  border-top: 1px solid var(--c-border);
  line-height: 1.4; margin-top: 0.6rem;
  font-style: italic;
}

.sidebar-user {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.7rem;
  margin-top: auto;
  border-top: 1px solid var(--c-border);
  font-size: 0.85rem;
}
.sidebar-user-name {
  color: var(--c-primary); font-weight: 600; flex: 1;
  display: flex; align-items: center; gap: 0.4rem;
}
.sidebar-user-name:hover { color: var(--c-primary-hover); }
.sidebar-user form { margin: 0; display: inline; }
.sidebar-logout {
  background: transparent; color: var(--c-text-muted);
  border: 1px solid var(--c-border-strong);
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-md);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
}
.sidebar-logout:hover {
  background: var(--c-surface-alt);
  color: var(--c-primary);
  border-color: var(--c-primary);
}

.main-area {
  flex: 1; min-width: 0;
  padding: 1.5rem 2rem; overflow-x: hidden;
}

/* ───────────────────────────────────────────────────────────
 * Auth (login, set-password, forgot, reset)
 * ─────────────────────────────────────────────────────────── */
.auth-body {
  margin: 0; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at top, rgba(30, 58, 95, 0.04), transparent 60%),
    var(--c-bg);
  padding: 1.5rem;
}
.auth-card {
  width: 100%; max-width: 420px;
  padding: 2.75rem 2.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}
.auth-brand {
  margin: 0 0 0.3rem;
  font-family: var(--font-serif);
  color: var(--c-primary);
  font-size: 2.1rem; text-align: center;
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center; color: var(--c-text-muted);
  margin: 0 0 1.75rem; font-size: 0.92rem;
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label {
  display: flex; flex-direction: column; gap: 0.35rem;
  font-size: 0.86rem; font-weight: 500; color: var(--c-text-muted);
  letter-spacing: 0.01em;
}
.auth-form input {
  padding: 0.7rem 0.85rem; font-size: 0.95rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--c-border-focus);
  box-shadow: var(--ring-focus);
}
.auth-form button {
  padding: 0.8rem; font-size: 0.95rem; font-weight: 600;
  margin-top: 0.5rem;
  background: var(--c-primary); color: #fff;
  border: 0; border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast);
}
.auth-form button:hover { background: var(--c-primary-hover); }
.auth-form button:active { transform: translateY(1px); }
.auth-error {
  padding: 0.7rem 0.85rem;
  background: var(--c-danger-bg); color: var(--c-danger-fg);
  border-radius: var(--r-md); font-size: 0.88rem;
  border: 1px solid rgba(155, 28, 28, 0.15);
}
.msg-ok {
  padding: 0.7rem 0.85rem;
  background: var(--c-success-bg); color: var(--c-success-fg);
  border-radius: var(--r-md); font-size: 0.88rem;
  border: 1px solid rgba(26, 116, 48, 0.15);
}
.auth-hint {
  margin-top: 1.5rem; color: var(--c-text-subtle);
  font-size: 0.8rem; line-height: 1.45; text-align: center;
}

/* ───────────────────────────────────────────────────────────
 * Landing pública
 * ─────────────────────────────────────────────────────────── */
.landing-body { margin: 0; background: var(--c-bg); color: var(--c-text); }

.landing-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.4rem 2rem;
  max-width: 1200px; margin: 0 auto;
}
.landing-brand {
  font-family: var(--font-serif);
  color: var(--c-primary); font-size: 1.6rem; font-weight: 700;
  letter-spacing: -0.01em;
}
.landing-cta {
  color: var(--c-primary);
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--c-primary);
  border-radius: var(--r-md);
  font-weight: 500;
  transition: all var(--t-fast);
}
.landing-cta:hover { background: var(--c-primary); color: #fff; }

.landing-main { max-width: 1100px; margin: 0 auto; padding: 0 2rem 5rem; }

.landing-hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 3rem;
  align-items: center;
  padding: 4.5rem 0 3.5rem;
}
.landing-hero-text { max-width: 540px; }
.landing-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4.4vw, 3rem);
  line-height: 1.1; margin: 0 0 1.5rem;
  color: var(--c-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.landing-lead {
  font-size: 1.1rem; color: var(--c-text-muted);
  margin: 0 0 2rem;
  line-height: 1.6;
}
.landing-hero-art {
  display: flex; align-items: center; justify-content: center;
  filter: drop-shadow(0 14px 28px rgba(15, 23, 42, 0.07));
}
.landing-hero-art img {
  width: 100%; max-width: 480px; height: auto;
  animation: hero-float 8s ease-in-out infinite;
}
@keyframes hero-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@media (max-width: 880px) {
  .landing-hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 3rem 0 2rem;
    gap: 2rem;
  }
  .landing-hero-text { margin: 0 auto; }
  .landing-hero-art img { max-width: 360px; }
}
@media (max-width: 880px) and (prefers-reduced-motion: no-preference) {
  .landing-hero-art img { animation-duration: 10s; }
}
.landing-cta-big {
  display: inline-block;
  padding: 0.9rem 2rem;
  font-size: 1rem; font-weight: 600;
  background: var(--c-primary); color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  transition: all var(--t-base);
  letter-spacing: 0.01em;
}
.landing-cta-big:hover {
  background: var(--c-primary-hover); color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem; padding: 3rem 0;
}
.landing-features article {
  background: var(--c-surface);
  padding: 1.75rem 1.5rem;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.landing-features article:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-border-strong);
}
.landing-features h3 {
  margin: 0 0 0.6rem; color: var(--c-primary);
  font-size: 1.05rem; font-weight: 600;
}
.landing-features p {
  margin: 0; color: var(--c-text-muted);
  line-height: 1.55; font-size: 0.95rem;
}

.landing-cta-section {
  text-align: center; padding: 4rem 0 2rem;
  border-top: 1px solid var(--c-border);
  margin-top: 2rem;
}
.landing-cta-section h2 {
  color: var(--c-primary);
  font-family: var(--font-serif);
  font-size: 2rem; letter-spacing: -0.01em;
}
.landing-footer {
  text-align: center; color: var(--c-text-subtle);
  font-size: 0.82rem;
  padding: 2.25rem 1.5rem;
  border-top: 1px solid var(--c-border);
  line-height: 1.5;
}

/* ───────────────────────────────────────────────────────────
 * Botones
 * ─────────────────────────────────────────────────────────── */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: var(--c-primary); color: #fff;
  border: 1px solid transparent;
  padding: 0.55rem 1.05rem;
  font-family: inherit; font-size: 0.92rem; font-weight: 500;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover, button:hover {
  background: var(--c-primary-hover); color: #fff;
}
.btn:active, button:active { transform: translateY(1px); }
.btn:focus-visible, button:focus-visible {
  outline: none; box-shadow: var(--ring-focus);
}
.btn:disabled, button:disabled {
  background: var(--c-border-strong); cursor: not-allowed; opacity: 0.7;
}

.btn-secondary {
  background: transparent; color: var(--c-primary);
  border: 1px solid var(--c-primary);
  padding: 0.4rem 0.85rem;
  font-size: 0.86rem; font-weight: 500;
  border-radius: var(--r-md);
  transition: all var(--t-fast);
  margin-right: 0.5rem; cursor: pointer;
}
.btn-secondary:hover { background: var(--c-primary); color: #fff; }

/* ───────────────────────────────────────────────────────────
 * Forms y tablas
 * ─────────────────────────────────────────────────────────── */
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin: 1rem 0 2rem;
  padding: 1.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  font-family: inherit; font-size: 0.92rem;
}
.form-grid button { grid-column: span 2; margin-top: 0.3rem; }
.form-grid textarea {
  grid-column: span 2; resize: vertical; padding: 0.6rem;
  min-height: 80px;
}

input, select, textarea {
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-border-focus);
  box-shadow: var(--ring-focus);
}
input::placeholder, textarea::placeholder { color: var(--c-text-subtle); }

table {
  width: 100%; border-collapse: collapse;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-xs);
}
th, td {
  text-align: left;
  padding: 0.7rem 0.95rem;
  border-bottom: 1px solid var(--c-border);
  font-size: 0.92rem;
}
th {
  background: var(--c-surface-alt);
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--c-surface-alt); }

.meta { color: var(--c-text-muted); margin-bottom: 1.5rem; font-size: 0.92rem; }
.hint { color: var(--c-text-muted); font-size: 0.88rem; }
.htmx-indicator { display: none; margin-left: 0.75rem; color: var(--c-text-muted); }
.htmx-request .htmx-indicator { display: inline-flex; align-items: center; gap: 0.4rem; }

/* ───────────────────────────────────────────────────────────
 * Barra de caso activo (en sidebar)
 * ─────────────────────────────────────────────────────────── */
.barra-caso {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  font-size: 0.92rem;
  box-shadow: var(--shadow-xs);
}
.barra-caso-info {
  display: flex; flex-direction: column; gap: 0.15rem;
  flex: 1; min-width: 0;
}
.barra-caso-label {
  font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text-subtle); font-weight: 600;
}
.barra-caso-titulo {
  color: var(--c-primary); font-size: 0.98rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.barra-caso-meta { color: var(--c-text-muted); font-size: 0.85rem; }
.barra-caso-switch select {
  padding: 0.4rem 0.55rem; font-size: 0.88rem; max-width: 320px;
}

/* ───────────────────────────────────────────────────────────
 * Panel de documentos
 * ─────────────────────────────────────────────────────────── */
.panel-docs { font-size: 0.9rem; }
.panel-docs > details {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: 0.5rem 0.95rem;
  box-shadow: var(--shadow-xs);
}
.panel-docs > details > summary {
  cursor: pointer; padding: 0.35rem 0;
  color: var(--c-primary); font-weight: 600;
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  list-style: none;
}
.panel-docs > details > summary::-webkit-details-marker { display: none; }
.panel-docs > details > summary::before {
  content: '▸'; color: var(--c-text-subtle);
  transition: transform var(--t-fast);
  font-size: 0.85rem;
}
.panel-docs > details[open] > summary::before { transform: rotate(90deg); }
.panel-docs-tag {
  background: var(--c-primary-soft); color: var(--c-primary);
  padding: 0.1rem 0.55rem;
  border-radius: var(--r-full);
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.panel-docs-body { padding: 0.55rem 0; }
.panel-docs-grupo + .panel-docs-grupo { margin-top: 0.7rem; }
.panel-docs-grupo h4 {
  margin: 0.25rem 0; font-size: 0.72rem; color: var(--c-text-subtle);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.panel-docs-grupo ul { margin: 0; padding-left: 1.1rem; list-style: disc; }
.panel-docs-grupo li { margin: 0.18rem 0; line-height: 1.45; }
.panel-docs-grupo .hint { font-size: 0.8rem; }

/* ───────────────────────────────────────────────────────────
 * Chat
 * ─────────────────────────────────────────────────────────── */
.chat-wrap {
  max-width: 900px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 0.85rem;
  height: calc(100vh - 3rem);
}
.chat-stream {
  flex: 1; overflow-y: auto;
  padding: 1.5rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  display: flex; flex-direction: column; gap: 0.85rem;
  scroll-behavior: smooth;
  box-shadow: var(--shadow-sm);
}
.bubble {
  max-width: 85%;
  padding: 0.85rem 1.15rem;
  border-radius: var(--r-xl);
  line-height: 1.55;
  font-family: var(--font-serif);
  font-size: 1rem;
  box-shadow: var(--shadow-xs);
  animation: bubble-in 220ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.bubble.user {
  align-self: flex-end;
  background: var(--c-primary); color: #fff;
  border-bottom-right-radius: var(--r-sm);
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--c-surface-alt); color: var(--c-text);
  border: 1px solid var(--c-border);
  border-bottom-left-radius: var(--r-sm);
}
.bubble-body { white-space: pre-wrap; word-wrap: break-word; }
.bubble.user .bubble-body strong { color: #fff; }
.bubble.user a { color: #c8d6e8; text-decoration: underline; }

.tool-trace { margin-top: 0.6rem; font-size: 0.8rem; opacity: 0.7; }
.tool-trace summary { cursor: pointer; user-select: none; }
.tool-trace pre {
  white-space: pre-wrap; max-height: 220px; overflow: auto;
  background: rgba(0, 0, 0, 0.04);
  padding: 0.6rem 0.8rem;
  border-radius: var(--r-md);
  margin-top: 0.4rem;
  font-size: 0.78rem;
  font-family: 'SF Mono', Menlo, monospace;
}

.chat-form {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.85rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.chat-form:focus-within {
  border-color: var(--c-primary);
  box-shadow: var(--ring-focus);
}
.chat-form textarea {
  border: 0; resize: vertical;
  padding: 0.5rem; outline: none;
  font-size: 0.98rem;
  font-family: var(--font-serif);
  background: transparent;
  min-height: 50px;
}
.chat-form textarea:focus { box-shadow: none; }

.chat-actions {
  display: flex; align-items: center; gap: 0.85rem;
}
.chat-actions button { margin-left: auto; min-width: 110px; }
.btn-enviar {
  font-weight: 600;
  padding: 0.55rem 1.4rem;
  font-size: 0.92rem;
}

.file-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  cursor: pointer;
  font-size: 0.88rem;
}
.file-btn input[type="file"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.file-btn span {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  background: var(--c-surface-alt); color: var(--c-primary);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md);
  font-size: 0.86rem; font-weight: 500;
  transition: all var(--t-fast);
}
.file-btn:hover span {
  background: var(--c-primary-soft);
  border-color: var(--c-primary);
}

.archivos-elegidos {
  list-style: none; margin: 0.5rem 0 0; padding: 0.65rem 0.85rem;
  background: var(--c-surface-alt);
  border-radius: var(--r-md);
  font-size: 0.86rem;
  border: 1px solid var(--c-border);
}
.archivos-elegidos li {
  padding: 0.15rem 0; color: var(--c-text);
  display: flex; align-items: center; gap: 0.4rem;
}
.archivos-elegidos li::before { content: '📄'; opacity: 0.7; }
.archivos-elegidos-hint {
  color: var(--c-text-subtle); font-style: italic; margin-top: 0.3rem;
}

/* Estado "trabajando" del form de chat */
.chat-form.htmx-request textarea,
.chat-form.htmx-request .file-btn {
  opacity: 0.5; pointer-events: none;
}
.chat-form.htmx-request .btn-enviar {
  background: var(--c-text-muted); cursor: wait;
  pointer-events: none; opacity: 0.85;
}
.chat-form.htmx-request .btn-label-default { display: none; }
.chat-form .btn-label-loading { display: none; }
.chat-form.htmx-request .btn-label-loading { display: inline; }

/* Burbuja "pensando" */
.thinking-body {
  display: inline-flex !important; align-items: center; gap: 0.45rem;
  color: var(--c-text-muted);
}
.thinking-label { font-style: italic; font-family: var(--font-serif); }

/* Tres puntos animados */
.bubble .dot, .htmx-indicator .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-primary); display: inline-block;
  animation: dot-bounce 1.2s infinite ease-in-out;
}
.bubble .dot:nth-child(2), .htmx-indicator .dot:nth-child(2) { animation-delay: 0.15s; }
.bubble .dot:nth-child(3), .htmx-indicator .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}
.ellipsis-anim::after {
  content: '';
  animation: ellipsis 1.5s infinite;
}
@keyframes ellipsis {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

/* Barra progreso upload */
.upload-progress {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0.4rem; padding: 0.6rem 0.85rem;
  background: var(--c-surface-alt); border-radius: var(--r-md);
  font-size: 0.86rem;
  border: 1px solid var(--c-border);
}
.upload-label { color: var(--c-text-muted); flex-shrink: 0; }
.upload-bar {
  flex: 1; height: 6px;
  background: var(--c-border);
  border-radius: var(--r-full); overflow: hidden;
}
.upload-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--c-primary), var(--c-primary-hover));
  border-radius: var(--r-full);
  transition: width 0.15s ease-out;
}
.upload-pct {
  color: var(--c-primary); font-weight: 600;
  min-width: 3.5em; text-align: right;
  font-variant-numeric: tabular-nums;
}

.chat-debug { font-size: 0.86rem; color: var(--c-text-muted); }
.chat-debug summary { cursor: pointer; user-select: none; }

/* ───────────────────────────────────────────────────────────
 * Aprendizajes
 * ─────────────────────────────────────────────────────────── */
.apr-cat {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: var(--r-full);
  background: var(--c-primary-soft); color: var(--c-primary);
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.apr-inactivo { opacity: 0.45; }

/* ───────────────────────────────────────────────────────────
 * Responsive
 * ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: relative;
    border-right: 0; border-bottom: 1px solid var(--c-border);
    padding: 0.85rem 1rem;
  }
  .sidebar-docs-wrap { max-height: 180px; }
  .main-area { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid button, .form-grid textarea { grid-column: span 1; }
  .chat-wrap { height: calc(100vh - 9rem); }
  .bubble { max-width: 95%; }
}

@media (max-width: 560px) {
  .landing-header { padding: 1rem; }
  .landing-main { padding: 0 1rem 3rem; }
  .landing-hero { padding: 2.5rem 0 2rem; }
  .auth-card { padding: 2rem 1.5rem; }
}

/* ───────────────────────────────────────────────────────────
 * Print: para que el PDF de demanda salga limpio
 * ─────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .chat-form, .htmx-indicator { display: none !important; }
  .main-area { padding: 0; }
  .bubble { box-shadow: none; border: 0; max-width: 100%; }
}

/* ───────────────────────────────────────────────────────────
 * Reduce motion
 * ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
