/* Los dos temas, en el mismo orden que en styles.css: si el usuario deja la
   aplicación en claro y luego cierra sesión, el login no debe salir oscuro. */
:root, :root[data-tema="oscuro"] {
  --ink: #101210;
  --ink-soft: #171a17;
  --panel: #1d211d;
  --line: #3a4038;
  --paper: #f0eadc;
  --muted: #9ca197;
  --signal: #ddff55;
  --cyan: #63d7cf;
  --ember: #ff7043;
  --danger: #ff8b7a;
  --tarjeta-bg: rgba(29, 33, 29, .88);
  --campo-bg: #111411;
  --halo-fuerte: rgba(221, 255, 85, .2);
  --halo-medio: rgba(221, 255, 85, .1);
  --halo-tenue: rgba(221, 255, 85, .018);
  --halo-cian: rgba(99, 215, 207, .09);
  --velo: rgba(255, 255, 255, .015);
  --esquema: dark;
}

:root[data-tema="claro"] {
  --ink: #f6f4ed;
  --ink-soft: #edeae0;
  --panel: #fffefa;
  --line: #cfccc0;
  --paper: #1b1d19;
  --muted: #63675c;
  --signal: #4b6a00;
  --cyan: #0f6f78;
  --ember: #b8410f;
  --danger: #a3271a;
  --tarjeta-bg: rgba(255, 254, 250, .92);
  --campo-bg: #fffefa;
  --halo-fuerte: rgba(75, 106, 0, .28);
  --halo-medio: rgba(75, 106, 0, .16);
  --halo-tenue: rgba(75, 106, 0, .04);
  --halo-cian: rgba(15, 111, 120, .1);
  --velo: rgba(27, 29, 25, .02);
  --esquema: light;
}

:root {
  --display: "Bodoni 72", Didot, "URW Palladio L", Georgia, serif;
  --body: "Avenir Next", Futura, "Trebuchet MS", sans-serif;
  --mono: "IBM Plex Mono", "Liberation Mono", monospace;
  color-scheme: var(--esquema);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body { min-height: 100vh; margin: 0; background: var(--ink); color: var(--paper); font-family: var(--body); }
button, input { font: inherit; }
button { color: inherit; }

.login-grain {
  position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(430px, .92fr); }
.login-story { position: relative; min-height: 100vh; overflow: hidden; padding: clamp(30px, 5vw, 72px); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: radial-gradient(circle at 21% 62%, var(--halo-cian), transparent 31%), var(--ink); }
.login-story::before { content: ""; position: absolute; width: 470px; height: 470px; right: -270px; top: -250px; border: 1px solid var(--halo-fuerte); border-radius: 50%; box-shadow: 0 0 0 64px var(--halo-tenue), 0 0 0 128px var(--halo-tenue); }
.login-brand { position: relative; z-index: 1; width: fit-content; display: flex; align-items: center; gap: 13px; color: var(--paper); text-decoration: none; font-size: 22px; letter-spacing: -.04em; }
.login-brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: var(--signal); color: var(--ink); font: 800 25px/1 var(--display); transform: rotate(-3deg); box-shadow: 7px 7px 0 var(--halo-medio); }
.story-copy { position: relative; z-index: 1; margin: auto 0 25px; animation: reveal .72s cubic-bezier(.2,.75,.25,1) both; }
.login-eyebrow { margin: 0 0 14px; color: var(--signal); font: 10px var(--mono); letter-spacing: .17em; }
.story-copy h1 { max-width: 760px; margin: 0; font: 400 clamp(58px, 7vw, 106px)/.84 var(--display); letter-spacing: -.055em; }
.story-copy h1 em { color: var(--signal); font-weight: 400; }
.story-lead { max-width: 550px; margin: 29px 0 0; color: var(--muted); font-size: clamp(15px, 1.4vw, 19px); line-height: 1.65; }

.agent-map { position: relative; z-index: 1; width: min(100%, 590px); height: 146px; margin-top: 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); animation: reveal .72s .14s cubic-bezier(.2,.75,.25,1) both; }
.agent-core { position: absolute; left: 0; top: 35px; width: 76px; height: 76px; display: grid; place-items: center; border: 1px solid var(--signal); border-radius: 50%; background: var(--ink); box-shadow: 0 0 24px var(--halo-tenue); }
.agent-core span { font: 32px/1 var(--display); }
.agent-core small { position: absolute; top: calc(100% + 8px); color: var(--signal); font: 8px var(--mono); letter-spacing: .12em; }
.agent-node { position: absolute; display: flex; align-items: center; gap: 8px; color: var(--muted); font: 10px var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.agent-node i { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--halo-cian); }
.node-codex { left: 41%; top: 24px; }
.node-claude { left: 66%; top: 68px; }
.node-opencode { left: 34%; top: 111px; }
.agent-line { position: absolute; left: 70px; height: 1px; background: linear-gradient(90deg, var(--signal), var(--line)); transform-origin: left center; }
.line-one { top: 66px; width: 38%; transform: rotate(-9deg); }
.line-two { top: 72px; width: 63%; transform: rotate(0); }
.line-three { top: 78px; width: 34%; transform: rotate(12deg); }
.local-note { position: relative; z-index: 1; margin: 24px 0 0; color: var(--muted); font: 10px var(--mono); letter-spacing: .04em; }
.local-note span { margin-right: 8px; color: var(--signal); }

