:root {
  --bg: #000000;
  --fg: #e8e8e8;
  --dim: #6b6b6b;
  --accent: #00ff66;
  --error: #ff3b3b;
  --border: #2a2a2a;
  --panel: #060606;

  /* config: block resize animation (e.g. login-box growing for the OTP step) */
  --resize-duration: 480ms;
  --resize-curve: cubic-bezier(0.22, 1, 0.36, 1);

  /* config: staggered entrance fade-in for the info/login panels */
  --entrance-duration: 600ms;
  --entrance-curve: cubic-bezier(0.16, 1, 0.3, 1);
  --entrance-delay-min: 500ms;
  --entrance-delay-max: 2000ms;

  /* config: pause between steps of the login-success sequence */
  --sequence-delay: 0ms;

  /* config: wizard step swap — old rows fade out, pause, new rows fade in;
     every element picks its own random duration within [min, max] */
  --step-fade-min: 50ms;
  --step-fade-max: 500ms;
  --step-fade-gap: 50ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono",
    Menlo, Consolas, "Liberation Mono", monospace;
  overflow: hidden;
}

a { color: inherit; }

/* staggered entrance: panels fade in with a random per-element delay (see script) */
.fade-in {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--entrance-duration) var(--entrance-curve),
              transform var(--entrance-duration) var(--entrance-curve);
}
.fade-in.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- flight-tunnel background ---------- */

#bgCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
}

/* ---------- fixed topbar — independent of content ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(16px, 3vh, 28px) clamp(20px, 4vw, 48px);
  font-size: clamp(11px, 1.4vh, 13px);
  letter-spacing: 0.08em;
  color: var(--dim);
  z-index: 5;
}
.topbar .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  margin-right: 0.5em;
  vertical-align: middle;
}
button.toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--dim);
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  padding: 0.4em 0.9em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
button.toggle-btn:hover { color: var(--accent); border-color: var(--accent); }
button.toggle-btn.is-active { color: var(--accent); border-color: var(--accent); }
/* logged in, the row reads: $ whoami [user:<email>] [./logout] … [info][about][manual] —
   the pane tabs move to the right edge; logged out they stay next to the prompt */
.prompt-row:has(#userToggle:not([hidden])) #infoToggle { margin-left: auto; }
#logoutBtn:hover { color: var(--error); border-color: var(--error); }

.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 5vw, 64px);
  padding: clamp(64px, 10vh, 96px) clamp(20px, 4vw, 48px) clamp(16px, 3vh, 32px);
}

/* ---------- info (left) ---------- */

.info {
  flex: 0 1 560px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(16px, 3vh, 32px) clamp(20px, 4vw, 40px);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(2px);
}

.info-body {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 16px);
}

.prompt-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.prompt {
  font-size: clamp(12px, 1.6vh, 15px);
  color: var(--accent);
}
.prompt::before { content: "$ "; color: var(--dim); }

h1 {
  margin: 0.2em 0 0;
  font-size: clamp(26px, 6vh, 54px);
  line-height: 1.05;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.tagline {
  margin: 0;
  max-width: 50ch;
  font-size: clamp(13px, 1.7vh, 16px);
  color: var(--fg);
  line-height: 1.5;
}
.tagline b { color: #fff; }

.points {
  margin: 0.4em 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  font-size: clamp(12px, 1.4vh, 13px);
  color: var(--fg);
  max-width: 52ch;
}
.points li { line-height: 1.45; }
.points .tag {
  color: var(--accent);
  margin-right: 0.6em;
}
.points .tag::before { content: "["; color: var(--border); }
.points .tag::after { content: "]"; color: var(--border); }

/* info/about/user/manual pane swap — the .info panel resizes around them
   (animated smoothly via animateResize(), same technique as the login panel) */
.toggle-stack > .info-content,
.toggle-stack > .about-content,
.toggle-stack > .user-content,
.toggle-stack > .manual-content {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 16px);
}
.toggle-stack > .is-hidden { display: none; }

/* shared key/value row list — used by the about pane and the user/account pane */
.kv-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 0.4em; font-size: 13px; }
.kv-rows .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.kv-rows .row span:first-child { color: var(--dim); }
.kv-rows .row a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--border); }
.kv-rows .row a:hover { color: var(--accent); border-color: var(--accent); }

