/*
 * GNSW Mail — sign-in.
 *
 * Above 1024px the screen is a hard split: the live half on its own ground,
 * the Gambian flag as the seam, the form on a light surface. Below it, one
 * card on the ground, and the live half is not rendered at all.
 */

@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/assets/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --gm-red: #e31e24;
  --gm-blue: #1e2c72;
  --gm-green: #0b6b3a;
  --brand: #22348a;
  --brand-strong: #1a2870;
  --brand-bright: #3b56d0;
  --brand-ring: rgba(59, 86, 208, 0.28);
  --ok: #10b981;
  --ok-ink: #0a7a4c;
  --warn: #f5b942;
  --bad: #d92d20;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --t-quick: 140ms;
  --t-smooth: 260ms;
  --t-slow: 520ms;

  --side-bg: #f4f6fb;
  --side-pool: radial-gradient(circle at 100% 0%, rgba(59, 86, 208, 0.10), rgba(59, 86, 208, 0) 55%);
  --card-bg: #ffffff;
  --card-line: #e3e8f2;
  --card-ink: #0e1630;
  --card-ink-soft: #3b4663;
  --card-muted: #66708a;
  --card-faint: #98a1b8;
  --field-bg: #f8faff;
  --field-line: #d9dfec;
  --field-line-hover: #bcc5d9;
}

[data-theme="dark"] {
  --side-bg: #080d1c;
  --side-pool: radial-gradient(circle at 100% 0%, rgba(90, 116, 240, 0.16), rgba(90, 116, 240, 0) 55%);
  --card-bg: #0f172b;
  --card-line: #1f2a45;
  --card-ink: #eef2fb;
  --card-ink-soft: #c5cde0;
  --card-muted: #8e99b5;
  --card-faint: #66718c;
  --field-bg: #0b1224;
  --field-line: #26324f;
  --field-line-hover: #354468;
  --brand-ring: rgba(122, 146, 255, 0.35);
}

.auth-view,
.loading-view {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* ── ground, shifting with the day in Banjul ─────────────────────────── */

.auth-view,
.loading-view {
  --ground: linear-gradient(165deg, #0a1642 0%, #13266a 55%, #0a1642 100%);
  --pool: radial-gradient(circle, rgba(92, 124, 255, 0.22) 0%, rgba(92, 124, 255, 0) 68%);
  --glow: #7c9bff;
}

.auth-view[data-daypart="night"] {
  --ground: linear-gradient(165deg, #040919 0%, #0a1433 58%, #050a1d 100%);
  --pool: radial-gradient(circle, rgba(82, 110, 255, 0.15) 0%, rgba(82, 110, 255, 0) 68%);
  --glow: #6d8bff;
}

.auth-view[data-daypart="dawn"] {
  --ground: linear-gradient(165deg, #0a1740 0%, #1a2a5e 55%, #3a2c50 100%);
  --pool: radial-gradient(circle, rgba(251, 191, 36, 0.14) 0%, rgba(251, 191, 36, 0) 68%);
  --glow: #fbbf24;
}

.auth-view[data-daypart="dusk"] {
  --ground: linear-gradient(165deg, #0b1740 0%, #291e4e 58%, #0c1128 100%);
  --pool: radial-gradient(circle, rgba(227, 30, 36, 0.12) 0%, rgba(227, 30, 36, 0) 68%);
  --glow: #fb7185;
}

/* ── layout ─────────────────────────────────────────────────────────── */

.auth-view {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  background: var(--ground);
  color: var(--card-ink);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background var(--t-slow) ease;
}

.auth-view.hidden {
  display: none !important;
}

.auth-stage {
  display: none;
}

.auth-seam {
  display: none;
}

.auth-side {
  position: relative;
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 440px);
  align-content: center;
  justify-content: center;
  padding: 72px 16px 32px;
}

@media (min-width: 1024px) {
  .auth-stage {
    position: relative;
    display: flex;
    flex: 0 0 57%;
    align-items: center;
    justify-content: center;
    padding: 48px clamp(32px, 4vw, 64px);
    overflow: hidden;
    color: #fff;
    background: var(--ground);
  }

  .auth-seam {
    display: block;
    flex: 0 0 4px;
    background: linear-gradient(
      to bottom,
      var(--gm-red) 0 33.33%,
      #fff 33.33% 38.89%,
      var(--gm-blue) 38.89% 61.11%,
      #fff 61.11% 66.67%,
      var(--gm-green) 66.67% 100%
    );
  }

  .auth-side {
    padding: 80px clamp(24px, 3vw, 56px) 40px;
    background: var(--side-pool), var(--side-bg);
  }
}

@media (min-width: 1440px) {
  .auth-stage {
    flex-basis: 60%;
  }
}

.stage-pool {
  position: absolute;
  top: -30%;
  left: 18%;
  width: 1100px;
  height: 1100px;
  border-radius: 50%;
  background: var(--pool);
  pointer-events: none;
  transform: translateX(-50%);
}

.stage-inner {
  position: relative;
  z-index: 1;
  display: grid;
  width: 100%;
  max-width: 960px;
}

/* Both faces stay mounted and cross-fade in one grid cell, so a swap never
   restarts anything and never moves the page. */
.stage-face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(14px, 2.2vh, 24px);
  min-width: 0;
  transition:
    opacity 720ms ease,
    transform 720ms var(--ease-out),
    visibility 0s linear 720ms;
}

.stage-face[aria-hidden="true"] {
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  visibility: hidden;
  pointer-events: none;
}

.stage-face[aria-hidden="false"] {
  transition:
    opacity 720ms ease 120ms,
    transform 720ms var(--ease-out) 120ms,
    visibility 0s;
}

.stage-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: rgba(255, 255, 255, 0.56);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stage-eyebrow .stage-sep {
  color: rgba(255, 255, 255, 0.28);
}

.stage-eyebrow .quiet {
  color: rgba(255, 255, 255, 0.38);
  font-weight: 600;
}

.stage-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--ok);
  animation: breathe 4s ease-in-out infinite;
}

.auth-stage[data-health="offline"] .stage-live-dot {
  background: var(--bad);
  color: var(--bad);
}

.auth-stage[data-health="degraded"] .stage-live-dot {
  background: var(--warn);
  color: var(--warn);
}

@keyframes breathe {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px currentColor; }
  50% { opacity: 0.55; box-shadow: 0 0 2px currentColor; }
}

