:root {
  --bg: #0c0f14;
  --bg-1: #111520;
  --bg-2: #161b28;
  --bg-3: #1c2235;
  --surface: #1a2030;
  --surface-2: #202840;
  --border: rgba(255, 255, 255, 0.06);
  --border-2: rgba(255, 255, 255, 0.1);
  --text-1: #eef2ff;
  --text-2: #8b93ad;
  --text-3: #5a6278;
  --accent: #3ecfb2;
  --accent-dim: rgba(62, 207, 178, 0.15);
  --accent-glow: rgba(62, 207, 178, 0.35);
  --green: #089981;
  --green-dim: rgba(8, 153, 129, 0.12);
  --amber: #f5a623;
  --amber-dim: rgba(245, 166, 35, 0.12);
  --red: #f23645;
  --red-dim: rgba(242, 54, 69, 0.12);
  --blue: #5b8fff;
  --blue-dim: rgba(91, 143, 255, 0.12);
  --ink: var(--text-1);
  --muted: rgba(223, 232, 255, 0.7);
  --line: var(--border-2);
  --panel: rgba(17, 21, 32, 0.96);
  --focus: rgba(62, 207, 178, 0.55);
  --good: #78f6c2;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body.no-scroll {
  overflow: hidden;
}

/* ─── Layout shell ─────────────────────────────── */

.scene {
  height: 100svh;
  width: 100%;
  overflow: hidden;
}

.device-wrap {
  position: relative;
  height: 100svh;
  overflow: hidden;
}

.phone {
  position: relative;
  width: 100%;
  height: 100svh;
  border-radius: 0;
  overflow: hidden;
  padding: 0;
  background: var(--bg-1);
  display: flex;
  flex-direction: column;
}

@media (prefers-reduced-motion: reduce) {
  .chat-fab,
  .community-backdrop,
  .community-card,
  .assistant-backdrop,
  .assistant-panel,
  .assistant-msg-dot,
  .auth-modal,
  .auth-modal-card {
    transition: none !important;
    animation: none !important;
  }
}

/* ─── Auth panel (inside modal) ────────────────── */

.auth-panel {
  position: relative;
  z-index: 2;
  margin-top: 0;
  border-radius: 0 0 24px 24px;
  border: 1px solid var(--line);
  border-top: 0;
  background: linear-gradient(
    145deg,
    rgba(13, 28, 58, 0.98),
    rgba(11, 20, 42, 0.99) 60%,
    rgba(10, 20, 42, 0.99)
  );
  box-shadow:
    0 20px 44px rgba(5, 11, 25, 0.68),
    inset 0 -1px 0 rgba(239, 248, 255, 0.08);
  backdrop-filter: blur(12px);
  padding: 20px 16px 20px;
}

.auth-head {
  display: grid;
  gap: 3px;
  margin-bottom: 14px;
  position: relative;
  padding-right: 60px;
}

.kicker {
  margin: 0;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: rgba(175, 206, 255, 0.92);
}

.auth-title {
  margin: 0;
  font-size: 1.14rem;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.auth-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* ─── View switch tabs ─────────────────────────── */

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-radius: 14px;
  background: rgba(11, 23, 48, 0.72);
  border: 1px solid rgba(220, 233, 255, 0.14);
  padding: 4px;
  gap: 4px;
}

.switch-btn {
  border: 0;
  border-radius: 10px;
  color: rgba(213, 228, 255, 0.72);
  background: transparent;
  font-family: inherit;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  min-height: 34px;
  cursor: pointer;
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    box-shadow 0.25s ease;
}

.switch-btn.is-active {
  color: #ffffff;
  background: linear-gradient(
    140deg,
    rgba(84, 214, 255, 0.96),
    rgba(66, 109, 255, 0.94)
  );
  box-shadow: 0 8px 16px rgba(51, 107, 238, 0.36);
}

/* ─── Focus ring ────────────────────────────────── */

