:root {
  color-scheme: light;
  --desk: #f3f1ec;
  --desk-accent: #eae6dc;
  --ink: #14171f;
  --muted: #646b78;
  --surface: #ffffff;
  --border: rgba(20, 23, 31, 0.1);
  --danger: #dc2626;
  --warn: #d97706;
  --emerald: #059669;
  --scrollbar-thumb: #c4c0b6;
  --scrollbar-track: #ebe8e0;
  accent-color: #14171f;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 999px; }
  ::-webkit-scrollbar-track { background: var(--scrollbar-track); }
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 42%, #ffffff 0%, var(--desk) 55%, var(--desk-accent) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Inter", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.muted { color: var(--muted); }
.tiny { font-size: 0.7rem; word-break: break-all; }
.strike { text-decoration: line-through; }
.green { color: var(--emerald); }

/* Minimal Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  background: rgba(243, 241, 236, 0.78);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left, .topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.brand-mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: #14171f;
  box-shadow: 0 0 0 3px rgba(20, 23, 31, 0.1);
}

.brand-name {
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.chain-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  color: var(--muted);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-dot 1.6s infinite;
}

.pill-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  min-height: 36px;
  padding: 0.35rem 0.78rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}
.pill-btn:hover:not(:disabled) {
  background: #fff;
  border-color: rgba(20, 23, 31, 0.28);
  transform: translateY(-1px);
}
.pill-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Main Studio Stage */
.studio-stage {
  max-width: 1180px;
  margin: 0 auto;
  min-height: calc(100dvh - 64px);
  padding: 1rem 1.2rem 1.6rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.8rem;
}

.stage-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.38rem 0.95rem;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.state-chip.is-alert {
  background: #fef2f2;
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.4);
}
.state-chip.is-secured {
  background: #ecfdf5;
  color: #047857;
  border-color: rgba(5, 150, 105, 0.35);
}

.receipt-pill {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: #14171f;
  color: #f8fafc;
  font-size: 0.76rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}
.receipt-pill a {
  color: #34d399;
  font-weight: 700;
  text-decoration: none;
}
.receipt-pill a:hover { text-decoration: underline; }

/* Interactive Desk Arena */
.desk-arena {
  position: relative;
  flex: 1 1 auto;
  min-height: 430px;
  display: grid;
  place-items: center;
}

.pod-stage-wrap {
  position: relative;
  z-index: 5;
  width: min(100%, 620px);
  height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#pod-canvas {
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: manipulation;
}

.pod-hint {
  margin: -0.6rem 0 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  max-width: 560px;
}

/* Physical Floating Asset Paper Cards (Shredline tactile aesthetic!) */
.asset-paper {
  position: absolute;
  z-index: 4;
  width: 172px;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid rgba(20, 23, 31, 0.09);
  box-shadow:
    0 14px 32px rgba(15, 23, 42, 0.08),
    0 2px 6px rgba(15, 23, 42, 0.05);
  transition:
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
  user-select: none;
}

.asset-paper:hover {
  box-shadow: 0 20px 42px rgba(15, 23, 42, 0.14);
}

.card-usdt { left: 3%; top: 8%; transform: rotate(-4deg); }
.card-weth { right: 4%; top: 7%; transform: rotate(3.5deg); }
.card-wbtc { left: 5%; bottom: 10%; transform: rotate(2.8deg); }
.card-mon  { right: 5%; bottom: 12%; transform: rotate(-3.2deg); }
.card-nft  {
  left: 22%;
  top: 2%;
  width: 132px;
  padding: 0.5rem 0.5rem 0.65rem;
  border-radius: 8px;
  transform: rotate(-2deg);
}

/* When Scam Brake locks the 50,000 mUSDT card */
.card-usdt.is-braked {
  border: 2px solid #dc2626;
  box-shadow: 0 18px 40px rgba(220, 38, 38, 0.22);
  transform: translate(24px, 10px) rotate(-1deg) scale(1.06);
  z-index: 8;
}

