:root {
  --bg: #0a0a0f;
  --panel: #11131a;
  --panel-strong: #171a24;
  --ink: #f2f7f6;
  --muted: #9aa7a8;
  --line: rgba(0, 255, 200, 0.22);
  --line-hot: rgba(0, 255, 200, 0.72);
  --accent: #00ffc8;
  --accent-ink: #001f1a;
  --rose: #ff4fa3;
  --gold: #ffd166;
  --danger: #ff5c6c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Syne", system-ui, sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(0, 255, 200, 0.16);
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent);
  box-shadow: 0 0 18px rgba(0, 255, 200, 0.72), inset 0 0 12px rgba(0, 255, 200, 0.22);
  transform: rotate(45deg);
}

.topbar-center,
.topbar-actions,
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sold-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 209, 102, 0.24);
  border-radius: var(--radius);
  color: var(--gold);
  background: rgba(255, 209, 102, 0.08);
  white-space: nowrap;
}

.user-chip {
  min-width: 0;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.user-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.user-chip span {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button,
.icon-button,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.button {
  gap: 8px;
  padding: 9px 13px;
  font-weight: 700;
  white-space: nowrap;
}

.button:hover,
.icon-button:hover,
.tool-button:hover {
  transform: translateY(-1px);
}

.button:disabled,
.icon-button:disabled,
.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.button-primary {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 0 24px rgba(0, 255, 200, 0.24);
}

.button-soft {
  color: var(--accent);
  border-color: rgba(0, 255, 200, 0.28);
  background: rgba(0, 255, 200, 0.08);
}

.button-soft.is-liked {
  color: #fff;
  border-color: rgba(255, 79, 163, 0.5);
  background: rgba(255, 79, 163, 0.18);
}

.button-ghost {
  color: var(--muted);
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.full-width {
  width: 100%;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  color: var(--accent);
  border-color: rgba(0, 255, 200, 0.26);
  background: rgba(10, 10, 15, 0.82);
  font-weight: 800;
}

.mural-app {
  position: relative;
  height: calc(100vh - 68px);
  overflow: hidden;
}

.mural-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle at 50% 45%, rgba(0, 255, 200, 0.06), transparent 34%), var(--bg);
}

.mural-viewport.is-panning {
  cursor: grabbing;
}

.mural-world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.mural-world::before {
  display: none;
}

.mural-cell {
  position: absolute;
  z-index: 1;
  padding: 0;
  overflow: hidden;
  border-right: 1px solid rgba(0, 255, 200, 0.18);
  border-bottom: 1px solid rgba(0, 255, 200, 0.18);
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.cell-available {
  opacity: 0.6;
}

.cell-available:hover {
  opacity: 1;
  box-shadow: inset 0 0 0 1px var(--line-hot), inset 0 0 18px rgba(0, 255, 200, 0.12);
  background: rgba(0, 255, 200, 0.08);
}

.cell-claimed {
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.34);
  background:
    repeating-linear-gradient(135deg, rgba(255, 209, 102, 0.16) 0 8px, rgba(255, 255, 255, 0.03) 8px 16px),
    rgba(23, 26, 36, 0.88);
  animation: claimedPulse 2.8s ease-in-out infinite;
}

.cell-published {
  box-shadow: inset 0 0 0 1px rgba(0, 255, 200, 0.54), 0 0 22px rgba(0, 255, 200, 0.18);
  background: #000;
}

.cell-published:hover {
  box-shadow: inset 0 0 0 1px var(--line-hot), 0 0 36px rgba(0, 255, 200, 0.34);
}

.cell-published img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lock-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72%;
  height: 28px;
  color: var(--gold);
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 999px;
  background: rgba(10, 10, 15, 0.64);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.like-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 79, 163, 0.84);
  font-size: 0.72rem;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.cell-published:hover .like-badge {
  opacity: 1;
  transform: translateY(0);
}

.zoom-dock {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 8;
  display: grid;
  gap: 8px;
}