.chat-fab:focus-visible,
.community-close:focus-visible,
.community-action:focus-visible,
.assistant-head-btn:focus-visible,
.assistant-reset-action:focus-visible,
.assistant-reset-link:focus-visible,
.assistant-send:focus-visible,
.assistant-input:focus-visible,
.assistant-reset-input:focus-visible,
.switch-btn:focus-visible,
.auth-link:focus-visible,
.toggle-pass:focus-visible,
.cta:focus-visible,
.remember input:focus-visible,
.preview-trade-btn:focus-visible,
.preview-auth-btn:focus-visible,
.preview-lot-input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ─── Views ─────────────────────────────────────── */

.views {
  margin-top: 10px;
}

.auth-view {
  display: none;
}

.auth-view.is-active {
  display: block;
  animation: auth-view-enter 0.24s ease;
}

@keyframes auth-view-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── Forms ─────────────────────────────────────── */

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-form[hidden] {
  display: none !important;
}

.field-wrap {
  display: grid;
  gap: 6px;
}

.auth-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(210, 226, 255, 0.7);
  font-weight: 600;
}

.input-row {
  position: relative;
}

.auth-input {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(206, 225, 255, 0.2);
  background: rgba(8, 16, 34, 0.62);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 12px;
  transition:
    border-color 0.22s ease,
    box-shadow 0.22s ease;
}

.auth-input::placeholder {
  color: rgba(213, 228, 255, 0.42);
}

.auth-input:focus {
  border-color: rgba(83, 212, 255, 0.85);
  box-shadow: 0 0 0 3px rgba(83, 212, 255, 0.18);
  outline: none;
}

.toggle-pass {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  border: 1px solid rgba(218, 234, 255, 0.24);
  border-radius: 999px;
  min-width: 56px;
  height: 30px;
  padding: 0 10px;
  background: rgba(14, 29, 60, 0.86);
  color: rgba(221, 236, 255, 0.9);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.72rem;
  color: rgba(215, 230, 255, 0.82);
}

.remember input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  margin: 0;
}

.auth-link {
  border: 0;
  background: none;
  color: rgba(182, 214, 255, 0.92);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dashed rgba(162, 204, 255, 0.68);
  cursor: pointer;
  padding: 0;
}

.auth-link:hover {
  color: #ffffff;
  border-bottom-color: rgba(83, 212, 255, 0.96);
}

.cta {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(
    125deg,
    rgba(82, 214, 255, 1),
    rgba(62, 106, 255, 1)
  );
  color: #ffffff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(46, 103, 238, 0.35);
  transition:
    transform 0.18s ease,
    filter 0.18s ease;
}

.cta:hover {
  filter: brightness(1.05);
}

.cta:active {
  transform: translateY(1px);
}

.cta.is-busy {
  opacity: 0.82;
  cursor: wait;
}

.feedback {
  margin: 8px 0 0;
  min-height: 1.35em;
  font-size: 0.72rem;
  color: rgba(200, 220, 255, 0.76);
}

.feedback.ok {
  color: var(--good);
}

.feedback.error {
  color: #ff9f9f;
}

.view-foot {
  margin-top: 10px;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(196, 218, 255, 0.8);
}

.prototype-note {
  margin: 12px 0 0;
  font-size: 0.65rem;
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(191, 209, 240, 0.6);
}

/* ─── Auth dashboard (post-login) ──────────────── */

.auth-dashboard {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.auth-access[hidden],
.auth-dashboard[hidden] {
  display: none !important;
}

.dashboard-card {
  border-radius: 14px;
  border: 1px solid rgba(206, 227, 255, 0.22);
  background: rgba(12, 25, 52, 0.58);
  padding: 12px;
}

.dashboard-title {
  margin: 0;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
}

.dashboard-subtitle {
  margin: 5px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  gap: 8px;
}

.dashboard-item {
  border-radius: 12px;
  border: 1px solid rgba(209, 229, 255, 0.18);
  background: rgba(9, 18, 38, 0.55);
  padding: 10px 11px;
  display: grid;
  gap: 4px;
}

.dashboard-item-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(189, 212, 247, 0.72);
  font-weight: 600;
}

