:root {
  --bg: #09090d;
  --bg-elevated: rgba(21, 21, 30, 0.88);
  --bg-soft: rgba(255, 255, 255, 0.04);
  --text: #ffffff;
  --muted: #a5a8b8;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #8b5cf6;
  --accent-strong: #a855f7;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --success: #34d399;
  --danger: #f87171;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(circle at top left, rgba(139, 92, 246, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(168, 85, 247, 0.12), transparent 22%),
    linear-gradient(180deg, #11111a 0%, var(--bg) 55%, #050507 100%);
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

.toast-layer {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  padding: 0 16px;
  pointer-events: none;
  z-index: 1000;
  width: 100%;
  max-width: 600px;
}

.toast {
  width: 100%;
  padding: 16px 20px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 15, 22, 0.88);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  pointer-events: auto;
  animation: toast-in 340ms cubic-bezier(0.16, 1, 0.3, 1);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.toast.is-hiding {
  animation: toast-out 280ms cubic-bezier(0.7, 0, 0.84, 0) forwards;
}

.toast-info {
  border-color: rgba(139, 92, 246, 0.44);
}

.toast-error {
  border-color: rgba(248, 113, 113, 0.44);
  background: rgba(30, 10, 10, 0.88);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.landing,
.dashboard {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.landing-grid {
  grid-template-columns: 1.15fr 0.85fr;
  align-items: start;
}

.landing {
  min-height: calc(100vh - 80px);
}

.hero-card,
.card,
.topbar {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card {
  width: min(720px, 100%);
  padding: 40px;
}

.hero-main {
  width: 100%;
}

.topbar,
.card {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.top-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(139, 92, 246, 0.28);
  background: rgba(139, 92, 246, 0.14);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.terminal-icon {
  display: inline-flex;
  align-items: center;
  color: inherit;
  line-height: 0;
  margin-right: 8px;
  font-size: 18px;
  flex-shrink: 0;
}

.icon-button .terminal-icon {
  margin-right: 0;
}

.terminal-icon-title {
  margin-right: 12px;
  color: #8b5cf6;
}

/* Field with icon */
.field-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.field-with-icon .terminal-icon {
  position: absolute;
  left: 14px;
  margin-right: 0;
  color: var(--muted);
  pointer-events: none;
}

.field-with-icon input,
.field-with-icon select {
  padding-left: 44px;
}

.top-link:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.28);
  color: var(--text);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font: 500 0.76rem/1 "IBM Plex Mono", monospace;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.3rem, 4vw, 4.5rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.45rem;
  margin-bottom: 24px;
}

h3 {
  font-size: 1.05rem;
}

.subtitle,
.hero-copy,
.hero-hint,
.section-copy,
.server-meta,
.empty-state,
.ref-item p,
.server-footer,
label {
  color: var(--muted);
}

.hero-copy,
.section-copy {
  margin-bottom: 18px;
  max-width: 52ch;
}

.hero-hint {
  margin-top: 18px;
  font-size: 0.95rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.hero-points,
.auth-stack {
  display: grid;
  gap: 16px;
}

.point-card {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.grid {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.grid-hero {
  grid-template-columns: 1.15fr 0.85fr;
}

.grid-panels {
  grid-template-columns: 0.82fr 1.18fr;
  align-items: start;
  min-width: 0;
}

.card-head,
.server-main,
.switch-row,
.server-footer,
.copy-box,
.ref-item,
.profile-field,
.modal-head,
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head {
  margin-bottom: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--text);
  font: 500 0.8rem/1 "IBM Plex Mono", monospace;
}

.chip-accent {
  background: rgba(139, 92, 246, 0.22);
}

.chip-muted {
  background: var(--bg-soft);
  color: var(--muted);
}

.stats-list,
.server-stats {
  display: grid;
  gap: 14px;
}

.stats-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.server-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 16px 0;
}

.stats-list div,
.server-stats div,
.ref-summary div {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

dt {
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 6px;
}

dd {
  margin: 0;
  font-weight: 500;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.profile-fields,
.server-actions {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.balance-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.profile-field {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg-soft);
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-width: 0;
}

.profile-field-action {
  align-items: center;
  min-height: 88px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.field-value {
  font-weight: 500;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mini-button-static {
  cursor: default;
}

.status-icon {
  color: var(--muted);
}

.status-icon-success {
  color: var(--success);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 14px 16px;
  color-scheme: dark;
}

select,
option {
  background-color: #11111a;
  color: var(--text);
}

select:disabled,
input:disabled,
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.mini-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  position: relative;
}

.mini-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 0.88rem;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  padding: 0;
}
.icon-button::after {
  content: "";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  color: var(--success);
  opacity: 0;
  transition: opacity 140ms ease;
}
.icon-button.is-copied .terminal-icon {
  opacity: 0;
}
.icon-button.is-copied::after {
  content: "✓";
  opacity: 1;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--text);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-color: var(--line);
}

.button-telegram {
  background: linear-gradient(135deg, #22a9f2 0%, #3fbdf7 100%);
  color: #06131b;
  font-weight: 700;
}

.ref-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.ref-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.copy-box {
  margin-bottom: 16px;
}

.copy-box-wide {
  margin-top: 18px;
}

.copy-box input {
  font-family: "IBM Plex Mono", monospace;
  min-width: 0;
}

.compact-copy-box {
  margin-top: 8px;
}

.copy-box-overlay {
  position: relative;
  display: block;
}

.copy-box-overlay input {
  padding-right: 54px;
}

.copy-box-overlay .icon-button {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  flex: 0 0 auto;
}

.telegram-login-box {
  display: grid;
  justify-content: start;
  margin: 8px 0 18px;
}

.dashboard-telegram-box {
  margin-top: 20px;
}

.ref-list,
.server-list {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.scroll-panel {
  max-height: 440px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 92, 246, 0.48) transparent;
}

.scroll-panel::-webkit-scrollbar {
  width: 8px;
}

.scroll-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.42);
}

.scroll-panel::-webkit-scrollbar-track {
  background: transparent;
}

.server-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.server-id {
  color: var(--muted);
  font: 500 0.88rem/1 "IBM Plex Mono", monospace;
}

.subscription-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
  width: 100%;
  min-width: 0;
}

.subscription-hint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}

.inline-link {
  color: #d6c7ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.or-divider {
  margin: 2px 0;
  color: var(--muted);
  text-align: center;
}

.landing-telegram-button {
  justify-self: center;
  min-width: min(280px, 100%);
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.ref-link-block {
  margin-bottom: 16px;
}

.ref-summary-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ref-notify-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pager {
  margin-top: 16px;
  color: var(--muted);
}

.pager-link {
  color: var(--text);
  font: 500 0.82rem/1 "IBM Plex Mono", monospace;
}

.pager-link.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.toggle-button {
  width: 52px;
  height: 32px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
}

.toggle-button span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  transition: transform 140ms ease;
}

.toggle-button.is-active {
  background: rgba(139, 92, 246, 0.24);
  border-color: rgba(139, 92, 246, 0.42);
}

.toggle-button.is-active span {
  transform: translateX(20px);
}

.password-strength {
  display: grid;
  gap: 8px;
  margin-top: -2px;
}

.password-strength small {
  color: var(--muted);
}

.password-strength-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.password-strength-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #6b7280;
  transition: width 140ms ease, background 140ms ease;
}

.password-strength[data-score="1"] .password-strength-bar span {
  background: #ef4444;
}

.password-strength[data-score="2"] .password-strength-bar span {
  background: #f59e0b;
}

.password-strength[data-score="3"] .password-strength-bar span {
  background: #8b5cf6;
}

.password-strength[data-score="4"] .password-strength-bar span {
  background: #34d399;
}

.inline-form {
  margin: 0;
}

.inline-feedback {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.12);
  color: #ffd5d5;
  font-size: 0.92rem;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 4, 8, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1100;
  opacity: 0;
  animation: backdrop-in 180ms ease-out forwards;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 1110;
}

.modal.is-visible .modal-card {
  animation: modal-in 200ms ease-out forwards;
}

.modal.is-hiding .modal-card {
  animation: modal-out 180ms ease-in forwards;
}

.modal-backdrop.is-hiding {
  animation: backdrop-out 180ms ease-in forwards;
}

.modal[hidden],
.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, calc(100vw - 32px));
  padding: 24px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(14, 14, 22, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.ref-item,
.server-item {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.ref-item span {
  font-family: "IBM Plex Mono", monospace;
  color: var(--accent-strong);
}

.compact-server-item {
  padding: 14px;
  gap: 12px;
}

.compact-server-stats {
  margin: 14px 0;
}

.compact-server-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.switch-form {
  display: grid;
  gap: 10px;
}

.switch-row {
  align-items: stretch;
}

.switch-row .button {
  min-width: 120px;
}

.link-mono {
  color: #cabdff;
  font-family: "IBM Plex Mono", monospace;
}

@media (max-width: 980px) {
  .landing-grid,
  .grid-hero,
  .grid-panels,
  .ref-summary,
  .ref-summary-compact,
  .stats-list,
  .server-stats {
    grid-template-columns: 1fr;
  }

  .topbar,
  .server-main,
  .copy-box,
  .switch-row {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar,
  .card,
  .hero-card {
    padding: 20px;
    border-radius: 24px;
  }

  .top-links {
    width: 100%;
  }

  .compact-server-actions {
    grid-template-columns: 1fr;
  }

  .subscription-actions {
    display: grid;
    justify-content: stretch;
  }

  .scroll-panel {
    max-height: 320px;
    padding: 8px;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modal-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes backdrop-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}