.stage-title {
  margin: 6px 0 0;
  max-width: 720px;
  color: #fff;
  font-size: clamp(28px, 2.6vw, 40px);
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.028em;
  text-wrap: balance;
}

.stage-title em {
  font-style: normal;
  background: linear-gradient(90deg, #9fb4ff, #7ee2b8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── the scene ──────────────────────────────────────────────────────── */

.scene-wrap {
  position: relative;
}

.scene {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 400;
  overflow: visible;
  /* No frame: the view runs out of the edges instead of stopping on them. */
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0%, #000 4%, #000 96%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 5%, #000 95%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to bottom, transparent 0%, #000 4%, #000 96%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 5%, #000 95%, transparent 100%);
  mask-composite: intersect;
}

.scene text {
  font-family: "Inter", system-ui, sans-serif;
}

.route-base {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.5;
  stroke-dasharray: 3 7;
}

.route-tunnel {
  fill: none;
  stroke: url(#stage-tunnel);
  stroke-width: 16;
  stroke-linecap: round;
}

.route-core {
  fill: none;
  stroke: rgba(126, 226, 184, 0.9);
  stroke-width: 2;
  stroke-linecap: round;
}

.lookup-line {
  fill: none;
  stroke: rgba(159, 180, 255, 0.7);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.lookup-line.answer {
  stroke: rgba(126, 226, 184, 0.75);
}

.dns-core {
  fill: #121f4a;
  stroke: rgba(159, 180, 255, 0.35);
  stroke-width: 1.2;
  transition: stroke var(--t-smooth) ease, fill var(--t-smooth) ease;
}

.dns[data-active="true"] .dns-core {
  fill: #1a2c66;
  stroke: rgba(159, 180, 255, 0.85);
}

.dns-halo {
  fill: none;
  stroke: rgba(159, 180, 255, 0.8);
  stroke-width: 1.5;
}

.dns-text {
  fill: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.node-shadow {
  fill: rgba(0, 0, 0, 0.28);
}

.node-unit {
  fill: #15245a;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
}

.node-vent {
  fill: rgba(255, 255, 255, 0.12);
}

.node-led {
  fill: rgba(126, 226, 184, 0.35);
  transition: fill 90ms linear;
}

.node-led[data-on="true"] {
  fill: #7ee2b8;
}

.node-led-dim {
  fill: rgba(255, 255, 255, 0.18);
}

.node-dest {
  transition: opacity var(--t-slow) ease;
}

.node-dest[data-flash="defer"] .node-unit {
  stroke: rgba(245, 185, 66, 0.9);
}

.node-dest[data-flash="ok"] .node-unit {
  stroke: rgba(126, 226, 184, 0.55);
}

.node-label {
  fill: rgba(255, 255, 255, 0.86);
  font-family: "JetBrains Mono", ui-monospace, monospace !important;
  font-size: 13px;
  font-weight: 600;
}

.node-sub {
  fill: rgba(255, 255, 255, 0.45);
  font-size: 12px;
}

.node-sub[data-bumped="true"] {
  fill: #7ee2b8;
}

.chip rect {
  fill: rgba(8, 16, 40, 0.88);
  stroke: rgba(255, 255, 255, 0.16);
}

.chip text {
  fill: rgba(255, 255, 255, 0.85);
  font-family: "JetBrains Mono", ui-monospace, monospace !important;
  font-size: 12px;
  font-weight: 600;
}

.chip-ok rect { stroke: rgba(126, 226, 184, 0.7); }
.chip-ok text { fill: #7ee2b8; }
.chip-defer rect { stroke: rgba(245, 185, 66, 0.75); }
.chip-defer text { fill: #f8cf7a; }
.chip-retry rect { stroke: rgba(245, 185, 66, 0.45); }
.chip-retry text { fill: #f8cf7a; font-size: 11px; }
.chip-answer rect { stroke: rgba(159, 180, 255, 0.5); }
.chip-answer text { fill: #c9d5ff; font-size: 11.5px; }

.ring-track {
  fill: none;
  stroke: rgba(245, 185, 66, 0.14);
  stroke-width: 3;
}

.ring {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
}

.ring-retry { stroke: #f5b942; }
.ring-ok { stroke: #7ee2b8; }

.lock-disc {
  fill: #0e1a44;
  stroke: rgba(255, 255, 255, 0.22);
  stroke-width: 1.2;
  transition: stroke var(--t-smooth) ease, fill var(--t-smooth) ease;
}

.lock-shackle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.lock-body {
  fill: rgba(255, 255, 255, 0.75);
}

.lock[data-closed="true"] .lock-disc {
  fill: #0c3a33;
  stroke: rgba(126, 226, 184, 0.85);
}

.lock[data-closed="true"] .lock-shackle { stroke: #7ee2b8; }
.lock[data-closed="true"] .lock-body { fill: #7ee2b8; }

.lock-label {
  fill: rgba(255, 255, 255, 0.6);
  font-family: "JetBrains Mono", ui-monospace, monospace !important;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.lock[data-closed="true"] .lock-label { fill: #7ee2b8; }

.packet {
  fill: #9fb4ff;
  filter: drop-shadow(0 0 6px rgba(159, 180, 255, 0.9));
}

.packet[data-dir="in"] {
  fill: #7ee2b8;
  filter: drop-shadow(0 0 6px rgba(126, 226, 184, 0.9));
}

.trail { fill: #c9d5ff; }
.trail[data-tint="deferred"] { fill: #f8cf7a; }

.envelope {
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}

.envelope .paper rect:first-child {
  fill: #ffffff;
  stroke: rgba(14, 22, 48, 0.12);
}

.paper-line { fill: #b9c3dc; }

.envelope-body {
  fill: #f4f7ff;
  stroke: rgba(14, 22, 48, 0.1);
}

.envelope-fold {
  fill: none;
  stroke: #cfd8ee;
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.envelope-flap {
  fill: #e4eafb;
  stroke: #c3cde8;
  stroke-width: 1.2;
  stroke-linejoin: round;
}

.envelope[data-tint="deferred"] .envelope-body { fill: #fff6e3; }
.envelope[data-tint="deferred"] .envelope-flap { fill: #fbe9c2; stroke: #eed49a; }

.seal-disc { fill: var(--gm-red); }
.seal-ring { fill: none; stroke: rgba(255, 255, 255, 0.45); stroke-width: 1; }
.seal-tick { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.hash {
  fill: rgba(255, 255, 255, 0.62);
  font-family: "JetBrains Mono", ui-monospace, monospace !important;
  font-size: 10.5px;
  font-weight: 600;
}

/* The message on this run: who it is from, who it is for, what it has earned. */
.message-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12.5px;
}

.message-strip .mono {
  font-family: var(--mono);
  font-size: 12px;
}

.strip-route {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.strip-arrow {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.strip-subject {
  min-width: 0;
  max-width: 34ch;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.5);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strip-subject::before {
  content: "\201C";
}

.strip-subject::after {
  content: "\201D";
}

.card-flags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.42);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: color var(--t-smooth) ease, border-color var(--t-smooth) ease, background-color var(--t-smooth) ease;
}

.card-flag svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-strip[data-signed="true"] [data-flag="signed"],
.message-strip[data-encrypted="true"] [data-flag="encrypted"],
.message-strip[data-outcome="delivered"] [data-flag="outcome"] {
  color: #7ee2b8;
  border-color: rgba(126, 226, 184, 0.45);
  background: rgba(16, 185, 129, 0.1);
}

.message-strip[data-outcome="deferred"] [data-flag="outcome"] {
  color: #f8cf7a;
  border-color: rgba(245, 185, 66, 0.5);
  background: rgba(245, 185, 66, 0.1);
}

/* ── under the scene: phases, note, transcript ─────────────────────── */

.stage-foot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
  gap: 14px 28px;
  align-items: start;
}

.phase-block {
  display: contents;
}

.phase-rail {
  grid-column: 1 / -1;
}

.phase-rail {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.phase-rail li {
  flex: 1 1 0;
  min-width: 0;
}

.phase-chip {
  position: relative;
  display: block;
  width: 100%;
  padding: 10px 0 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.42);
  background: transparent;
  font-size: 11.5px;
  font-weight: 650;
  text-align: left;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}

.phase-chip::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.phase-fill {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 999px;
  background: #9fb4ff;
  transform: scaleX(0);
  transform-origin: left center;
}

.phase-chip[data-state="done"] .phase-fill { background: #7ee2b8; }
.phase-chip[data-key="deferred"] .phase-fill { background: #f5b942; }
.phase-chip[data-state="current"] { color: #fff; }
.phase-chip[data-state="done"] { color: rgba(255, 255, 255, 0.7); }
.phase-chip[data-pinned="true"] .phase-label { color: #f8cf7a; }

.phase-chip:hover { color: rgba(255, 255, 255, 0.9); }

.phase-chip:focus-visible {
  outline: 2px solid #9fb4ff;
  outline-offset: 4px;
  border-radius: 4px;
}

.phase-note {
  min-height: 44px;
  margin: 4px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.phase-note.note-in {
  animation: note-in 420ms var(--ease-out) both;
}

@keyframes note-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.transcript {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(3, 8, 24, 0.55);
  overflow: hidden;
}

.transcript-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.42);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.transcript-head span:first-child {
  flex: 0 0 auto;
  white-space: nowrap;
}

.transcript-head span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.transcript-lines {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: calc(8 * 19px + 16px);
  margin: 0;
  padding: 8px 12px;
  overflow: hidden;
  list-style: none;
  /* Older lines scroll off under a fade, the way a terminal does. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 26px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 26px);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 19px;
}

.transcript-lines li {
  display: flex;
  gap: 10px;
  min-width: 0;
  color: rgba(255, 255, 255, 0.75);
}

.transcript-lines .who {
  flex: 0 0 10px;
  color: rgba(255, 255, 255, 0.3);
  font-weight: 700;
}

.transcript-lines .text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transcript-lines li[data-who="C"] .who { color: #9fb4ff; }
.transcript-lines li[data-who="S"] .who { color: #7ee2b8; }
.transcript-lines li[data-who="sys"] { color: rgba(255, 255, 255, 0.5); }
.transcript-lines li[data-code="4"] .text { color: #f8cf7a; }
.transcript-lines li[data-code="5"] .text { color: #fca5a5; }

.transcript-lines li.line-new {
  animation: line-in 260ms var(--ease-out) both;
}

@keyframes line-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}

/* ── the status face ────────────────────────────────────────────────── */

.status-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
}

.status-hero .stage-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-orb {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ok);
  color: var(--ok);
  animation: breathe 4s ease-in-out infinite;
}

.auth-stage[data-health="checking"] .status-orb { background: #9fb4ff; color: #9fb4ff; }
.auth-stage[data-health="degraded"] .status-orb { background: var(--warn); color: var(--warn); }
.auth-stage[data-health="offline"] .status-orb { background: var(--bad); color: var(--bad); }

.status-clock {
  text-align: right;
}

.status-clock strong {
  display: block;
  color: #fff;
  font-family: var(--mono);
  font-size: clamp(40px, 4.4vw, 64px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.status-clock span {
  display: block;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12.5px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-tile {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.stage-tile.stage-tile-changed {
  animation: tile-flash 1.6s ease-out;
}

@keyframes tile-flash {
  0% { border-color: rgba(126, 226, 184, 0.85); background-color: rgba(16, 185, 129, 0.14); }
  100% { border-color: rgba(255, 255, 255, 0.11); background-color: rgba(255, 255, 255, 0.05); }
}

.stage-tile .stage-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.52);
  font-size: 12px;
  font-weight: 650;
}

.stage-tile .stage-tile-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.72);
}

.stage-tile .stage-tile-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-tile strong {
  align-self: end;
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stage-tile[data-tone="good"] .stage-tile-icon { color: #7ee2b8; background: rgba(16, 185, 129, 0.12); }
.stage-tile[data-tone="warn"] .stage-tile-icon { color: #f8cf7a; background: rgba(245, 185, 66, 0.12); }

.status-foot {
  margin: 0;
  color: rgba(255, 255, 255, 0.42);
  font-size: 12.5px;
}

.stage-toggle {
  position: absolute;
  right: 22px;
  bottom: 22px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.66);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 650;
  transition: color var(--t-quick) ease, background-color var(--t-quick) ease, border-color var(--t-quick) ease;
}

.stage-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}

.stage-toggle:focus-visible {
  outline: 2px solid #9fb4ff;
  outline-offset: 3px;
}

.stage-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stage-toggle .when-panel { display: none; }
.stage-toggle[data-face="panel"] .when-loop { display: none; }
.stage-toggle[data-face="panel"] .when-panel { display: inline; }

/* ── the form side ──────────────────────────────────────────────────── */

.auth-topbar {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 650;
}

@media (min-width: 1024px) {
  .status-pill {
    border-color: var(--card-line);
    color: var(--card-ink-soft);
    background: var(--card-bg);
  }
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9fb4ff;
}

.status-pill[data-state="online"] .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18); }
.status-pill[data-state="degraded"] .status-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(245, 185, 66, 0.2); }
.status-pill[data-state="offline"] .status-dot { background: var(--bad); box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.18); }

.auth-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.08);
  transition: background-color var(--t-quick) ease, color var(--t-quick) ease, border-color var(--t-quick) ease;
}

.auth-icon-button:hover {
  background: rgba(255, 255, 255, 0.16);
}

@media (min-width: 1024px) {
  .auth-icon-button {
    border-color: var(--card-line);
    color: var(--card-muted);
    background: var(--card-bg);
  }

  .auth-icon-button:hover {
    color: var(--card-ink);
    border-color: var(--field-line-hover);
    background: var(--card-bg);
  }
}

.auth-icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-icon-button .icon-sun { display: none; }
[data-theme="dark"] .auth-icon-button .icon-sun { display: block; }
[data-theme="dark"] .auth-icon-button .icon-moon { display: none; }

.auth-icon-button:focus-visible,
.auth-view .link-button:focus-visible,
.auth-view .check input:focus-visible + .check-box {
  outline: 2px solid var(--brand-bright);
  outline-offset: 2px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 28px 22px 22px;
  overflow: hidden;
  border: 1px solid var(--card-line);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 1px 2px rgba(14, 22, 48, 0.06),
    0 32px 64px rgba(0, 0, 0, 0.32);
}

@media (min-width: 400px) {
  .auth-card {
    padding: 34px 32px 26px;
  }
}

@media (min-width: 1024px) {
  .auth-card {
    padding: 38px 36px 28px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04),
      0 1px 2px rgba(14, 22, 48, 0.05),
      0 24px 56px rgba(14, 22, 48, 0.10);
  }

  [data-theme="dark"] .auth-card {
    box-shadow: 0 24px 56px rgba(0, 0, 0, 0.45);
  }
}

/* The flag along the top edge of the card, at the card's own scale. */
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--gm-red) 0 33.33%,
    #fff 33.33% 35.5%,
    var(--gm-blue) 35.5% 64.5%,
    #fff 64.5% 66.67%,
    var(--gm-green) 66.67% 100%
  );
}

.auth-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.auth-logo {
  flex: 0 0 auto;
  width: 84px;
  height: 46px;
  padding: 4px 6px;
  object-fit: contain;
  border: 1px solid var(--card-line);
  border-radius: 10px;
  background: #fff;
}

.auth-product {
  color: var(--card-ink);
  font-size: 19px;
  font-weight: 780;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.auth-org {
  margin-top: 3px;
  color: var(--card-muted);
  font-size: 12.5px;
  line-height: 1.3;
}

/* Scoped overrides for the app-wide form styles. */
.auth-view .auth-panel {
  display: grid;
  gap: 18px;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-view .auth-panel:hover {
  box-shadow: none;
}

.auth-heading h1 {
  margin: 0;
  color: var(--card-ink);
  font-size: 26px;
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.auth-heading p {
  margin: 6px 0 0;
  color: var(--card-muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-step {
  display: grid;
  gap: 16px;
}

.auth-view .field {
  display: grid;
  gap: 7px;
}

.auth-view .field > label,
.auth-view .field-label {
  display: block;
  color: var(--card-ink-soft);
  font-size: 13px;
  font-weight: 620;
  letter-spacing: 0;
  text-transform: none;
  transition: color var(--t-quick) ease;
}

.auth-view .field:focus-within > label {
  color: var(--brand-bright);
}

[data-theme="dark"] .auth-view .field:focus-within > label {
  color: #9fb4ff;
}

.input-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--card-faint);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-50%);
  pointer-events: none;
  transition: stroke var(--t-quick) ease;
}

.input-wrap:focus-within .input-icon {
  stroke: var(--brand-bright);
}

.auth-view .input-wrap input {
  height: 52px;
  padding: 0 14px 0 44px;
  border: 1.5px solid var(--field-line);
  border-radius: 12px;
  color: var(--card-ink);
  background: var(--field-bg);
  font-size: 15px;
  font-weight: 500;
  transition:
    border-color var(--t-quick) ease,
    box-shadow var(--t-quick) ease,
    background-color var(--t-quick) ease;
}

.auth-view .input-wrap input.has-reveal {
  padding-right: 52px;
}

.auth-view .input-wrap input::placeholder {
  color: var(--card-faint);
}

.auth-view .input-wrap input:hover {
  border-color: var(--field-line-hover);
}

.auth-view .input-wrap input:focus-visible {
  outline: none;
}

.auth-view .input-wrap input:focus {
  border-color: var(--brand-bright);
  background: var(--card-bg);
  box-shadow: 0 0 0 4px var(--brand-ring);
}

.auth-view .input-wrap input[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 4px rgba(217, 45, 32, 0.14);
}

.auth-view .input-wrap input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.reveal {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 9px;
  color: var(--card-faint);
  background: transparent;
  transform: translateY(-50%);
}

.reveal:hover {
  color: var(--card-ink-soft);
  background: rgba(125, 140, 180, 0.12);
}

.reveal:focus-visible {
  outline: 2px solid var(--brand-bright);
  outline-offset: -2px;
}

.reveal svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reveal .icon-hide { display: none; }
.reveal[aria-pressed="true"] .icon-show { display: none; }
.reveal[aria-pressed="true"] .icon-hide { display: block; }

.field-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: #b7791f;
  font-size: 12.5px;
  font-weight: 620;
}

[data-theme="dark"] .field-hint { color: #f8cf7a; }

.field-hint svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
}

.auth-view .check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--card-ink-soft);
  font-size: 13.5px;
  font-weight: 520;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.auth-view .check input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.check-box {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--field-line-hover);
  border-radius: 5px;
  background: var(--field-bg);
  transition: background-color var(--t-quick) ease, border-color var(--t-quick) ease;
}

.check-box svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity var(--t-quick) ease, transform var(--t-quick) var(--ease-out);
}

.auth-view .check input:checked + .check-box {
  border-color: var(--brand-bright);
  background: var(--brand-bright);
}

.auth-view .check input:checked + .check-box svg {
  opacity: 1;
  transform: none;
}

.auth-view .link-button {
  padding: 4px 2px;
  border-radius: 6px;
  color: var(--brand-bright);
  background: transparent;
  font-size: 13.5px;
  font-weight: 650;
}

[data-theme="dark"] .auth-view .link-button {
  color: #9fb4ff;
}

.auth-view .link-button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-view .link-button.centered {
  justify-self: center;
}

/* The announced message. A single fixed node, so screen readers announce it
   reliably; it collapses to nothing when empty. */
.auth-view .form-message {
  min-height: 0;
  margin: 0;
  color: var(--card-ink-soft);
  font-size: 13.5px;
  line-height: 1.45;
}

.auth-view .form-message:empty {
  display: none;
}

.auth-view .form-message:not(:empty) {
  padding: 11px 13px;
  border: 1px solid var(--card-line);
  border-radius: 11px;
  background: var(--field-bg);
  animation: note-in 260ms var(--ease-out) both;
}

.auth-view .form-message.error {
  color: #a8201a;
  border-color: rgba(217, 45, 32, 0.28);
  background: #fef3f2;
}

.auth-view .form-message.success {
  color: #0a6b43;
  border-color: rgba(16, 185, 129, 0.3);
  background: #ecfdf5;
}

.auth-view .form-message.info {
  color: #2a3a8c;
  border-color: rgba(59, 86, 208, 0.25);
  background: #eef2ff;
}

[data-theme="dark"] .auth-view .form-message.error { color: #fca5a5; background: rgba(217, 45, 32, 0.12); }
[data-theme="dark"] .auth-view .form-message.success { color: #7ee2b8; background: rgba(16, 185, 129, 0.1); }
[data-theme="dark"] .auth-view .form-message.info { color: #c9d5ff; background: rgba(59, 86, 208, 0.16); }

/* The submit button: one saturated thing on this side. */
.auth-view .auth-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  margin-top: 2px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(180deg, #3550c4 0%, #22348a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 8px 20px rgba(34, 52, 138, 0.28);
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.005em;
  transition:
    transform var(--t-quick) var(--ease-std),
    box-shadow var(--t-smooth) var(--ease-std),
    filter var(--t-quick) ease;
}

.auth-view .auth-submit:hover:not(:disabled) {
  background: linear-gradient(180deg, #3d5ad6 0%, #283c9a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 12px 28px rgba(34, 52, 138, 0.36);
  transform: translateY(-1px);
}

.auth-view .auth-submit:active:not(:disabled) {
  transform: scale(0.985);
}

.auth-view .auth-submit:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px var(--brand-ring),
    0 8px 20px rgba(34, 52, 138, 0.28);
}

.auth-view .auth-submit:disabled {
  cursor: not-allowed;
  opacity: 0.62;
  box-shadow: none;
}

.auth-view .auth-submit[data-state="busy"] {
  cursor: progress;
  opacity: 1;
}

.submit-spinner,
.submit-check {
  display: none;
  flex: 0 0 auto;
}

.submit-spinner {
  width: 17px;
  height: 17px;
  border: 2.2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.submit-check svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
}

.auth-submit[data-state="busy"] .submit-spinner { display: block; }
.auth-submit[data-state="ok"] .submit-check { display: block; }
.auth-submit[data-state="ok"] .submit-check svg { animation: check-draw 360ms var(--ease-out) forwards; }

.auth-view .auth-submit[data-state="ok"] {
  background: linear-gradient(180deg, #14a36b 0%, #0a7a4c 100%);
  box-shadow: 0 8px 20px rgba(10, 122, 76, 0.3);
  animation: settle 320ms var(--ease-out) 1;
}

.auth-view .auth-submit[data-state="bad"] {
  animation: shake 240ms cubic-bezier(0.36, 0.07, 0.19, 0.97) 1;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes check-draw { to { stroke-dashoffset: 0; } }
@keyframes settle { 40% { transform: scale(1.015); } }
@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Two-step verification. */
.totp-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--card-line);
  border-radius: 12px;
  background: var(--field-bg);
}

.totp-head .totp-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--brand-bright);
  background: rgba(59, 86, 208, 0.1);
}

.totp-head svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.totp-head strong {
  display: block;
  color: var(--card-ink);
  font-size: 14.5px;
  font-weight: 700;
}

.totp-head p {
  margin: 3px 0 0;
  color: var(--card-muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-view .input-wrap input.totp-input {
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.5em;
  text-align: center;
  text-indent: 0.5em;
}

.auth-trust {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--card-line);
  color: var(--card-muted);
  font-size: 12px;
}

.auth-trust span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-trust svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--ok-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

[data-theme="dark"] .auth-trust svg { stroke: #7ee2b8; }

.auth-copyright {
  margin: 14px 0 0;
  color: var(--card-faint);
  font-size: 11.5px;
  text-align: center;
}

/* Entrance choreography: the lockup, then the heading, then the fields. */
.auth-view:not(.hidden) .auth-card > *,
.auth-view:not(.hidden) .auth-panel:not(.hidden) > * {
  animation: rise 520ms var(--ease-out) both;
}

.auth-view:not(.hidden) .auth-card > :nth-child(2) { animation-delay: 40ms; }
.auth-view:not(.hidden) .auth-card > :nth-child(3) { animation-delay: 80ms; }
.auth-view:not(.hidden) .auth-panel:not(.hidden) > :nth-child(1) { animation-delay: 110ms; }
.auth-view:not(.hidden) .auth-panel:not(.hidden) > :nth-child(2) { animation-delay: 150ms; }
.auth-view:not(.hidden) .auth-panel:not(.hidden) > :nth-child(3) { animation-delay: 190ms; }
.auth-view:not(.hidden) .auth-panel:not(.hidden) > :nth-child(4) { animation-delay: 230ms; }
.auth-view:not(.hidden) .auth-panel:not(.hidden) > :nth-child(5) { animation-delay: 270ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── loading, on the same ground ───────────────────────────────────── */

.loading-view {
  background: var(--ground);
}

.loading-brand img {
  width: 84px;
  height: 46px;
  padding: 4px 6px;
  border-radius: 10px;
  background: #fff;
  filter: none;
}

.loading-line::before {
  background: linear-gradient(90deg, var(--gm-red), #fff, var(--gm-blue), #fff, var(--gm-green));
}

/* ── height and width pressure ─────────────────────────────────────── */

@media (min-width: 1024px) and (max-width: 1279px) {
  .stage-foot {
    grid-template-columns: 1fr;
  }

  .transcript {
    display: none;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) and (max-height: 780px) {
  .auth-stage {
    padding-block: 24px 64px;
  }

  .scene-wrap {
    width: min(100%, calc(40vh * 2.25));
    margin-inline: auto;
  }

  .transcript-lines {
    height: calc(5 * 19px + 16px) !important;
  }

  .stage-face {
    gap: 12px;
  }
}

@media (min-width: 1024px) and (max-height: 820px) {
  .strip-subject,
  .status-foot {
    display: none;
  }

  .stage-title {
    font-size: clamp(24px, 2.2vw, 32px);
  }

  .transcript-lines {
    height: calc(6 * 19px + 16px);
  }

  .stage-tile {
    min-height: 96px;
  }
}

@media (max-width: 380px) {
  .auth-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .auth-logo {
    width: 70px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-face,
  .stage-face[aria-hidden="false"] {
    transition: none;
  }

  .stage-live-dot,
  .status-orb,
  .auth-view:not(.hidden) .auth-card > *,
  .auth-view:not(.hidden) .auth-panel:not(.hidden) > *,
  .auth-view .auth-submit[data-state],
  .phase-note.note-in,
  .transcript-lines li.line-new,
  .stage-tile.stage-tile-changed {
    animation: none !important;
  }

  .submit-spinner {
    animation-duration: 1.6s;
  }

  .submit-check svg {
    stroke-dashoffset: 0;
  }
}
