/* Moonshot Studio — lunar mission-control instrument panel.
   Space-black chassis, hairline seams, moon-gold accents, mono readouts. */

:root {
  --bg:        #0a0a0c;
  --chassis:   #111014;
  --panel:     #16151b;
  --panel-2:   #1c1b22;
  --seam:      rgba(255, 255, 255, 0.07);
  --seam-soft: rgba(255, 255, 255, 0.04);
  --ink:       #ece9e2;
  --ink-dim:   #9b97a3;
  --ink-faint: #615e6b;
  --gold:      #f5b841;
  --gold-soft: rgba(245, 184, 65, 0.14);
  --danger:    #f87171;
  --ok:        #4ade80;
  --font-ui:   "Schibsted Grotesk", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", monospace;
  --font-disp: "Instrument Serif", Georgia, serif;
  --rail-w:    336px;
  --topbar-h:  60px;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display rules below. */
[hidden] { display: none !important; }

/* Keyboard focus must be visible on the dark chassis. */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Top bar ─────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 14px;
  background: linear-gradient(to bottom, #131217, #0e0d11);
  border-bottom: 1px solid var(--seam);
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}

.brand-moon { width: 22px; height: 22px; }

.brand-name {
  font-family: var(--font-disp);
  font-size: 21px;
  letter-spacing: 0.01em;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.32em;
  color: var(--gold);
  border: 1px solid rgba(245, 184, 65, 0.35);
  padding: 3px 6px 2px 8px;
  border-radius: 3px;
  margin-top: 2px;
}

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

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--seam);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover { border-color: rgba(255, 255, 255, 0.18); background: #232229; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1406;
}
.btn.primary:hover { background: #ffca5f; border-color: #ffca5f; }

.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }

.btn.wide { width: 100%; }

.spark { color: var(--gold); }

.pro-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: #1a1406;
  background: var(--gold);
  border-radius: 4px;
  padding: 4px 7px 3px 9px;
}

.export-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: 1px solid var(--seam);
}

.scale-select {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--seam);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 6px;
  cursor: pointer;
}

/* ── Workspace ───────────────────────────────────────── */

.workspace {
  display: flex;
  height: calc(100% - var(--topbar-h));
}

.viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 36px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, rgba(245, 184, 65, 0.035), transparent 70%),
    repeating-conic-gradient(#0d0d10 0% 25%, #0a0a0c 0% 50%) 0 0 / 24px 24px;
}

#preview {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  /* Flex items default to min-size:auto, which would let the canvas's
     intrinsic bitmap size force overflow on small screens. */
  min-width: 0;
  min-height: 0;
  border-radius: 4px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--seam-soft);
}

.size-indicator {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  background: rgba(10, 10, 12, 0.7);
  border: 1px solid var(--seam-soft);
  padding: 5px 12px;
  border-radius: 20px;
  pointer-events: none;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  border: 2px dashed var(--gold);
  border-radius: 16px;
  background: rgba(245, 184, 65, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}

.drop-overlay-inner {
  font-family: var(--font-disp);
  font-size: 28px;
  color: var(--gold);
}

/* ── Control rail ────────────────────────────────────── */

.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--chassis);
  border-left: 1px solid var(--seam);
  scrollbar-width: thin;
  scrollbar-color: #2c2b33 transparent;
}

.panel {
  padding: 18px 18px 20px;
  border-bottom: 1px solid var(--seam-soft);
}

.panel-title {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(to right, var(--seam) 0 4px, transparent 4px 8px);
}

.row { display: flex; gap: 8px; margin-bottom: 10px; }
.row:last-child { margin-bottom: 0; }

.hint {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-faint);
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--panel-2);
  border: 1px solid var(--seam);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
}

/* Selects & inputs */

.select, .text-input {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--seam);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.select:focus, .text-input:focus { border-color: rgba(245, 184, 65, 0.5); }
.wide { width: 100%; }

.mini-field {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}

.mini-field input {
  width: 100%;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--seam);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 7px 8px;
  outline: none;
}
.mini-field input:focus { border-color: rgba(245, 184, 65, 0.5); }

/* Segmented controls */

.seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--seam);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 10px;
}

.seg:last-child { margin-bottom: 0; }
.seg.small { display: inline-flex; }

.seg-btn {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.seg-btn:hover { color: var(--ink); }

.seg-btn.active {
  background: var(--panel-2);
  color: var(--gold);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--seam);
}

/* Swatch grids */

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.swatch {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--seam);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}

.swatch:hover { transform: scale(1.08); border-color: rgba(255, 255, 255, 0.25); }

.swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 184, 65, 0.35);
}

