/* Nousy /app — design system aligned with landing.css palette.
   Tokens declared here so app.css is self-contained (no load-order dependency).
   v1 — top nav + dropdowns + welcome + mode toggle */

/* ── TOKENS ──────────────────────────────────────────────────────────────── */
:root {
  --bg-dark:   #0A2F33;
  --bg-dark-2: #05201F;
  --bg-dark-3: #0E3A3E;
  --bg:        #F5F8F7;
  --bg-soft:   #EAEFED;
  --surface:   #FFFFFF;
  --text:      #0A1F22;
  --text-soft: #3A4F52;
  --text-muted:#6B7B7E;
  --on-dark:        #F0F5F4;
  --on-dark-soft:   #A8BDBE;
  --accent-teal:        #14B8A6;
  --accent-teal-hover:  #0F9B8E;
  --accent-teal-soft:   #E0F5F1;
  --accent-cyan:        #3ECFAE;
  --accent-purple:      #9B7FE8;
  --accent-purple-hover:#8567D9;
  --border:      #D8E2DF;
  --border-strong:#B8C8C4;
  --border-dark: rgba(255,255,255,0.08);
  --error:       #DC2626;
  --warn:        #D97706;
  --step--1: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  --step-0:  clamp(0.9375rem, 0.9rem  + 0.2vw,  1rem);
  --step-1:  clamp(1.0625rem, 1rem    + 0.3vw,  1.1875rem);
  --step-2:  clamp(1.25rem,   1.1rem  + 0.6vw,  1.5rem);
  --step-3:  clamp(1.75rem,   1.4rem  + 1.4vw,  2.375rem);
  --sp-1:.25rem; --sp-2:.5rem;  --sp-3:.75rem; --sp-4:1rem;
  --sp-5:1.5rem; --sp-6:2rem;  --sp-7:3rem;   --sp-8:4rem;
  --radius-sm:8px; --radius:12px; --radius-lg:20px; --radius-xl:28px;
  --shadow-card:   0 1px 2px rgba(10,31,34,.04), 0 8px 24px -12px rgba(10,31,34,.10);
  --shadow-lifted: 0 2px 4px rgba(10,31,34,.06), 0 20px 48px -16px rgba(10,31,34,.16);
  --shadow-dropdown: 0 4px 6px rgba(10,31,34,.04), 0 16px 32px -8px rgba(10,31,34,.14);
  --font-sans:"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --nav-h: 56px;
  --fucs-accent: #7C3AED;
  --fucs-accent-dark: #6D28D9;
  --code-bg: #EEF2F0;
  --bubble-user-bg: var(--accent-teal-soft);
  --bubble-user-text: var(--text);
  --bubble-bot-bg: var(--surface);
  --bubble-bot-text: var(--text);
}

:root[data-theme="dark"] {
  --bg:        #0D1F22;
  --bg-soft:   #111D20;
  --surface:   #162124;
  --text:      #E8F0EE;
  --text-soft: #9DB8B4;
  --text-muted:#6B8A86;
  --border:    #243840;
  --border-strong:#2F4A50;
  --code-bg:   #0A1A1D;
  --bubble-user-bg: #1A3A3F;
  --bubble-user-text: #E0F5F1;
  --bubble-bot-bg: #162124;
  --bubble-bot-text: #E8F0EE;
  --fucs-accent: #A78BFA;
  --fucs-accent-dark: #8B5CF6;
  --error: #F87171;
  --warn: #FBB724;
}

/* ── RESET ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── ACCESSIBILITY ───────────────────────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent-teal);
  color: #fff;
  padding: 8px 16px;
  z-index: 10000;
  font-size: var(--step--1);
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 0; }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-teal);
  outline-offset: 2px;
}

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--nav-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.toast.visible { opacity: 1; }
.toast.info { background: var(--accent-teal); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

/* ── TOP NAV ─────────────────────────────────────────────────────────────── */
#app-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-dark);
  display: none;
  align-items: center;
  padding: 0 var(--sp-5);
  gap: var(--sp-3);
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  color: var(--on-dark);
  font-weight: 700;
  font-size: var(--step-0);
  flex-shrink: 0;
  margin-right: var(--sp-3);
}
.nav-brand svg { color: var(--accent-teal); flex-shrink: 0; }

