/* Bitflow · Design system
   One sheet of tokens and shared controls for every page (sign-in, register, devices, admin).
   The palette comes from the mark: midnight navy carrying streams of mint and cyan light.
   Dark is the default; theme.js sets data-theme on <html>. */

/* Animatable custom properties (ignored where @property is unsupported; the effects then simply switch). */
@property --spot-a { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --trace { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Brand constants, identical in both themes */
  --mint: #5ff2d6;
  --cyan: #3cc8ff;
  --violet: #8f7dff;
  --navy: #0b1233;

  /* Night */
  --bg: #050a1c;
  --ink: #ecf3ff;
  --ink-2: #c9d5ec;
  --muted: #9fb0cd;
  --subtle: #8192b2;
  --line: #a4bcff26;
  --line-strong: #a4bcff47;
  --line-soft: #a4bcff14;
  --surface: linear-gradient(180deg, #141f48a8 0%, #0b1434a3 100%);
  --surface-flat: #0f1a3dcc;
  --surface-solid: #0c1431;
  --sheet: linear-gradient(180deg, #121c43 0%, #0b1331 100%);
  --sheet-solid: #0d1637;
  --raised: #ffffff0d;
  --raised-hover: #ffffff19;
  --well: #02061866;
  --field: #030a2199;
  --field-focus: #040c26d9;
  --accent: #5ff2d6;
  --accent-text: #78f6df;
  --accent-soft: #5ff2d61f;
  --accent-ring: #5ff2d670;
  --accent-grad: linear-gradient(135deg, #93fde8 0%, #52ead4 42%, #3cc8ff 100%);
  --text-grad: linear-gradient(120deg, #ffffff 10%, #c8fff3 55%, #7fdcff 100%);
  --upload: #a897ff;
  --download: #4ff0d0;
  --upload-grad: linear-gradient(180deg, #c3b8ff, #8a74ff);
  --download-grad: linear-gradient(180deg, #8bfbe5, #2fd2c4);
  --primary-bg: linear-gradient(135deg, #93fde8 0%, #52ead4 42%, #3cc8ff 100%);
  --primary-ink: #03221e;
  --primary-shadow: inset 0 1px 0 #ffffffb3, inset 0 -1px 0 #00303026, 0 1px 2px #00000066, 0 12px 30px -12px #34d8e0b3;
  --primary-shadow-hover: inset 0 1px 0 #ffffffb3, inset 0 -1px 0 #00303026, 0 1px 2px #00000066, 0 18px 42px -12px #34d8e0f2;
  --sheen: #ffffff8c;
  --ok: #4be3a0;
  --ok-soft: #4be3a01f;
  --warn: #ffc56b;
  --warn-soft: #ffc56b1f;
  --danger: #ff8a93;
  --danger-soft: #ff80891f;
  --danger-line: #ff80895c;
  --shadow-sm: 0 1px 2px #00000066;
  --shadow-md: 0 1px 2px #0000004d, 0 12px 30px -14px #000000b3;
  --shadow-lg: 0 2px 6px #00000040, 0 40px 100px -30px #000000e0;
  --glass-rim: inset 0 1px 0 #ffffff1c, inset 0 0 0 1px #ffffff06;
  --glass-edge: linear-gradient(160deg, #ffffff47, #ffffff0d 26%, #5ff2d600 58%, #5ff2d633);
  --glass-blur: blur(26px) saturate(1.6);
  --lens: radial-gradient(120% 120% at 30% 18%, #ffffff2e 0, #ffffff08 46%, #ffffff17 100%);
  --spot: 95 242 214;
  --backdrop: #01040fa6;
  --scrollbar: #a4bcff38;
  --selection: #5ff2d64d;
  --sky:
    radial-gradient(55% 45% at 8% 92%, #0c4a5c 0, transparent 70%),
    radial-gradient(50% 45% at 92% 6%, #2a1f72 0, transparent 70%),
    radial-gradient(45% 40% at 55% 55%, #0d2c5a66 0, transparent 70%),
    linear-gradient(180deg, #071029 0%, #040818 100%);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;
  --ease: cubic-bezier(.2,.8,.2,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --ease-in: cubic-bezier(.5,0,.75,0);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-soft: cubic-bezier(.3,1.25,.5,1);
  --dur-fast: .14s;
  --dur: .24s;
  --dur-slow: .42s;
  --gutter: clamp(1.1rem, 4vw, 3.5rem);
  --content: 1160px;

  color-scheme: dark;
  font-family: var(--font-sans);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color: var(--ink);
  background: var(--bg);
}
:root[data-theme="light"] {
  --bg: #eef3fb;
  --ink: #0b1533;
  --ink-2: #27344f;
  --muted: #4a5875;
  --subtle: #5d6b88;
  --line: #1a2c5c1f;
  --line-strong: #1a2c5c38;
  --line-soft: #1a2c5c12;
  --surface: linear-gradient(180deg, #ffffffc2 0%, #ffffffa8 100%);
  --surface-flat: #ffffffd9;
  --surface-solid: #ffffff;
  --sheet: linear-gradient(180deg, #ffffff 0%, #f6f9ff 100%);
  --sheet-solid: #fbfdff;
  --raised: #ffffffb8;
  --raised-hover: #ffffff;
  --well: #1a2c5c0a;
  --field: #f4f7fcf2;
  --field-focus: #ffffff;
  --accent: #0fb89b;
  --accent-text: #05705f;
  --accent-soft: #0fb89b1f;
  --accent-ring: #0fb89b66;
  --accent-grad: linear-gradient(135deg, #3fe0c4 0%, #14bfa5 45%, #1d9bf0 100%);
  --text-grad: linear-gradient(120deg, #0b1533 15%, #13306e 60%, #0b8d7b 100%);
  --upload: #6b4fe0;
  --download: #0aa48b;
  --upload-grad: linear-gradient(180deg, #8f78ff, #5b3fd6);
  --download-grad: linear-gradient(180deg, #2fd8bd, #0a9c86);
  --ok: #0b7148;
  --ok-soft: #0b71481a;
  --warn: #935606;
  --warn-soft: #c27a0d1a;
  --danger: #c2343f;
  --danger-soft: #c2343f12;
  --danger-line: #c2343f4d;
  --shadow-sm: 0 1px 2px #1a2c5c1f;
  --shadow-md: 0 1px 2px #1a2c5c14, 0 12px 28px -16px #1a2c5c66;
  --shadow-lg: 0 1px 2px #1a2c5c14, 0 30px 80px -34px #1a2c5c73;
  --glass-rim: inset 0 1px 0 #ffffff, inset 0 0 0 1px #ffffff8c;
  --glass-edge: linear-gradient(160deg, #ffffff, #ffffff73 28%, #0fb89b00 58%, #0fb89b3d);
  --glass-blur: blur(24px) saturate(1.8);
  --lens: radial-gradient(120% 120% at 30% 18%, #ffffff 0, #ffffff8c 46%, #ffffffbf 100%);
  --spot: 15 184 155;
  --backdrop: #0b12334d;
  --scrollbar: #1a2c5c33;
  --selection: #0fb89b40;
  --sky:
    radial-gradient(55% 45% at 8% 92%, #c4f2e8 0, transparent 70%),
    radial-gradient(50% 45% at 92% 6%, #dcd5ff 0, transparent 70%),
    radial-gradient(45% 40% at 55% 55%, #d8e8ff99 0, transparent 70%),
    linear-gradient(180deg, #f4f8fe 0%, #e8eef9 100%);
  color-scheme: light;
}
:root[data-theme="light"] {
  --primary-bg: linear-gradient(135deg, #22337c 0%, #0b1233 75%);
  --primary-ink: #ffffff;
  --primary-shadow: inset 0 1px 0 #ffffff33, inset 0 -1px 0 #00000040, 0 1px 2px #0b123340, 0 12px 26px -12px #0b1233b3;
  --primary-shadow-hover: inset 0 1px 0 #ffffff33, inset 0 -1px 0 #00000040, 0 1px 2px #0b123340, 0 18px 36px -12px #0fb89bb3;
  --sheen: #ffffff3d;
}

/* ── Base ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; scroll-padding-top: 5.5rem; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: none; color: var(--ink); line-height: 1.55; }
/* The painted sky sits on a fixed layer behind the page; the live wallpaper (wallpaper.js) replaces it when it can draw. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--sky); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; text-wrap: balance; }
h1 { font-size: clamp(2rem, 3.4vw, 2.85rem); font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: 1.22rem; font-weight: 600; letter-spacing: -.015em; }
h3 { font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
button, a, summary { touch-action: manipulation; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
::selection { background: var(--selection); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button:disabled { cursor: not-allowed; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
.icon { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.18em; pointer-events: none; }
.muted, .meta { color: var(--muted); }
.gradient-text, .auth-card-heading h1, .usage-total, .brand span {
  background: var(--text-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Short Chinese copy breaks only at spaces and punctuation, so words such as 收件箱 stay whole; very long runs still wrap. */
.auth-card-heading p, #code-help, .message, .modal-copy, .steps li, .empty p, #passkey-status, .usage-note, .usage-feedback, .meta { word-break: keep-all; overflow-wrap: anywhere; }

/* ── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%;
  padding: max(.95rem, env(safe-area-inset-top)) calc(max(0px, (100% - var(--content)) / 2) + var(--gutter)) .95rem;
}
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: var(--surface-flat);
  -webkit-backdrop-filter: blur(22px) saturate(1.7); backdrop-filter: blur(22px) saturate(1.7);
  box-shadow: inset 0 -1px 0 var(--line-soft), 0 10px 30px -24px #000;
  opacity: 0; transition: opacity var(--dur-slow) var(--ease);
}
html[data-scrolled] .topbar::before { opacity: 1; }
.brand { display: inline-flex; align-items: center; gap: .62rem; font-family: var(--font-display); font-size: 1.22rem; font-weight: 720; letter-spacing: -.03em; border-radius: var(--r-md); }
.brand img { width: 2.3rem; height: 2.3rem; filter: drop-shadow(0 6px 14px #3cc8ff59); transition: transform .6s var(--ease-spring); }
.brand:hover img { transform: rotate(-8deg) scale(1.07); }
.brand:active img { transform: scale(.94); transition-duration: .1s; }
.header-actions { display: flex; align-items: center; gap: .5rem; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.button, .auth-primary, .round {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  color: var(--ink); background: var(--raised);
  font-weight: 500; text-decoration: none; text-align: center;
  -webkit-user-select: none; user-select: none;
  transition: transform var(--dur) var(--ease-spring), background-color var(--dur) var(--ease), border-color var(--dur) var(--ease),
    box-shadow var(--dur-slow) var(--ease), color var(--dur) var(--ease), opacity var(--dur) var(--ease) .3s, filter var(--dur) var(--ease) .3s;
}
.button, .auth-primary { overflow: hidden; }
.button { min-height: 2.65rem; padding: .55rem 1.15rem; font-size: .92rem; line-height: 1.3; box-shadow: var(--glass-rim); }
.button .icon { width: 1.08rem; height: 1.08rem; margin-left: -.15rem; transition: transform .45s var(--ease-spring); }
.round { flex: none; width: 2.65rem; height: 2.65rem; padding: 0; box-shadow: var(--glass-rim), var(--shadow-sm); }
.round .icon { width: 1.18rem; height: 1.18rem; transition: transform .5s var(--ease-spring), opacity .3s var(--ease); }

/* Primary: the mint stream; a soft sheen crosses it on hover. */
.button.primary, .auth-primary { color: var(--primary-ink); background: var(--primary-bg); border-color: transparent; box-shadow: var(--primary-shadow); font-weight: 600; }
.button.primary::after, .auth-primary::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, var(--sheen) 48%, transparent 64%);
  transform: translateX(-120%); transition: transform 1s var(--ease-out);
}
.button.danger { color: var(--danger); }
.auth-primary {
  display: flex; width: 100%; min-height: 3.15rem; padding: .8rem 1.4rem;
  font-size: 1.02rem; line-height: 1.3; letter-spacing: .01em;
}
@media (hover: hover) {
  .button:hover:not(:disabled), .round:hover:not(:disabled) { background-color: var(--raised-hover); border-color: var(--line-strong); }
  .button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--glass-rim), var(--shadow-md); }
  .button.primary:hover:not(:disabled), .auth-primary:hover:not(:disabled) { box-shadow: var(--primary-shadow-hover); transform: translateY(-1px); }
  .button.primary:hover:not(:disabled)::after, .auth-primary:hover:not(:disabled)::after { transform: translateX(120%); }
  .button.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger-line); }
  .button:hover:not(:disabled) .icon { transform: scale(1.12); }
  .round:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--glass-rim), var(--shadow-md); }
}
.button:active:not(:disabled), .auth-primary:active:not(:disabled), .round:active:not(:disabled) { transform: scale(.955); transition-duration: .09s; }
.button:disabled, .auth-primary:disabled, .round:disabled { opacity: .5; filter: saturate(.25); box-shadow: none; }
.button.primary:disabled, .auth-primary:disabled { opacity: .55; }

/* Working: only the button that started a request shows it. A ring turns inside and the colours stay,
   so it reads as "in progress"; the other controls simply rest as unavailable. */
.button[aria-busy="true"], .auth-primary[aria-busy="true"], #register-form[aria-busy="true"] .auth-primary:disabled { opacity: 1; filter: none; cursor: progress; }
.button[aria-busy="true"]::before, .auth-primary[aria-busy="true"]::before, .auth-text-button[aria-busy="true"]::before, #register-form[aria-busy="true"] .auth-primary:disabled::before {
  content: ""; width: 1rem; height: 1rem; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  -webkit-mask: none; mask: none; background: none;
  animation: spin .7s linear infinite;
}
.auth-text-button[aria-busy="true"]::before { width: .8rem; height: .8rem; }

.auth-text-button {
  display: inline-flex; align-items: center; gap: .35rem; min-height: 2.25rem; padding: 0 .8rem;
  border-radius: var(--r-pill); color: var(--accent-text); font-size: .875rem; font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur) var(--ease-spring), color var(--dur) var(--ease), opacity var(--dur);
}
@media (hover: hover) { .auth-text-button:hover:not(:disabled) { background: var(--accent-soft); } }
.auth-text-button:active:not(:disabled) { transform: scale(.95); }
.auth-text-button:disabled { opacity: .5; }

/* Theme toggle: a sun at night, a moon by day; they trade places with a turn. */
.theme-toggle { overflow: hidden; }
.theme-toggle .icon { position: absolute; inset: 0; margin: auto; }
.theme-toggle .icon-moon { opacity: 0; transform: rotate(-100deg) scale(.4); }
:root[data-theme="light"] .theme-toggle .icon-moon { opacity: 1; transform: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(100deg) scale(.4); }
@media (hover: hover) {
  .theme-toggle:hover .icon-sun { transform: rotate(45deg); }
  :root[data-theme="light"] .theme-toggle:hover .icon-moon { transform: rotate(-18deg); }
}

/* ── Fields ────────────────────────────────────────────────────────────── */
.signup-email { display: block; margin: 0 .2rem .45rem; color: var(--ink-2); font-size: .875rem; font-weight: 500; }
.signup-input, .field-input {
  display: block; width: 100%; min-height: 3.1rem; margin: 0 0 1.1rem; padding: .78rem 1rem;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--field); color: var(--ink); font-size: 1rem; line-height: 1.4;
  caret-color: var(--accent); outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur-slow) var(--ease), background-color var(--dur) var(--ease);
}
.signup-input::placeholder, .field-input::placeholder { color: var(--subtle); opacity: 1; }
@media (hover: hover) { .signup-input:hover:not(:focus, :read-only), .field-input:hover:not(:focus) { border-color: var(--line-strong); } }
.signup-input:focus, .field-input:focus { border-color: var(--accent); background: var(--field-focus); box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 24px -14px rgb(var(--spot) / .6); }
.signup-input:read-only { opacity: .75; }
.signup-input:-webkit-autofill { -webkit-text-fill-color: var(--ink); caret-color: var(--accent); box-shadow: 0 0 0 1000px var(--surface-solid) inset; transition: background-color 9999s; }

/* ── Messages ──────────────────────────────────────────────────────────── */
.message {
  --tone: var(--accent-text); --tone-bg: var(--accent-soft);
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .65rem;
  margin: .8rem 0 1.1rem; padding: .75rem 1rem .75rem .85rem;
  border: 1px solid color-mix(in srgb, var(--tone) 28%, transparent); border-radius: var(--r-md);
  background: var(--tone-bg); color: var(--ink); font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere;
  animation: msg-in .5s var(--ease-out);
}
.message::before {
  content: ""; flex: none; width: 1.15rem; height: 1.15rem; align-self: flex-start; margin-top: .14em;
  background: var(--tone);
  -webkit-mask: var(--msg-icon, var(--i-info)) center / contain no-repeat; mask: var(--msg-icon, var(--i-info)) center / contain no-repeat;
}
.message[data-error="false"] { --msg-icon: var(--i-check-circle); }
.message[data-error="true"] { --tone: var(--danger); --tone-bg: var(--danger-soft); --msg-icon: var(--i-alert); }
.message .button, .message .auth-text-button { margin-left: auto; min-height: 2.2rem; }
:root {
  --i-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5.2M12 7.7v.1'/%3E%3C/svg%3E");
  --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7.6v5.4M12 16.3v.1'/%3E%3C/svg%3E");
  --i-check-circle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8.2 12.3 2.6 2.6 5-5.2'/%3E%3C/svg%3E");
  --i-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14m-5.5-5.5L19 12l-5.5 5.5'/%3E%3C/svg%3E");
  --i-arrow-left: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5m5.5-5.5L5 12l5.5 5.5'/%3E%3C/svg%3E");
  --i-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.1' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --i-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8.4' r='3.8'/%3E%3Cpath d='M4.8 20c.8-3.8 3.6-6 7.2-6s6.4 2.2 7.2 6'/%3E%3C/svg%3E");
  --i-fingerprint: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M5.2 16.3c.6-1.2.9-2.6.9-4.1a5.9 5.9 0 0 1 10.6-3.6M17.8 11c.1.4.1.8.1 1.2 0 1.5-.1 2.9-.4 4.2M9.1 20.4c1.3-2.3 2-5 2-8.2a.9.9 0 0 1 1.8 0c0 3-.5 5.6-1.6 7.9M8.6 12.2a3.4 3.4 0 0 1 6.8 0c0 2.6-.4 5-1.3 7.1M3.6 9.4A8.9 8.9 0 0 1 19 6.7'/%3E%3C/svg%3E");
}

/* ── Sign-in & registration ────────────────────────────────────────────── */
.landing { display: flex; flex-direction: column; }
.auth-shell {
  flex: 1; display: flex; flex-direction: column; min-height: 0;
  padding: .75rem max(1.25rem, env(safe-area-inset-right)) max(clamp(2.5rem, 9vh, 7rem), env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
}
.auth-main { display: flex; flex-direction: column; align-items: center; gap: 1.75rem; width: 100%; margin: auto; }

/* The mark sits in a glass lens; a ring of light orbits it and the lens tips toward the pointer. */
.auth-mark {
  --tilt-x: 0deg; --tilt-y: 0deg;
  position: relative; isolation: isolate; flex: none;
  display: grid; place-items: center; width: 116px; height: 116px; border-radius: 50%;
  background: var(--lens);
  -webkit-backdrop-filter: blur(14px) saturate(1.7); backdrop-filter: blur(14px) saturate(1.7);
  box-shadow: var(--glass-rim), 0 1px 2px #0000004d, 0 22px 50px -20px #000000b3;
  transform: perspective(600px) rotateX(var(--tilt-y)) rotateY(var(--tilt-x));
  transition: transform .8s var(--ease-out);
  animation: mark-in 1.1s var(--ease-out) backwards;
}
.auth-mark img { position: relative; z-index: 1; width: 62%; height: 62%; filter: drop-shadow(0 10px 18px #3cc8ff66); animation: float 6s ease-in-out infinite; }
.auth-mark::before {
  content: ""; position: absolute; inset: -7px; border-radius: 50%; padding: 2px; pointer-events: none;
  background: conic-gradient(transparent 0 52%, #5ff2d600 56%, var(--mint) 78%, var(--cyan) 90%, transparent 97%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  animation: spin 5.5s linear infinite;
}
.auth-mark::after {
  content: ""; position: absolute; inset: -42px; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, rgb(var(--spot) / .3), rgb(var(--spot) / .08) 55%, transparent);
  animation: breathe 5.5s ease-in-out infinite;
}

/* The card stays opaque so the inputs and the verification frame sit on an unfiltered surface. */
.auth-card {
  position: relative; width: min(440px, 100%); min-width: 0;
  padding: 2.2rem 2.1rem 1.7rem; border-radius: 30px;
  background: var(--sheet);
  box-shadow: var(--glass-rim), var(--shadow-lg);
  animation: card-in .95s var(--ease-out) .1s backwards;
}
.auth-card::after {
  content: ""; position: absolute; inset: 0; padding: 1px; border-radius: inherit; pointer-events: none;
  background: var(--glass-edge);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
}
/* A drop of light travels around the rim, like a packet along the stream. */
.auth-card::before {
  content: ""; position: absolute; inset: -1px; padding: 1.5px; border-radius: inherit; pointer-events: none;
  background: conic-gradient(from var(--trace), transparent 0deg 250deg, rgb(var(--spot) / .15) 290deg, var(--mint) 338deg, var(--cyan) 354deg, transparent 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); mask-composite: exclude;
  animation: trace 9s linear infinite;
}
@keyframes trace { to { --trace: 360deg; } }
.auth-card-heading { text-align: center; margin-bottom: 1.6rem; }
.auth-card-heading h1 {
  font-size: 1.95rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: .45rem;
  background-image: linear-gradient(105deg, transparent 42%, #ffffffd9 50%, transparent 58%), var(--text-grad);
  background-size: 260% 100%, 100% 100%; background-repeat: no-repeat; background-position: 130% 0, 0 0;
  animation: title-sheen 2.4s var(--ease-out) .9s both;
}
@keyframes title-sheen { from { background-position: 130% 0, 0 0; } to { background-position: -30% 0, 0 0; } }
.auth-card-heading h1:focus { outline: none; }
#signup-instruction:empty { display: none; }
.auth-card-heading:has(#signup-instruction:empty) h1 { margin-bottom: 0; }
.auth-card-heading p { color: var(--muted); font-size: .95rem; line-height: 1.7; text-wrap: balance; overflow-wrap: anywhere; }
.auth-card > .message { margin-top: -.4rem; }

/* Each step of the card glides in when it appears. */
#home-actions, #email-login-form, #verify-code-form, #register-form, .return-home { animation: step-in .55s var(--ease-out) backwards; }
#verify-code-form, #register-form { animation-delay: .04s; }

/* The two ways in: identical anatomy (icon, name, a line of context, arrow); signing in carries the stream colour. */
.entry-actions { display: grid; gap: .75rem; }
.entry-tile {
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .95rem;
  min-height: 4.5rem; padding: .8rem 1.15rem .8rem .8rem;
  border: 1px solid var(--line); border-radius: 20px;
  background: var(--raised); color: var(--ink); text-align: left;
  box-shadow: var(--glass-rim);
  transition: transform .45s var(--ease-spring), box-shadow .4s var(--ease), border-color .25s var(--ease), background-color .25s var(--ease);
  animation: step-in .6s var(--ease-out) backwards;
}
.entry-tile + .entry-tile { animation-delay: .08s; }
.entry-icon {
  display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 14px;
  color: var(--accent-text); background: var(--accent-soft); border: 1px solid rgb(var(--spot) / .3);
  transition: transform .55s var(--ease-spring);
}
.entry-icon .icon { width: 1.3rem; height: 1.3rem; }
.entry-text { display: grid; gap: .12rem; min-width: 0; }
.entry-label { font-size: 1.05rem; font-weight: 600; line-height: 1.3; }
.entry-note { color: var(--muted); font-size: .82rem; font-weight: 400; line-height: 1.4; }
.entry-arrow { width: 1.15rem; height: 1.15rem; color: var(--subtle); transition: transform .45s var(--ease-spring), color .25s var(--ease); }
.entry-tile.is-primary { color: var(--primary-ink); background: var(--primary-bg); border-color: transparent; box-shadow: var(--primary-shadow); }
.entry-tile.is-primary .entry-icon { color: currentColor; background: #ffffff38; border-color: #ffffff59; }
:root[data-theme="light"] .entry-tile.is-primary .entry-icon { background: #ffffff1f; border-color: #ffffff33; }
.entry-tile.is-primary .entry-note { color: currentColor; opacity: .74; }
.entry-tile.is-primary .entry-arrow { color: currentColor; }
.entry-tile.is-primary::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, var(--sheen) 48%, transparent 64%);
  transform: translateX(-120%); transition: transform 1.1s var(--ease-out);
}
@media (hover: hover) {
  .entry-tile:hover { transform: translateY(-2px); border-color: var(--line-strong); background-color: var(--raised-hover); box-shadow: var(--glass-rim), var(--shadow-md); }
  .entry-tile.is-primary:hover { box-shadow: var(--primary-shadow-hover); }
  .entry-tile.is-primary:hover::after { transform: translateX(120%); }
  .entry-tile:hover .entry-arrow { transform: translateX(4px); color: currentColor; }
  .entry-tile:hover .entry-icon { transform: rotate(-8deg) scale(1.06); }
}
.entry-tile:active { transform: scale(.98); transition-duration: .1s; }
.entry-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

#login-check-area, #registration-check { margin: .1rem 0 0; }
#login-check-area { margin-bottom: .2rem; }
#login-check, #registration-check { display: flex; justify-content: center; max-width: 100%; }
#login-check-status:not(:empty), #registration-check-status:not(:empty) { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: .5rem 0 .2rem; font-size: .85rem; text-align: center; }
#login-check-status:not(:empty)::before, #registration-check-status:not(:empty)::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: var(--accent); animation: pulse-dot 1.4s ease-in-out infinite; }
#login-check-retry, #registration-check-retry { display: flex; margin: 0 auto .3rem; }
#signup-send-code { margin-top: 1rem; }
#send-code { margin-top: 0; }
/* Passkeys lead: the primary action. Signing in by email code follows a quiet divider as the secondary path. */
#passkey-login { width: 100%; margin-top: .9rem; }
.login-divider { display: flex; align-items: center; gap: .8rem; margin: 1.4rem 0 1.05rem; color: var(--subtle); font-size: .82rem; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-strong)); }
.login-divider::after { background: linear-gradient(90deg, var(--line-strong), transparent); }
#passkey-login[hidden] + .login-divider { display: none; }
#email-login-form:has(#passkey-login:not([hidden])) #send-code { min-height: 2.95rem; color: var(--ink); background: var(--raised); border-color: var(--line); box-shadow: var(--glass-rim); font-size: .96rem; font-weight: 500; }
#email-login-form:has(#passkey-login:not([hidden])) #send-code::after { display: none; }
@media (hover: hover) { #email-login-form:has(#passkey-login:not([hidden])) #send-code:hover:not(:disabled) { background: var(--raised-hover); border-color: var(--line-strong); box-shadow: var(--glass-rim), var(--shadow-md); } }
#passkey-login::before {
  content: ""; width: 1.15rem; height: 1.15rem; flex: none; background: currentColor;
  -webkit-mask: var(--i-fingerprint) center / contain no-repeat; mask: var(--i-fingerprint) center / contain no-repeat;
}
#passkey-login[aria-busy="true"]::before { -webkit-mask: none; mask: none; background: none; }

/* One-time code: six slots that light up as digits arrive. */
.otp-field { position: relative; margin-bottom: .9rem; }
#login-code {
  margin: 0; min-height: 3.6rem; padding-left: calc(1rem + .45em);
  font-family: var(--font-mono); font-size: 1.55rem; font-weight: 650; letter-spacing: .45em; text-align: center;
  font-variant-numeric: tabular-nums;
}
#login-code::placeholder { font-family: var(--font-sans); font-size: 1rem; font-weight: 400; letter-spacing: .05em; }
.otp-progress { display: flex; justify-content: center; gap: 7px; margin-top: .7rem; }
.otp-progress i { width: 26px; height: 4px; border-radius: 4px; background: var(--line); transition: background-color .3s var(--ease), transform .45s var(--ease-spring), box-shadow .3s var(--ease); }
.otp-field[data-filled="1"] .otp-progress i:nth-child(-n+1),
.otp-field[data-filled="2"] .otp-progress i:nth-child(-n+2),
.otp-field[data-filled="3"] .otp-progress i:nth-child(-n+3),
.otp-field[data-filled="4"] .otp-progress i:nth-child(-n+4),
.otp-field[data-filled="5"] .otp-progress i:nth-child(-n+5),
.otp-field[data-filled="6"] .otp-progress i { background: var(--accent); transform: scaleY(1.4); }
.otp-field[data-filled="6"] .otp-progress i { box-shadow: 0 0 10px rgb(var(--spot) / .7); }
#code-help { margin: 0 0 1rem; font-size: .86rem; text-align: center; }
.login-options { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .35rem .8rem; margin-top: .75rem; }
.login-options button { margin: 0; }
.return-home { display: flex; width: fit-content; margin: 1rem auto 0; color: var(--muted); }
.return-home::before {
  content: ""; width: .95rem; height: .95rem; background: currentColor; transition: transform .4s var(--ease-spring);
  -webkit-mask: var(--i-arrow-left) center / contain no-repeat; mask: var(--i-arrow-left) center / contain no-repeat;
}
@media (hover: hover) { .return-home:hover { color: var(--accent-text); } .return-home:hover::before { transform: translateX(-3px); } }


/* ── Server pages: device authorization, hand-off back to the client, expiry and errors ── */
/* Device ⇄ Bitflow: the dashed wire carries a steady flow while the request waits for approval. */
.consent-link { display: flex; align-items: center; justify-content: center; gap: .55rem; margin: 0 auto 1.15rem; }
.consent-node {
  display: grid; place-items: center; width: 2.9rem; height: 2.9rem; border-radius: 15px;
  color: var(--accent-text); background: var(--accent-soft); border: 1px solid rgb(var(--spot) / .32);
}
.consent-node .icon { width: 1.4rem; height: 1.4rem; }
.consent-link img { width: 2.9rem; height: 2.9rem; filter: drop-shadow(0 8px 16px #3cc8ff4d); }
.consent-wire {
  width: 3.6rem; height: 2px; border-radius: 2px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 11px) 0 0 / 11px 2px;
  animation: wire-flow .9s linear infinite;
}
@keyframes wire-flow { to { background-position: 11px 0; } }
.auth-card-heading .consent-account {
  display: inline-flex; align-items: center; gap: .45rem; max-width: 100%; margin: .15rem auto .75rem;
  padding: .32rem .85rem .32rem .6rem; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--raised); color: var(--ink-2); font-size: .86rem; overflow-wrap: anywhere;
}
.consent-account .icon { width: 1rem; height: 1rem; color: var(--accent-text); }
.consent-form { display: grid; gap: .7rem; }
.consent-form > .message { margin: 0; }
.consent-form .auth-primary .icon { width: 1.1rem; height: 1.1rem; }
.consent-devices { display: grid; gap: .6rem; }
button.entry-tile { width: 100%; font: inherit; cursor: pointer; }
.consent-device .entry-arrow { color: var(--danger); }
@media (hover: hover) { .consent-device:hover { border-color: var(--danger-line); } .consent-device:hover .entry-arrow { color: var(--danger); } }
.consent-cancel { justify-self: center; color: var(--muted); }

.status-page { text-align: center; }
.status-glyph {
  --tone: var(--accent-text);
  position: relative; display: grid; place-items: center; width: 3.7rem; height: 3.7rem; margin: 0 auto 1.15rem; border-radius: 50%;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent);
  box-shadow: 0 0 0 .5rem color-mix(in srgb, var(--tone) 7%, transparent);
  animation: pop-in .65s var(--ease-spring) .15s backwards;
}
.status-glyph .icon { width: 1.65rem; height: 1.65rem; }
[data-tone="wait"] > .status-glyph, .status-glyph[data-tone="wait"] { --tone: var(--warn); }
[data-tone="bad"] > .status-glyph, .status-glyph[data-tone="bad"] { --tone: var(--danger); }
[data-tone="ok"] > .status-glyph, .status-glyph[data-tone="ok"] { --tone: var(--ok); }
.status-page h1 { margin-bottom: .5rem; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.status-page > p { color: var(--muted); font-size: .95rem; line-height: 1.7; text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere; }
.status-actions { display: grid; gap: .6rem; margin-top: 1.5rem; }
.status-actions .button { min-height: 3rem; font-size: .98rem; }
/* Hand-off: a ring turns round the check mark while the browser returns to the app; the button stays as the way back. */
.handoff form { margin-top: 1.4rem; }
.handoff .meta { margin-top: .85rem; font-size: .84rem; }
.handoff .status-glyph::after {
  content: ""; position: absolute; inset: -.5rem; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--tone); border-right-color: color-mix(in srgb, var(--tone) 40%, transparent);
  animation: spin 1.1s linear infinite;
}

/* ── Theme reveal (theme.js): the new look spreads from the toggle as a circle. ── */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { animation: theme-reveal .75s var(--ease-out); }
@keyframes theme-reveal {
  from { clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0)); }
  to { clip-path: circle(var(--vt-r, 150vmax) at var(--vt-x, 50%) var(--vt-y, 0)); }
}

/* ── Motion ────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 50% { transform: translateY(-3px); } }
@keyframes breathe { 0%, 100% { opacity: .65; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.04); } }
@keyframes mark-in { from { opacity: 0; transform: perspective(600px) scale(.78) translateY(10px); } }
@keyframes card-in { from { opacity: 0; transform: translateY(22px) scale(.975); } }
@keyframes step-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.4); } 70% { transform: scale(1.12); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse-dot { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-height: 760px) and (min-width: 600px) {
  .auth-main { gap: 1.3rem; }
  .auth-mark { width: 96px; height: 96px; }
  .auth-card { padding: 1.8rem 2rem 1.4rem; }
  .auth-card-heading { margin-bottom: 1.25rem; }
}
@media (max-height: 640px) and (min-width: 600px) {
  .auth-mark { width: 76px; height: 76px; }
}
@media (max-width: 600px) {
  .auth-main { gap: 1.45rem; }
  .auth-mark { width: 96px; height: 96px; }
  .auth-card { padding: 1.8rem 1.3rem 1.35rem; border-radius: 26px; }
  .auth-card-heading { margin-bottom: 1.35rem; }
  .auth-card-heading h1 { font-size: 1.75rem; }
}
@media (max-width: 360px) {
  .auth-shell { padding-left: max(.75rem, env(safe-area-inset-left)); padding-right: max(.75rem, env(safe-area-inset-right)); }
  .auth-card { padding: 1.6rem 1rem 1.2rem; border-radius: 22px; }
  .entry-tile { gap: .8rem; padding-inline: .7rem .9rem; }
  .otp-progress i { width: 20px; }
}

/* ── Preferences ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .auth-mark { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --surface: var(--surface-solid); --surface-flat: var(--surface-solid); --glass-blur: none; --sky: var(--bg); }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --surface: var(--surface-solid); --surface-flat: var(--surface-solid); }
}
@media (prefers-contrast: more) {
  :root { --line: #a4bcff66; --line-soft: #a4bcff40; --muted: var(--ink-2); }
  :root[data-theme="light"] { --line: #1a2c5c66; --line-soft: #1a2c5c40; --muted: var(--ink-2); }
}
@media (forced-colors: active) {
  .gradient-text, .auth-card-heading h1, .usage-total, .brand span { background: none; -webkit-text-fill-color: currentColor; }
  .button, .round, .auth-primary, .auth-card, .signup-input, .message, .entry-tile { border: 1px solid ButtonText; }
  .auth-mark::before, .auth-mark::after, .auth-card::before, .button::after, .auth-primary::after, .entry-tile::after { display: none; }
  .otp-progress i { background: GrayText; }
  .otp-field[data-filled] .otp-progress i { forced-color-adjust: none; }
}
