:root {
  --bg: #0b1120;
  --card: #111827;
  --surface: #0f172a;
  --border: #1e293b;
  --border-light: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #334155;
  --secondary-hover: #475569;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --wa: #16a34a;
  --wa-hover: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  padding: 24px 16px 40px;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  margin: 0 0 8px;
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 460px;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.feature-pill {
  font-size: 0.76rem;
  font-weight: 600;
  color: #bfdbfe;
  background: rgba(37, 99, 235, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-tab {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 10px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.mode-tab strong {
  font-size: 0.92rem;
}

.mode-tab span {
  font-size: 0.76rem;
  color: var(--muted);
}

.mode-tab.active {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.16);
}

.mode-tab.active span {
  color: #93c5fd;
}

.mode-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* PILIHAN JENIS LINK: LINK AMAN VS CUSTOM LINK */
.link-type-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.link-type-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.link-type-tab {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 11px 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.link-type-tab strong {
  font-size: 0.88rem;
}

.lt-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.lt-badge-safe {
  background: rgba(22, 163, 74, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.4);
  color: #86efac;
}

.lt-badge-warn {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.42);
  color: #fde68a;
}

.lt-desc {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.link-type-tab.active-safe {
  border-color: #22c55e;
  background: rgba(22, 163, 74, 0.12);
}

.link-type-tab.active-custom {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.link-type-tab:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.custom-link-box {
  background: var(--surface);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slug-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s ease;
}

.slug-field:focus-within {
  border-color: #f59e0b;
}

.slug-prefix {
  padding: 0 4px 0 11px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.slug-field input[type="text"] {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 10px 10px 10px 2px;
  min-width: 0;
  flex: 1;
}

.slug-status.is-ok {
  color: #86efac;
  font-weight: 600;
}

.slug-status.is-err {
  color: #fca5a5;
  font-weight: 600;
}

.pin-setup {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* BARIS VOUCHER SEJAJAR: INPUT + CEK SALDO + HAPUS */
.voucher-row {
  gap: 8px;
  align-items: stretch;
}

.voucher-row input {
  flex: 1 1 150px;
  min-width: 0;
}

.voucher-row .btn {
  padding: 10px 13px;
  font-size: 0.84rem;
}

.btn-outline-danger {
  background: rgba(220, 38, 38, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.42);
  color: #fca5a5;
}

.btn-outline-danger:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

/* SLIDER + ANGKA SINKRON UNTUK MASA AKTIF & BATAS UNDUH */
.r2-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.range-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.range-head .label {
  font-size: 0.8rem;
}

.range-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 3px 8px;
}

.range-input-wrap input[type="number"] {
  width: 40px;
  background: transparent;
  border: none;
  padding: 2px 0;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  outline: none;
}

.range-input-wrap span {
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 600;
}

.range-card input[type="range"] {
  width: 100%;
  margin: 2px 0 0;
  accent-color: #3b82f6;
  cursor: pointer;
}

.range-card input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
}

.range-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.range-note.is-burn {
  color: #fca5a5;
  font-weight: 600;
}

.label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

.label.is-required {
  color: #fde68a;
}

.link-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.link-row input {
  flex: 1;
  min-width: 0;
}

.link-row .btn {
  width: auto;
  flex-shrink: 0;
}

.link-row .btn-primary {
  min-width: 88px;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  border-color: #3b82f6;
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.center {
  text-align: center;
}

.voucher-buy-bar {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.voucher-buy-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.voucher-buy-info strong {
  font-size: 0.84rem;
  color: var(--text);
}

.voucher-buy-info span {
  font-size: 0.76rem;
  color: var(--muted);
}

.btn-buy-token {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(147, 197, 253, 0.35);
  color: #ffffff;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-buy-token:hover {
  filter: brightness(1.1);
}

.btn-buy-token:active {
  transform: scale(0.98);
}

.drop-area {
  border: 1.5px dashed var(--border-light);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.55);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.drop-area.dragover {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.12);
}

/* PRATINJAU DAFTAR BANYAK FILE (AUTO-ZIP) */
.file-list-preview {
  width: 100%;
  max-height: 118px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.file-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.77rem;
  color: #cbd5e1;
}

.file-list-item span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list-item span:last-child {
  color: var(--muted);
  flex-shrink: 0;
}

.cost-pill {
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.18);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #bfdbfe;
  font-size: 0.8rem;
  font-weight: 600;
}

.countdown-pill {
  margin-top: 4px;
  align-self: flex-start;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  font-size: 0.76rem;
  font-weight: 600;
}

.countdown-pill.is-urgent {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

.turnstile-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.btn-danger {
  background: var(--danger);
  width: 100%;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-wa {
  background: var(--wa);
  width: 100%;
}

.btn-wa:hover:not(:disabled) {
  background: var(--wa-hover);
}

.btn-install {
  background: #1e293b;
  border: 1px solid var(--border-light);
  font-size: 0.85rem;
  padding: 9px 16px;
}

.btn-install:hover {
  background: var(--secondary);
}

.share-actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.status-badge {
  background: rgba(22, 163, 74, 0.16);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #86efac;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

.progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
  transition: width 0.15s ease;
}

.qr-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.qr-box canvas {
  background: #ffffff;
  border-radius: 8px;
  padding: 6px;
  max-width: 100%;
  height: auto;
}

.hint {
  margin: 0;
  font-size: 0.82rem;
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
}

.file-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-break: break-word;
}

.file-meta strong {
  font-size: 0.96rem;
}

.burn-notice {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.83rem;
}

.warning {
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fde68a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.83rem;
}

.error {
  margin-top: 12px;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
}

.back-link {
  display: inline-block;
  text-align: center;
  color: #93c5fd;
  text-decoration: none;
  font-size: 0.86rem;
  margin-top: 4px;
}

.back-link:hover {
  text-decoration: underline;
}

.site-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.site-footer a {
  color: #93c5fd;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 999;
  overflow-y: auto;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-close {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.pkg-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 6px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.pkg-card .pkg-title {
  font-size: 0.78rem;
  color: var(--muted);
}

.pkg-card .pkg-tokens {
  font-size: 0.92rem;
  font-weight: 700;
}

.pkg-card .pkg-price {
  font-size: 0.82rem;
  color: #93c5fd;
  font-weight: 600;
}

.pkg-card.active {
  border-color: #3b82f6;
  background: rgba(37, 99, 235, 0.18);
}

.voucher-result-box {
  background: var(--surface);
  border: 1px dashed #3b82f6;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.voucher-result-box strong {
  font-size: 1.35rem;
  letter-spacing: 0.06em;
  color: #86efac;
  word-break: break-all;
}

.inline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legal-content {
  gap: 16px;
}

.legal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.legal-nav a {
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: #93c5fd;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
}

.legal-section h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: var(--text);
}

.legal-section p,
.legal-section li {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.legal-section ul {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-section a {
  color: #93c5fd;
}

@media (max-width: 440px) {
  .feature-pills {
    flex-wrap: nowrap;
    gap: 5px;
  }

  .feature-pill {
    font-size: clamp(0.62rem, 2.65vw, 0.74rem);
    padding: 4px 8px;
  }

  .mode-tab {
    padding: 10px 6px;
  }

  .mode-tab span {
    font-size: 0.69rem;
  }

  .link-type-tab {
    padding: 10px 6px;
  }

  .lt-badge {
    font-size: 0.63rem;
    padding: 2px 6px;
  }

  .lt-desc {
    font-size: 0.68rem;
  }

  .slug-prefix {
    font-size: 0.76rem;
    padding: 0 3px 0 9px;
  }

  .r2-options-grid,
  .share-actions,
  .pkg-grid,
  .inline-actions {
    grid-template-columns: 1fr;
  }

  .voucher-buy-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .btn-buy-token {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .voucher-row {
    flex-wrap: wrap;
  }

  .voucher-row input {
    flex: 1 1 100%;
  }

  .voucher-row .btn {
    flex: 1;
  }
}

@media (max-width: 340px) {
  .feature-pills {
    flex-wrap: wrap;
  }
}