.nav-left {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex: 1;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Hamburger — hidden on desktop */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--on-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.nav-hamburger:hover { background: rgba(255,255,255,.08); }

/* ── DROPDOWN ────────────────────────────────────────────────────────────── */
.dropdown { position: relative; }

.dropdown-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 36px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--on-dark-soft);
  font-size: var(--step--1);
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.dropdown-trigger:hover,
.dropdown-trigger[aria-expanded="true"] {
  background: rgba(255,255,255,.08);
  color: var(--on-dark);
}
.dropdown-trigger .chevron {
  width: 12px;
  height: 12px;
  transition: transform .18s ease;
  flex-shrink: 0;
  opacity: .7;
}
.dropdown-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.dropdown-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-dropdown);
  z-index: 300;
  overflow: hidden;
}
.dropdown-panel.open {
  display: block;
  animation: dropdown-in .18s ease;
}
.dropdown-panel.right { right: 0; left: auto; }

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes dropdown-in { from { opacity: 0; } to { opacity: 1; } }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: var(--step--1);
  font-family: var(--font-sans);
  text-align: left;
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-soft); }
.dropdown-item.active { color: var(--accent-teal); font-weight: 600; }
.dropdown-item.danger { color: var(--error); }
.dropdown-item.danger:hover { background: #FEF2F2; }
.dropdown-item-muted {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 8px 16px;
  color: var(--text-muted);
  font-size: var(--step--1);
  font-style: italic;
}
.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.dropdown-header {
  padding: 10px 16px 6px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

[data-theme="dark"] .dropdown-item.danger:hover { background: #2A1010; }

/* ── THEME TOGGLE ─────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
  margin-right: var(--sp-2);
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--accent-teal); border-color: var(--accent-teal); }
.theme-toggle .theme-icon-sun { display: none; }
.theme-toggle .theme-icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

/* ── HISTORIAL DROPDOWN ───────────────────────────────────────────────────── */
#dd-historial { min-width: 260px; max-height: 420px; overflow-y: auto; }

.dd-new-chat {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--accent-teal-soft);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--accent-teal-hover);
  font-size: var(--step--1);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background .12s;
}
.dd-new-chat:hover { background: var(--border); }

[data-theme="dark"] .dd-new-chat { background: rgba(20,184,166,.12); color: var(--accent-teal); border-bottom-color: var(--border); }
[data-theme="dark"] .dd-new-chat:hover { background: rgba(20,184,166,.2); }

.conv-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 8px 40px 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: var(--step--1);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: background .12s;
}
.conv-item:hover { background: var(--bg-soft); }
.conv-item.active { background: var(--accent-teal-soft); color: var(--accent-teal-hover); }

[data-theme="dark"] .conv-item.active { background: rgba(20,184,166,.12); color: var(--accent-teal); }