.side-panel {
  position: fixed;
  top: 68px;
  right: 0;
  z-index: 18;
  width: min(390px, 100vw);
  height: calc(100vh - 68px);
  padding: 18px;
  border-left: 1px solid rgba(0, 255, 200, 0.18);
  background: rgba(17, 19, 26, 0.96);
  box-shadow: var(--shadow);
  transform: translateX(100%);
  transition: transform 220ms ease;
  overflow-y: auto;
}

.side-panel.is-open {
  transform: translateX(0);
}

.panel-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-header h2,
.modal-header h2,
.tool-section h2 {
  margin: 0;
  font-family: "Orbitron", system-ui, sans-serif;
  letter-spacing: 0;
}

.panel-content,
.copy-stack,
.form-grid,
.cell-list {
  display: grid;
  gap: 14px;
}

.panel-art {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border: 1px solid rgba(0, 255, 200, 0.2);
  border-radius: var(--radius);
  background: #000;
}

.art-meta {
  display: grid;
  gap: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.artist-line {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.text-link {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.cell-list-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal-backdrop {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 18px;
  background: rgba(0, 0, 0, 0.7);
}

.modal-dialog {
  width: min(520px, 100%);
  max-height: min(720px, 92vh);
  padding: 18px;
  border: 1px solid rgba(0, 255, 200, 0.22);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.modal-body {
  margin: 18px 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid rgba(0, 255, 200, 0.24);
  border-radius: var(--radius);
  padding: 10px 11px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 255, 200, 0.12);
}

.field-label {
  color: var(--ink);
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 1.05rem;
  margin: 0 0 12px 0;
  letter-spacing: 0.5px;
}

.size-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.size-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(0, 255, 200, 0.15);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--muted);
  outline: none;
}

.size-card:hover {
  background: rgba(0, 255, 200, 0.06);
  border-color: rgba(0, 255, 200, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 255, 200, 0.1);
  color: var(--ink);
}

.size-card.is-selected {
  background: rgba(0, 255, 200, 0.12);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 255, 200, 0.2), inset 0 0 12px rgba(0, 255, 200, 0.1);
}

.size-grid-preview {
  display: grid;
  grid-template-columns: repeat(var(--span), 1fr);
  grid-template-rows: repeat(var(--span), 1fr);
  gap: 2px;
  width: 44px;
  height: 44px;
  padding: 4px;
  background: rgba(10, 10, 15, 0.8);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.25s ease;
}

.size-card.is-selected .size-grid-preview {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 255, 200, 0.3);
}

.size-grid-cell {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 1px;
  transition: background 0.25s ease;
}

.size-card.is-selected .size-grid-cell {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

.size-card-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.price-readout {
  color: var(--gold);
  font-family: "Orbitron", system-ui, sans-serif;
  font-size: 1.8rem;
  display: block;
  text-align: center;
  margin: 16px 0;
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.4);
}

.warning-copy {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 209, 102, 0.24);
  border-radius: var(--radius);
  color: var(--gold);
  background: rgba(255, 209, 102, 0.08);
}

.muted {
  color: var(--muted);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 12px 14px;
  border: 1px solid rgba(0, 255, 200, 0.2);
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(17, 19, 26, 0.96);
  box-shadow: var(--shadow);
  overflow-wrap: anywhere;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast-success {
  border-color: rgba(0, 255, 200, 0.46);
}

.toast-warning {
  border-color: rgba(255, 209, 102, 0.5);
}

.toast-error {
  border-color: rgba(255, 92, 108, 0.55);
}

.toast-out {
  opacity: 0;
  transform: translateY(8px);
}

.editor-topbar {
  min-height: 74px;
}

.editor-title {
  display: grid;
  gap: 3px;
  min-width: 0;
  text-align: center;
}

.editor-title strong {
  color: var(--accent);
  font-family: "Orbitron", system-ui, sans-serif;
}

.editor-title span {
  color: var(--muted);
  font-size: 0.9rem;
}

.editor-app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100vh - 74px);
  min-height: 0;
}

.tool-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 16px;
  border-right: 1px solid rgba(0, 255, 200, 0.16);
  background: var(--panel);
  overflow-y: auto;
  scrollbar-color: rgba(0, 255, 200, 0.72) rgba(255, 255, 255, 0.08);
  scrollbar-width: thin;
}