.dashboard-item-value {
  font-size: 0.86rem;
  color: rgba(237, 245, 255, 0.96);
  font-weight: 600;
  word-break: break-word;
}

.logout-cta {
  margin-top: 4px;
}

/* ─── Reset stage ───────────────────────────────── */

.reset-stage-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.reset-stage-hint {
  margin: 2px 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(188, 214, 255, 0.88);
}

.reset-stage-hint[hidden] {
  display: none !important;
}

/* ─── Referrer lock badge ───────────────────────── */

.referrer-lock-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(120, 205, 255, 0.34);
  background: linear-gradient(
    135deg,
    rgba(21, 41, 82, 0.88),
    rgba(10, 24, 54, 0.78)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 10px 24px rgba(8, 18, 37, 0.28);
}

.referrer-lock-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(111, 228, 255, 0.42),
    rgba(55, 107, 255, 0.18)
  );
  color: rgba(213, 239, 255, 0.96);
  flex: 0 0 auto;
}

.referrer-lock-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.referrer-lock-label {
  margin: 0;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(181, 214, 255, 0.78);
  font-weight: 700;
}

.referrer-lock-value {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(245, 250, 255, 0.98);
  font-weight: 700;
  word-break: break-word;
}

.referrer-lock-note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.38;
  color: rgba(191, 218, 255, 0.86);
}

/* ─── Chat FAB ──────────────────────────────────── */

.chat-fab {
  position: fixed;
  z-index: 42;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(105px + env(safe-area-inset-bottom, 0px));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(196, 225, 255, 0.34);
  background: linear-gradient(
    140deg,
    rgba(86, 220, 255, 0.96),
    rgba(63, 106, 255, 0.96)
  );
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(38, 98, 231, 0.38);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

.chat-fab:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.chat-fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Community modal ───────────────────────────── */

.community-modal,
.assistant-chat {
  position: fixed;
  inset: 0;
  z-index: 52;
}

.assistant-chat {
  z-index: 58;
}

.community-modal[hidden],
.assistant-chat[hidden] {
  display: none;
}

.community-backdrop,
.assistant-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 11, 26, 0.68);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.community-card {
  position: absolute;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 14px) scale(0.985);
  width: min(92vw, 420px);
  border-radius: 22px;
  border: 1px solid rgba(198, 224, 255, 0.2);
  background: linear-gradient(
    150deg,
    rgba(12, 25, 53, 0.96),
    rgba(10, 20, 44, 0.98)
  );
  box-shadow: 0 22px 44px rgba(4, 8, 20, 0.64);
  padding: 14px;
  opacity: 0;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
}

.community-modal.is-open .community-backdrop,
.assistant-chat.is-open .assistant-backdrop {
  opacity: 1;
}

.community-modal.is-open .community-card {
  transform: translate(-50%, 0) scale(1);
  opacity: 1;
}

.community-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.community-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.community-close {
  border: 1px solid rgba(198, 224, 255, 0.3);
  background: rgba(235, 245, 255, 0.06);
  color: rgba(227, 240, 255, 0.95);
  width: 32px;
  height: 32px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
}

.community-note {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: rgba(201, 220, 255, 0.74);
}

