:root {
  color-scheme: dark;
  --bg: #050505;
  --card: rgba(18, 18, 20, 0.84);
  --card-strong: rgba(24, 23, 22, 0.94);
  --line: rgba(218, 170, 92, 0.22);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #f8f1e7;
  --muted: rgba(248, 241, 231, 0.62);
  --gold: #d9aa5a;
  --gold-2: #ffe2a4;
  --danger: #ff706a;
  --success: #73e5a4;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 10% 0%, rgba(217, 170, 90, 0.22), transparent 32rem),
    radial-gradient(circle at 85% 18%, rgba(155, 92, 28, 0.16), transparent 26rem),
    linear-gradient(180deg, #0a0908 0%, var(--bg) 48%, #030303 100%);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 100%) 0 0 / 24px 24px,
    transparent;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.admin-shell {
  max-width: 760px;
}

.hero-card,
.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(28, 25, 22, 0.92), rgba(8, 8, 9, 0.86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.hero-card {
  padding: 26px 22px 22px;
  min-height: 190px;
}

.hero-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 226, 164, 0.18), transparent 34%),
    radial-gradient(circle at 94% 14%, rgba(217, 170, 90, 0.16), transparent 30%);
}

.hero-top,
.section-head,
.two-cols {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head {
  margin-bottom: 16px;
}

.section-head.tight {
  align-items: flex-start;
}

.section-head.compact {
  justify-content: flex-start;
  display: block;
  margin: 22px 0 12px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--gold-2);
  font-size: 11px;
  letter-spacing: 0.22em;
  font-weight: 800;
}

h1,
h2 {
  position: relative;
  margin: 0;
  line-height: 1.08;
  letter-spacing: -0.04em;
}

h1 {
  font-size: clamp(34px, 9vw, 48px);
}

h2 {
  font-size: 23px;
}

.hero-desc {
  position: relative;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 15px;
}

.panel {
  margin-top: 14px;
  padding: 20px;
}

.credit-pill,
.price-chip,
.status-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(217, 170, 90, 0.34);
  border-radius: 999px;
  background: rgba(217, 170, 90, 0.1);
  color: var(--gold-2);
  padding: 9px 12px;
  font-size: 13px;
}

.credit-pill {
  margin-top: 20px;
}

.credit-pill b,
.price-chip b {
  color: #fff5db;
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 16px;
}

.tab {
  color: var(--muted);
  background: transparent;
  padding: 11px 12px;
  border-radius: 14px;
  font-weight: 800;
}

.tab.active {
  color: #16110a;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
}

.form-stack {
  position: relative;
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 17px;
  outline: 0;
  color: var(--text);
  background: rgba(0, 0, 0, 0.28);
  padding: 14px 14px;
}

textarea {
  min-height: 130px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
textarea:focus {
  border-color: rgba(217, 170, 90, 0.62);
  box-shadow: 0 0 0 4px rgba(217, 170, 90, 0.12);
}

.primary-btn,
.ghost-btn,
.download-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  border-radius: 18px;
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.primary-btn {
  color: #16110a;
  background: linear-gradient(135deg, var(--gold-2), var(--gold) 62%, #a8732c);
  box-shadow: 0 14px 34px rgba(217, 170, 90, 0.22);
}

.ghost-btn,
.download-btn {
  border: 1px solid rgba(217, 170, 90, 0.36);
  color: var(--gold-2);
  background: rgba(217, 170, 90, 0.08);
}

.glow-btn {
  margin-top: 18px;
}

.glow-btn::after {
  content: "";
  position: absolute;
  inset: 8px 18px -10px;
  z-index: -1;
  border-radius: inherit;
  background: rgba(217, 170, 90, 0.34);
  filter: blur(20px);
}

.mini-link {
  position: relative;
  width: auto;
  color: var(--gold-2);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 8px 12px;
}

.upload-box {
  position: relative;
  display: grid;
  min-height: 330px;
  border: 1px dashed rgba(217, 170, 90, 0.42);
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(217, 170, 90, 0.16), transparent 36%),
    rgba(255, 255, 255, 0.035);
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  z-index: 3;
}

.remove-image-btn {
  margin-top: 12px;
}

.upload-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  min-height: 330px;
  text-align: center;
  color: var(--muted);
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 24px;
  color: #16110a;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  font-size: 34px;
  font-weight: 300;
}