.conv-item-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  line-height: 1.3;
}
.conv-item-time {
  font-size: .68rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.conv-item.active .conv-item-time { color: var(--accent-teal); opacity: .7; }

.btn-conv-delete {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
  padding: 0;
}
.conv-item:hover .btn-conv-delete,
.conv-item:focus-within .btn-conv-delete { display: flex; }
.btn-conv-delete:hover { background: #FEE2E2; color: var(--error); }

[data-theme="dark"] .btn-conv-delete:hover { background: #2A1010; }

.conv-delete-confirm {
  position: absolute;
  inset: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  font-size: var(--step--1);
  color: var(--text);
  z-index: 2;
}
.conv-delete-confirm span { color: var(--error); font-weight: 600; }
.conv-delete-confirm button {
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
}
.conv-delete-confirm .btn-yes { background: var(--error); color: #fff; }
.conv-delete-confirm .btn-no { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }

.conv-empty {
  padding: 20px 16px;
  font-size: var(--step--1);
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.conv-skeleton { display: flex; flex-direction: column; gap: 6px; padding: 10px 16px; }
.conv-skeleton-line {
  height: 10px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}
.conv-skeleton-line:first-child { width: 75%; }
.conv-skeleton-line:last-child { width: 45%; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.conv-error { padding: 12px 16px; font-size: var(--step--1); color: var(--error); text-align: center; }

/* ── MI PLAN DROPDOWN ─────────────────────────────────────────────────────── */
.plan-info {
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 10px;
  border-radius: 20px;
  align-self: flex-start;
}
.tier-badge.free { background: var(--bg-soft); color: var(--text-muted); border: 1px solid var(--border); }
.tier-badge.pro  { background: rgba(20,184,166,.12); color: var(--accent-teal-hover); border: 1px solid var(--accent-teal); }
.tier-badge.premium { background: rgba(251,191,36,.12); color: #D97706; border: 1px solid #FBBF24; }

.plan-usage-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plan-usage-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--step--1);
  color: var(--text-soft);
}
.plan-usage-label span.val { font-weight: 600; color: var(--text); }
.plan-usage-label span.warn { color: var(--warn); font-weight: 600; }
.plan-usage-label span.limit { color: var(--error); font-weight: 600; }

.plan-usage-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.plan-usage-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent-teal);
  transition: width .3s ease;
}
.plan-usage-fill.warn { background: var(--warn); }
.plan-usage-fill.limit { background: var(--error); }

.plan-limit-msg {
  font-size: .75rem;
  color: var(--error);
  line-height: 1.4;
}

.btn-upgrade {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 32px);
  margin: 0 16px 12px;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-teal);
  background: var(--accent-teal);
  color: #fff;
  font-size: var(--step--1);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
}
.btn-upgrade:hover { background: var(--accent-teal-hover); border-color: var(--accent-teal-hover); }

/* ── CUENTA DROPDOWN ─────────────────────────────────────────────────────── */
.account-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.account-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-purple) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.account-meta { flex: 1; min-width: 0; }
.account-username {
  font-weight: 700;
  font-size: var(--step--1);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-email {
  font-size: .7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.verify-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 3px;
}
.verify-chip.ok { background: #D1FAE5; color: #065F46; }
.verify-chip.pending { background: #FEF3C7; color: #92400E; }

[data-theme="dark"] .verify-chip.ok { background: #052E16; color: #6EE7B7; }
[data-theme="dark"] .verify-chip.pending { background: #451A03; color: #FBB724; }

/* ── MOBILE DRAWER ────────────────────────────────────────────────────────── */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
}
.mobile-drawer-overlay.open { display: flex; }

.mobile-drawer-bg {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
}

.mobile-drawer {
  position: relative;
  z-index: 1;
  width: 280px;
  height: 100%;
  background: var(--bg-dark);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4);
  gap: var(--sp-1);
}

.mobile-drawer-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--on-dark);
  font-weight: 700;
  font-size: var(--step-0);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border-dark);
  margin-bottom: var(--sp-2);
  flex-shrink: 0;
}
.mobile-drawer-brand svg { color: var(--accent-teal); }

.mobile-drawer-section {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--on-dark-soft);
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
}

.mobile-drawer-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 10px var(--sp-3);
  border: none;
  background: transparent;
  color: var(--on-dark-soft);
  font-size: var(--step--1);
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .12s, color .12s;
}
.mobile-drawer-item:hover { background: rgba(255,255,255,.08); color: var(--on-dark); }
.mobile-drawer-item.active { color: var(--accent-teal); }
.mobile-drawer-item.danger { color: #F87171; }

.mobile-drawer-conv-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
}