/* user/manual panes: pane content with the accent-tinted QR alongside */
.user-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: clamp(14px, 2.5vw, 28px);
}
.user-grid .kv-rows,
.user-grid .points { flex: 1 1 220px; min-width: 0; }
.qr-box {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 0.4em;
  text-decoration: none;
}
.qr-box[hidden] { display: none; }
/* the SVG paths use fill: currentColor, so `color` here is what tints the QR */
.qr-svg {
  display: block;
  width: clamp(104px, 17vh, 140px);
  aspect-ratio: 1;
  color: var(--accent);
  border: 1px solid var(--border);
  background: rgba(0, 255, 102, 0.05);
}
.qr-svg svg { display: block; width: 100%; height: 100%; }
.qr-box:hover .qr-svg { border-color: var(--accent); }
.qr-caption { font-size: 10px; letter-spacing: 0.1em; color: var(--dim); }
.qr-caption::before { content: "[ "; color: var(--border); }
.qr-caption::after { content: " ]"; color: var(--border); }
.qr-box:hover .qr-caption { color: var(--accent); }

/* telegram linking block in the user pane */
.tg-link { display: flex; flex-direction: column; gap: 8px; }
.tg-link[hidden] { display: none; }
.tg-link-notice {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.tg-link-notice::before { content: "> "; }
.tg-link-status {
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--error);
}
.tg-link-status::before { content: "! "; }
.tg-link-status.is-ok { color: var(--accent); }
.tg-link-status.is-ok::before { content: "> "; }

/* manual pane: the logged-in panel is wide, so the steps use all of it
   (the 52ch cap is for the info pane) and read a bit larger */
.manual-content .points {
  max-width: none;
  font-size: clamp(12px, 1.6vh, 14px);
  gap: 0.8em;
}

