:root {
  --bg: #050505;
  --green: #33ff00;
  --green-dim: #26ba01;
  --green-rgb: 51, 255, 0;
  --status-ok: #5dff4a;
  --status-error: #ff7b5c;
  --status-info: #8ec8ff;
  --font: "Courier New", Courier, monospace;
  --panel-border: rgba(var(--green-rgb), 0.22);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--green);
  font-family: var(--font);
  font-size: 14px;
}

.app-header {
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--panel-border);
  box-shadow: 0 0 40px rgba(var(--green-rgb), 0.06);
}

.app-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.header-brand {
  flex: 1 1 12rem;
  min-width: 0;
}

.header-auth {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem 0.65rem;
  flex: 0 1 auto;
}

.header-auth #auth-user {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.header-auth .btn {
  padding: 0.45rem 0.7rem;
  font-size: 0.76rem;
}

.app-header h1 { margin: 0; font-size: 1.1rem; letter-spacing: 0.08em; }
.app-header .dim { opacity: 0.45; }
.tagline { margin: 0.35rem 0 0; opacity: 0.65; font-size: 0.85rem; max-width: 36rem; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.app-header .status {
  margin: 0.65rem 0 0;
  min-height: 1.1em;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 1;
}

.status--ok {
  color: var(--status-ok);
  text-shadow: 0 0 12px rgba(93, 255, 74, 0.35);
}

.status--error {
  color: var(--status-error);
  text-shadow: 0 0 12px rgba(255, 123, 92, 0.35);
}

.status--info {
  color: var(--status-info);
  text-shadow: 0 0 10px rgba(142, 200, 255, 0.28);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 0;
  min-height: calc(100vh - 88px);
  align-items: start;
  overflow-x: hidden;
}

@media (min-width: 1200px) {
  .layout {
    grid-template-columns: minmax(380px, 480px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .header-auth {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
  .header-actions {
    order: 2;
    width: 100%;
  }
  .header-actions .btn { flex: 1; }
}

.panel {
  padding: 1.25rem 1.5rem;
}

.editor-panel {
  border-right: 1px solid var(--panel-border);
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

@media (max-width: 900px) {
  .editor-panel {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--panel-border);
  }
}

.flow-step {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid rgba(var(--green-rgb), 0.08);
}

.flow-step:last-of-type {
  border-bottom: none;
  margin-bottom: 0.75rem;
}

.flow-step-header {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.step-badge {
  flex-shrink: 0;
  width: 1.65rem;
  height: 1.65rem;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: bold;
  border: 1px solid rgba(var(--green-rgb), 0.35);
  background: rgba(var(--green-rgb), 0.08);
  color: var(--green);
}

.flow-step-title {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.step-lead {
  margin: 0.3rem 0 0;
  font-size: 0.78rem;
  opacity: 0.6;
  line-height: 1.45;
  max-width: 34rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
}

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

.fold {
  margin: 0.75rem 0 0;
  border: 1px solid rgba(var(--green-rgb), 0.14);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 2px;
}

.fold-advanced {
  margin-bottom: 0.65rem;
}

.fold > summary {
  cursor: pointer;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  user-select: none;
}

.fold > summary::-webkit-details-marker { display: none; }

.fold > summary::after {
  content: "+";
  opacity: 0.45;
  font-size: 1rem;
  line-height: 1;
}

.fold[open] > summary::after { content: "−"; }

.fold > summary:hover {
  background: rgba(var(--green-rgb), 0.04);
}

.fold-body {
  padding: 0 0.75rem 0.85rem;
  border-top: 1px solid rgba(var(--green-rgb), 0.08);
}

.fold-body .hint:first-child {
  margin-top: 0.65rem;
}

.fold-badge {
  font-size: 0.68rem;
  opacity: 0.5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.fold-badge.is-active {
  opacity: 0.85;
  color: var(--green);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field span { font-size: 0.8rem; opacity: 0.85; }
.field em { opacity: 0.55; font-style: normal; }

input[type="text"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--panel-border);
  color: var(--green);
  font-family: inherit;
  padding: 0.5rem 0.65rem;
  font-size: 0.9rem;
}

input[type="file"] {
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
}

input:focus, select:focus {
  outline: none;
  border-color: rgba(var(--green-rgb), 0.55);
  box-shadow: 0 0 10px rgba(var(--green-rgb), 0.15);
}

.distro-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.distro-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.distro-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 2px;
  width: fit-content;
  max-width: 100%;
}

.distro-chip:hover {
  border-color: rgba(var(--green-rgb), 0.2);
  background: rgba(var(--green-rgb), 0.04);
}

.distro-chip input { accent-color: var(--green); }

.distro-url-wrap {
  padding-left: 1.35rem;
}

.distro-url-wrap[hidden] { display: none !important; }

.distro-url-wrap input {
  width: 100%;
}

.hint { font-size: 0.72rem; opacity: 0.55; margin: 0.35rem 0 0; }
.hint.muted { margin-bottom: 0.5rem; }

.muted { opacity: 0.65; }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.btn {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--panel-border);
  background: rgba(var(--green-rgb), 0.06);
  color: var(--green);
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
}

.btn:hover {
  border-color: rgba(var(--green-rgb), 0.5);
  box-shadow: 0 0 12px rgba(var(--green-rgb), 0.2);
}

.btn.primary {
  background: rgba(var(--green-rgb), 0.14);
  border-color: rgba(var(--green-rgb), 0.45);
}

.status {
  min-height: 1.2em;
  margin-top: 0.75rem;
}

.actions.row-tight { margin-bottom: 1rem; }

.search-results {
  list-style: none;
  margin: 0.5rem 0 1.25rem;
  padding: 0;
  max-height: min(50vh, 480px);
  overflow-y: auto;
}

.search-results li { margin: 0.25rem 0; }

.search-hit {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.45rem 0.5rem;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.4);
  color: var(--green);
  cursor: pointer;
}

.search-hit:hover {
  border-color: rgba(var(--green-rgb), 0.45);
}

.search-results .muted {
  opacity: 0.55;
  font-size: 0.78rem;
}

.my-tracks-sentinel {
  text-align: center;
  padding: 0.5rem 0.25rem;
  font-size: 0.72rem;
  opacity: 0.55;
  list-style: none;
}

/* --- Preview scaler --- */
.preview-panel {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 88px);
  max-height: calc(100vh - 88px);
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(var(--green-rgb), 0.06), transparent 55%),
    #0a0a0a;
}

@media (max-width: 900px) {
  .preview-panel {
    position: static;
    height: auto;
    max-height: none;
    overflow: hidden;
  }

  .preview-stage {
    min-height: min(70vh, 520px);
    overflow: hidden;
  }
}

.preview-panel-head {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
}

.preview-promo-wrap {
  margin: 0 0 0.85rem;
  line-height: 1.35;
  word-break: break-all;
}

.preview-promo-link {
  color: var(--status-ok);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: underline;
  text-decoration-color: rgba(93, 255, 74, 0.45);
  text-underline-offset: 3px;
}

.preview-promo-link:hover {
  color: #9fff8f;
  text-decoration-color: rgba(159, 255, 143, 0.7);
}

.preview-promo-placeholder {
  font-size: 0.78rem;
}

.preview-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  opacity: 0.7;
  text-transform: uppercase;
}

.preview-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
}