/* ── EMAIL VERIFICATION BANNER ───────────────────────────────────────────── */
.verify-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 10px var(--sp-5);
  background: #451A03;
  color: #FDE68A;
  border-bottom: 1px solid #D97706;
  font-size: var(--step--1);
  line-height: 1.4;
  flex-shrink: 0;
}
.verify-banner.show { display: flex; }
.verify-banner-text { flex: 1; min-width: 0; }
.verify-banner-text strong { color: #FBBF24; }
.verify-banner-actions { display: flex; gap: var(--sp-2); flex-shrink: 0; }
.verify-banner button {
  background: transparent;
  color: #FDE68A;
  border: 1px solid #D97706;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .15s;
}
.verify-banner button:hover:not(:disabled) { background: #78350F; }
.verify-banner button:disabled { opacity: .5; cursor: wait; }
.verify-banner .verify-close {
  background: transparent;
  border: none;
  color: #FDE68A;
  font-size: 1.2rem;
  padding: 0 4px;
  cursor: pointer;
  line-height: 1;
}

@media (max-width: 560px) {
  .verify-banner { flex-direction: column; align-items: stretch; text-align: center; }
  .verify-banner-actions { justify-content: center; }
}

/* ── LOGIN VIEW ──────────────────────────────────────────────────────────── */
#login-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--bg-soft);
  padding: var(--sp-6) var(--sp-4);
  gap: var(--sp-5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
}
.login-brand svg { color: var(--accent-teal); }
.login-brand-name {
  font-size: var(--step-2);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card);
}

.login-card-title {
  font-size: var(--step-2);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.login-card-sub {
  font-size: var(--step--1);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}

.form-group { margin-bottom: var(--sp-4); }

.form-group label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-family: var(--font-sans);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: var(--bg);
  color: var(--text);
}
.form-group input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px rgba(20,184,166,.12);
}

.form-group-pw { position: relative; }
.form-group-pw input { padding-right: 44px; }
.btn-pw-toggle {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 44px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.btn-pw-toggle:hover { color: var(--text); }

.forgot-link {
  display: block;
  text-align: right;
  font-size: .75rem;
  color: var(--accent-teal);
  text-decoration: none;
  margin-top: -8px;
  margin-bottom: var(--sp-4);
  font-weight: 500;
}
.forgot-link:hover { text-decoration: underline; }

.btn-primary {
  width: 100%;
  min-height: 46px;
  padding: 12px;
  background: var(--accent-teal);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--step--1);
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background .15s;
  letter-spacing: .01em;
}
.btn-primary:hover { background: var(--accent-teal-hover); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

#login-error {
  color: var(--error);
  font-size: var(--step--1);
  margin-top: var(--sp-3);
  min-height: 20px;
  text-align: center;
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  box-sizing: border-box;
}
.btn-oauth-google {
  background: #FFFFFF;
  color: #1F1F1F;
  border: 1px solid #DADCE0;
}
.btn-oauth-google:hover {
  background: #F8F9FA;
  border-color: #C6CACE;
}
[data-theme="dark"] .btn-oauth-google {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
[data-theme="dark"] .btn-oauth-google:hover {
  background: rgba(255, 255, 255, 0.04);
}
.btn-oauth .oauth-icon { flex-shrink: 0; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-5) 0;
  color: var(--text-muted);
  font-size: var(--step--1);
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-toggle {
  text-align: center;
  font-size: var(--step--1);
  color: var(--text-muted);
}
.auth-toggle a {
  color: var(--accent-teal);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.auth-toggle a:hover { text-decoration: underline; }

.login-footer {
  display: flex;
  gap: var(--sp-4);
  font-size: .75rem;
  color: var(--text-muted);
}
.login-footer a { color: var(--text-muted); text-decoration: none; }
.login-footer a:hover { color: var(--text); }

/* ── CHAT VIEW ───────────────────────────────────────────────────────────── */
#chat-view {
  display: none;
  flex-direction: column;
  height: 100dvh;
}

/* ── CHAT MAIN AREA ──────────────────────────────────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── WELCOME STATE ───────────────────────────────────────────────────────── */
#welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: var(--sp-8) var(--sp-5) var(--sp-5);
  text-align: center;
  gap: var(--sp-6);
  overflow-y: auto;
}

.welcome-headline {
  font-size: var(--step-3);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.2;
  max-width: 600px;
}

.welcome-headline .cursor {
  display: inline-block;
  width: 3px;
  height: .9em;
  background: var(--accent-teal);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 1s step-end infinite;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-headline .cursor { animation: none; }
}