/* manual pane: plain links (stores, INCY) + inline ./commands */
.manual-content .points a:not(.cmd-inline) {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.manual-content .points a:not(.cmd-inline):hover { color: var(--accent); border-color: var(--accent); }
.manual-links a { margin-right: 0.6em; }
.cmd-inline {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
}
.cmd-inline:hover { background: var(--accent); color: #000; }

/* ---------- login (right) ---------- */

.login {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.login-box {
  /* fixed width (capped on small screens) so an auto-sizing input growing as the
     user types can't widen the box and shift the centered layout */
  width: 340px;
  max-width: 100%;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border);
  backdrop-filter: blur(2px);
}

.cta-telegram {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0.9em 1.4em;
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  font-size: clamp(13px, 1.6vh, 15px);
  letter-spacing: 0.06em;
  transition: background 0.3s ease, color 0.3s ease;
}
.cta-telegram:hover { background: var(--accent); color: #000; transition: none; }
.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
.cta-telegram:hover .cursor { background: #000; }
@keyframes blink { 50% { opacity: 0; } }

.divider {
  display: flex;
  align-items: center;
  gap: 0.6em;
  color: var(--border);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
}
/* terminal-style input line — same box as the buttons, with a faint accent
   tint so fields read as editable. A fixed "./cmd" prefix (white, smaller)
   reads as the prompt, with a blinking square caret while the line is empty. */
.auth-line {
  display: flex;
  align-items: center;
  width: 100%;
  /* tighter horizontal padding than the buttons: the prompt hugs the left
     edge, leaving more room for the typed value */
  padding: 0.9em 0.7em;
  background: rgba(0, 255, 102, 0.07);
  border: 1px solid var(--accent);
  font-size: clamp(13px, 1.6vh, 15px);
  letter-spacing: 0.06em;
  cursor: text;
  overflow: hidden;
}
.auth-cmd {
  flex: 0 0 auto;
  margin-right: 0.5em;
  color: #fff;
  font-size: 0.85em;
  white-space: nowrap;
  cursor: text;
}
/* the input fills the whole line so a click anywhere in the field lands on it
   (Chrome only opens its autofill popup on clicks on the input itself) */
.auth-input {
  flex: 1 1 auto;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  padding: 0;
  font: inherit;
  letter-spacing: 0;
  color: var(--accent);
  caret-color: var(--accent);
}
.auth-input::placeholder { color: var(--dim); }
@supports (caret-shape: block) {
  .auth-input { caret-shape: block; }
}
/* decorative square caret after the "./cmd" prompt, shown only while the field
   is empty and unfocused; once focused the native caret takes over (inputs
   carry placeholder=" " so :placeholder-shown means "empty") */
.auth-line .cursor { flex: 0 0 auto; }
.auth-line:focus-within .cursor,
.auth-line:has(.auth-input:not(:placeholder-shown)) .cursor { display: none; }
/* Chrome's autofill repaint: keep the field's tinted background with accent
   text (#001207 ≈ the accent tint composited over black) */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--accent);
  -webkit-box-shadow: 0 0 0 1000px #001207 inset;
  box-shadow: 0 0 0 1000px #001207 inset;
}

.auth-btn,
.auth-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  width: 100%;
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font: inherit;
  font-size: clamp(13px, 1.6vh, 15px);
  letter-spacing: 0.06em;
  padding: 0.9em 1.4em;
  cursor: pointer;
  transition: background 0.3s ease, color 0.3s ease;
}
/* lights up instantly, the base transition only plays the fade-out */
.auth-btn:hover,
.auth-back:hover { background: var(--accent); color: #000; transition: none; }

/* error state: the offending button glows red, with a matching message below */
.auth-btn.is-error {
  border-color: var(--error);
  color: var(--error);
}
.auth-btn.is-error:hover { background: var(--error); color: #000; }

.auth-error {
  display: none;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--error);
}
.auth-error.is-visible { display: block; }
.auth-error::before { content: "! "; }
/* neutral notice variant (e.g. "code already sent") in the same slot */
.auth-error.is-info { color: var(--accent); }
.auth-error.is-info::before { content: "> "; }

/* two-step wizard: "choose" shows the method buttons (signin/signup/restore),
   "entry" shows the chosen method's field plus the back-arrow + submit row */
.auth-methods { display: flex; flex-direction: column; gap: 8px; }
.auth-entry { display: flex; align-items: center; gap: 8px; }
.auth-back { flex: 0 0 auto; width: auto; padding: 0.9em 1em; gap: 0; }
/* hover expands the button into its shell-alias definition: ../='go back' */
.back-alias {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: max-width 0.3s ease;
}
.auth-back:hover .back-alias { max-width: 11ch; }
.auth-entry .auth-btn { flex: 1; width: auto; white-space: nowrap; }

.auth-extra,
.auth-form:not([data-step="choose"]) .auth-methods,
.auth-form[data-step="choose"] .auth-entry { display: none; }

/* entry: signin -> password, signup/restore -> code; setpw -> password + repeat */
.auth-form[data-step="entry"][data-mode="signin"] .auth-extra[data-mode="signin"],
.auth-form[data-step="entry"][data-mode="signup"] .auth-extra[data-mode="code"],
.auth-form[data-step="setpw"] .auth-extra[data-mode="setpw"] { display: flex; }

/* eye toggle for password lines — pinned to the line's right edge */
.eye-btn {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 0 0 0.6em;
  background: none;
  border: none;
  font-size: 14px;
  line-height: 1;
  color: var(--dim);
  cursor: pointer;
  opacity: 0.6;
}
.eye-btn:hover,
.eye-btn[aria-pressed="true"] { opacity: 1; }

.hint {
  font-size: 11px;
  color: var(--border);
}


/* ---------- mobile ---------- */

@media (max-width: 768px) {
  html, body { height: auto; overflow: auto; }
  .topbar { position: static; padding: 16px clamp(20px, 6vw, 32px); }
  .app {
    height: auto;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
  }
  .info { flex: none; border-bottom: 1px solid var(--border); padding: 24px clamp(20px, 6vw, 32px); }
  .login { padding: 32px clamp(20px, 6vw, 32px) 40px; }
  h1 { font-size: clamp(28px, 9vw, 40px); }
}