.preview-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem 1rem;
  width: 100%;
  overflow: hidden;
  container-type: size;
  container-name: preview-stage;
}

.preview-scaler {
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-png {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-png:not([src]),
.preview-png[src=""] {
  visibility: hidden;
}

@container preview-stage (min-width: 0) {
  .preview-scaler:not(.is-story) {
    --preview-w: min(100cqw, 100cqh);
    width: var(--preview-w);
    height: var(--preview-w);
  }

  .preview-scaler.is-story {
    --preview-w: min(100cqw, calc(100cqh * 1080 / 1920));
    width: var(--preview-w);
    height: calc(var(--preview-w) * 1920 / 1080);
  }
}

.render-source {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* --- Promo card base (export source) --- */

.promo-card {
  position: relative;
  width: 1080px;
  height: 1080px;
  overflow: hidden;
  font-family: var(--font);
  color: #fff;
}

.promo-card.format-story {
  height: 1920px;
}



.card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.card-bg-art {
  position: absolute;
  inset: -14%;
  filter: blur(22px);
  transform: scale(1.12);
  pointer-events: none;
}

.card-bg-art .card-bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card-bg-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.42) 48%, rgba(0, 0, 0, 0.62) 100%);
}

.card-scanlines {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.16;
  background: linear-gradient(rgba(0,0,0,0) 50%, rgba(0,0,0,0.16) 50%);
  background-size: 100% 3px;
}

.exporting .card-scanlines {
  opacity: 0.12;
}

.promo-card .card-inner {
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.65);
}

.card-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 48px;
}

.format-story .card-inner {
  padding-top: 120px;
  justify-content: flex-start;
  gap: 32px;
}

/* Square 1080² — compact layout so QR + footer fit */
.format-square .card-inner {
  padding: 36px 40px 28px;
  justify-content: flex-start;
  gap: 0;
}

.format-square .card-cover-wrap {
  width: 40%;
  max-width: 400px;
  margin-bottom: 14px;
  border-radius: 18px;
}

.format-square .card-cover-frame {
  border-radius: 22px;
}

.format-square .card-meta {
  flex: 0 1 auto;
}

.format-square .card-kicker {
  font-size: 20px;
  margin-bottom: 6px;
}

.format-square .card-title {
  font-size: 40px;
}

.format-square .card-artist {
  font-size: 26px;
  margin-top: 8px;
}

