:root {
  --paper: #efe7d6;
  --muted: rgba(239, 231, 214, .72);
  --ink: #111111;
  --gold: #d0a342;
  --rust: #9c3d31;
  --blue: #365c70;
  --olive: #657047;
  --bg-a: #111111;
  --bg-b: #312923;
  --accent: #d0a342;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(circle at 68% 18%, rgba(208, 163, 66, .15), transparent 24rem),
    linear-gradient(130deg, #111 0%, #20282c 48%, #3c2c24 100%);
  font-family: Arial, sans-serif;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(330px, 410px) minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
}

.panel,
.readout,
.reference,
.notes,
.mosaic-frame {
  border: 1px solid rgba(239, 231, 214, .2);
  background: rgba(15, 15, 15, .72);
  box-shadow: 0 22px 80px rgba(0, 0, 0, .3);
  backdrop-filter: blur(16px);
}

.panel {
  display: grid;
  align-content: start;
  gap: 15px;
  padding: 24px;
}

.eyebrow,
.label {
  margin: 0;
  color: var(--gold);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(46px, 7vw, 82px);
  line-height: .85;
  letter-spacing: 0;
}

.intro {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

label {
  display: grid;
  gap: 8px;
  color: rgba(239, 231, 214, .82);
  font-size: 12px;
  line-height: 1.3;
  font-weight: 900;
  text-transform: uppercase;
}

textarea,
select {
  width: 100%;
  border: 1px solid rgba(239, 231, 214, .22);
  color: var(--paper);
  background: rgba(255, 255, 255, .08);
  outline: none;
  font: 15px/1.45 Arial, sans-serif;
}

textarea {
  min-height: 116px;
  padding: 12px;
  resize: vertical;
}

select {
  min-height: 44px;
  padding: 10px 12px;
}

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

.song-prompts {
  grid-template-columns: repeat(2, 1fr);
}

.quick-prompts {
  grid-template-columns: repeat(3, 1fr);
}

button {
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

.preset {
  min-height: 36px;
  color: rgba(239, 231, 214, .82);
  border: 1px solid rgba(239, 231, 214, .16);
  background: rgba(255, 255, 255, .08);
}

.preset:hover {
  border-color: rgba(208, 163, 66, .8);
}

.toggle {
  grid-template-columns: 18px 1fr;
  align-items: start;
  text-transform: none;
  font-size: 13px;
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr 0 54px;
  align-items: center;
  gap: 10px;
  text-transform: none;
  font-size: 13px;
}

.switch-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-ui {
  position: relative;
  width: 54px;
  height: 31px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(239, 231, 214, .18);
  transition: background 180ms ease, border-color 180ms ease;
}

.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .32);
  transition: transform 180ms ease;
}

.switch-input:checked + .switch-ui {
  background: var(--gold);
  border-color: var(--gold);
}

.switch-input:checked + .switch-ui::after {
  transform: translateX(23px);
}

.switch-row:hover .switch-ui {
  border-color: rgba(239, 231, 214, .42);
}

.primary {
  min-height: 52px;
  color: #141414;
  background: var(--gold);
  text-transform: uppercase;
}

.primary:disabled {
  opacity: .65;
  cursor: progress;
}

.tech {
  display: grid;
  gap: 7px;
  padding: 13px;
  color: rgba(239, 231, 214, .82);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(239, 231, 214, .16);
  font-size: 13px;
  line-height: 1.45;
}

.stage {
  display: grid;
  grid-template-rows: minmax(560px, 1fr) auto auto;
  gap: 14px;
  min-width: 0;
}

.mosaic-frame {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, color-mix(in srgb, var(--accent), transparent 70%), transparent 30rem),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

.mosaic-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 49%, rgba(239, 231, 214, .08) 49% 51%, transparent 51%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 10px);
  opacity: .55;
  pointer-events: none;
}

.frame-top {
  position: absolute;
  z-index: 3;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: rgba(239, 231, 214, .76);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

#mood {
  color: var(--gold);
}

.mosaic {
  position: absolute;
  left: 50%;
  top: 52%;
  width: min(78vh, 74vw);
  max-width: 720px;
  min-width: 330px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  grid-template-rows: repeat(16, 1fr);
  gap: clamp(2px, .45vw, 6px);
  transform: translate(-50%, -50%);
}

.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(239, 231, 214, .16);
  background: rgba(255, 255, 255, .05);
  opacity: .36;
  transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(var(--scale));
  transition:
    transform 800ms cubic-bezier(.2, .9, .2, 1),
    background 600ms ease,
    opacity 500ms ease,
    border-radius 600ms ease;
}

.tile.on {
  opacity: 1;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .16), transparent 42%),
    var(--tile-color);
  border-color: color-mix(in srgb, var(--tile-color), white 32%);
  box-shadow: 0 12px 28px color-mix(in srgb, var(--tile-color), transparent 66%);
}

.tile.ghost {
  opacity: .18;
}

.tile.badge {
  border-radius: 45% 45% 52% 52%;
}

.tile.eye {
  border-radius: 50%;
}

.tile.light {
  box-shadow: 0 0 34px color-mix(in srgb, var(--tile-color), transparent 35%);
}

.tile.door {
  border-radius: 2px;
}

.tile::after {
  content: attr(data-role);
  position: absolute;
  left: 6px;
  bottom: 5px;
  color: rgba(17, 17, 17, .42);
  font-size: 6px;
  font-weight: 900;
  text-transform: uppercase;
  pointer-events: none;
}

.readout,
.notes {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 14px;
  padding: 16px;
}

.notes {
  grid-template-columns: 1fr;
}

.readout article,
.note-grid,
.reference div {
  display: grid;
  gap: 8px;
}

.readout p,
.notes p,
.reference p {
  margin: 0;
  color: rgba(239, 231, 214, .82);
  line-height: 1.52;
}

.note-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.note-grid article {
  padding: 12px;
  border: 1px solid rgba(239, 231, 214, .14);
  background: rgba(255, 255, 255, .055);
}

.note-grid strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold);
  font-size: 12px;
  text-transform: uppercase;
}

.reference {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 16px;
  align-items: center;
  padding: 14px;
}

.reference img {
  display: none;
  width: 220px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(239, 231, 214, .24);
  background: rgba(255, 255, 255, .05);
}

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 8, 8, .72);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.loader-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loader-card {
  width: min(360px, 92vw);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  color: var(--paper);
  text-align: center;
  border: 1px solid rgba(239, 231, 214, .22);
  background: rgba(15, 15, 15, .88);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .42);
}

.loader-card strong {
  font-size: 16px;
  text-transform: uppercase;
}

.loader-card span {
  color: var(--muted);
  line-height: 1.45;
}

.loader-spinner {
  width: 54px;
  height: 54px;
  border: 4px solid rgba(239, 231, 214, .18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .stage {
    grid-template-rows: 560px auto auto;
  }

  .readout,
  .note-grid,
  .reference {
    grid-template-columns: 1fr;
  }

  .reference img {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 560px) {
  .app {
    padding: 12px;
  }

  .presets {
    grid-template-columns: repeat(2, 1fr);
  }

  .mosaic {
    width: 88vw;
    min-width: 0;
    gap: 2px;
  }
}