.community-list {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.community-action {
  border-radius: 14px;
  border: 1px solid rgba(198, 224, 255, 0.24);
  background: rgba(13, 29, 59, 0.84);
  color: rgba(228, 239, 255, 0.96);
  min-height: 44px;
  padding: 0 12px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    filter 0.2s ease;
}

.community-action:hover {
  border-color: rgba(89, 214, 255, 0.72);
  transform: translateY(-1px);
}

.community-action.ai {
  background: linear-gradient(
    130deg,
    rgba(95, 228, 255, 0.96),
    rgba(65, 109, 255, 0.97)
  );
  color: #fff;
  border-color: rgba(201, 230, 255, 0.54);
  box-shadow: 0 14px 24px rgba(39, 99, 236, 0.34);
  font-weight: 700;
}

/* ─── Assistant panel ───────────────────────────── */

.assistant-panel {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(198, 224, 255, 0.22);
  background:
    radial-gradient(
      70% 50% at 85% -10%,
      rgba(74, 132, 255, 0.26),
      transparent 70%
    ),
    linear-gradient(180deg, rgba(11, 23, 49, 0.98), rgba(8, 18, 39, 0.99));
  transform: translateY(12px);
  opacity: 0;
  transition:
    transform 0.22s ease,
    opacity 0.22s ease;
  display: flex;
  flex-direction: column;
}

.assistant-chat.is-open .assistant-panel {
  transform: none;
  opacity: 1;
}

.assistant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px 10px;
  border-bottom: 1px solid rgba(194, 221, 255, 0.2);
  background: rgba(10, 21, 46, 0.88);
}

.assistant-head h3 {
  margin: 0;
  font-size: 0.94rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.assistant-head-btn {
  border: 1px solid rgba(194, 221, 255, 0.26);
  background: rgba(234, 245, 255, 0.06);
  color: rgba(229, 240, 255, 0.96);
  min-width: 64px;
  height: 32px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(145, 182, 243, 0.5) transparent;
}

.assistant-msg {
  max-width: min(84%, 420px);
  border-radius: 14px;
  border: 1px solid rgba(200, 224, 255, 0.2);
  padding: 8px 10px;
  font-size: 0.81rem;
  line-height: 1.4;
}

.assistant-msg p {
  margin: 0;
}

.assistant-rich {
  display: grid;
  gap: 5px;
}

.assistant-rich p,
.assistant-rich ul,
.assistant-rich ol,
.assistant-rich h1,
.assistant-rich h2,
.assistant-rich h3,
.assistant-rich h4,
.assistant-rich h5,
.assistant-rich h6 {
  margin: 0;
}

.assistant-rich h1,
.assistant-rich h2,
.assistant-rich h3,
.assistant-rich h4,
.assistant-rich h5,
.assistant-rich h6 {
  font-size: 0.88rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.assistant-rich ul,
.assistant-rich ol {
  padding-left: 1.1rem;
}

.assistant-rich li + li {
  margin-top: 2px;
}

.assistant-rich code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.74rem;
  background: rgba(8, 18, 42, 0.62);
  border: 1px solid rgba(193, 220, 255, 0.18);
  border-radius: 6px;
  padding: 1px 4px;
}

.assistant-rich pre {
  margin: 0;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(193, 220, 255, 0.18);
  background: rgba(8, 18, 42, 0.72);
  padding: 8px 10px;
}

.assistant-rich pre code {
  border: 0;
  padding: 0;
  background: transparent;
  font-size: 0.72rem;
  white-space: pre;
  display: block;
}

.assistant-rich a {
  color: #67d7ff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.assistant-msg.user .assistant-rich code {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.35);
}

.assistant-msg.assistant {
  justify-self: start;
  background: rgba(12, 31, 67, 0.86);
  color: rgba(227, 239, 255, 0.96);
}

.assistant-msg.user {
  justify-self: end;
  background: linear-gradient(
    135deg,
    rgba(84, 214, 255, 0.94),
    rgba(66, 109, 255, 0.95)
  );
  color: #fff;
  border-color: rgba(202, 229, 255, 0.54);
}

.assistant-msg.reset-card {
  max-width: min(96%, 520px);
  width: 100%;
  justify-self: stretch;
  padding: 0;
  border: 0;
  background: transparent;
}

.assistant-reset-card {
  display: grid;
  gap: 10px;
  border-radius: 15px;
  border: 1px solid rgba(196, 222, 255, 0.24);
  background: linear-gradient(
    160deg,
    rgba(11, 29, 62, 0.95),
    rgba(8, 19, 42, 0.98)
  );
  box-shadow: inset 0 1px 0 rgba(236, 246, 255, 0.08);
  padding: 11px;
}

.assistant-reset-title {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(184, 222, 255, 0.92);
  font-weight: 700;
}

.assistant-reset-copy {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(218, 233, 255, 0.89);
}

.assistant-reset-form {
  display: grid;
  gap: 8px;
}

.assistant-reset-label {
  font-size: 0.67rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(195, 219, 252, 0.86);
  font-weight: 600;
}

.assistant-reset-input {
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(194, 221, 255, 0.28);
  background: rgba(9, 21, 45, 0.78);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  padding: 8px 10px;
}

.assistant-reset-input::placeholder {
  color: rgba(191, 215, 249, 0.48);
}

.assistant-reset-action {
  min-height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(208, 230, 255, 0.4);
  background: linear-gradient(
    135deg,
    rgba(95, 228, 255, 0.94),
    rgba(65, 109, 255, 0.96)
  );
  color: #fff;
  font: inherit;
  font-size: 0.77rem;
  font-weight: 700;
  cursor: pointer;
}

.assistant-reset-action.is-busy {
  opacity: 0.7;
  cursor: wait;
}

.assistant-reset-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.assistant-reset-link {
  border: 0;
  background: transparent;
  color: rgba(167, 206, 255, 0.94);
  font: inherit;
  font-size: 0.69rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dashed rgba(154, 196, 251, 0.76);
  padding: 0;
}

.assistant-reset-feedback {
  margin: 0;
  min-height: 1.25em;
  font-size: 0.7rem;
  color: rgba(202, 223, 252, 0.86);
}

.assistant-reset-feedback.ok {
  color: var(--good);
}

.assistant-reset-feedback.error {
  color: #ffadad;
}

.assistant-reset-meta {
  margin: 0;
  font-size: 0.66rem;
  color: rgba(170, 199, 235, 0.85);
}

.assistant-msg.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 35px;
}

