/* Fordino sign-in gateway. System type on purpose: the page should feel native on every device. */
:root {
  color-scheme: light dark;
  /* Tokens mirror the Fordino app's BLUE_THEME: background, surface, borderColor, textPrimary, muted. */
  --bg: #f7f9fa;
  --fg: #29343d;
  --fg-2: #526b7a;
  --fg-3: #7a8a96;
  --glass: rgba(255, 255, 255, 0.78);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --glass-border: rgba(224, 230, 235, 0.9);
  --row-hover: rgba(41, 52, 61, 0.05);
  --row-active: rgba(99, 91, 255, 0.12);
  --brand: #635bff;
  --brand-2: #16cdc7;
  --brand-text: #5a52f0;
  --brand-ink: #ffffff;
  --danger: #d70015;
  --shadow: 0 2px 6px -2px rgba(10, 37, 64, 0.08), 0 24px 56px -26px rgba(10, 37, 64, 0.22);
  --ring: 0 0 0 4px rgba(99, 91, 255, 0.2);
  --radius: 20px;
  --redirect-ms: 1100ms;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", system-ui, "Segoe UI", sans-serif;
  --blob-a: rgba(99, 91, 255, 0.32);
  --blob-b: rgba(22, 205, 199, 0.28);
  --blob-c: rgba(99, 91, 255, 0.18);
  --glow-a: rgba(99, 91, 255, 0.1);
  --glow-b: rgba(22, 205, 199, 0.1);
  --shard-a: rgba(99, 91, 255, 0.13);
  --shard-b: rgba(22, 205, 199, 0.14);
  --shard-c: rgba(99, 91, 255, 0.09);
  --mark-opacity: 0.07;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181b34;
    --fg: #ffffff;
    --fg-2: #b6b9c9;
    --fg-3: #9da0b0;
    --glass: rgba(41, 43, 74, 0.78);
    --glass-strong: rgba(41, 43, 74, 0.92);
    --glass-border: rgba(61, 63, 92, 0.9);
    --row-hover: rgba(255, 255, 255, 0.06);
    --row-active: rgba(99, 91, 255, 0.28);
    --brand-2: #14e9e2;
    --brand-text: #9a94ff;
    --danger: #ff6b6b;
    --shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.24), 0 24px 56px -26px rgba(0, 0, 0, 0.5);
    --ring: 0 0 0 4px rgba(99, 91, 255, 0.4);
    --blob-a: rgba(99, 91, 255, 0.42);
    --blob-b: rgba(20, 233, 226, 0.2);
    --blob-c: rgba(99, 91, 255, 0.22);
    --glow-a: rgba(99, 91, 255, 0.24);
    --glow-b: rgba(20, 233, 226, 0.1);
    --shard-a: rgba(99, 91, 255, 0.16);
    --shard-b: rgba(20, 233, 226, 0.12);
    --shard-c: rgba(99, 91, 255, 0.1);
    --mark-opacity: 0.11;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Background: the app's auth canvas (two radial glows, the faded F mark, three skewed shards)
   with the gateway's slow-drifting colour washes kept underneath, in the same palette. */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.backdrop::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(1200px 700px at 88% 18%, var(--glow-a), transparent 60%),
    radial-gradient(900px 600px at 22% 92%, var(--glow-b), transparent 60%);
}
.blob {
  position: absolute; border-radius: 50%; filter: blur(90px); will-change: transform;
  animation: drift 32s ease-in-out 4 alternate;
}
.blob-a { width: 52vmax; height: 52vmax; left: -16vmax; top: -20vmax; background: var(--blob-a); }
.blob-b { width: 44vmax; height: 44vmax; right: -14vmax; top: 12vmax; background: var(--blob-b); animation-delay: -9s; }
.blob-c { width: 40vmax; height: 40vmax; left: 24vmax; bottom: -22vmax; background: var(--blob-c); animation-delay: -18s; }
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vmax, 4vmax, 0) scale(1.08); }
}
.mark {
  position: absolute; right: 0; top: 50%; width: min(58vw, 1150px); height: auto;
  opacity: var(--mark-opacity); transform: translate(10%, -50%);
  animation: mark-drift 22s ease-in-out 6 alternate;
}
@keyframes mark-drift {
  from { transform: translate(10%, -50%) translateY(-14px) rotate(1.2deg); }
  to   { transform: translate(10%, -50%) translateY(14px) rotate(-1.2deg); }
}
.shard { position: absolute; top: -6%; border-radius: 6px; transform: skewX(-19deg); }
.shard-a { right: 46%; width: 120px; height: 58%; background: linear-gradient(180deg, var(--shard-a), transparent); }
.shard-b { right: 58%; width: 74px; height: 52%; background: linear-gradient(180deg, var(--shard-b), transparent); }
.shard-c { right: 88%; width: 190px; height: 74%; background: linear-gradient(180deg, var(--shard-c), transparent); }
@media (max-width: 900px) {
  .mark { width: 120vw; right: -30vw; opacity: calc(var(--mark-opacity) * 0.8); }
  .shard-a, .shard-b { display: none; }
}

