/* Circles Ai · pantalla de acceso. Sin dependencias. Contraste AA. Respeta reduced-motion. */
:root {
  --bg: #f4f2fb;
  --bg-elev: #ffffff;
  --fg: #1a1633;
  --mut: #5c5678;
  --line: #e4dff2;
  --input-bg: #faf9ff;
  --accent: #5b21b6;
  --accent-hover: #4c1d95;
  --accent-soft: #7c3aed;
  --accent-wash: rgba(109, 40, 217, 0.12);
  --accent-glow: rgba(108, 76, 255, 0.28);
  --on-accent: #ffffff;
  --error: #b42318;
  --error-bg: #fef3f2;
  --error-line: #fecdca;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --ok-line: #abefc6;
  --focus: #7c3aed;
  --shadow: 0 18px 50px rgba(26, 22, 51, 0.1), 0 0 0 1px rgba(91, 33, 182, 0.06);
  --radius: 18px;
  --radius-sm: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --bg-elev: #111832;
    --fg: #e8ecf5;
    --mut: #9aa4bf;
    --line: #2a3358;
    --input-bg: #0b1020;
    --accent: #6d28d9;
    --accent-hover: #5b21b6;
    --accent-soft: #c4b5fd;
    --accent-wash: rgba(109, 40, 217, 0.18);
    --accent-glow: rgba(139, 92, 246, 0.22);
    --on-accent: #ffffff;
    --error: #ffb4ab;
    --error-bg: rgba(255, 180, 171, 0.1);
    --error-line: #7a3a3a;
    --ok: #7ee2b8;
    --ok-bg: rgba(126, 226, 184, 0.1);
    --ok-line: #245c45;
    --focus: #c4b5fd;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(139, 92, 246, 0.08);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Saltar al contenido: visible solo al enfocar */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 10;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

a {
  color: var(--accent-soft);
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Marca: debajo del formulario en móvil (el acceso primero) */
.brand {
  position: relative;
  overflow: hidden;
  order: 2;
  padding: 32px 20px 40px;
  border-top: 1px solid var(--line);
  background:
    radial-gradient(900px 420px at 10% -20%, var(--accent-glow), transparent 60%),
    linear-gradient(165deg, var(--accent-wash), transparent 55%);
}

.brand-inner {
  position: relative;
  z-index: 1;
  max-width: 36rem;
  margin: 0 auto;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin-bottom: 28px;
}

.logo-word em {
  font-style: normal;
  color: var(--accent-soft);
}

.logo-mark {
  display: block;
  flex-shrink: 0;
  border-radius: 10px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
}

.brand h1 {
  margin: 0 0 12px;
  font-size: clamp(1.55rem, 4.5vw, 2.15rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.brand h1 em {
  font-style: normal;
  color: var(--accent-soft);
}

.lead,
.sub {
  margin: 0;
  color: var(--mut);
}

.lead {
  margin-bottom: 24px;
  max-width: 46ch;
}

.highlights {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.highlights li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.highlights strong {
  display: block;
  font-size: 0.98rem;
}

.highlights span:not(.dot) {
  color: var(--mut);
  font-size: 0.92rem;
}

.dot {
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent-soft);
  box-shadow: 0 0 10px var(--accent-soft);
  flex-shrink: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
  opacity: 0.55;
}

.orb-a {
  width: 220px;
  height: 220px;
  right: -60px;
  top: -40px;
  background: #6c4cff;
}

.orb-b {
  width: 180px;
  height: 180px;
  left: -50px;
  bottom: -50px;
  background: #22d3a6;
  opacity: 0.28;
}

.panel {
  order: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 16px 16px;
}

.card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.card-head h2,
.success h2 {
  margin: 0 0 4px;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.card-head .sub {
  margin-bottom: 20px;
  font-size: 0.95rem;
}

form {
  display: grid;
  gap: 16px;
  margin: 0;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-weight: 600;
  font-size: 0.92rem;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
}

.field input::placeholder {
  color: color-mix(in srgb, var(--mut) 80%, var(--fg) 20%);
  opacity: 1;
}

.field input[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-bg);
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 52px;
}

.toggle-password {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--mut);
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-password:hover,
.toggle-password[aria-pressed="true"] {
  color: var(--fg);
}

.field-error {
  margin: 0;
  color: var(--error);
  font-size: 0.88rem;
}

.caps-warning {
  margin: 0;
  color: var(--fg);
  background: var(--accent-wash);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.88rem;
  font-weight: 600;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.forgot {
  font-weight: 600;
  text-underline-offset: 2px;
}

.btn {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.72;
  cursor: not-allowed;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid color-mix(in srgb, var(--on-accent) 35%, transparent);
  border-top-color: var(--on-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

[hidden] {
  display: none !important;
}

.btn-busy:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.alert {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
}

.alert.error {
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid var(--error-line);
}

.demo {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--mut);
}

.demo summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--fg);
}

.demo p {
  margin: 8px 0 0;
}

.demo code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86rem;
  color: var(--fg);
  background: var(--input-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
}

.demo-note {
  font-size: 0.84rem;
}

.success {
  text-align: center;
  padding: 12px 4px 4px;
}

.success-mark {
  color: var(--ok);
  margin-bottom: 12px;
}

.success .sub {
  margin-bottom: 16px;
}

.signed-in {
  margin: 0 0 20px;
  padding: 10px 12px;
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: 10px;
  color: var(--ok);
  font-weight: 600;
}

.legal {
  max-width: 420px;
  margin: 18px auto 0;
  text-align: center;
  color: var(--mut);
  font-size: 0.85rem;
}

/* Página recuperar */
.recover-card .sub {
  margin-bottom: 18px;
}

.recover-note {
  margin: 0 0 18px;
  padding: 12px 14px;
  background: var(--accent-wash);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--fg);
}

@media (min-width: 900px) {
  .layout {
    flex-direction: row;
    min-height: 100vh;
  }

  .brand,
  .panel {
    order: unset;
    width: 50%;
  }

  .brand {
    border-top: 0;
    border-right: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 56px 48px;
  }

  .brand-inner {
    margin: 0;
  }

  .panel {
    padding: 48px 28px;
  }

  .card {
    padding: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--on-accent);
    opacity: 0.9;
  }

  .orb {
    filter: none;
    opacity: 0.25;
  }
}

/* ===== App funcional: estados, registro, inicio y perfil ===== */
.pending body { visibility: hidden; }

.alert.success {
  color: var(--ok);
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
}

.field-hint {
  margin: 0;
  color: var(--mut);
  font-size: 0.85rem;
}

.field input[readonly] {
  opacity: 0.8;
  cursor: not-allowed;
}

.switch {
  margin: 18px 0 0;
  text-align: center;
  font-size: 0.92rem;
  color: var(--mut);
}

.switch a {
  font-weight: 600;
}

.btn[href], a.btn {
  text-decoration: none;
}

.success .btn { margin-top: 4px; }

/* Barra superior */
body.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-sm { margin: 0; font-size: 1.05rem; }

.topnav { display: none; gap: 4px; margin-left: 8px; flex: 1; }

.topnav a {
  color: var(--mut);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
}

.topnav a:hover { color: var(--fg); background: var(--accent-wash); }
.topnav a[aria-current="page"] { color: var(--fg); background: var(--accent-wash); }

.usermenu { position: relative; margin-left: auto; }

.usermenu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.usermenu-btn:hover { background: var(--accent-wash); }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.usermenu-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.usermenu-list {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 2px;
}

.usermenu-email {
  margin: 0;
  padding: 6px 10px 8px;
  color: var(--mut);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
}

.usermenu-list a,
.usermenu-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.usermenu-list a:hover,
.usermenu-list button:hover { background: var(--accent-wash); }

/* Contenido de la app */
.app-main {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 16px 40px;
  flex: 1;
  background:
    radial-gradient(800px 320px at 0% -10%, var(--accent-glow), transparent 60%);
}

.app-main.narrow { max-width: 640px; }

.hero { margin-bottom: 28px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 5vw, 2.3rem); letter-spacing: -0.03em; line-height: 1.2; }
.hero .lead { margin: 0; }

.section-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--accent-wash);
  color: var(--fg);
}

.modules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.module {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.module h3 { margin: 6px 0 0; font-size: 1.05rem; letter-spacing: -0.01em; }
.module p { margin: 0; color: var(--mut); font-size: 0.93rem; }

.module-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-wash);
  color: var(--accent-soft);
}

.module-state {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--mut);
}

.module-link { margin-top: auto; padding-top: 8px; font-weight: 700; }

.card-wide { max-width: none; }

.app-footer {
  text-align: center;
  padding: 18px 16px 26px;
  color: var(--mut);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

@media (min-width: 640px) {
  .modules { grid-template-columns: repeat(2, 1fr); }
  .topnav { display: flex; }
}

@media (min-width: 960px) {
  .modules { grid-template-columns: repeat(3, 1fr); }
  .app-main { padding-top: 44px; }
}