.format-square .card-album {
  font-size: 20px;
  margin-top: 6px;
}

.format-square .card-distro {
  margin-top: 10px;
  padding-top: 10px;
  gap: 10px;
}

.format-square .distro-pill.icon-only {
  padding: 8px;
}

.format-square .distro-pill.icon-only svg {
  width: 30px;
  height: 30px;
}

.format-square .card-qr-wrap {
  margin-top: 10px;
  gap: 4px;
  flex-shrink: 0;
}

.format-square .card-qr {
  width: 96px;
  height: 96px;
}

.format-square .card-qr-label {
  font-size: 13px;
}

.format-square .card-brand {
  margin-top: auto;
  padding-top: 10px;
  font-size: 18px;
  flex-shrink: 0;
}

.card-cover-wrap {
  position: relative;
  width: 52%;
  max-width: 520px;
  aspect-ratio: 1;
  margin: 0 auto 28px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 22px;
  transform: translateY(-6px);
  filter:
    drop-shadow(0 28px 56px rgba(0, 0, 0, 0.58))
    drop-shadow(0 10px 24px rgba(0, 0, 0, 0.42))
    drop-shadow(0 0 48px rgba(var(--card-accent-rgb, 51, 255, 0), 0.22));
}

.format-story .card-cover-wrap {
  width: 78%;
  max-width: 840px;
  border-radius: 28px;
}

.card-cover {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #111;
  border-radius: inherit;
}

.card-cover-frame {
  position: absolute;
  inset: -5px;
  z-index: 2;
  border: 2px solid rgba(var(--card-accent-rgb, 51, 255, 0), 0.65);
  border-radius: 26px;
  box-shadow:
    inset 0 0 20px rgba(var(--card-accent-rgb, 51, 255, 0), 0.12),
    0 0 32px rgba(var(--card-accent-rgb, 51, 255, 0), 0.28);
  pointer-events: none;
}

.format-story .card-cover-frame {
  border-radius: 32px;
}

.exporting .card-cover-wrap {
  filter: none;
  box-shadow:
    0 28px 56px rgba(0, 0, 0, 0.58),
    0 10px 24px rgba(0, 0, 0, 0.42),
    0 0 48px rgba(var(--card-accent-rgb, 51, 255, 0), 0.22);
}

.card-meta { text-align: center; flex: 1; }

.card-kicker {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: 0.2em;
  opacity: 0.75;
  color: rgba(var(--card-accent-rgb, 51, 255, 0), 1);
}

.card-title {
  margin: 0;
  font-size: 56px;
  line-height: 1.1;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(var(--card-accent-rgb, 51, 255, 0), 0.35);
  word-break: break-word;
}

.format-story .card-title { font-size: 64px; }

.card-artist {
  margin: 16px 0 0;
  font-size: 40px;
  opacity: 0.92;
}

.card-album {
  margin: 10px 0 0;
  font-size: 30px;
  opacity: 0.6;
}

.card-album:empty { display: none; }

.card-distro {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.distro-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid rgba(var(--card-accent-rgb, 51, 255, 0), 0.35);
  background: rgba(0,0,0,0.35);
  font-size: 22px;
  color: rgba(var(--card-accent-rgb, 51, 255, 0), 0.95);
}

.distro-pill svg {
  width: 28px;
  height: 28px;
}

.distro-pill.icon-only {
  padding: 14px;
  gap: 0;
}

.distro-pill.icon-only svg {
  width: 40px;
  height: 40px;
}

.card-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.card-qr-wrap.is-hidden {
  display: none;
}

.card-qr {
  width: 140px;
  height: 140px;
  border: 2px solid rgba(var(--card-accent-rgb, 51, 255, 0), 0.4);
  background: rgba(0, 0, 0, 0.5);
}

.format-story .card-qr {
  width: 160px;
  height: 160px;
}

.card-qr-label {
  font-size: 18px;
  letter-spacing: 0.2em;
  opacity: 0.65;
  color: rgba(var(--card-accent-rgb, 51, 255, 0), 0.9);
}

.extra-links-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.extra-link-row {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  gap: 0.5rem;
  align-items: center;
}

.btn.tiny {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
}

.checkbox-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-direction: row;
}

.checkbox-inline input { accent-color: var(--green); }

textarea#promo-blurb {
  resize: vertical;
  min-height: 4.5rem;
}

.card-brand {
  margin-top: auto;
  padding-top: 24px;
  text-align: center;
  font-size: 26px;
  letter-spacing: 0.35em;
  opacity: 0.5;
  color: rgba(var(--card-accent-rgb, 51, 255, 0), 0.8);
}

.format-story .card-brand { margin-top: 48px; }
.auth-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.subhead {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.75rem 0 0.25rem;
  color: #7a9a82;
}

.fold-body code {
  font-size: 0.85em;
  opacity: 0.85;
}