.assistant-msg-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(229, 241, 255, 0.88);
  animation: assistant-dot 0.9s ease-in-out infinite;
}

.assistant-msg-dot:nth-child(2) {
  animation-delay: 0.12s;
}

.assistant-msg-dot:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes assistant-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: translateY(1px);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

.assistant-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(194, 221, 255, 0.2);
  background: rgba(8, 17, 37, 0.9);
}

.assistant-input {
  min-height: 42px;
  max-height: 148px;
  border-radius: 12px;
  border: 1px solid rgba(194, 221, 255, 0.25);
  background: rgba(10, 25, 52, 0.84);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 9px 11px;
  resize: none;
  overflow-y: hidden;
}

.assistant-input::placeholder {
  color: rgba(202, 222, 255, 0.5);
}

.assistant-send {
  min-width: 72px;
  min-height: 42px;
  align-self: end;
  border-radius: 12px;
  border: 1px solid rgba(202, 229, 255, 0.54);
  background: linear-gradient(
    130deg,
    rgba(95, 228, 255, 0.96),
    rgba(65, 109, 255, 0.97)
  );
  color: #fff;
  font: inherit;
  font-size: 0.79rem;
  font-weight: 700;
  cursor: pointer;
}

.assistant-send:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

/* ─── Trade preview ─────────────────────────────── */

.trade-preview {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.preview-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
  height: 100%;
  background: var(--bg-1);
  overflow: hidden;
}

.preview-analysis {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
  background: linear-gradient(
    90deg,
    rgba(18, 28, 70, 0.95),
    rgba(11, 22, 43, 0.94) 58%,
    rgba(8, 43, 56, 0.92)
  );
  border-bottom: 1px solid rgba(94, 122, 255, 0.2);
}

.preview-analysis-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.preview-kicker {
  display: none;
}

.preview-analysis-title {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: #94d7ff;
}

.preview-analysis-note {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  color: var(--muted);
}