/* ── INPUT CARD (welcome state) ──────────────────────────────────────────── */
.input-card {
  width: 100%;
  max-width: 680px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lifted);
  overflow: hidden;
}

.mode-pills {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4) 0;
}

.mode-pill {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.mode-pill:hover { border-color: var(--accent-teal); color: var(--accent-teal); }
.mode-pill.active {
  border-color: var(--accent-teal);
  background: var(--accent-teal-soft);
  color: var(--accent-teal-hover);
}

[data-theme="dark"] .mode-pill.active { background: rgba(20,184,166,.14); color: var(--accent-teal); }

.simulacro-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(155,127,232,.18);
  color: var(--accent-purple);
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
}

#user-input,
#user-input-conv {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  font-size: var(--step-0);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 24px;
  max-height: 200px;
  background: transparent;
  color: var(--text);
  padding: 4px 0;
}
#user-input::placeholder,
#user-input-conv::placeholder { color: var(--text-muted); }

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-teal);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-send:hover:not(:disabled) { background: var(--accent-teal-hover); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

.btn-stop {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--error);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.btn-stop:hover { background: #B91C1C; }

/* ── QUICK CHIPS (below input card on welcome) ───────────────────────────── */
.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: center;
  max-width: 680px;
  width: 100%;
}

.quick-chip {
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: var(--step--1);
  color: var(--text-soft);
  cursor: pointer;
  background: var(--surface);
  transition: border-color .15s, color .15s;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
}
.quick-chip:hover { border-color: var(--accent-teal); color: var(--accent-teal); }

/* ── MESSAGES AREA ───────────────────────────────────────────────────────── */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-4) var(--sp-3);
  display: none;
  flex-direction: column;
  gap: var(--sp-4);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
#messages.active { display: flex; }

.msg-row {
  display: flex;
  gap: var(--sp-3);
  max-width: 780px;
  width: 100%;
  align-self: flex-start;
  animation: msg-slide-up .2s ease;
}

@keyframes msg-slide-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  @keyframes msg-slide-up { from { opacity: 0; } to { opacity: 1; } }
}

.msg-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  margin-top: 2px;
}
.avatar.bot {
  background: linear-gradient(135deg, var(--accent-teal) 0%, var(--accent-cyan) 100%);
  color: #fff;
}
.avatar.user {
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-purple-hover) 100%);
  color: #fff;
}

.bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: var(--step--1);
  line-height: 1.65;
  max-width: calc(100% - 44px);
  word-break: break-word;
}

.msg-row.bot .bubble {
  background: var(--bubble-bot-bg);
  color: var(--bubble-bot-text);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  box-shadow: var(--shadow-card);
}

.msg-row.user .bubble {
  background: var(--bubble-user-bg);
  color: var(--bubble-user-text);
  border-top-right-radius: 4px;
  border: 1px solid rgba(20,184,166,.2);
}