/* When Escape Pod vacuums all 5 cards into the center 3D hatch! */
.asset-paper.is-vacuumed {
  left: 50% !important;
  right: auto !important;
  top: 46% !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) scale(0.08) rotate(24deg) !important;
  opacity: 0 !important;
  pointer-events: none;
}

.paper-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 0.45rem;
}

.paper-tag {
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.12rem 0.42rem;
  border-radius: 5px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  flex-shrink: 0;
}
.tag-green  { background: #dcfce7; color: #166534; }
.tag-indigo { background: #e0e7ff; color: #3730a3; }
.tag-amber  { background: #fef3c7; color: #92400e; }
.tag-purple { background: #f3e8ff; color: #6b21a8; }

.paper-issuer {
  font-size: 0.65rem;
  color: #8b92a1;
}

.paper-amount {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.paper-symbol {
  font-size: 0.72rem;
  font-weight: 700;
  color: #64748b;
  margin-top: -2px;
}

.paper-lines {
  margin-top: 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.paper-lines span {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: #edf0f5;
}
.paper-lines span:last-child { width: 65%; }

.paper-stamp {
  margin-top: 0.55rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
}
.stamp-brake {
  border: 1.5px solid #dc2626;
  color: #dc2626;
  background: #fef2f2;
}
.stamp-void {
  border: 1.5px solid #059669;
  color: #047857;
  background: #ecfdf5;
}

/* Polaroid NFT Card */
.polaroid-frame {
  width: 100%;
  aspect-ratio: 1 / 0.88;
  border-radius: 5px;
  background: linear-gradient(135deg, #111827, #1e293b 55%, #0f766e);
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.polaroid-art {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.polaroid-badge {
  font-size: 0.58rem;
  font-weight: 800;
  color: #5eead4;
  letter-spacing: 0.08em;
}
.polaroid-orb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #a7f3d0, #06b6d4 55%, #312e81);
  box-shadow: 0 0 24px rgba(45, 212, 191, 0.65);
}
.polaroid-caption {
  margin-top: 0.45rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
}

/* Floating Alert & Secured Overlays */
.alert-toast {
  position: absolute;
  top: 0;
  right: 22%;
  z-index: 9;
  width: min(92vw, 330px);
  padding: 0.8rem 1rem;
  border-radius: 14px;
  background: #fef2f2;
  border: 1.5px solid #ef4444;
  color: #7f1d1d;
  box-shadow: 0 16px 36px rgba(220, 38, 38, 0.18);
  font-size: 0.78rem;
}
.alert-toast-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  color: #b91c1c;
  margin-bottom: 0.3rem;
}
.alert-toast p { margin: 0; }

.secured-dock {
  position: absolute;
  bottom: 0.4rem;
  z-index: 9;
  width: min(96vw, 660px);
  padding: 0.9rem 1.1rem;
  border-radius: 16px;
  background: #ffffff;
  border: 1.5px solid rgba(5, 150, 105, 0.45);
  box-shadow: 0 18px 44px rgba(5, 150, 105, 0.12);
  text-align: center;
}
.secured-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  font-weight: 800;
  color: #047857;
}
.secured-head a { color: #059669; text-decoration: none; font-size: 0.76rem; }
.secured-assets {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.8rem;
}
.secured-assets span {
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
}
.secured-note {
  margin: 0.5rem 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

/* Bottom Tactile Action Dock */
.action-dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.dock-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 760px;
}

.tactile-btn {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 64px;
  padding: 0.85rem 1.25rem;
  border-radius: 16px;
  border: 1px solid transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.tactile-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.03);
}
.tactile-btn:active:not(:disabled) { transform: translateY(0); }
.tactile-btn:disabled { opacity: 0.48; cursor: not-allowed; }
.tactile-btn strong { display: block; font-size: 0.94rem; }
.tactile-btn small { display: block; font-size: 0.74rem; opacity: 0.82; margin-top: 2px; }
.btn-icon { font-size: 1.4rem; flex-shrink: 0; }

.btn-warn {
  background: #14171f;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(20, 23, 31, 0.22);
}
.btn-dark {
  background: #ffffff;
  color: #14171f;
  border-color: rgba(20, 23, 31, 0.16);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
}
.btn-danger {
  background: linear-gradient(135deg, #dc2626, #be123c);
  color: #ffffff;
  box-shadow: 0 16px 36px rgba(220, 38, 38, 0.34);
}
.btn-emerald {
  background: #059669;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(5, 150, 105, 0.24);
}
.btn-light {
  background: #ffffff;
  color: #14171f;
  border-color: rgba(20, 23, 31, 0.14);
}

.pulse-launch { animation: pulse-crimson 1.5s infinite; }

.dock-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  font-size: 0.73rem;
  color: var(--muted);
}
.dock-meta a { color: #0f172a; text-decoration: underline; text-underline-offset: 2px; }

/* Guardian Dedicated Mobile Mode (?role=guardian) */
body.role-guardian .card-usdt,
body.role-guardian .card-weth,
body.role-guardian .card-wbtc,
body.role-guardian .card-mon,
body.role-guardian .card-nft {
  display: none;
}

/* Native <dialog> (modern-web-guidance `dialog` compliant) */
dialog {
  margin: auto;
  padding: 0;
  border: 1px solid rgba(20, 23, 31, 0.14);
  border-radius: 20px;
  background: #ffffff;
  color: var(--ink);
  width: min(92vw, 560px);
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
}

dialog[open] { display: flex; flex-direction: column; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.dlg-head h2 { margin: 0; font-size: 1rem; }
.dlg-head p { margin: 0.25rem 0 0; font-size: 0.78rem; color: var(--muted); }

.dlg-close {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.dlg-body {
  padding: 1.1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.dlg-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  background: #f8f7f3;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.dlg-metrics .lbl { display: block; font-size: 0.7rem; color: var(--muted); }
.dlg-metrics strong { font-size: 0.95rem; }

.sec-list { display: flex; flex-direction: column; gap: 0.55rem; }
.sec-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 0.75rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #faf9f6;
  font-size: 0.8rem;
}
.sec-row p { margin: 0.15rem 0 0; font-size: 0.73rem; color: var(--muted); }
.sec-out {
  grid-column: 1 / -1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid rgba(5, 150, 105, 0.3);
  word-break: break-word;
}

.dlg-unfreeze {
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 0.8rem;
}
.dlg-unfreeze-btns {
  margin-top: 0.55rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}
.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #faf9f6;
  font-size: 0.82rem;
  text-align: center;
}
.qr-box img { border-radius: 8px; border: 1px solid var(--border); }

button:focus-visible, a:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes pulse-crimson {
  0%, 100% { box-shadow: 0 16px 36px rgba(220, 38, 38, 0.35), 0 0 0 0 rgba(220, 38, 38, 0.45); }
  50% { box-shadow: 0 16px 36px rgba(220, 38, 38, 0.45), 0 0 0 12px rgba(220, 38, 38, 0); }
}

/* Mobile Responsive Layout */
@media (max-width: 900px) {
  .desk-arena {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    min-height: auto;
  }
  .pod-stage-wrap {
    order: 1;
    height: 270px;
  }
  .asset-paper {
    position: static;
    transform: none !important;
    width: calc(50% - 0.35rem);
  }
  .asset-paper.is-vacuumed {
    display: none;
  }
  .desk-arena {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .pod-stage-wrap { width: 100%; }
  .alert-toast, .secured-dock {
    position: static;
    width: 100%;
    order: 2;
  }
  .qr-grid, .dlg-metrics { grid-template-columns: 1fr; }
}