.preview-analysis-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  font-size: 13px;
  font-family: "DM Mono", monospace;
  color: var(--text-1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.preview-analysis-pill.is-locked {
  color: var(--amber);
}

.preview-controls {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.preview-trade-btn,
.preview-auth-btn {
  font-family: inherit;
  cursor: pointer;
  transition:
    filter 0.16s ease,
    opacity 0.16s ease,
    transform 0.16s ease;
}

.preview-trade-btn {
  border: 0;
  min-height: 48px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg-2);
}

.preview-trade-btn:hover:not(:disabled),
.preview-auth-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.preview-trade-btn.sell {
  background: rgba(242, 54, 69, 0.16);
  color: var(--red);
}

.preview-trade-btn.buy {
  background: rgba(8, 153, 129, 0.18);
  color: var(--green);
}

.preview-trade-btn[disabled],
.preview-auth-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.preview-lot-card {
  background: var(--bg-1);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  min-width: 132px;
  padding: 4px 8px;
  text-align: center;
}

.preview-lot-card span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.preview-lot-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-1);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  font-family: "DM Mono", monospace;
  padding: 0;
  outline: none;
  box-shadow: none;
}

.preview-chart-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-1);
}

.preview-chart-head {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.preview-chart-pair {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-1);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
}

.preview-chart-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid rgba(245, 166, 35, 0.26);
  background: rgba(12, 15, 20, 0.72);
  color: var(--amber);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.preview-chart-status.is-running {
  border-color: rgba(62, 207, 178, 0.28);
  color: #9df3e5;
}

.preview-chart-stage {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 100%;
  height: 100%;
  background: var(--bg-1);
}

.trade-preview .trade-chart-panel {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-1);
}

.trade-preview .trade-chart-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
}

#preview-trade-chart {
  width: 100%;
  height: 100%;
  touch-action: none;
}

.preview-chart-copy {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(12, 15, 20, 0.72);
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.preview-chart-copy p {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(238, 242, 255, 0.8);
}

.preview-trade-feedback {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 4;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(12, 15, 20, 0.84);
  font-size: 11px;
  line-height: 1.45;
  color: rgba(238, 242, 255, 0.88);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    border-color 0.18s ease;
}

.preview-trade-feedback:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

.preview-trade-feedback.is-error {
  border-color: rgba(242, 54, 69, 0.28);
  color: #ffbcc4;
}

.preview-trade-feedback.is-ok {
  border-color: rgba(8, 153, 129, 0.28);
  color: #9df3e5;
}

/* ─── Auth row (login/register buttons at bottom) ── */

.preview-auth-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  margin-bottom: 20px;
}

.preview-auth-btn {
  min-height: 46px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-1);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.preview-auth-btn.is-primary {
  border-color: rgba(62, 207, 178, 0.34);
  background: rgba(62, 207, 178, 0.12);
  color: #9df3e5;
}

/* ──────────────────────────────────────────────────
   AUTH MODAL — slides in from top, sticks under bar
   ────────────────────────────────────────────────── */

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 10040;
  /* backdrop is separate; the card slides in from top */
}

.auth-modal[hidden] {
  display: none;
}

/* dim the content behind */
.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 18, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.28s ease;
}

/* the sliding card itself */
.auth-modal-card.auth-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 1;
  width: 100%;
  /* slides from above the screen */
  transform: translateY(-100%);
  opacity: 0.6;
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.28s ease;
  border-radius: 0 0 24px 24px;
  max-height: 92svh;
  overflow-y: auto;
  /* allow scrolling inside if form is tall */
  overscroll-behavior: contain;
}

.auth-modal.is-open .auth-modal-backdrop {
  opacity: 1;
}

.auth-modal.is-open .auth-modal-card.auth-panel {
  transform: translateY(0);
  opacity: 1;
}

/* close button sits at top-right of the card */
.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(214, 232, 255, 0.2);
  border-radius: 12px;
  background: rgba(10, 20, 41, 0.82);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition:
    background 0.18s ease,
    border-color 0.18s ease;
}

