:root {
  /* Chia green identity (from v1: #3AAA35 / #2d8f2a), brightened a touch for
     legibility on a dark modern surface. */
  --bg: #0a0e0c;
  --bg-elev: #10161300;
  --card: #141b17;
  --card-2: #1a231d;
  --card-border: #24312a;
  --text: #eef2ee;
  --muted: #93a29a;
  --accent: #3aaa35;
  --accent-bright: #4ed94a;
  --accent-foreground: #04220a;
  --danger: #f0655a;
  --success: #4ed94a;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 0 1px rgba(58, 170, 53, 0.15), 0 10px 30px rgba(58, 170, 53, 0.08);
  --grad-accent: linear-gradient(135deg, #4ed94a 0%, #3aaa35 55%, #2d8f2a 100%);
}

* {
  box-sizing: border-box;
}

/* Reserve the scrollbar area so the layout doesn't shift ("tremble") when a
   page grows past the viewport after data loads. */
html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 50% -10%, rgba(58, 170, 53, 0.14), transparent 70%),
    radial-gradient(600px 400px at 100% 0%, rgba(78, 217, 74, 0.06), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Pre-paint routing (set by the inline head script on offer links): hide the
   home view and reveal the offer view's skeleton before main.js runs, so
   refreshing an offer page never flashes the home page. Higher specificity
   than .hidden so it wins until main.js takes over. */
html.offer-mode #home-view {
  display: none !important;
}

html.offer-mode #offer-view {
  display: block !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--card-border);
  padding: 12px 20px;
  background: rgba(10, 14, 12, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-logo {
  width: 20px;
  height: 20px;
  filter: drop-shadow(0 2px 8px rgba(78, 217, 74, 0.3));
}

main {
  flex: 1;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
}

.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}

h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 12px;
}

.mono {
  font-family: ui-monospace, monospace;
}

textarea,
input {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 170, 53, 0.18);
}

textarea {
  margin-bottom: 12px;
  resize: vertical;
}

.btn {
  display: inline-block;
  background: var(--grad-accent);
  color: var(--accent-foreground);
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.12s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 0 1px rgba(58, 170, 53, 0.3), 0 12px 26px rgba(58, 170, 53, 0.18);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  background: rgba(58, 170, 53, 0.06);
  color: var(--accent-bright);
  border: 1px solid rgba(58, 170, 53, 0.4);
  box-shadow: none;
}