.preview {
  width: 100%;
  height: 380px;
  object-fit: cover;
}

.style-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.custom-style-field {
  position: relative;
  margin-top: 12px;
}

.style-card {
  min-height: 112px;
  border: 1px solid var(--line-soft);
  border-radius: 22px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(217, 170, 90, 0.14), transparent 44%),
    rgba(255, 255, 255, 0.045);
}

.style-card.active {
  border-color: rgba(255, 226, 164, 0.74);
  background:
    linear-gradient(145deg, rgba(217, 170, 90, 0.2), rgba(255, 255, 255, 0.05)),
    rgba(255, 255, 255, 0.04);
  box-shadow: 0 12px 28px rgba(217, 170, 90, 0.14);
}

.style-card b {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
}

.style-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.result-image {
  width: 100%;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #0d0d0d;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.download-btn {
  margin-top: 13px;
}

.recharge-buy-btn {
  margin: 0 0 13px;
}

.recharge-instructions {
  position: relative;
  margin: 0 0 14px;
  border: 1px solid rgba(217, 170, 90, 0.28);
  border-radius: 18px;
  color: var(--text);
  background: rgba(217, 170, 90, 0.075);
  padding: 13px 14px;
  white-space: pre-line;
  line-height: 1.65;
  font-size: 13px;
}

.history-list,
.serial-list {
  display: grid;
  gap: 10px;
}

.history-item,
.serial-row,
.stat-card {
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.045);
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px;
  align-items: center;
}

.history-preview {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 12px;
  width: 100%;
  padding: 0;
  color: var(--text);
  text-align: left;
  background: transparent;
}

.history-item img {
  width: 78px;
  height: 102px;
  border-radius: 16px;
  object-fit: cover;
  background: #0c0c0c;
}

.history-item b,
.serial-row b {
  display: block;
  margin-bottom: 6px;
}

.history-item p,
.serial-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.history-delete {
  align-self: stretch;
  border: 1px solid rgba(255, 112, 106, 0.32);
  border-radius: 14px;
  color: var(--danger);
  background: rgba(255, 112, 106, 0.08);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 460px);
  border: 1px solid rgba(217, 170, 90, 0.36);
  border-radius: 18px;
  color: var(--text);
  background: rgba(18, 18, 18, 0.94);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  text-align: center;
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
}

.spinner {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(217, 170, 90, 0.2);
  border-top-color: var(--gold-2);
  border-radius: 50%;
  animation: spin 0.82s linear infinite;
}

.loading p {
  margin: 0;
  color: var(--gold-2);
}

.queue-status {
  width: min(calc(100% - 40px), 420px);
  color: var(--muted) !important;
  text-align: center;
  line-height: 1.7;
  font-size: 13px;
}

.result-dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(16px);
}

.result-dialog-card {
  width: min(100%, 430px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(28, 25, 22, 0.98), rgba(8, 8, 9, 0.96));
  box-shadow: var(--shadow);
  padding: 22px;
}

.result-dialog-card p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.75;
  margin: 14px 0 18px;
}

.result-dialog.success .result-dialog-card {
  border-color: rgba(115, 229, 164, 0.32);
}

.result-dialog.error .result-dialog-card {
  border-color: rgba(255, 112, 106, 0.42);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 14px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.stat-card b {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.two-cols {
  align-items: start;
}

.two-cols > label {
  flex: 1;
}

.serial-output {
  margin-top: 16px;
  border: 1px solid rgba(115, 229, 164, 0.28);
  border-radius: 20px;
  background: rgba(115, 229, 164, 0.06);
  padding: 14px;
}

.serial-code {
  display: block;
  color: var(--success);
  word-break: break-all;
  font-size: 13px;
  line-height: 1.55;
}

.serial-row {
  padding: 13px;
}

.serial-row.redeemed {
  opacity: 0.62;
}

.hidden {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel {
    padding: 17px;
    border-radius: 26px;
  }

  .hero-card {
    border-radius: 28px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