.auth-modal-close:hover {
  background: rgba(242, 54, 69, 0.18);
  border-color: rgba(242, 54, 69, 0.4);
}

.prototype-note {
  text-align: center;
}
.hidden {
  display: none !important;
}

/* ──────────────────────────────────────────────────
   RESPONSIVE DESIGN
   ────────────────────────────────────────────────── */

/* ── Mid: 560–919px — phone card centred on bg ── */
@media (min-width: 560px) and (max-width: 919px) {
  .device-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100svh;
    padding: 20px;
  }

  .phone {
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: min(calc(100svh - 40px), 860px);
    border-radius: 28px;
    box-shadow:
      0 0 0 1px var(--border),
      0 32px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
  }

  /* Modal card constrained inside the phone frame */
  .auth-modal {
    position: absolute;
    border-radius: inherit;
    overflow: hidden;
  }

  .auth-modal-card.auth-panel {
    border-radius: 0 0 24px 24px;
  }
}

/* ── Tablet tweaks ── */
@media (min-width: 740px) {
  .chat-fab {
    right: 24px;
    bottom: 24px;
  }

  .community-card {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, calc(-50% + 14px)) scale(0.985);
  }

  .community-modal.is-open .community-card {
    transform: translate(-50%, -50%) scale(1);
  }

  .assistant-panel {
    inset: auto;
    left: 50%;
    top: 50%;
    width: min(560px, calc(100vw - 56px));
    height: min(78svh, 700px);
    border-radius: 22px;
    box-shadow: 0 28px 56px rgba(4, 8, 20, 0.62);
    transform: translate(-50%, calc(-50% + 12px));
  }

  .assistant-chat.is-open .assistant-panel {
    transform: translate(-50%, -50%);
  }
}

/* ── Desktop: 2-column split ── */
@media (min-width: 920px) {
  .device-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100svh;
    padding: 24px;
    overflow: hidden;
  }

  .phone {
    width: 100%;
    max-width: 1080px;
    height: min(calc(100svh - 48px), 800px);
    min-height: 600px;
    display: grid;
    grid-template-columns: minmax(380px, 1fr) 400px;
    gap: 24px;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
    max-height: none;
  }

  /* Left: chart preview card */
  .trade-preview {
    height: 100%;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
    overflow: hidden;
    background: var(--bg-1);
    min-height: 0;
  }

  .preview-shell {
    height: 100%;
  }

  .preview-chart-head {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  .preview-chart-copy {
    left: 20px;
    right: 20px;
    bottom: 20px;
    width: auto;
  }

  .preview-trade-feedback {
    left: 20px;
    right: 20px;
    bottom: 74px;
    width: auto;
  }

  /* Hide mobile bottom button row on desktop */
  .preview-auth-row {
    display: none !important;
  }

  /* ── Right column: auth modal is always visible on desktop ── */
  /* The modal element stays in DOM but we restyle it inline */
  .auth-modal,
  .auth-modal[hidden] {
    position: relative !important;
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    padding: 0;
    background: transparent;
    inset: auto;
    z-index: 1;
  }

  .auth-modal-backdrop {
    display: none !important;
  }

  /* Override the slide-from-top animation — just show it */
  .auth-modal-card.auth-panel {
    position: relative !important;
    left: auto !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    opacity: 1 !important;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    border-radius: 24px !important;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
    padding: 28px 24px;
    margin: 0;
    border: 1px solid var(--line);
  }

  .auth-modal-close {
    display: none !important;
  }
}

/* ── Small phones ── */
@media (max-width: 480px) {
  .preview-controls {
    grid-template-columns: 1fr 104px 1fr;
  }

  .preview-lot-card {
    min-width: 104px;
  }

  .preview-chart-copy {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .preview-trade-feedback {
    left: 8px;
    right: 8px;
    bottom: 68px;
  }

  .auth-modal {
    padding: 0;
  }
}
