: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; }

.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);
}

.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; }
.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%; display: block; margin-top: 8px; }
.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);
}

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