/* ── MARKDOWN in bot bubble ──────────────────────────────────────────────── */
.bubble h1, .bubble h2, .bubble h3 {
  font-size: var(--step-0);
  font-weight: 700;
  margin: 12px 0 4px;
  color: var(--text);
}
.bubble p { margin-bottom: 10px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 24px; margin: 8px 0 12px; }
.bubble li { margin-bottom: 8px; line-height: 1.6; }
.bubble li > p { margin-bottom: 4px; }
.bubble li::marker { color: var(--accent-teal); font-weight: 700; }
.bubble ol > li { padding-left: 4px; }
.bubble h1, .bubble h2, .bubble h3 { margin-top: 16px; }
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child { margin-top: 4px; }
.bubble blockquote {
  border-left: 3px solid var(--accent-teal);
  padding: 6px 14px;
  margin: 10px 0;
  color: var(--text-soft);
  background: var(--bg-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.bubble code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: .88em;
  font-family: var(--font-mono);
}
.bubble pre {
  background: var(--code-bg);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin-bottom: 8px;
}
.bubble pre code { background: none; padding: 0; }
.bubble strong { font-weight: 700; }
.bubble em { font-style: italic; }
.bubble table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 8px;
  font-size: .88rem;
}
.bubble th, .bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.bubble th { background: var(--bg-soft); font-weight: 600; }
.bubble .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 8px; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── TYPING / STATUS INDICATORS ─────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 2px;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce-dot 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 2px;
  font-size: var(--step--1);
  color: var(--text-muted);
  font-style: italic;
}
.status-indicator .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR BUBBLE ────────────────────────────────────────────────────────── */
.bubble.error {
  background: #FEF2F2;
  border-color: #FECACA;
  color: #B91C1C;
}
[data-theme="dark"] .bubble.error { background: #2A1010; border-color: #7F1D1D; color: #FCA5A5; }

/* ── REVEAL CHIP (quiz answer) ───────────────────────────────────────────── */
.reveal-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 8px 18px;
  margin-top: var(--sp-3);
  border: 1.5px solid var(--accent-teal);
  border-radius: 20px;
  background: transparent;
  color: var(--accent-teal);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .15s, color .15s;
}
.reveal-chip:hover { background: var(--accent-teal); color: #fff; }

/* ── SUGGESTION CHIPS (post-response) ───────────────────────────────────── */
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}
.suggestion-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: var(--step--1);
  color: var(--accent-teal);
  cursor: pointer;
  background: var(--surface);
  font-family: var(--font-sans);
  transition: border-color .15s, background .15s, color .15s;
}
.suggestion-chip:hover { border-color: var(--accent-teal); background: var(--accent-teal); color: #fff; }

/* ── INPUT AREA (active conversation bottom bar) ─────────────────────────── */
.input-area {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: none;
}
.input-area.active { display: block; }

.input-wrap {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  max-width: 780px;
  margin: 0 auto;
  transition: border-color .15s;
  box-shadow: var(--shadow-card);
}
.input-wrap:focus-within { border-color: var(--accent-teal); }

/* ── FUCS PANEL ──────────────────────────────────────────────────────────── */
.fucs-panel {
  display: none;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--fucs-accent);
  border-radius: var(--radius);
  max-width: 780px;
  width: calc(100% - var(--sp-6));
  margin: var(--sp-5) auto var(--sp-3);
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
}
.fucs-panel.visible { display: flex; }

.fucs-panel-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.fucs-panel-title {
  font-size: .7rem;
  font-weight: 800;
  color: var(--fucs-accent);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.fucs-panel-header::after {
  content: 'Preguntas y casos del diplomado FUCS 2026';
  font-size: var(--step--1);
  color: var(--text-muted);
  font-weight: 500;
}

.fucs-submodes { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.fucs-submode-btn {
  min-height: 36px;
  padding: 6px 16px;
  border-radius: 18px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}
.fucs-submode-btn:hover { border-color: var(--fucs-accent); color: var(--fucs-accent); }
.fucs-submode-btn.active { border-color: var(--fucs-accent); background: var(--fucs-accent); color: #fff; }

.fucs-panel-esp-row { display: flex; align-items: center; gap: var(--sp-2); }
.fucs-panel-esp-row label { font-size: var(--step--1); color: var(--text-muted); flex-shrink: 0; font-weight: 500; }

.fucs-esp-select {
  min-height: 34px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: var(--step--1);
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  transition: border-color .15s;
  flex: 1;
  max-width: 260px;
}
.fucs-esp-select:focus { border-color: var(--fucs-accent); }

/* FUCS question cards */
#fucs-questions-container {
  display: none;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5) 0;
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}
#fucs-questions-container.visible { display: flex; }

.fucs-question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--fucs-accent);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: var(--sp-4);
}
.fucs-question-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.fucs-question-num { font-size: .72rem; font-weight: 700; color: var(--fucs-accent); text-transform: uppercase; letter-spacing: .05em; }

.fucs-score {
  font-size: .75rem;
  font-weight: 700;
  color: var(--fucs-accent);
  background: var(--bg);
  padding: 4px 11px;
  border-radius: 10px;
  border: 1.5px solid var(--fucs-accent);
}
.fucs-question-text { font-size: var(--step--1); line-height: 1.6; color: var(--text); margin-bottom: var(--sp-4); font-weight: 500; }

