@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;800;900&family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --bg-card: #12121a;
  --bg-card-hover: #1a1a26;
  --bg-surface: #16161f;
  --border: #1e1e2e;
  --border-hover: #2a2a3e;
  --text: #e4e4ef;
  --text-dim: #8888a0;
  --text-muted: #55556a;
  --accent: #f7931a;
  --accent-dim: rgba(247, 147, 26, 0.15);
  --accent-hover: #ff9f2e;
  --gold: #d4a843;
  --gold-dim: rgba(212, 168, 67, 0.15);
  --danger: #ff4466;
  --success: #22c55e;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 180ms ease;
}

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.hidden { display: none !important; }
.mono { font-family: var(--mono); font-size: 0.85em; word-break: break-all; }

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.wallet-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.balance-badge, .address-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.balance-badge { color: var(--accent); }

/* ── Tab Navigation ── */
.tab-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
}

.tab-btn:hover { color: var(--text-dim); }

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.tab-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tab-badge {
  background: var(--accent);
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 9px;
  min-width: 18px;
  text-align: center;
  line-height: 1.2;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px rgba(247, 147, 26, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--bg-surface);
}

.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Hero ── */
.hero {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px - 60px);
  text-align: center;
  padding: 2rem 1.25rem;
}

.hero-content { max-width: 600px; }

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--gold), #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.hero-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Loading ── */
.loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 1rem;
  color: var(--text-dim);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── Inscriptions Section ── */
.inscriptions-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ── Stats Bar ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Inscriptions Grid ── */
.inscriptions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.inscription-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
}

.inscription-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-preview {
  aspect-ratio: 1;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-preview iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

.card-preview .preview-placeholder {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
}

.card-content-type {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.card-number {
  font-weight: 700;
  font-size: 0.9rem;
}

.card-id {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-value {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-dim);
}

.empty-icon {
  width: 64px;
  height: 64px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

/* ── Load More ── */
.load-more-wrap {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

/* ── Modal ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  padding: 1rem;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  position: relative;
}

.modal-content h2 { margin-bottom: 0.75rem; }
.modal-content p { color: var(--text-dim); margin-bottom: 1.5rem; }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.modal-lg {
  max-width: 800px;
  text-align: left;
  padding: 0;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 10;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

/* ── Detail Modal ── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 400px;
}

.detail-preview {
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 300px;
}

.detail-preview img,
.detail-preview iframe {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: none;
}

.detail-info {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
  max-height: 80vh;
}

.detail-info h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

.detail-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.field-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-value {
  font-size: 0.85rem;
  color: var(--text);
  overflow-wrap: break-word;
}

.detail-actions {
  margin-top: auto;
  padding-top: 1rem;
}

.detail-actions .btn { width: 100%; justify-content: center; }

/* ── List Modal ── */
.modal-list {
  max-width: 420px;
  text-align: left;
  padding: 1.5rem;
}

.modal-list h2 {
  margin-bottom: 1rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.list-modal-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  margin-bottom: 1.25rem;
}

.list-modal-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-modal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.list-modal-thumb iframe {
  width: 100%;
  height: 100%;
  border: none;
  pointer-events: none;
}

.list-modal-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.list-modal-id {
  font-size: 0.7rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 260px;
}

.list-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.list-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.list-input-wrap:focus-within {
  border-color: var(--accent);
}

.list-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.1rem;
  padding: 0.65rem 0.75rem;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
}

.list-input::-webkit-outer-spin-button,
.list-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.list-input-suffix {
  padding: 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.list-price-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.list-confirm-btn {
  margin-top: 0.5rem;
  width: 100%;
  justify-content: center;
}

/* ── Buy Modal ── */
.buy-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.buy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.buy-row:last-child { border-bottom: none; }

.buy-row .mono {
  color: var(--text);
  font-size: 0.85rem;
}

.buy-row-total {
  background: var(--accent-dim);
  font-weight: 700;
}

.buy-row-total span { color: var(--text); }
.buy-row-total .mono { color: var(--accent); font-size: 0.95rem; }

.buy-row-seller {
  background: var(--bg-surface);
}

.buy-row-seller .mono {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buy-status {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.buy-status.status-pending {
  background: var(--accent-dim);
  color: var(--accent);
}

.buy-status.status-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
}

.buy-status.status-error {
  background: rgba(255, 68, 102, 0.1);
  color: var(--danger);
}

.buy-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* ── Card Listing Overlay ── */
.card-listed-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  background: rgba(247, 147, 26, 0.92);
  backdrop-filter: blur(4px);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-listed-badge .listed-price {
  font-family: var(--mono);
}

.card-actions {
  display: flex;
  gap: 0.4rem;
  padding: 0 0.75rem 0.65rem;
}

.card-actions .btn {
  flex: 1;
  justify-content: center;
  font-size: 0.75rem;
  padding: 0.35rem 0.5rem;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(255, 68, 102, 0.3);
}
.btn-danger:hover {
  background: rgba(255, 68, 102, 0.1);
  border-color: var(--danger);
}

.btn-accent {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(247, 147, 26, 0.3);
}
.btn-accent:hover {
  background: rgba(247, 147, 26, 0.25);
  border-color: var(--accent);
}

/* ── Market Card Price ── */
.market-card-price {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--accent-dim);
}

.market-price-value {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--accent);
}

.market-price-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.market-seller {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

.market-count {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* ── Detail Listing Badge ── */
.detail-listing-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.listing-price-tag {
  background: var(--accent-dim);
  border: 1px solid rgba(247, 147, 26, 0.3);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* ── Footer ── */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.footer-brand {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dim);
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

.footer-social {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.footer-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all var(--transition);
}

.footer-social a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
  text-decoration: none;
}

.footer-social svg {
  width: 16px;
  height: 16px;
}

.footer-quote {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.footer-copy {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .header-inner { padding: 0 0.75rem; gap: 0.5rem; }

  .tab-nav { order: 10; }

  .wallet-info { display: none; }

  .tab-btn { font-size: 0.72rem; padding: 0.35rem 0.6rem; }
  .tab-icon { width: 12px; height: 12px; }

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

  .inscriptions-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-preview {
    min-height: 200px;
    max-height: 300px;
  }

  .modal-lg {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.75rem; }
  .hero-sub { font-size: 0.95rem; }

  .inscriptions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .card-body { padding: 0.5rem; }
  .card-number { font-size: 0.8rem; }
  .card-id { font-size: 0.6rem; }
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.inscription-card {
  animation: fadeIn 0.3s ease both;
}

.inscription-card:nth-child(n+1) { animation-delay: 0.02s; }
.inscription-card:nth-child(n+5) { animation-delay: 0.08s; }
.inscription-card:nth-child(n+9) { animation-delay: 0.14s; }
.inscription-card:nth-child(n+13) { animation-delay: 0.2s; }