.swatch .pro-star {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1406;
  font-size: 8px;
  line-height: 14px;
  text-align: center;
  font-weight: 700;
}

/* Sliders — instrument style */

.slider-row {
  display: grid;
  grid-template-columns: 58px 1fr 34px;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

.slider-row:last-child { margin-bottom: 0; }

.slider-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-dim);
}

.slider-row output {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: linear-gradient(to right, rgba(245, 184, 65, 0.4), rgba(245, 184, 65, 0.15));
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--gold);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

input[type="range"]::-moz-range-track {
  height: 3px;
  background: linear-gradient(to right, rgba(245, 184, 65, 0.4), rgba(245, 184, 65, 0.15));
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--gold);
}

.frame-opts { align-items: center; }

.rail-footer {
  padding: 16px 18px 22px;
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
}

.rail-footer p { margin: 0; }

/* ── Pro modal ───────────────────────────────────────── */

.modal {
  border: 1px solid var(--seam);
  border-radius: 16px;
  background: linear-gradient(160deg, #17161c, #101013);
  color: var(--ink);
  padding: 0;
  width: min(400px, calc(100vw - 40px));
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
}

.modal::backdrop { background: rgba(5, 5, 8, 0.7); backdrop-filter: blur(4px); }

.modal-body { padding: 30px 28px 26px; position: relative; }

.modal-moon { width: 44px; margin-bottom: 14px; }
.modal-moon svg { width: 100%; }

.modal-title {
  margin: 0 0 14px;
  font-family: var(--font-disp);
  font-weight: 400;
  font-size: 30px;
}

.modal-title em { color: var(--gold); font-style: italic; }

.modal-perks {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  font-size: 13.5px;
  line-height: 2;
  color: var(--ink-dim);
}

.modal-perks li::before { content: "✦  "; color: var(--gold); }

.modal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.modal-divider::before, .modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--seam);
}

.license-row { display: flex; gap: 8px; }

.crypto-box { margin-bottom: 4px; }

.crypto-step {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.crypto-step strong { color: var(--gold); font-weight: 600; }

.addr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.addr-row code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10.5px;
  word-break: break-all;
  background: var(--panel);
  border: 1px solid var(--seam);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  user-select: all;
}

.wallet-link {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--gold);
}

.license-msg {
  min-height: 18px;
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-faint);
}

.license-msg.ok { color: var(--ok); }
.license-msg.err { color: var(--danger); }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: 0;
  color: var(--ink-faint);
  font-size: 14px;
  cursor: pointer;
  padding: 6px;
}

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

/* ── Redact overlay ──────────────────────────────────── */

.redact-modal {
  border: 1px solid var(--seam);
  border-radius: 16px;
  background: linear-gradient(160deg, #17161c, #101013);
  color: var(--ink);
  padding: 0;
  width: min(960px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.7);
}

.redact-modal::backdrop { background: rgba(5, 5, 8, 0.72); backdrop-filter: blur(4px); }

.redact-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--seam-soft);
}

.redact-title {
  margin: 0 0 4px;
  font-family: var(--font-disp);
  font-weight: 400;
  font-size: 22px;
}

.redact-sub { margin: 0; font-size: 13px; color: var(--ink-dim); max-width: 52ch; }

.redact-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  min-height: 300px;
  background:
    repeating-conic-gradient(#141418 0% 25%, #0f0f13 0% 50%) 0 0 / 22px 22px;
  overflow: auto;
}

#redact-canvas {
  cursor: crosshair;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  touch-action: none;
  max-width: 100%;
}

.redact-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--seam-soft);
}

.redact-spacer { flex: 1; }

/* ── Toast ───────────────────────────────────────────── */

.toast {
  position: fixed;
  inset: auto;                      /* cancel popover's default centering */
  bottom: 26px;
  left: 50%;
  margin: 0;
  transform: translate(-50%, 16px);
  background: #1d1c23;
  border: 1px solid var(--seam);
  color: var(--ink);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  max-width: min(480px, 90vw);
  text-align: center;
}

/* As a popover the toast lives in the top layer (above dialog backdrops);
   [popover] is display:none until shown, so .show still drives the fade. */
.toast:popover-open { display: block; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.gold { border-color: rgba(245, 184, 65, 0.4); }

/* ── Small screens ───────────────────────────────────── */

@media (max-width: 860px) {
  html, body { overflow: auto; }
  .workspace { flex-direction: column; height: auto; }
  .viewport { min-height: 46vh; padding: 20px; }
  .rail { width: 100%; border-left: 0; border-top: 1px solid var(--seam); }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
  .brand-tag { display: none; }
  #btn-surprise { display: none; }
}
