:root {
  --bg: #070707;
  --fg: #f4f4f4;
  --muted: #8f8f8f;
  --line: rgba(255, 255, 255, 0.1);
  --card: rgba(18, 18, 18, 0.88);
  --btn: #fff;
  --btn-fg: #0a0a0a;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--fg);
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      -28deg,
      transparent 0,
      transparent 11px,
      rgba(255, 255, 255, 0.018) 11px,
      rgba(255, 255, 255, 0.018) 12px
    ),
    radial-gradient(900px 420px at 50% -12%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, #0c0c0c, #050505 55%, #000);
  background-attachment: fixed;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.boot {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  animation: fade-in 0.35s var(--ease);
}
.boot.error { color: #ccc; }

.auth-card {
  max-width: 440px;
  margin: 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
}
.auth-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.auth-text {
  margin: 0 0 14px;
  color: var(--muted);
}
.auth-note {
  margin-top: 12px;
}

.login-shell {
  max-width: 440px;
  margin: 0 auto;
  padding: 8px 0 24px;
}
.login-brand {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 16px;
}
.login-card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
}
.login-tabs,
.email-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.login-tab,
.email-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
}
.login-tab.active,
.email-tab.active {
  background: #fff;
  color: #000;
  border-color: #fff;
}
.login-panel.hidden {
  display: none;
}
.auth-hint {
  margin: 0 0 14px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.qr-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}
#auth-qr {
  width: 220px;
  height: 220px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.btn.tg-blue {
  background: #2aabee;
  color: #fff;
  border-color: #2aabee;
}
.btn.tg-blue .tg-btn-icon-wrap {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
}
.btn.tg-blue .tg-btn-icon {
  display: block;
  width: 20px;
  height: 20px;
}
.btn.tg-blue .tg-btn-label {
  line-height: 20px;
}
.btn.tg-blue:active:not(:disabled) {
  opacity: 0.9;
}
.auth-command {
  margin-top: 14px;
}
.auth-command-label {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 8px;
}
.auth-command-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.auth-command-row code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.03);
}
.auth-wait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}
.auth-wait.hidden {
  display: none;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.email-form {
  display: grid;
  gap: 12px;
}
.email-form.hidden {
  display: none;
}
.field-label {
  display: grid;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}
.field-label input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 12px;
  font: inherit;
}
.auth-error {
  margin-top: 10px;
  color: #ffb4b4;
  font-size: 0.88rem;
}
.auth-error.hidden {
  display: none;
}

#tg-login-slot {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 48px;
  overflow: visible;
}
#tg-login-slot iframe {
  display: block;
  max-width: none;
}

.app {
  max-width: 440px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 96px;
  animation: fade-in 0.4s var(--ease);
}
.app.fast-open {
  animation: none;
}
#browser-auth {
  content-visibility: auto;
  contain-intrinsic-size: 520px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px 10px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(7, 7, 7, 0.72);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  min-height: 40px;
}
.brand-logo {
  height: 40px;
  width: auto;
  display: block;
  object-fit: contain;
}
.top-meta {
  color: var(--muted);
  font-size: 0.84rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 11px;
  background: rgba(255, 255, 255, 0.03);
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.pages {
  flex: 1;
  padding: 14px 16px 28px;
  position: relative;
}

.page {
  display: none;
  opacity: 0;
  transform: translateY(8px);
}
.page.active {
  display: block;
  animation: page-in 0.32s var(--ease) forwards;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.block {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease);
}

.label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }

.hint, .note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
  margin: 0 0 10px;
}

textarea,
input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.45);
  color: var(--fg);
  padding: 11px 13px;
  font-size: 0.86rem;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s var(--ease);
}
textarea { resize: none; margin-bottom: 10px; }
input:focus, textarea:focus { border-color: rgba(255, 255, 255, 0.28); }

.list { display: grid; gap: 10px; }
.item {
  border: 1px solid var(--line);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease), opacity 0.2s var(--ease);
}
.item.col { flex-direction: column; align-items: stretch; }
.item .meta { color: var(--muted); font-size: 0.8rem; margin-top: 3px; }
.item .price { font-weight: 600; white-space: nowrap; }
.cfg-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}
.cfg-step {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cfg-step .cfg-val {
  min-width: 1.6em;
  text-align: center;
  color: var(--text);
}
.cfg-step .cfg-btn {
  min-width: 36px;
  padding: 6px 10px;
}
.item.claimed {
  opacity: 0.45;
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.06);
}
.item.claimed .btn.claimed-btn {
  background: #1a1a1a;
  color: #666;
  border-color: #333;
  cursor: default;
}

.sub-card {
  border: 1px solid var(--line);
  background: var(--card);
  padding: 14px;
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  animation: page-in 0.35s var(--ease) both;
}
.sub-card + .sub-card { margin-top: 0; }
.sub-card .sub-title {
  font-weight: 700;
  font-size: 1.02rem;
  margin-bottom: 2px;
}
.sub-card .badge {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #111;
  background: #fff;
  border-radius: var(--radius-pill);
  padding: 3px 8px;
  margin-bottom: 10px;
}

.row-btns, .inline, .topup-custom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.topup-custom {
  margin-top: 10px;
  margin-bottom: 6px;
}

.btn, .toggle {
  appearance: none;
  border: 1px solid var(--fg);
  background: var(--btn);
  color: var(--btn-fg);
  padding: 11px 14px;
  font-weight: 650;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: transform 0.15s var(--ease), opacity 0.2s var(--ease), background 0.2s var(--ease), color 0.2s var(--ease);
}
.btn:active:not(:disabled), .toggle:active:not(:disabled), .chip:active:not(:disabled) {
  transform: scale(0.97);
}
.btn.ghost, .toggle {
  background: transparent;
  color: var(--fg);
}
.btn.full, a.btn.full { width: 100%; margin-top: 8px; box-sizing: border-box; }
a.btn.full:not(.tg-blue) { display: block; }
a.btn.tg-blue.full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  text-align: center;
  text-decoration: none;
}
.btn:disabled, .toggle:disabled { opacity: 0.4; cursor: default; }
.toggle.on {
  background: var(--fg);
  color: var(--btn-fg);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--fg);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius-pill);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.chip.selected {
  background: var(--fg);
  color: var(--btn-fg);
  border-color: var(--fg);
}
.chip:active {
  background: var(--fg);
  color: var(--btn-fg);
  border-color: var(--fg);
}

.pay {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  animation: page-in 0.28s var(--ease);
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet.hidden { display: none !important; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  animation: fade-in 0.22s var(--ease);
}
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: min(78vh, 560px);
  overflow: auto;
  background: #111;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
  animation: sheet-up 0.32s var(--ease);
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  margin: 2px auto 14px;
}
@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: calc(100% - 24px);
  max-width: 416px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  padding: 8px;
  z-index: 10;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 4px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 18px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.2s var(--ease);
  min-height: 58px;
}
.tab-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  transition: transform 0.25s var(--ease);
}
.tab-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}
.tab-text {
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  line-height: 1;
}
.tab.active {
  color: var(--fg);
  background: rgba(255, 255, 255, 0.1);
}
.tab.active .tab-icon {
  transform: translateY(-1px);
}

.hidden { display: none !important; }
.empty { color: var(--muted); font-size: 0.88rem; }
.empty-hero {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 36px 12px;
  animation: fade-in 0.35s var(--ease);
}
.boot.offline {
  color: var(--muted);
}
.app.loading {
  opacity: 0.55;
  pointer-events: none;
}
.pay-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.pay-row .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