.btn-outline:hover {
  background: rgba(58, 170, 53, 0.14);
  border-color: var(--accent);
  box-shadow: none;
}

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row input {
  flex: 1;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

.warning {
  color: #f59e0b;
  font-size: 13px;
  margin-bottom: 12px;
}

.result h2 {
  color: var(--success);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.offer-card {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 10px 12px;
}

.offer-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.offer-card-date {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--card-border);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-active { background: rgba(34,197,94,.15); color: #22c55e; }
.badge-pending { background: rgba(245,158,11,.15); color: #f59e0b; }
.badge-completed { background: rgba(59,130,246,.15); color: #3b82f6; }
.badge-cancelled, .badge-expired, .badge-failed { background: rgba(239,68,68,.15); color: #ef4444; }

.asset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}

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

.asset-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.asset-icon {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
}

.asset-icon-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text);
  background: #334155;
}

.nft-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.nft-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
}

.asset-amount {
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

.verified-badge {
  color: var(--success);
  margin-left: 4px;
  font-weight: 700;
}

.pay { color: var(--danger); }
.receive { color: var(--success); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 560px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 12px 0 4px;
}

.hero {
  position: relative;
  text-align: center;
  padding: 44px 24px 40px;
  margin-bottom: 24px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--card-border);
  background:
    radial-gradient(120% 140% at 50% -20%, rgba(78, 217, 74, 0.28), transparent 60%),
    linear-gradient(160deg, #16241a 0%, #0f1712 100%);
  box-shadow: var(--shadow-md);
}

.hero-logo {
  width: 96px;
  height: 96px;
  margin-bottom: 16px;
  object-fit: contain;
  filter: drop-shadow(0 6px 22px rgba(78, 217, 74, 0.35));
}

.hero h1 {
  font-size: clamp(26px, 5vw, 34px);
  margin-bottom: 10px;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #ffffff, #bfe9bd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero .lead {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 540px;
  margin: 0 auto 20px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}

.pill {
  display: inline-block;
  background: rgba(78, 217, 74, 0.1);
  color: var(--accent-bright);
  border: 1px solid rgba(78, 217, 74, 0.28);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.offer-card-id {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.trade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.trade-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.trade-label.receive { color: var(--success); }
.trade-label.pay { color: var(--danger); }

.mini-asset-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mini-asset-item .asset-icon,
.mini-asset-item .asset-icon-fallback,
.mini-asset-item .nft-thumb,
.mini-asset-item .nft-thumb-fallback {
  width: 22px;
  height: 22px;
  font-size: 10px;
  border-radius: 6px;
}

.mini-asset-info {
  min-width: 0;
}

.mini-asset-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.mini-asset-amount {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.mini-more {
  font-size: 11px;
}

.small {
  font-size: 12px;
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .status-grid {
    grid-template-columns: 1fr;
  }
}

.status-display {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}

.status-text {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 6px;
  font-size: 13px;
}

.stat-item:last-child {
  border-bottom: none;
}

.asset-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.asset-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.asset-card:hover,
.asset-card:focus-visible {
  border-color: var(--accent);
}

.asset-card-main {
  min-width: 0;
}

.asset-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.asset-symbol {
  font-weight: 700;
}

.asset-card-name {
  margin-bottom: 6px;
  font-size: 12px;
}

.asset-card .asset-icon,
.asset-card .asset-icon-fallback {
  width: 32px;
  height: 32px;
  font-size: 10px;
  flex-shrink: 0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-box {
  position: relative;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.nft-modal-body h2 {
  margin: 0 0 4px;
}

.nft-modal-image {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: 8px;
  margin-bottom: 12px;
}

.attributes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.attribute-chip {
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--bg);
}

.attribute-chip .attr-type {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
}

.attribute-chip .attr-value {
  font-weight: 600;
  font-size: 13px;
  word-break: break-word;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.step {
  text-align: center;
}

.step-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--grad-accent);
  color: var(--accent-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  margin: 0 auto 10px;
  box-shadow: var(--shadow-glow);
}

.step h3 {
  margin-bottom: 4px;
}

.step p {
  font-size: 12px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
}

.feature {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: rgba(0, 0, 0, 0.15);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.feature:hover {
  border-color: rgba(58, 170, 53, 0.4);
  transform: translateY(-2px);
}

.feature h3 {
  margin-bottom: 8px;
}

.feature ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  color: var(--muted);
}

.feature li {
  margin-bottom: 4px;
}

.credits a {
  color: var(--accent);
}

.disclaimer {
  margin-top: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #f59e0b;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

.footer {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--card-border);
}

/* Keeps the dig.net tip widget contained under the Thank You card instead
   of stretching across the bottom of the page. */
.tip-container {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.tip-container > * {
  max-width: 100%;
}

/* ---------- Backend outage notice ---------- */
.backend-down {
  text-align: center;
  padding: 18px 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.07);
}

.backend-down-title {
  font-weight: 700;
  font-size: 15px;
}

.backend-down a,
.error a {
  color: var(--accent-bright);
}

/* ---------- Loading skeletons ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(78, 217, 74, 0.07), transparent);
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes skeleton-sweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
}

.skeleton-block {
  height: 90px;
  margin-bottom: 10px;
}

.skeleton-card {
  pointer-events: none;
}

.w30 { width: 30%; }
.w40 { width: 40%; }
.w55 { width: 55%; }
.w60 { width: 60%; }
.w70 { width: 70%; }
.w80 { width: 80%; }

.footer-sep {
  opacity: 0.5;
  margin: 0 4px;
}

.powered-by-dig {
  margin-top: 12px;
}

.powered-by-dig a {
  display: inline-block;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.powered-by-dig a:hover {
  opacity: 1;
}

.powered-by-dig img {
  height: 34px;
  width: auto;
}

.footer-link {
  color: var(--accent-bright);
  text-decoration: none;
}

.footer-link:hover {
  text-decoration: underline;
}

/* ---------- Admin page ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}

.stat-box .stat-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff, #bfe9bd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-box .stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  margin-right: 6px;
}

.status-dot.ok {
  background: var(--success);
}

.status-dot.bad {
  background: var(--danger);
}

.log-line {
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--card-border);
}

.log-line:last-child {
  border-bottom: none;
}

.log-type {
  color: var(--accent-bright);
  font-family: ui-monospace, monospace;
  margin-right: 8px;
}
