/* KR CONNECT — sign-in: "campus constellation" (builds on app-ui.css tokens; canvas from js/sky.js) */

/* ---------- Animated role / sky tokens ---------- */
@property --a1 { syntax: '<color>'; inherits: true; initial-value: #5b34f2; }
@property --a2 { syntax: '<color>'; inherits: true; initial-value: #8f3fe0; }
@property --ag { syntax: '<color>'; inherits: true; initial-value: #14c8e8; }
@property --ai { syntax: '<color>'; inherits: true; initial-value: #5b34f2; }
@property --neb { syntax: '<color>'; inherits: true; initial-value: rgba(109, 77, 255, .16); }
@property --hz { syntax: '<color>'; inherits: true; initial-value: rgba(90, 70, 255, .2); }
@property --ang { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

body.auth {
    --a1: #5b34f2; --a2: #8f3fe0; --ag: #14c8e8; --ai: #5b34f2;
    --neb: rgba(109, 77, 255, .17); --hz: rgba(80, 190, 255, .2);
    --hero-ink: #0e1330; --hero-mut: #4a5078; --hero-line: rgba(14, 19, 48, .1); --hero-glass: rgba(255, 255, 255, .55);
    --mut: #585e82; --bad-ink: #c92a2a;
    --card-bg: rgba(255, 255, 255, .8); --sheet-bg: #ffffff;
    --f-bg: rgba(243, 244, 251, .92); --f-line: #e1e4f0; --seg-bg: rgba(14, 19, 48, .045);
    --top-h: 60px;
    min-height: 100vh; min-height: 100dvh; overflow-x: hidden; background: #f3f3fb;
    transition: --a1 .7s var(--ease), --a2 .7s var(--ease), --ag .7s var(--ease), --ai .7s var(--ease), --neb 1.2s var(--ease), --hz 1.2s var(--ease);
}
body.auth[data-role="faculty"] { --a1: #c2410c; --a2: #be185d; --ag: #ff9f43; --ai: #b4380a; --neb: rgba(255, 122, 64, .17); }
body.auth[data-daypart="dawn"] { --hz: rgba(255, 150, 120, .26); }
body.auth[data-daypart="dusk"] { --hz: rgba(255, 112, 80, .26); }
body.auth[data-daypart="night"] { --hz: rgba(100, 80, 255, .2); }

[data-theme="dark"] body.auth {
    --ai: #b9adff; --neb: rgba(109, 77, 255, .3);
    --hero-ink: #ffffff; --hero-mut: rgba(232, 234, 255, .74); --hero-line: rgba(255, 255, 255, .13); --hero-glass: rgba(255, 255, 255, .07);
    --mut: #a2a8cf; --bad-ink: #ff8f8f;
    --card-bg: rgba(15, 18, 42, .72); --sheet-bg: #0f1230;
    --f-bg: rgba(6, 8, 28, .5); --f-line: rgba(255, 255, 255, .09); --seg-bg: rgba(255, 255, 255, .05);
    background: #070820;
}
[data-theme="dark"] body.auth[data-role="faculty"] { --ai: #ffb37a; --neb: rgba(240, 96, 60, .26); }
[data-theme="dark"] body.auth[data-daypart="dawn"] { --hz: rgba(255, 130, 110, .3); }
[data-theme="dark"] body.auth[data-daypart="day"] { --hz: rgba(60, 160, 255, .28); }
[data-theme="dark"] body.auth[data-daypart="dusk"] { --hz: rgba(255, 96, 70, .32); }
[data-theme="dark"] body.auth[data-daypart="night"] { --hz: rgba(96, 70, 255, .34); }

/* ---------- Sky ---------- */
.sky {
    position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
    background:
        radial-gradient(55% 60% at 24% 42%, var(--neb), transparent 70%),
        radial-gradient(70% 55% at 75% 112%, var(--hz), transparent 70%),
        linear-gradient(180deg, #faf9ff 0%, #eef0fb 100%);
}
[data-theme="dark"] .sky {
    background:
        radial-gradient(55% 60% at 24% 42%, var(--neb), transparent 70%),
        radial-gradient(70% 55% at 75% 112%, var(--hz), transparent 70%),
        linear-gradient(180deg, #03041a 0%, #080a26 55%, #100b30 100%);
}
.sky canvas { display: block; width: 100%; height: 100%; animation: skyIn 1.2s var(--ease) both; }
@keyframes skyIn { from { opacity: 0; } }

/* ---------- Layout (desktop first) ---------- */
.auth-wrap {
    position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh;
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(400px, 460px); grid-template-rows: auto 1fr;
    column-gap: clamp(28px, 5vw, 96px);
    padding: clamp(16px, 2.2vw, 28px) clamp(20px, 4vw, 64px) clamp(18px, 3vw, 40px);
}
.topbar { position: relative; z-index: 3; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: var(--top-h); }
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand-tile { flex: none; display: grid; place-items: center; height: 54px; padding: 0 12px; border-radius: 13px; background: #fff; box-shadow: 0 8px 22px -10px rgba(14, 19, 48, .35), 0 0 0 1px rgba(14, 19, 48, .06); }
.brand-tile img { height: 38px; width: auto; display: block; }
.brand-tx { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-tx b { font-size: 16px; font-weight: 800; letter-spacing: .16em; color: var(--hero-ink); }
.brand-tx small { font-size: 11.5px; font-weight: 600; color: var(--hero-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: inline-flex; align-items: center; gap: 8px; }
.clock {
    display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px;
    background: var(--hero-glass); border: 1px solid var(--hero-line); color: var(--hero-ink);
    font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.clock i { width: 7px; height: 7px; border-radius: 50%; background: var(--ag); box-shadow: 0 0 0 0 var(--ag); animation: beat 2s ease-out infinite; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ag) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 8px transparent; } }

.auth-hero { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; min-width: 0; padding: 4px 0 8px; }
.sky-mark { flex: 1 1 auto; width: min(100%, 700px); min-height: 220px; max-height: 50vh; margin: 2vh 0 1vh; }
.hero-copy { max-width: 640px; animation: rise .9s var(--ease) .15s both; }
.eyebrow { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--hero-mut); }
.eyebrow::before { content: ''; width: 28px; height: 2px; border-radius: 2px; background: linear-gradient(90deg, var(--a1), var(--ag)); }
.auth-hero h1 { margin: 0; font-size: clamp(44px, 5.4vw, 84px); line-height: .98; font-weight: 800; letter-spacing: -.05em; color: var(--hero-ink); }
.auth-hero h1 .dot { color: var(--ai); }
[data-theme="dark"] .auth-hero h1 .dot { color: var(--ag); }
.lede { margin: 18px 0 0; max-width: 32em; font-size: 16.5px; line-height: 1.6; color: var(--hero-mut); }
.nowrap { white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; }
.meta li { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 13px; border-radius: 999px; font-size: 12.5px; font-weight: 650; color: var(--hero-ink); background: var(--hero-glass); border: 1px solid var(--hero-line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.meta i { color: var(--ai); font-size: 12px; }
[data-theme="dark"] .meta i { color: var(--ag); }

.panel { grid-column: 2; grid-row: 2; display: flex; align-items: center; justify-content: center; min-width: 0; padding: 10px 0; }

/* ---------- The card: glass, depth, a slowly orbiting light on its rim ---------- */
.auth-card {
    position: relative; isolation: isolate; width: 100%; max-width: 460px;
    padding: 32px 34px 24px; border-radius: 30px;
    background: var(--card-bg);
    backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 50px 90px -40px rgba(14, 19, 48, .45);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 50px 90px -40px color-mix(in srgb, var(--a1) 55%, rgba(14, 19, 48, .5));
    animation: cardIn .9s var(--ease) both;
}
[data-theme="dark"] .auth-card { box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 50px 100px -40px rgba(0, 0, 0, .8); }
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.auth-card::before, .auth-card::after, .dlg-card::before, .dlg-card::after {
    content: ''; position: absolute; inset: 0; z-index: -1; border-radius: inherit; padding: 1.5px; pointer-events: none;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
}
.auth-card::before, .dlg-card::before { background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, .35)); }
[data-theme="dark"] .auth-card::before, [data-theme="dark"] .dlg-card::before { background: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, .04)); }
.auth-card::after, .dlg-card::after {
    z-index: 0;
    background: conic-gradient(from var(--ang), transparent 0deg 230deg, var(--ag) 290deg, var(--a1) 325deg, transparent 360deg);
    animation: orbit 9s linear infinite;
}
@keyframes orbit { to { --ang: 360deg; } }

.grip { display: none; }
.card-logo { display: flex; align-items: center; justify-content: center; }
.card-logo img { height: 96px; width: auto; max-width: 100%; }
[data-theme="dark"] .card-logo img { filter: brightness(0) invert(1); opacity: .92; }

.view { animation: viewIn .4s var(--ease) both; }
.view[hidden], .pane[hidden] { display: none; }
@keyframes viewIn { from { opacity: 0; transform: translateX(10px); } }

.hello { display: flex; align-items: center; gap: 14px; margin: 22px 0 20px; }
.hello-tx { min-width: 0; }
.hello h2 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 800; letter-spacing: -.03em; color: var(--ink); }
.hello p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; color: var(--mut); }
.hello.swap .hello-tx { animation: swapIn .5s var(--ease) both; }
@keyframes swapIn { from { opacity: 0; transform: translateY(8px); filter: blur(4px); } }

.role-badge {
    position: relative; flex: 0 0 50px; width: 50px; height: 50px; border-radius: 16px; color: #fff; font-size: 19px;
    background: linear-gradient(135deg, var(--a1), var(--a2));
    box-shadow: 0 14px 28px -14px var(--a1), inset 0 1px 0 rgba(255, 255, 255, .3);
    transform-style: preserve-3d; transition: transform .8s var(--spring);
}
.role-badge .face { position: absolute; inset: 0; display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.role-badge .f-faculty { transform: rotateY(180deg); }
body[data-role="faculty"] .role-badge:not(.solo) { transform: rotateY(180deg); }
.role-badge.warm { background: var(--grad-warm); box-shadow: 0 14px 28px -14px #f0509b; }

/* ---------- Role switch: an elastic pill that stretches across, then settles ---------- */
.auth .role-switch {
    display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: row; gap: 0; padding: 5px; margin-bottom: 18px;
    border-radius: 19px; background: var(--seg-bg); border: 1px solid var(--f-line);
}
.auth .role-switch button {
    height: 56px; min-width: 0; justify-content: flex-start; gap: 10px; padding: 0 14px; border-radius: 14px;
    color: var(--ink-2); text-align: left; transition: color .35s var(--ease);
}
.auth .role-switch button > i { flex: none; font-size: 17px; color: var(--ai); transition: transform .5s var(--spring), color .35s; }
.r-tx { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.r-tx b { font-size: 13.5px; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-tx small { font-size: 11.5px; font-weight: 600; color: var(--mut); transition: color .35s; }
.auth .role-switch button[aria-selected="true"] { color: #fff; }
.auth .role-switch button[aria-selected="true"] > i { color: #fff; transform: scale(1.12) rotate(-6deg); }
.auth .role-switch button[aria-selected="true"] small { color: rgba(255, 255, 255, .95); }
.auth .role-switch button:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
.auth .role-switch .thumb {
    top: 5px; bottom: 5px; left: 5px; right: 50%; width: auto; transform: none; border-radius: 14px;
    background: linear-gradient(135deg, var(--a1), var(--a2));
    box-shadow: 0 12px 26px -12px var(--a1), inset 0 1px 0 rgba(255, 255, 255, .28);
    transition: left .42s var(--spring), right .42s var(--spring);
}
.auth .role-switch.to-right .thumb { transition: right .36s var(--spring), left .42s var(--spring) .1s; }
.auth .role-switch.to-left .thumb { transition: left .36s var(--spring), right .42s var(--spring) .1s; }
.auth .role-switch.no-anim .thumb { transition: none; }

/* ---------- Fields: soft wells with a glowing underline ---------- */
.pane, #recoverForm, #changePasswordForm { display: flex; flex-direction: column; gap: 12px; }
.pane { animation: viewIn .35s var(--ease) both; }
.auth .ffield .input {
    height: 60px; padding: 22px 50px 6px 50px; border-radius: 16px; font-size: 15.5px; font-weight: 600; color: var(--ink);
    background-color: var(--f-bg); border: 1.5px solid var(--f-line);
    transition: border-color .25s, box-shadow .3s, background-color .25s;
}
.auth .ffield .input:hover { border-color: color-mix(in srgb, var(--ai) 35%, var(--f-line)); }
.auth .ffield .input:focus {
    border-color: var(--ai); background-color: var(--surface);
    box-shadow: var(--ring);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ai) 16%, transparent), 0 14px 30px -20px var(--a1);
}
.auth .ffield label { left: 50px; color: var(--mut); }
.auth .ffield .input:focus + label, .auth .ffield .input:not(:placeholder-shown) + label { color: var(--ai); }
.auth .ffield .lead { left: 19px; color: var(--mut); transition: color .25s, transform .35s var(--spring); }
.auth .ffield .input:focus ~ .lead { color: var(--ai); transform: translateY(-50%) scale(1.12); }
.ffield .line {
    position: absolute; left: 16px; right: 16px; bottom: 0; height: 2px; border-radius: 2px; pointer-events: none;
    background: linear-gradient(90deg, var(--a1), var(--ag)); transform: scaleX(0); transition: transform .5s var(--ease);
}
.ffield .input:focus ~ .line { transform: scaleX(1); }
.auth .ffield .trail { right: 9px; color: var(--mut); }
.auth .ffield .trail:hover { background: color-mix(in srgb, var(--ai) 10%, transparent); color: var(--ai); }
.auth .ffield .trail:focus-visible { outline: 2px solid var(--ai); outline-offset: 1px; }
.auth .ffield .trail i { transition: transform .3s var(--spring); }
.auth .ffield .trail:active i { transform: scale(.8); }
.auth .ffield select.input { padding-top: 6px; padding-bottom: 6px; padding-right: 40px; }
#deptGroup:not([hidden]) { animation: drop .45s var(--spring) both; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px) scaleY(.9); } }

.ffield.is-bad .input { border-color: var(--bad); background-color: color-mix(in srgb, var(--bad) 5%, var(--f-bg)); }
.ffield.is-bad .input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 16%, transparent); }
.ffield.is-bad .lead, .ffield.is-bad label { color: var(--bad-ink) !important; }
.ffield.is-bad .line { background: var(--bad); transform: scaleX(1); }
.fmsg { display: flex; align-items: center; gap: 7px; margin: -5px 6px 0; font-size: 12.5px; font-weight: 650; color: var(--bad-ink); animation: msgIn .3s var(--ease) both; }
.fmsg::before { content: '\f06a'; font: 900 12px 'Font Awesome 6 Free'; }
.fmsg:empty { display: none; }
@keyframes msgIn { from { opacity: 0; transform: translateY(-4px); } }

.caps {
    align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; margin: -2px 0 0; padding: 6px 12px; border-radius: 999px;
    background: var(--warn-soft); color: #8a4b00; font-size: 12.5px; font-weight: 700; animation: msgIn .3s var(--spring) both;
}
[data-theme="dark"] .caps { color: #ffc078; }
.caps[hidden] { display: none; }

/* "Keep me signed in" (unticked: signed out when the browser closes) */
.remember { align-self: flex-start; display: inline-flex; align-items: flex-start; gap: 10px; margin: 2px 0 0; cursor: pointer; user-select: none; }
.remember input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.remember-box { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin-top: 1px; border-radius: 7px;
    border: 1.5px solid color-mix(in srgb, var(--ink-2) 35%, transparent); background: transparent; color: #fff; font-size: 11px;
    transition: background .2s, border-color .2s, transform .25s var(--spring); }
.remember-box i { opacity: 0; transform: scale(.4); transition: opacity .2s, transform .25s var(--spring); }
.remember input:checked + .remember-box { background: var(--ai); border-color: var(--ai); }
.remember input:checked + .remember-box i { opacity: 1; transform: none; }
.remember input:focus-visible + .remember-box { outline: 2px solid var(--ai); outline-offset: 2px; }
.remember:active .remember-box { transform: scale(.92); }
.remember-text { display: flex; flex-direction: column; gap: 1px; font-size: 13px; font-weight: 650; color: var(--ink-2); line-height: 1.35; }
.remember-text small { font-size: 11.5px; font-weight: 500; color: var(--mut); }

.form-alert { display: none; margin: 0; }
.form-alert.is-on {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px;
    background: var(--bad-soft); color: var(--bad-ink); font-size: 13px; font-weight: 650; line-height: 1.45;
    border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent); animation: msgIn .35s var(--ease) both;
}
.form-alert.is-on::before { content: '\f071'; font: 900 13px/1.45 'Font Awesome 6 Free'; }

/* ---------- Submit: label -> progress ring -> check ---------- */
.go {
    position: relative; isolation: isolate; overflow: hidden; align-self: center; width: 100%; height: 58px; margin-top: 4px;
    display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 22px;
    border: 0; border-radius: 18px; cursor: pointer; white-space: nowrap;
    color: #fff; font: 750 15.5px var(--font); letter-spacing: .005em;
    background: linear-gradient(135deg, var(--a1), var(--a2));
    box-shadow: 0 18px 36px -18px var(--a1), inset 0 1px 0 rgba(255, 255, 255, .28);
    transition: width .5s var(--ease), border-radius .5s var(--ease), transform .15s var(--ease), box-shadow .3s, translate .3s var(--ease);
}
.go::before {
    content: ''; position: absolute; inset: 0; z-index: -1;
    background: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, .32) 50%, transparent 65%);
    transform: translateX(-110%); transition: transform .9s var(--ease);
}
.go:hover::before { transform: translateX(110%); }
.go:hover { box-shadow: 0 22px 40px -18px var(--a1), inset 0 1px 0 rgba(255, 255, 255, .28); }
.go:active { transform: scale(.98); }
.go:focus-visible { outline: 3px solid var(--ag); outline-offset: 3px; }
.go-label, .go-arrow { transition: opacity .2s, transform .35s var(--spring); }
.go:hover .go-arrow { transform: translateX(5px); }
.go-ring, .go-check { position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; opacity: 0; transition: opacity .2s; }
.go-ring circle { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-dasharray: 38 100; }
.go-check path { fill: none; stroke: #fff; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 24; stroke-dashoffset: 24; }
.go.is-loading, .go.is-done { width: 58px; padding: 0; border-radius: 29px; cursor: default; }
.go.is-loading .go-label, .go.is-loading .go-arrow, .go.is-done .go-label, .go.is-done .go-arrow { opacity: 0; }
.go.is-loading .go-ring { opacity: 1; transition-delay: .18s; animation: ringSpin .8s linear infinite; }
@keyframes ringSpin { to { rotate: 360deg; } }
.go.is-done { background: linear-gradient(135deg, #0ca678, #20c997); box-shadow: 0 18px 36px -16px #12b886; }
.go.is-done .go-check { opacity: 1; }
.go.is-done .go-check path { stroke-dashoffset: 0; transition: stroke-dashoffset .3s var(--ease) .05s; }

.help { display: flex; align-items: flex-start; justify-content: center; gap: 8px; margin: 2px 0 0; text-align: center; font-size: 12.5px; line-height: 1.5; color: var(--mut); }
.help i { margin-top: 3px; color: var(--ai); }
.link-btn { align-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; border-radius: 12px; background: none; color: var(--ai); font: 700 13px var(--font); cursor: pointer; transition: background .2s; }
.link-btn:hover { background: color-mix(in srgb, var(--ai) 10%, transparent); }
.back { display: inline-flex; align-items: center; gap: 8px; margin: 18px 0 0; padding: 8px 12px 8px 8px; border: 0; border-radius: 12px; background: none; color: var(--ink-2); font: 700 13px var(--font); cursor: pointer; }
.back:hover { background: color-mix(in srgb, var(--ai) 9%, transparent); }
.back i { transition: transform .3s var(--spring); }
.back:hover i { transform: translateX(-3px); }
#recoverView .hello { margin-top: 12px; }
.link-btn:focus-visible, .back:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }

.auth .btn-x.primary {
    --bh: 58px; border-radius: 18px; background: linear-gradient(135deg, var(--a1), var(--a2));
    box-shadow: 0 18px 36px -18px var(--a1), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.auth .btn-x.primary:hover { box-shadow: 0 22px 40px -18px var(--a1); }
.auth .btn-x.primary:focus-visible { outline: 3px solid var(--ag); outline-offset: 3px; }

.card-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--f-line); font-size: 11.5px; font-weight: 600; color: var(--mut); }
.card-foot i { margin-right: 6px; color: var(--ok); }

.shake { animation: shake .5s var(--ease); }
@keyframes shake { 15%, 55% { transform: translateX(-8px); } 35%, 75% { transform: translateX(7px); } 90% { transform: translateX(-2px); } }

/* ---------- Success portal: the card's accent opens into the dashboard ---------- */
.portal {
    position: fixed; inset: 0; z-index: 5000; pointer-events: none;
    background: radial-gradient(circle at var(--px) var(--py), color-mix(in srgb, var(--a1) 22%, var(--bg)) 0, var(--bg) 70vmax);
    clip-path: circle(0 at var(--px) var(--py)); transition: clip-path .32s cubic-bezier(.7, 0, .3, 1);
}
.portal.is-on { clip-path: circle(150vmax at var(--px) var(--py)); }

/* ---------- Toasts stay clear of the form ---------- */
.auth .toasts { top: calc(14px + var(--safe-t)); bottom: auto; }

/* ---------- Forced password change ---------- */
.dlg {
    position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 20px;
    background: rgba(5, 6, 26, .5); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); animation: fade .25s both;
}
@keyframes fade { from { opacity: 0; } }
.dlg[hidden] { display: none; }
.dlg-card {
    position: relative; isolation: isolate; width: 100%; max-width: 470px; max-height: calc(100dvh - 40px); overflow-y: auto;
    padding: 28px; border-radius: 28px; background: var(--card-bg);
    backdrop-filter: blur(26px) saturate(160%); -webkit-backdrop-filter: blur(26px) saturate(160%);
    box-shadow: 0 50px 100px -40px rgba(0, 0, 0, .6); animation: cardIn .5s var(--spring) both;
}
[data-theme="dark"] .dlg-card { background: rgba(15, 18, 42, .9); }
.dlg-head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.dlg-head h3 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.dlg-head p { margin: 4px 0 0; color: var(--mut); font-size: 13.5px; line-height: 1.45; }
.strength { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: -2px 4px 2px; }
.strength i { height: 5px; border-radius: 5px; background: var(--f-line); transition: background .35s, transform .35s var(--spring); }
.strength[data-level="1"] i:nth-child(-n+1) { background: var(--bad); }
.strength[data-level="2"] i:nth-child(-n+2) { background: var(--warn); }
.strength[data-level="3"] i:nth-child(-n+3) { background: #74b816; }
.strength[data-level="4"] i { background: var(--ok); }
.rules { margin: 4px 0 6px; padding: 14px 16px; list-style: none; border-radius: 16px; background: var(--f-bg); border: 1px solid var(--f-line); display: grid; gap: 8px; }
.rules li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 650; color: var(--mut); transition: color .25s; }
.rules li i { font-size: 7px; width: 14px; text-align: center; }
.rules li.ok { color: #0b8a63; } .rules li.ok i { font-size: 13px; animation: tick .4s var(--spring); }
.rules li.bad { color: var(--bad-ink); } .rules li.bad i { font-size: 13px; }
[data-theme="dark"] .rules li.ok { color: #63e6be; }
@keyframes tick { from { transform: scale(.3); } }

/* ======================================================================
   Add-ons (all lg-*; app-ui.css owns the plain component names)
   ====================================================================== */

/* ---------- System status pill (top bar) ---------- */
.lg-status-wrap { --lg-c: #3ddc97; --lg-ink: #c8f7e1; position: relative; display: inline-flex; min-width: 0; }
.lg-status-wrap[data-status-mode="info"] { --lg-c: #4dabf7; --lg-ink: #d4ecff; }
.lg-status-wrap[data-status-mode="maintenance"] { --lg-c: #ffb444; --lg-ink: #ffe9c7; }
.lg-status-wrap[data-status-mode="down"] { --lg-c: #ff6b6b; --lg-ink: #ffd9d9; }
.lg-status {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 440px; height: 38px; padding: 0 14px 0 12px; border-radius: 999px;
    background: color-mix(in srgb, var(--lg-c) 11%, rgba(255, 255, 255, .04)); border: 1px solid color-mix(in srgb, var(--lg-c) 32%, transparent);
    color: var(--lg-ink); font: 700 12.5px var(--font); white-space: nowrap; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
button.lg-status { cursor: pointer; transition: background .25s, border-color .25s; }
button.lg-status:hover, button.lg-status[aria-expanded="true"] { background: color-mix(in srgb, var(--lg-c) 18%, rgba(255, 255, 255, .05)); border-color: color-mix(in srgb, var(--lg-c) 55%, transparent); }
button.lg-status:focus-visible { outline: 2px solid var(--lg-c); outline-offset: 2px; }
.lg-status-dot { position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--lg-c); box-shadow: 0 0 10px var(--lg-c); }
.lg-status-dot::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--lg-c); animation: lgPulse 2.4s ease-out infinite; }
.lg-status-wrap[data-status-mode="down"] .lg-status-dot::after { animation-duration: 1.3s; }
@keyframes lgPulse { from { transform: scale(1); opacity: .7; } to { transform: scale(3); opacity: 0; } }
.lg-status-tx { flex: none; font-weight: 750; }
.lg-status-short { display: none; font-weight: 750; }
.lg-status-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: color-mix(in srgb, var(--lg-ink) 88%, #fff); }
.lg-status-msg::before { content: '·'; margin: 0 7px 0 1px; opacity: .7; }
.lg-status-chev { flex: none; font-size: 10px; opacity: .8; transition: transform .3s var(--spring); }
button.lg-status[aria-expanded="true"] .lg-status-chev { transform: rotate(180deg); }
.lg-status-pop {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: max-content; max-width: min(340px, calc(100vw - 32px));
    padding: 12px 14px; border-radius: 16px; background: rgba(13, 16, 40, .96); border: 1px solid color-mix(in srgb, var(--lg-c) 40%, transparent);
    color: #eceeff; font-size: 13px; font-weight: 600; line-height: 1.5; white-space: normal; overflow-wrap: anywhere;
    box-shadow: 0 24px 44px -20px rgba(0, 0, 0, .85); animation: msgIn .25s var(--ease) both;
}
.lg-status-pop[hidden] { display: none; }
.lg-status-pop b { display: block; margin-bottom: 2px; color: var(--lg-ink); font-weight: 800; }
.lg-status-pop small { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--mut); font-size: 12px; font-weight: 650; }

/* ---------- Aurora: a soft ribbon along the horizon, breathing in the role colours ---------- */
.lg-aurora {
    position: absolute; left: -12%; right: -12%; bottom: -4%; height: 48%; pointer-events: none;
    -webkit-mask: linear-gradient(to top, transparent 0, #000 28%, #000 62%, transparent 100%);
    mask: linear-gradient(to top, transparent 0, #000 28%, #000 62%, transparent 100%);
}
.lg-aurora i { position: absolute; inset: 0; will-change: transform, opacity; }
.lg-aurora i:nth-child(1) { background: radial-gradient(48% 26% at 32% 64%, color-mix(in srgb, var(--a1) 46%, transparent), transparent 72%); animation: lgAur1 13s ease-in-out infinite alternate; }
.lg-aurora i:nth-child(2) { background: radial-gradient(40% 20% at 62% 56%, color-mix(in srgb, var(--ag) 30%, transparent), transparent 72%); animation: lgAur2 17s ease-in-out infinite alternate; }
.lg-aurora i:nth-child(3) { background: radial-gradient(36% 22% at 48% 76%, color-mix(in srgb, var(--a2) 38%, transparent), transparent 72%); animation: lgAur3 21s ease-in-out infinite alternate; }
@keyframes lgAur1 { from { transform: translate3d(-5%, 2%, 0) scale(1, .9); opacity: .55; } to { transform: translate3d(6%, -3%, 0) scale(1.18, 1.05); opacity: .95; } }
@keyframes lgAur2 { from { transform: translate3d(7%, 0, 0) scale(1.1, 1); opacity: .9; } to { transform: translate3d(-6%, -4%, 0) scale(.92, 1.15); opacity: .45; } }
@keyframes lgAur3 { from { transform: translate3d(0, 3%, 0) scale(.95, 1); opacity: .5; } to { transform: translate3d(4%, -2%, 0) scale(1.12, .9); opacity: .9; } }
body.lg-hidden .lg-aurora i, body.lg-hidden .lg-status-dot::after { animation-play-state: paused; }

/* ---------- Rotating tagline under the greeting ---------- */
.lg-tag { display: grid; margin: 14px 0 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; line-height: 1.4; }
.lg-tag span {
    grid-area: 1 / 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: #eef0ff; background: linear-gradient(90deg, #ffffff 30%, color-mix(in srgb, var(--ag) 55%, #ffffff)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    opacity: 0; transform: translateY(9px); transition: opacity .55s var(--ease), transform .55s var(--ease);
}
.lg-tag span.is-on { opacity: 1; transform: none; transition-delay: .18s; }
.lg-tag + .lede { margin-top: 10px; }

/* ---------- Card spotlight (desktop, follows the cursor) ---------- */
.lg-spot { position: absolute; inset: 0; z-index: -1; border-radius: inherit; overflow: hidden; pointer-events: none; opacity: 0; transition: opacity .45s var(--ease); }
.lg-spot i {
    position: absolute; left: 0; top: 0; width: 560px; height: 560px; margin: -280px 0 0 -280px; border-radius: 50%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--ag) 15%, transparent), color-mix(in srgb, var(--a1) 6%, transparent) 55%, transparent);
    will-change: transform;
}
.auth-card.lg-lit .lg-spot { opacity: 1; }
@media (min-width: 992px) { .panel { perspective: 1400px; } }

/* ---------- Ripple on the sign-in button ---------- */
.lg-ripple {
    position: absolute; z-index: -1; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; pointer-events: none;
    background: rgba(255, 255, 255, .42); animation: lgRipple .65s var(--ease) forwards;
}
@keyframes lgRipple { to { transform: scale(var(--lg-r, 30)); opacity: 0; } }

/* ---------- Intro (first visit per session; html.lg-intro, ended by login.js) ---------- */
.lg-intro .auth-card { animation-delay: .75s; animation-duration: .8s; }
.lg-intro .topbar { animation: lgFade .7s var(--ease) .1s both; }
.lg-intro #krGreet .lg-w, .lg-intro .auth-hero h1 .dot { display: inline-block; animation: lgWord .6s var(--ease) calc(.3s + var(--i, 0) * .14s) both; }
.lg-intro .auth-hero h1 .dot { --i: 2.4; }
.lg-intro .lg-tag { animation: lgFade .6s var(--ease) .85s both; }
@keyframes lgWord { from { opacity: 0; transform: translateY(.32em); } }
@keyframes lgFade { from { opacity: 0; } }

/* ---------- Large desktop ---------- */
@media (min-width: 1440px) {
    .auth-wrap { grid-template-columns: minmax(0, 1fr) 480px; }
    .auth-card { max-width: 480px; padding: 38px 40px 28px; }
}
/* ---------- Short desktop screens ---------- */
@media (min-width: 992px) and (max-height: 780px) {
    .auth-card { padding: 24px 30px 18px; }
    .card-logo img { height: 80px; }
    .hello { margin: 16px 0 14px; }
    .auth .ffield .input { height: 56px; }
    .card-foot { margin-top: 16px; padding-top: 12px; }
    .sky-mark { min-height: 160px; }
    .auth-hero h1 { font-size: clamp(40px, 4.6vw, 66px); }
    .lede { margin-top: 12px; }
    .meta { margin-top: 14px; }
    .lg-tag { margin-top: 10px; font-size: 15px; }
}

/* ---------- Tablet & phone: animated header band + bottom sheet ---------- */
@media (max-width: 991.98px) {
    body.auth { --band-h: clamp(210px, 30svh, 290px); --pb: var(--sheet-bg); background: var(--sheet-bg); }
    .sky::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 35%; background: linear-gradient(transparent, var(--pb)); }
    .sky { position: absolute; bottom: auto; height: calc(var(--band-h) + var(--safe-t)); }
    .auth-wrap { display: flex; flex-direction: column; padding: 0; }
    .topbar { flex: none; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
    .brand-tile { height: 46px; padding: 0 10px; border-radius: 13px; }
    .brand-tile img { height: 32px; }
    .brand-tx b { font-size: 14px; }
    .brand-tx small { font-size: 10.5px; }
    .clock { height: 36px; padding: 0 12px; font-size: 12px; }
    .lg-status { height: 36px; max-width: 300px; font-size: 12px; }
    .lg-aurora { bottom: 10%; height: 55%; }
    .lg-spot { display: none; }

    .auth-hero { position: relative; flex: none; height: calc(var(--band-h) - var(--top-h)); padding: 0 20px 42px; justify-content: flex-end; }
    .sky-mark { position: absolute; top: 2px; right: 10px; bottom: 40px; width: 46%; min-height: 0; max-height: none; margin: 0; }
    .hero-copy { position: relative; max-width: 58%; }
    .eyebrow { margin-bottom: 8px; font-size: 10.5px; letter-spacing: .12em; gap: 8px; }
    .eyebrow::before { width: 18px; }
    .auth-hero h1 { font-size: clamp(28px, 8.4vw, 44px); line-height: 1.02; }
    .lede, .meta, .lg-tag { display: none; }

    .panel { flex: 1 0 auto; display: flex; align-items: stretch; margin-top: -26px; padding: 0; z-index: 2; }
    .auth-card {
        max-width: none; border-radius: 28px 28px 0 0;
        padding: 10px max(20px, env(safe-area-inset-right)) calc(18px + var(--safe-b)) max(20px, env(safe-area-inset-left));
        background: var(--sheet-bg); backdrop-filter: none; -webkit-backdrop-filter: none;
        box-shadow: 0 -24px 50px -24px rgba(14, 19, 48, .35); animation: sheetUp .7s var(--ease) both;
    }
    [data-theme="dark"] .auth-card { box-shadow: 0 -24px 50px -20px rgba(0, 0, 0, .7); }
    .auth-card::after { animation-duration: 14s; }
    @keyframes sheetUp { from { transform: translateY(48px); opacity: 0; } }
    .grip { display: block; width: 42px; height: 5px; margin: 0 auto 14px; border-radius: 5px; background: var(--line-strong); }
    .card-logo img { height: 74px; }
    .hello { margin: 14px 0 16px; gap: 12px; }
    .role-badge { flex-basis: 44px; width: 44px; height: 44px; border-radius: 14px; font-size: 17px; }
    .hello h2 { font-size: 21px; }
    .hello p { font-size: 13.5px; }
    .auth .ffield .input { font-size: 16px; } /* no iOS zoom on focus */
    .card-foot { margin-top: 18px; padding-top: 14px; }

    .dlg { align-items: end; padding: 0; }
    .dlg-card {
        max-width: none; max-height: 94dvh; border-radius: 28px 28px 0 0;
        padding: 10px 20px calc(20px + var(--safe-b)); background: var(--sheet-bg); backdrop-filter: none; -webkit-backdrop-filter: none;
        animation: sheetUp .45s var(--ease) both;
    }
    .dlg-card .grip { display: block; }
}
/* Tablet: floating sheet, roomier band */
@media (min-width: 600px) and (max-width: 991.98px) {
    body.auth { --band-h: clamp(290px, 40svh, 400px); --pb: #f1f1fa; background: var(--pb); }
    [data-theme="dark"] body.auth { --pb: #090a24; }
    .auth-hero { padding: 0 36px 64px; }
    .sky-mark { right: 24px; bottom: 60px; width: 44%; }
    .auth-hero h1 { font-size: clamp(38px, 6.4vw, 56px); }
    .lede { display: block; font-size: 15px; margin-top: 10px; }
    .lg-tag { display: grid; font-size: 14.5px; margin-top: 10px; }
    .panel { justify-content: center; padding: 0 24px 32px; margin-top: -44px; }
    .auth-card { max-width: 540px; border-radius: 30px; padding: 28px 34px 22px; box-shadow: 0 30px 70px -30px rgba(14, 19, 48, .45); }
    .grip { display: none; }
}
/* Phones: the pill keeps a short label (full message one tap away); a non-live status takes the clock's place */
@media (max-width: 599.98px) {
    .lg-status { padding: 0 11px 0 10px; gap: 7px; }
    .lg-status-tx, .lg-status-msg { display: none; }
    .lg-status-short { display: inline; }
    .tools:has(button.lg-status) .clock { display: none; }
}
/* Small phones */
@media (max-width: 400px) {
    .brand-tx small { display: none; }
    .auth .role-switch button { padding: 0 9px; gap: 8px; }
    .r-tx b { font-size: 13px; }
    .auth-hero { padding: 0 16px 40px; }
}
@media (max-width: 991.98px) and (max-height: 600px) {
    body.auth { --band-h: 190px; }
    .auth-hero h1 { font-size: 26px; }
}

/* ---------- Reduced motion: still beautiful, just still ---------- */
@media (prefers-reduced-motion: reduce) {
    .auth-card::after, .dlg-card::after { animation: none; --ang: 300deg; }
    .portal { transition: none; clip-path: none; opacity: 0; }
    .portal.is-on { opacity: 1; }
    .clock i { animation: none; }
    .lg-aurora i, .lg-status-dot::after { animation: none; }
    .lg-tag span { transition: none; }
    .lg-spot, .lg-ripple { display: none; }
}

/* ---------- KR CONNECT v2.0: welcome lockup + version ---------- */
.brand-ver { font-style: normal; font-size: .62em; font-weight: 800; letter-spacing: .04em; margin-left: 6px; padding: 2px 7px; border-radius: 999px; vertical-align: 2px;
    color: #fff; background: linear-gradient(135deg, var(--a1), var(--ag)); }
.lg-welcome { display: flex; align-items: center; gap: 16px; margin: 0 0 18px; }
.lg-welcome-logo { flex: none; display: grid; place-items: center; height: 84px; padding: 0 16px; border-radius: 22px; background: #fff;
    box-shadow: 0 18px 40px -18px rgba(14, 19, 48, .45), 0 0 0 1px rgba(14, 19, 48, .06); }
.lg-welcome-logo img { height: 62px; width: auto; display: block; }
.lg-welcome-tx { font-size: clamp(20px, 2vw, 30px); font-weight: 700; color: var(--hero-mut); line-height: 1.15; }
.lg-welcome-tx b { display: block; font-size: 1.35em; font-weight: 900; letter-spacing: .06em; color: var(--hero-ink); }
.card-welcome { margin: 10px 0 0; text-align: center; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); }
.card-welcome b { color: var(--a1); letter-spacing: .12em; }
[data-theme="dark"] .card-welcome b { color: var(--ag); }
.card-foot b { font-weight: 800; color: var(--ink, inherit); }
@media (min-width: 992px) {
    .card-welcome { display: none; }                                  /* the hero shows it on big screens */
    .brand-tile { display: none; }                                    /* one KR CONNECT logo: the big one beside "Welcome to" */
}
@media (max-width: 991.98px) {
    .lg-welcome { display: none; }                                    /* the sheet shows it on tablets / phones */
    .card-logo { margin-top: 2px; }
}
.brand-tx b { white-space: nowrap; }
.clock time { white-space: nowrap; }
@media (max-width: 599.98px) {
    .brand-tile { height: 42px; padding: 0 8px; }
    .brand-tile img { height: 28px; }
    .brand-tx b { font-size: 13px; letter-spacing: .1em; }
    .brand-ver { display: none; }                                     /* the card footer shows the version on phones */
}
@media (max-width: 400px) { .card-logo img { height: 66px; } .brand-tx b { font-size: 12px; } }

/* ---------- Analog clock (top bar) ---------- */
.aclock { gap: 12px; padding: 0 18px 0 6px; height: 66px; font-size: 15px; }
.aclock .ac { width: 56px; height: 56px; flex: none; filter: drop-shadow(0 6px 12px rgba(124, 77, 255, .45)); }
.ac-t { stroke: #b7b0dc; stroke-width: 1.1; stroke-linecap: round; }
.ac-t.b { stroke: #5b34f2; stroke-width: 2.6; }
.ac-hand { transform-origin: 50px 50px; transform-box: view-box; transition: transform .35s cubic-bezier(.4, 2.2, .5, 1); }
.ac-hand.jump { transition: none; }
.ac-hand line { stroke-linecap: round; }
.ac-h line { stroke: #1b1446; stroke-width: 5.5; }
.ac-m line { stroke: #5b34f2; stroke-width: 3.8; }
.ac-s line { stroke: #e64980; stroke-width: 1.6; }
.ac-s circle { fill: #e64980; }
.ac-pin { fill: #e64980; }
[data-theme="dark"] .ac-face { fill: #17163a; }
[data-theme="dark"] .ac-t { stroke: #5f5a8f; }
[data-theme="dark"] .ac-t.b { stroke: #14c8e8; }
[data-theme="dark"] .ac-h line { stroke: #ffffff; }
[data-theme="dark"] .ac-m line { stroke: #9b7bff; }
@media (max-width: 991.98px) {
    .aclock { height: 50px; padding: 0 14px 0 4px; font-size: 13px; }
    .aclock .ac { width: 42px; height: 42px; }
}
@media (max-width: 599.98px) {
    .aclock { padding: 0 3px; gap: 0; width: 48px; height: 48px; justify-content: center; }
    .aclock time { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* hands only on phones */
}
@media (prefers-reduced-motion: reduce) { .ac-hand { transition: none; } }