.fucs-options { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.fucs-option {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-sans);
  text-align: left;
  min-height: 48px;
  width: 100%;
}
.fucs-option:hover:not(:disabled) { border-color: var(--fucs-accent); background: var(--surface); }
.fucs-option:disabled { cursor: default; }
.fucs-option.correct { border-color: #16A34A; background: #F0FDF4; color: #15803D; }
.fucs-option.incorrect { border-color: #DC2626; background: #FEF2F2; color: #B91C1C; }

[data-theme="dark"] .fucs-option.correct { background: #052E16; color: #86EFAC; border-color: #16A34A; }
[data-theme="dark"] .fucs-option.incorrect { background: #450A0A; color: #FCA5A5; border-color: #DC2626; }

.fucs-option-letter { font-weight: 700; font-size: .8rem; min-width: 20px; color: var(--fucs-accent); flex-shrink: 0; margin-top: 1px; }
.fucs-option.correct .fucs-option-letter,
.fucs-option.incorrect .fucs-option-letter { color: inherit; }

.fucs-feedback {
  display: none;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: var(--step--1);
  line-height: 1.6;
  margin-bottom: var(--sp-4);
  font-weight: 500;
}
.fucs-feedback.visible { display: block; }
.fucs-feedback.correct-fb { background: #F0FDF4; border: 1px solid #BBF7D0; color: #15803D; }
.fucs-feedback.incorrect-fb { background: #FEF2F2; border: 1px solid #FECACA; color: #B91C1C; }

[data-theme="dark"] .fucs-feedback.correct-fb { background: #052E16; border-color: #16A34A; color: #86EFAC; }
[data-theme="dark"] .fucs-feedback.incorrect-fb { background: #450A0A; border-color: #DC2626; color: #FCA5A5; }

.fucs-card-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; margin-top: 4px; }

.fucs-btn-next {
  min-height: 44px;
  padding: 10px 24px;
  border-radius: 22px;
  border: none;
  background: var(--fucs-accent);
  color: #fff;
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .15s;
}
.fucs-btn-next:hover { background: var(--fucs-accent-dark); }

.fucs-btn-explain {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 22px;
  border: 1.5px solid var(--fucs-accent);
  background: transparent;
  color: var(--fucs-accent);
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .15s, color .15s;
}
.fucs-btn-explain:hover { background: var(--fucs-accent); color: #fff; }

.fucs-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--fucs-accent);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: var(--sp-4);
}
.fucs-summary-title { font-size: var(--step-1); font-weight: 700; color: var(--text); margin-bottom: var(--sp-2); }
.fucs-summary-score { font-size: 2.5rem; font-weight: 800; color: var(--fucs-accent); margin: var(--sp-3) 0; line-height: 1; }
.fucs-summary-sub { font-size: var(--step--1); color: var(--text-muted); margin-bottom: var(--sp-5); }
.fucs-btn-restart {
  min-height: 42px;
  padding: 10px 28px;
  border-radius: 21px;
  border: none;
  background: var(--fucs-accent);
  color: #fff;
  font-size: var(--step--1);
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background .15s;
}
.fucs-btn-restart:hover { background: var(--fucs-accent-dark); }

/* ── REDUCED MOTION ──────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #messages { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── RESPONSIVE < 768px ──────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .nav-left, .nav-right { display: none; }
  .nav-hamburger { display: flex; }
  #app-nav { padding: 0 var(--sp-4); gap: var(--sp-2); }

  .welcome-headline { font-size: var(--step-2); }
  #welcome-state { padding: var(--sp-5) var(--sp-4) var(--sp-4); gap: var(--sp-4); }

  .quick-chips { gap: var(--sp-1); }
  .quick-chip { font-size: .78rem; padding: 6px 12px; }

  .login-card { padding: 28px 20px; }
  .input-card { border-radius: var(--radius); }

  .dropdown-panel { position: fixed; left: var(--sp-3); right: var(--sp-3); top: auto; min-width: 0; }
}

@media (max-width: 480px) {
  .mode-pills { gap: var(--sp-1); }
  .mode-pill { padding: 5px 10px; font-size: .78rem; }
}