.login-panel { min-height: 100vh; padding: clamp(26px, 5vw, 76px); display: grid; place-content: center; background: linear-gradient(135deg, var(--velo), transparent 45%), var(--ink-soft); }
.login-card { width: min(100%, 480px); padding: clamp(28px, 4vw, 50px); border: 1px solid var(--line); background: var(--tarjeta-bg); box-shadow: 0 32px 80px rgba(0,0,0,.34); animation: reveal .65s .08s cubic-bezier(.2,.75,.25,1) both; }
.access-state { width: fit-content; margin: 0 0 50px auto; padding: 8px 10px; border: 1px solid var(--line); color: var(--muted); font: 9px var(--mono); letter-spacing: .08em; }
.access-state span { display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 9px var(--halo-medio); }
.login-card h2 { margin: 0; font: 400 clamp(45px, 5vw, 68px)/1 var(--display); letter-spacing: -.045em; }
.login-card header > p:last-child { max-width: 380px; margin: 16px 0 34px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.login-card form > label { display: block; margin: 18px 0 8px; color: var(--muted); font: 9px var(--mono); letter-spacing: .11em; text-transform: uppercase; }
.field-wrap { position: relative; display: grid; grid-template-columns: 48px minmax(0, 1fr); border: 1px solid var(--line); background: var(--campo-bg); transition: border-color .2s, box-shadow .2s, transform .2s; }
.field-wrap:focus-within { border-color: var(--signal); box-shadow: 0 0 0 1px var(--signal), 0 12px 30px rgba(0,0,0,.18); transform: translateY(-1px); }
.field-index { display: grid; place-items: center; border-right: 1px solid var(--line); color: var(--muted); font: 9px var(--mono); }
.field-wrap input { min-width: 0; height: 54px; padding: 0 16px; border: 0; outline: 0; background: transparent; color: var(--paper); font-size: 15px; }
.field-wrap input::placeholder { color: var(--muted); }
.password-wrap { grid-template-columns: 48px minmax(0, 1fr) auto; }
.password-toggle { width: 56px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--signal); cursor: pointer; font: 10px var(--mono); text-transform: uppercase; }
.password-toggle:hover, .password-toggle:focus-visible { background: var(--signal); color: var(--ink); outline: 0; }
.caps-notice { margin: 8px 0 0; color: var(--ember); font: 10px var(--mono); }
.login-message { min-height: 38px; padding-top: 13px; color: var(--danger); font-size: 12px; line-height: 1.45; }
.login-message.success { color: var(--signal); }
.login-submit { width: 100%; min-height: 58px; padding: 0 19px; display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--signal); background: var(--signal); color: var(--ink); cursor: pointer; font: 700 12px var(--mono); letter-spacing: .04em; text-transform: uppercase; transition: background .2s, color .2s, transform .2s; }
.login-submit b { font-size: 22px; }
.login-submit:hover { background: transparent; color: var(--signal); transform: translateY(-2px); }
.login-submit:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.login-submit:disabled { cursor: wait; opacity: .6; transform: none; }
.login-card footer { margin-top: 31px; padding-top: 23px; display: grid; grid-template-columns: 36px 1fr; gap: 12px; border-top: 1px solid var(--line); }
.shield { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); color: var(--cyan); }
.login-card footer p { margin: 0; color: var(--muted); font: 10px/1.55 var(--mono); }
.login-card footer b { color: var(--paper); font-weight: 400; }
.terminal-hint { width: min(100%, 480px); margin: 18px auto 0; color: var(--muted); font: 9px/1.6 var(--mono); text-align: center; }
.terminal-hint code { color: var(--muted); overflow-wrap: anywhere; }

@keyframes reveal { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-story { min-height: auto; padding: 28px 28px 36px; border-right: 0; border-bottom: 1px solid var(--line); }
  .story-copy { margin: 70px 0 16px; }
  .story-copy h1 { font-size: clamp(52px, 12vw, 82px); }
  .story-lead { margin-top: 22px; }
  .agent-map { display: none; }
  .login-panel { min-height: auto; padding: 44px 24px 60px; }
}

@media (max-width: 520px) {
  .login-story { padding: 22px 20px 30px; }
  .login-brand { font-size: 19px; }
  .login-brand-mark { width: 34px; height: 34px; }
  .story-copy { margin-top: 52px; }
  .story-copy h1 { font-size: clamp(46px, 15vw, 65px); }
  .story-lead { font-size: 14px; }
  .login-panel { padding: 26px 14px 42px; place-content: start center; }
  .login-card { padding: 27px 20px; }
  .access-state { margin-bottom: 34px; }
  .login-card h2 { font-size: 47px; }
  .login-card header > p:last-child { margin-bottom: 27px; }
  .field-wrap { grid-template-columns: 40px minmax(0, 1fr); }
  .password-wrap { grid-template-columns: 40px minmax(0, 1fr) 50px; }
  .field-wrap input { padding: 0 12px; }
  .terminal-hint { padding: 0 10px; }
}