.tool-panel::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.tool-panel::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
}

.tool-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(0, 255, 200, 0.72);
}

.tool-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.tool-section h2 {
  font-size: 0.9rem;
  color: var(--accent);
}

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

.tool-grid-icons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-button {
  min-width: 0;
  padding: 9px 8px;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  font-weight: 800;
}

.tool-button.is-active {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.compact-field {
  gap: 8px;
}

.compact-field input[type="color"] {
  height: 44px;
  padding: 4px;
}

.compact-field input[type="range"] {
  accent-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.editor-workspace {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.025) 75%),
    #07080c;
  background-position: 0 0, 12px 12px, 0 0;
  background-size: 24px 24px;
}

.editor-stage {
  position: relative;
  width: min(78vh, 82vw);
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(0, 255, 200, 0.28);
  border-radius: var(--radius);
  background: #050608;
  box-shadow: 0 0 38px rgba(0, 255, 200, 0.18);
  overflow: hidden;
}

.frame-canvas,
.art-canvas {
  position: absolute;
  image-rendering: pixelated;
  touch-action: none;
}

.frame-canvas {
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.art-canvas {
  left: var(--art-left, 0%);
  top: var(--art-top, 0%);
  width: var(--art-width, 100%);
  height: var(--art-height, 100%);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    #11131a;
  background-position: 0 0, 8px 8px, 0 0;
  background-size: 16px 16px;
}

.editor-stage.frame-active .frame-canvas {
  pointer-events: auto;
}

.editor-stage.frame-active .art-canvas {
  pointer-events: none;
}

.editor-stage.has-frame {
  border-color: rgba(255, 79, 163, 0.45);
  box-shadow: 0 0 36px rgba(255, 79, 163, 0.16), 0 0 42px rgba(0, 255, 200, 0.12);
}

@keyframes claimedPulse {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.1);
  }
  50% {
    box-shadow: 0 0 26px rgba(255, 209, 102, 0.32);
  }
}

@media (max-width: 860px) {
  body {
    overflow: hidden;
  }

  .topbar,
  .editor-topbar {
    align-items: stretch;
    flex-wrap: wrap;
    min-height: auto;
  }

  .topbar-center {
    order: 3;
    width: 100%;
  }

  .topbar-actions {
    flex-wrap: wrap;
  }

  .user-chip {
    width: 100%;
    justify-content: space-between;
  }

  .mural-app {
    height: calc(100vh - 122px);
  }

  .side-panel {
    top: 0;
    height: 100vh;
  }

  .editor-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - 150px);
  }

  .tool-panel {
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 260px);
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid rgba(0, 255, 200, 0.16);
  }

  .editor-workspace {
    padding: 14px;
  }

  .editor-stage {
    width: min(92vw, 72vh);
  }
}

@media (max-width: 540px) {
  .brand {
    font-size: 0.96rem;
  }

  .button {
    width: auto;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.9rem;
  }

  .topbar > nav.topbar-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    width: min(calc(100vw - 56px), 330px);
    justify-content: stretch;
  }

  .topbar > nav.topbar-actions > .button,
  .topbar > nav.topbar-actions > .user-chip {
    width: 100%;
    min-width: 0;
  }

  .sold-pill {
    width: min(calc(100vw - 56px), 330px);
    justify-content: center;
  }

  .zoom-dock {
    right: 12px;
    bottom: 12px;
  }

  .toast-stack {
    left: 12px;
    right: auto;
    width: min(calc(100vw - 24px), 330px);
  }

  .modal-dialog {
    padding: 14px;
  }

  .editor-title {
    width: 100%;
    text-align: left;
  }
}

/* ── Admin-specific UI ───────────────────────────────────── */

.button-admin {
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--gold) 0%, #ff9f43 100%);
  border-color: rgba(255, 209, 102, 0.6);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.28);
  text-decoration: none;
  font-weight: 800;
}

.button-admin:hover {
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.48);
}

/* Admin view: thin gold outline on every occupied cell */
.cell-admin-view {
  outline: 2px solid rgba(255, 209, 102, 0.55);
  outline-offset: -2px;
}

