:root {
  /* Match the app shell base scale (≈ browser zoom 125%). */
  zoom: 1.25;

  --bg: #07070a;
  --bg-left: #0a0a0d;
  --bg-right: #060608;
  --surface: #0e0e12;
  --surface-2: #131318;
  --line: #1d1d24;
  --line-soft: #16161c;
  --txt: #e9e7e6;
  --txt-mid: #8d8a90;
  --txt-dim: #5a5860;
  --txt-faint: #36353c;
  --red-h: 12;
  --red: oklch(0.52 0.16 var(--red-h));
  --red-bright: oklch(0.6 0.19 var(--red-h));
  --red-deep: oklch(0.4 0.13 var(--red-h));
  --red-glow: oklch(0.55 0.18 var(--red-h) / 0.35);
  --radius: 4px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  overflow-x: hidden;
}

::selection { background: var(--red-deep); color: #fff; }

/* ============ LAYOUT ============ */
.auth {
  flex: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 100vh;
}
body[data-layout="centered"] .auth { grid-template-columns: 1fr; }
body[data-layout="centered"] .brand { display: none; }
body[data-layout="centered"] .panel {
  background:
    radial-gradient(1200px 600px at 50% -10%, oklch(0.52 0.16 var(--red-h) / 0.08), transparent 60%),
    var(--bg-right);
}

/* ============ BRAND (LEFT) ============ */
.brand {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(900px 700px at 12% 8%, oklch(0.5 0.16 var(--red-h) / 0.13), transparent 55%),
    radial-gradient(700px 500px at 90% 95%, oklch(0.45 0.14 var(--red-h) / 0.08), transparent 60%),
    linear-gradient(160deg, var(--bg-left), #050507 70%);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(40px, 4.5vw, 76px);
}

/* background texture layers */
.brand .grid-layer,
.brand .depth-layer,
.brand .book-layer { position: absolute; inset: 0; pointer-events: none; }

.brand .grid-layer {
  background-image:
    linear-gradient(to right, var(--line-soft) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(120% 100% at 30% 30%, #000 20%, transparent 80%);
  mask-image: radial-gradient(120% 100% at 30% 30%, #000 20%, transparent 80%);
  opacity: 0.6;
}
body[data-pattern="off"] .grid-layer { display: none; }

.brand .depth-layer { opacity: 0.34; }
.brand .depth-layer svg { position: absolute; right: -4%; bottom: 0; width: 74%; height: 54%; }
body[data-pattern="grid"] .depth-layer,
body[data-pattern="book"] .depth-layer,
body[data-pattern="off"] .depth-layer { display: none; }

.brand .book-layer {
  left: auto; right: 0; width: 320px;
  display: flex; flex-direction: column; justify-content: center;
  gap: 3px; padding: 0 38px 0 0;
  -webkit-mask-image: linear-gradient(to left, #000, transparent 92%);
  mask-image: linear-gradient(to left, #000, transparent 92%);
  opacity: 0.45;
}
body[data-pattern="depth"] .book-layer,
body[data-pattern="grid"] .book-layer,
body[data-pattern="off"] .book-layer { display: none; }
.book-row {
  position: relative;
  display: flex; justify-content: space-between;
  font-size: 10px; letter-spacing: 0.04em;
  padding: 2.5px 10px; color: var(--txt-dim);
}
.book-row .bar {
  position: absolute; top: 0; right: 0; height: 100%;
  background: var(--bar-color); opacity: 0.5;
}
.book-row .px { position: relative; z-index: 1; }
.book-row .sz { position: relative; z-index: 1; color: var(--txt-faint); }
.book-row.ask { --bar-color: oklch(0.5 0.16 var(--red-h) / 0.5); }
.book-row.ask .px { color: var(--red-bright); }
.book-row.bid { --bar-color: #2a2a32; }
.book-spread {
  display: flex; justify-content: space-between;
  font-size: 9px; letter-spacing: 0.18em;
  color: var(--txt-faint); padding: 7px 10px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  margin: 4px 0;
}

.brand-inner { position: relative; z-index: 2; }

/* logo */
.logo { display: flex; align-items: center; gap: 16px; }
.logo .mark {
  width: 46px; height: 46px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 1px);
  background: linear-gradient(150deg, var(--surface-2), #08080b);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 6px 24px -12px var(--red-glow);
  overflow: hidden;
}
.logo .mark svg { width: 30px; height: 30px; display: block; }
.logo .mark .mark-logo { width: 122%; height: 122%; object-fit: contain; display: block; transform: translateY(-4px); }
.logo .word {
  font-size: 21px; font-weight: 600; letter-spacing: -0.01em;
  line-height: 1;
}
.logo .word b { font-weight: 600; color: var(--txt); }
.logo .word span { color: var(--red-bright); font-weight: 500; }
.logo .word small {
  display: block; font-size: 9.5px; font-weight: 500;
  letter-spacing: 0.34em; color: var(--txt-dim);
  margin-top: 7px; text-indent: 1px;
}

/* brand body */
.brand-mid { position: relative; z-index: 2; max-width: 30ch; }
.brand-mid .eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 10.5px; letter-spacing: 0.26em; color: var(--txt-mid);
  margin-bottom: 26px;
}
.brand-mid .eyebrow::before {
  content: ""; width: 22px; height: 1px; background: var(--red);
}
.brand-mid h1 {
  font-size: clamp(28px, 2.7vw, 42px);
  font-weight: 500; line-height: 1.2; letter-spacing: -0.02em;
  color: var(--txt); text-wrap: balance;
}
.brand-mid h1 em {
  font-style: normal; color: var(--red-bright); font-weight: 600;
}
.brand-mid p {
  margin-top: 22px; font-size: 14.5px; line-height: 1.75;
  color: var(--txt-mid); max-width: 40ch; font-weight: 400;
}

/* brand footer status */
.brand-foot { position: relative; z-index: 2; }
.status-line {
  display: flex; align-items: center; gap: 12px;
  font-size: 11.5px; letter-spacing: 0.08em; color: var(--txt-mid);
}
.status-line .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--red-bright); box-shadow: 0 0 0 0 var(--red-glow);
  animation: pulse 2.6s var(--ease) infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 oklch(0.6 0.19 var(--red-h) / 0.5); }
  70% { box-shadow: 0 0 0 7px oklch(0.6 0.19 var(--red-h) / 0); }
  100% { box-shadow: 0 0 0 0 oklch(0.6 0.19 var(--red-h) / 0); }
}
.status-line b { color: var(--txt-mid); font-weight: 500; }

/* ============ PANEL (RIGHT) ============ */
.panel {
  position: relative;
  background: var(--bg-right);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: clamp(32px, 4vw, 64px);
}

.card {
  width: 100%; max-width: 392px;
  display: flex; flex-direction: column;
}

.badge {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10.5px; letter-spacing: 0.2em; color: var(--txt-mid);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 7px 14px 7px 12px; margin-bottom: 30px;
  background: linear-gradient(var(--surface), #0a0a0d);
}
.badge .lk {
  width: 11px; height: 11px; display: block;
}
.badge .lk svg { width: 11px; height: 11px; display: block; stroke: var(--red-bright); }

.card h2 {
  font-size: 24px; font-weight: 600; letter-spacing: -0.015em;
  margin-bottom: 7px;
}
.card .sub {
  font-size: 13.5px; color: var(--txt-mid); font-weight: 400;
  margin-bottom: 28px; line-height: 1.55;
}

/* tabs */
.tabs {
  position: relative; display: flex; gap: 4px;
  border-bottom: 1px solid var(--line); margin-bottom: 28px;
}
.tabs button {
  flex: 1; appearance: none; background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--txt-dim); padding: 0 0 14px; transition: color 0.3s var(--ease);
}
.tabs button.active { color: var(--txt); }
.tabs .ink {
  position: absolute; bottom: -1px; left: 0; height: 1px; width: 50%;
  background: var(--red-bright);
  box-shadow: 0 0 12px var(--red-glow);
  transition: transform 0.4s var(--ease);
}
.tabs[data-tab="register"] .ink { transform: translateX(100%); }

/* form */
form { display: flex; flex-direction: column; gap: 17px; }
.pane { display: flex; flex-direction: column; gap: 17px; }
.pane[hidden] { display: none; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
label {
  font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--txt-mid); display: flex; justify-content: space-between;
  align-items: center;
}
label .opt { color: var(--txt-faint); letter-spacing: 0.1em; }
.input-wrap { position: relative; display: flex; align-items: center; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; appearance: none;
  background: var(--surface); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: inherit; font-size: 14px; letter-spacing: 0.01em;
  padding: 13px 14px; transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
input::placeholder { color: var(--txt-faint); letter-spacing: 0.02em; }
input:focus {
  outline: none; border-color: var(--red);
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--red-deep), 0 0 24px -6px var(--red-glow);
}
.input-wrap .reveal {
  position: absolute; right: 4px; background: none; border: none; cursor: pointer;
  color: var(--txt-dim); padding: 8px; display: grid; place-items: center;
  transition: color 0.2s;
}
.input-wrap .reveal:hover { color: var(--txt-mid); }
.input-wrap .reveal svg { width: 15px; height: 15px; display: block; }

/* 2fa segments */
.otp { display: flex; gap: 8px; }
.otp input {
  width: 100%; text-align: center; padding: 12px 0;
  font-size: 15px; letter-spacing: 0.1em; color: var(--txt);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.otp input:focus {
  outline: none; border-color: var(--red); background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--red-deep);
}

.row-between {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; gap: 12px;
}
.check {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  color: var(--txt-mid); user-select: none; white-space: nowrap;
}
.row-between a.link { white-space: nowrap; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 15px; height: 15px; border: 1px solid var(--line);
  border-radius: 3px; display: grid; place-items: center;
  background: var(--surface); transition: all 0.2s;
}
.check .box svg { width: 9px; height: 9px; opacity: 0; transition: opacity 0.15s; stroke: #fff; }
.check input:checked + .box {
  background: var(--red); border-color: var(--red-bright);
}
.check input:checked + .box svg { opacity: 1; }
a.link {
  color: var(--txt-mid); text-decoration: none;
  border-bottom: 1px solid transparent; transition: color 0.2s, border-color 0.2s;
}
a.link:hover { color: var(--red-bright); border-color: var(--red-deep); }

/* primary button */
.btn {
  appearance: none; cursor: pointer; width: 100%;
  font-family: inherit; font-size: 12px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  padding: 15px; border-radius: var(--radius); border: 1px solid var(--red-bright);
  color: #fff; margin-top: 4px;
  background: linear-gradient(180deg, var(--red), var(--red-deep));
  box-shadow: 0 8px 30px -10px var(--red-glow), inset 0 1px 0 oklch(0.7 0.19 var(--red-h) / 0.4);
  transition: transform 0.12s var(--ease), box-shadow 0.25s, filter 0.2s;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn:hover { filter: brightness(1.08); box-shadow: 0 12px 38px -10px var(--red-glow), inset 0 1px 0 oklch(0.7 0.19 var(--red-h) / 0.4); }
.btn:active { transform: translateY(1px); }
.btn .arr { transition: transform 0.25s var(--ease); }
.btn:hover .arr { transform: translateX(3px); }

.divider {
  display: flex; align-items: center; gap: 14px;
  color: var(--txt-faint); font-size: 9.5px; letter-spacing: 0.2em;
  margin: 4px 0 2px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line-soft);
}

.switch-line {
  text-align: center; font-size: 12px; color: var(--txt-dim); white-space: nowrap;
}
.switch-line button {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; color: var(--red-bright); padding: 0; margin-left: 4px;
  border-bottom: 1px solid transparent; transition: border-color 0.2s;
  white-space: nowrap;
}
.switch-line button:hover { border-color: var(--red-deep); }

/* form-level error message */
.form-error {
  font-size: 11px; letter-spacing: 0.02em; line-height: 1.5;
  color: var(--red-bright);
  background: oklch(0.5 0.16 var(--red-h) / 0.08);
  border: 1px solid var(--red-deep); border-radius: var(--radius);
  padding: 10px 12px;
}
.field-error { font-size: 10px; color: var(--red-bright); letter-spacing: 0.02em; }
input.has-error { border-color: var(--red); }

/* confirm-in-telegram screen */
.tg-confirm { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 8px 0 4px; }
.tg-confirm[hidden] { display: none; }

/* sign-in method toggle (Password / Telegram) */
form[hidden] { display: none; }
.method-toggle {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.method-toggle button {
  flex: 1; appearance: none; cursor: pointer; font-family: inherit;
  font-size: 11px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 10px; border: none; border-radius: calc(var(--radius) - 1px);
  background: none; color: var(--txt-dim); transition: color 0.2s, background 0.2s;
}
.method-toggle button.active { color: var(--txt); background: var(--surface-3); }
.method-toggle button:hover:not(.active) { color: var(--txt-mid); }
.tg-confirm .tg-icon {
  width: 54px; height: 54px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: linear-gradient(150deg, var(--surface-2), #08080b);
  color: var(--red-bright);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 6px 24px -12px var(--red-glow);
}
.tg-confirm .tg-icon svg { width: 24px; height: 24px; }
.tg-confirm h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.tg-confirm .tg-sub { font-size: 12.5px; color: var(--txt-mid); line-height: 1.6; font-weight: 400; max-width: 32ch; }
.tg-confirm .tg-sub b { color: var(--txt); font-weight: 500; }
.tg-confirm .btn { margin-top: 2px; }
.tg-status {
  display: flex; align-items: center; gap: 10px; margin-top: 4px;
  font-size: 11.5px; color: var(--txt-mid);
}
.tg-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--red-bright);
  box-shadow: 0 0 0 0 var(--red-glow); animation: pulse 2.6s var(--ease) infinite;
}
.tg-status .tg-timer { color: var(--txt-dim); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }
.tg-restart {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 11.5px; color: var(--txt-dim); padding: 4px; transition: color 0.2s;
}
.tg-restart:hover { color: var(--red-bright); }

/* language switch (top-right of the panel) */
.panel .lang-switch {
  position: absolute; top: 18px; right: clamp(24px, 4vw, 48px); z-index: 5;
  display: flex; gap: 4px;
}
.lang-switch a {
  font-size: 10px; letter-spacing: 0.08em; color: var(--txt-dim); text-decoration: none;
  padding: 5px 9px; border: 1px solid var(--line); border-radius: 4px;
  background: linear-gradient(var(--surface), #0a0a0d); transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.lang-switch a:hover { color: var(--txt-mid); }
.lang-switch a.active { color: var(--txt); background: var(--surface-2); border-color: var(--line); }

/* language scramble animation */
html.lang-scrambling body { opacity: 0; }
@keyframes dp-shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 50%{transform:translateX(3px)} 75%{transform:translateX(-2px)} }
.lang-switch.cooldown { animation: dp-shake 0.38s ease; }
.lang-hint {
  position: fixed; z-index: 300; font-size: 10.5px; letter-spacing: 0.03em;
  color: var(--txt); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; pointer-events: none;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s;
  box-shadow: 0 10px 30px -12px #000;
}
.lang-hint.show { opacity: 1; transform: translateY(0); }

/* panel footer */
.panel-foot {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px clamp(32px, 4vw, 64px);
  font-size: 10px; letter-spacing: 0.06em; color: var(--txt-faint);
  border-top: 1px solid var(--line-soft);
}
.panel-foot nav { display: flex; gap: 20px; }
.panel-foot nav a {
  color: var(--txt-dim); text-decoration: none; transition: color 0.2s;
}
.panel-foot nav a:hover { color: var(--txt-mid); }

/* entrance */
.reveal-in { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .status-line .dot { animation: none; }
}

@media (max-width: 920px) {
  .auth { grid-template-columns: 1fr; }
  .brand { display: none; }
  .panel { background:
    radial-gradient(1000px 500px at 50% -10%, oklch(0.52 0.16 var(--red-h) / 0.1), transparent 60%),
    var(--bg-right); }
  .panel-foot { position: static; margin-top: 36px; }
}