/* Stage */
.stage {
  position: relative; z-index: 1;
  width: min(560px, 100% - 32px);
  margin: 0 auto;
  padding: clamp(40px, 12vh, 120px) 0 40px;
  display: flex; flex-direction: column; align-items: center;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.brand { margin-bottom: 28px; }
.wordmark { display: block; height: 34px; width: auto; }
.wordmark-dark { display: none; }
@media (prefers-color-scheme: dark) { .wordmark-light { display: none; } .wordmark-dark { display: block; } }

.title {
  margin: 0 0 8px; font-size: clamp(28px, 4.5vw, 36px); font-weight: 700; letter-spacing: -0.02em; text-align: center;
}
.subtitle { margin: 0 0 28px; color: var(--fg-2); font-size: 17px; text-align: center; line-height: 1.4; }

/* Spotlight bar */
.spotlight { width: 100%; position: relative; }
.bar {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 66px; padding: 0 9px 0 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}
.bar:focus-within { box-shadow: var(--ring), var(--shadow); }
.bar-icon { color: var(--fg-3); display: inline-flex; flex: none; }
.bar-input {
  flex: 1; min-width: 0;
  font: 400 21px/1.2 var(--font);
  color: var(--fg); background: transparent; border: 0; outline: 0; padding: 0;
}
.bar-input::placeholder { color: var(--fg-3); }
.bar-go {
  flex: none; width: 46px; height: 46px; border: 0; border-radius: 14px;
  background: var(--brand); color: var(--brand-ink);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: opacity 0.2s ease, transform 0.15s ease;
}
.bar[data-empty="true"] .bar-go { opacity: 0.35; }
.bar-go:hover { transform: scale(1.04); }
.bar-go:active { transform: scale(0.96); }
.bar-spinner {
  display: none; flex: none; width: 22px; height: 22px; margin: 0 12px;
  border-radius: 50%; border: 2.5px solid var(--glass-border); border-top-color: var(--brand);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
[data-state="loading"] .bar-go { display: none; }
[data-state="loading"] .bar-spinner { display: block; }

/* Panel under the bar */
.panel {
  margin-top: 10px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-origin: top center;
  animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.panel[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.985); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 6px; color: var(--fg-3);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.panel-head .count { font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 6px; }
.row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px; border-radius: 14px;
  color: inherit; text-decoration: none; cursor: pointer;
  transition: background 0.12s ease;
}
.row:hover { background: var(--row-hover); }
.row[aria-selected="true"] { background: var(--row-active); }
.row-text { flex: 1; min-width: 0; }
.row-name { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-host { display: block; font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-key {
  flex: none; color: var(--fg-3); font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.row-key kbd { display: none; }
.row[aria-selected="true"] .row-key { color: var(--brand-text); }
.row[aria-selected="true"] .row-key kbd { display: inline-block; }

.avatar {
  --c: var(--brand);
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--c); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; letter-spacing: 0.02em;
  overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; border-radius: 18px; font-size: 24px; }

/* Single workspace: brief tile, then redirect */
.single { padding: 26px 20px 22px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.single-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; overflow-wrap: anywhere; }
.single-host { font-size: 14px; color: var(--fg-2); }
.progress { width: 160px; height: 4px; border-radius: 4px; background: var(--row-hover); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--brand); animation: fill var(--redirect-ms) linear forwards; }
@keyframes fill { to { width: 100%; } }

/* Password step */
.pw { padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 12px; }
.pw-head { display: flex; align-items: center; gap: 14px; }
.pw-text { min-width: 0; }
.pw-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.pw-sub { font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field {
  display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 6px 0 16px;
  border-radius: 14px; background: var(--row-hover); border: 1px solid var(--glass-border);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.field:focus-within { box-shadow: var(--ring); border-color: var(--brand); }
.field.is-error { border-color: var(--danger); animation: shake 0.35s ease; }
.field input { flex: 1; min-width: 0; font: 400 17px var(--font); color: var(--fg); background: transparent; border: 0; outline: 0; }
.field input::placeholder { color: var(--fg-3); }
.eye {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; color: var(--fg-3);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.eye:hover { background: var(--row-hover); color: var(--fg); }
.pw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.link { color: var(--brand-text); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.btn-block { width: 100%; justify-content: center; height: 48px; font-size: 16px; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; }
.pw-foot { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.progress-indeterminate i { width: 40%; animation: slide 1s ease-in-out infinite alternate; }
@keyframes slide { from { transform: translateX(-20%); } to { transform: translateX(170%); } }

/* Welcome back chooser */
.welcome-foot { padding: 2px 16px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.countdown { font-size: 13px; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.welcome-foot .actions-tight { margin-top: 0; gap: 4px; }

/* Messages, code entry */
.message { padding: 24px 22px 20px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.message-icon {
  width: 52px; height: 52px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--row-active); color: var(--brand-text); margin-bottom: 4px;
}
.message-icon.is-danger { background: rgba(255, 59, 48, 0.12); color: var(--danger); }
.message-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.message-text { color: var(--fg-2); font-size: 15px; line-height: 1.45; max-width: 40ch; overflow-wrap: anywhere; }
.message-text strong { color: var(--fg); font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

.btn {
  height: 44px; padding: 0 18px; border-radius: 12px; border: 0; cursor: pointer;
  font: 500 15px var(--font); display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--brand-text); }
.btn-ghost:hover { background: var(--row-hover); }

.code { display: flex; gap: 10px; justify-content: center; margin: 10px 0 4px; }
.code input {
  width: 48px; height: 58px; text-align: center; font: 600 26px var(--font); color: var(--fg);
  background: var(--row-hover); border: 1px solid var(--glass-border); border-radius: 12px; outline: 0;
  caret-color: var(--brand); font-variant-numeric: tabular-nums;
}
.code input:focus { box-shadow: var(--ring); border-color: var(--brand); }
.code.is-error input { border-color: var(--danger); animation: shake 0.35s ease; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.inline-error { color: var(--danger); font-size: 14px; min-height: 18px; }

/* Recent email chip and hint */
.recent { margin-top: 16px; display: flex; align-items: center; gap: 6px; }
.recent[hidden] { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 12px;
  border-radius: 999px; border: 1px solid var(--glass-border); background: var(--glass); color: var(--fg);
  font: 500 14px var(--font); cursor: pointer;
}
.chip:hover { background: var(--glass-strong); }
.chip-main { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; }
.chip-x {
  width: 24px; height: 24px; border-radius: 50%; border: 0; background: transparent; color: var(--fg-3);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 15px;
}
.chip-x:hover { background: var(--row-hover); color: var(--fg); }
.hint { margin: 18px 0 0; color: var(--fg-3); font-size: 13px; transition: opacity 0.2s ease, visibility 0.2s, height 0.2s ease, margin 0.2s ease; height: 16px; }
.hint kbd, .row-key kbd {
  font: 500 12px var(--font); padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--glass-border); background: var(--glass); color: inherit;
}
[data-state]:not([data-state="idle"]) ~ .hint { opacity: 0; visibility: hidden; height: 0; margin: 0; overflow: hidden; }

/* Footer */
.foot {
  position: relative; z-index: 1;
  display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 18px 16px 26px; color: var(--fg-3); font-size: 13px;
}
.foot-brand { font-weight: 600; color: var(--fg-2); }

:focus-visible { outline: 3px solid rgba(99, 91, 255, 0.5); outline-offset: 2px; }
.bar-input:focus-visible { outline: 0; }

@media (max-height: 740px) {
  .stage { padding-top: clamp(16px, 4vh, 40px); padding-bottom: 16px; }
  .brand { margin-bottom: 14px; }
  .title { font-size: 24px; margin-bottom: 4px; }
  .subtitle { font-size: 14px; margin-bottom: 16px; }
  .pw { padding: 14px 16px 12px; gap: 10px; }
  .avatar-lg { width: 52px; height: 52px; font-size: 20px; }
  .foot { padding: 10px 16px 14px; }
}

@media (max-width: 480px) {
  .bar { height: 60px; padding-left: 16px; }
  .bar-input { font-size: 18px; }
  .subtitle { font-size: 15px; }
  .code { gap: 7px; }
  .code input { width: 42px; height: 52px; font-size: 22px; }
}

@media (hover: none) and (pointer: coarse) {
  .hint, .row-key kbd { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .mark, .stage, .panel, .progress i { animation: none; }
  .progress i { width: 100%; }
  * { transition: none !important; }
}
