:root {
  --bg: #111111;
  --card: #f4e8d7;
  --ink: #1b1714;
  --muted: #4d4640;
  --shadow: rgba(0, 0, 0, 0.55);
  --coral: #ff6b6b;
  --green: #7ae582;
  --cream: #f7ede2;
  --charcoal: #1b1714;
  --pink:   #ec4899;
  --violet: #8b5cf6;
  --indigo: #6366f1;
  --blue:   #3b82f6;
  --cyan:   #06b6d4;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: linear-gradient(180deg, #151515 0%, #090909 100%);
  color: var(--ink);
  font-family: "Poppins", "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  place-items: center;
  padding: 18px;
  user-select: none;
}

.palette-card {
  width: min(92vw, 460px);
  border-radius: 26px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.58), rgba(255,255,255,0.16)),
    linear-gradient(180deg, #f7eedf 0%, #f1e3d0 100%);
  box-shadow:
    0 28px 70px rgba(0,0,0,0.50),
    inset 0 1px 0 rgba(255,255,255,0.86),
    inset 0 -1px 0 rgba(86, 64, 45, 0.08);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.seed-shell {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: center;
  flex: 0 1 auto;
  min-width: 0;
}

.seed-entry {
  display: grid;
  gap: 4px;
  justify-items: end;
  min-width: 0;
  color: #4d4640;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sync-rail .seed-shell {
  margin-left: auto;
}

.seed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.seed-fav-btn {
  background: none;
  border: 0;
  padding: 2px;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: #c4b8ab;
  transition: color 120ms ease;
  flex-shrink: 0;
}
.seed-fav-btn:hover,
.seed-fav-btn.is-fav { color: #a78bfa; }

.seed-picker {
  position: relative;
  display: flex;
  min-width: 0;
}

.seed-display {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 10px;
  border: 0;
  border-radius: 8px 0 0 8px;
  background: rgba(255,255,255,0.5);
  color: #1b1714;
  font: inherit;
  letter-spacing: 0.08em;
  text-align: right;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), inset 0 -1px 0 rgba(0,0,0,0.06);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.seed-display:focus-visible {
  outline: 2px solid rgba(27, 23, 20, 0.18);
  outline-offset: 2px;
}

.seed-chevron {
  flex-shrink: 0;
  width: 26px;
  border: 0;
  border-radius: 0 8px 8px 0;
  background: rgba(255,255,255,0.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), inset 0 -1px 0 rgba(0,0,0,0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4d4640;
  padding: 0;
  border-left: 1px solid rgba(0,0,0,0.06);
}
.seed-chevron svg { width: 10px; height: 6px; }

.seed-fav-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 100%;
  background: #f4e8d7;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.7);
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 10;
}

.seed-fav-item {
  display: flex;
  align-items: center;
  border-radius: 6px;
}

.seed-fav-pick {
  flex: 1;
  text-align: right;
  background: none;
  border: 0;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: #1b1714;
  cursor: pointer;
  border-radius: 6px;
  text-transform: none;
}
.seed-fav-pick:hover { background: rgba(0,0,0,0.05); }

.seed-fav-del {
  flex-shrink: 0;
  background: none;
  border: 0;
  padding: 7px 8px;
  color: #c4b8ab;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
}
.seed-fav-del:hover { color: #a78bfa; background: rgba(0,0,0,0.04); }

.seed-fav-empty {
  padding: 10px 12px;
  color: #4d4640;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-align: right;
}


.seed-code {
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  color: #1b1714;
}


.head-copy { flex: 1; min-width: 0; }

.brand-row {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  overflow: visible;
}

.brand-row h1 {
  margin: 0;
  font-size: 2.35rem;
  line-height: 0.92;
  letter-spacing: -0.08em;
  font-weight: 100;
}

.palette-tag {
  margin-top: 10px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  color: #4d4640;
}

.top-grid,
.bottom-grid {
  --dot: 2px;
  --step: 14px;
  margin: 0;
  background-image:
    radial-gradient(circle, #1b1714 0 var(--dot), transparent calc(var(--dot) + 0.1px));
  background-size: var(--step) var(--step);
  background-repeat: repeat;
  background-position: 0 0;
  box-shadow: none;
  border-radius: 0;
}

.top-grid {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  height: calc(var(--step) * 4);
}

.bottom-grid {
  width: calc(var(--step) * 4);
  height: calc(var(--step) * 4);
}

.top-right-cluster {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  align-self: center;
  gap: 14px;
}

.top-grid {
  align-self: center;
  margin-top: 0;
  justify-self: end;
}

.bottom-grid {
  align-self: center;
}

.power-knob {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid rgba(98, 79, 58, 0.20);
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.98) 0 12%, transparent 13%),
    radial-gradient(circle at 50% 54%, #f7f0e7 0%, #efe3d4 54%, #d7c7b4 100%);
  box-shadow:
    0 9px 16px rgba(57, 42, 31, 0.22),
    inset 0 2px 4px rgba(255,255,255,0.86),
    inset 0 -5px 10px rgba(98,73,48,0.12);
  position: relative;
  cursor: ns-resize;
  touch-action: none;
}

.power-knob::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 3px;
  height: 16px;
  border-radius: 999px;
  transform: translateX(-50%) rotate(calc(var(--knob-angle, 0) * 1deg));
  transform-origin: center 21px;
  background: linear-gradient(180deg, #a5b4fc 0%, #818cf8 100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.04), 0 0 10px rgba(129,140,248,0.36);
}


.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 -24px;
  padding: 0 24px;
  background: transparent;
  border: 0;
}

.control-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
}

.control-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
}

.footer-knobs {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}


.panel-button {
  appearance: none;
  position: relative;
  min-width: 54px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 2px;
  padding: 12px 14px;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-shadow: none;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.85) inset,
    0 6px 12px rgba(77,55,32,0.10),
    inset 0 -1px 0 rgba(64,46,28,0.10);
}

.panel-button-coral { background: #1b1714; color: #f87171; }
.panel-button-green { background: #7ae582; color: #f7ede2; }
.panel-button-cyan  { background: #818cf8; color: #1b1714; }


.lcd-display {
  padding: clamp(6px, 2vw, 16px) clamp(5px, 1.5vw, 14px);
  background: #1b1714;
  color: #818cf8;
  text-align: center;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.lcd-value {
  font-size: clamp(0.85rem, 4vw, 1.4rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 3ch;
  text-align: center;
}
.swatch-list {
  display: grid;
  gap: 12px;
  margin: 24px 0;
}

.part-header-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 2px;
}

.part-header-knobs {
  display: flex;
  gap: 10px;
  align-items: end;
  justify-content: flex-end;
}

.part-header-knobs span {
  width: 47px;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1;
  letter-spacing: 0.18em;
  color: #4d4640;
  text-transform: uppercase;
}

.part-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.part-row.is-off {
  opacity: 0.82;
}

.part-row.is-muted {
  opacity: 0.38;
}

.part-role-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  justify-self: center;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #4d4640;
  margin-right: -2px;
}

.part-pad-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.part-pad {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 0;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.34),
    inset 0 -1px 0 rgba(0,0,0,0.08);
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease, outline-color 120ms ease;
}

.part-pad.swatch-charcoal { background: #1b1714; }
.part-pad.swatch-pink   { background: linear-gradient(90deg, #4338ca, #6366f1); }
.part-pad.swatch-violet { background: linear-gradient(90deg, #7c3aed, #8b5cf6); }
.part-pad.swatch-indigo { background: linear-gradient(90deg, #9333ea, #a855f7); }
.part-pad.swatch-blue   { background: linear-gradient(90deg, #be185d, #ec4899); }
.part-pad.swatch-cyan   { background: linear-gradient(90deg, #dc2626, #ef4444); }

.part-pad.is-off {
  opacity: 1;
  filter: none;
  transform: translateY(0);
  background: #f4e8d7;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.34),
    inset 0 -1px 0 rgba(0,0,0,0.08);
}

.part-pad.is-active {
  opacity: 1;
  outline: 2px solid rgba(27, 23, 20, 0.34);
  box-shadow:
    0 10px 16px rgba(57,42,31,0.24),
    inset 0 1px 2px rgba(255,255,255,0.90),
    inset 0 -5px 10px rgba(98,73,48,0.14);
  transform: translateY(-2px);
}

.part-knob-strip {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.part-knob {
  touch-action: none;
  width: 47px;
  height: 47px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.08) 0 9%, transparent 10%),
    radial-gradient(circle at 50% 54%, #1f1714 0%, #17120f 58%, #0f0b0a 100%);
  box-shadow:
    0 7px 14px rgba(57,42,31,0.18),
    inset 0 1px 2px rgba(255,255,255,0.08),
    inset 0 -4px 8px rgba(0,0,0,0.26);
  position: relative;
  flex: 0 0 auto;
}

.part-knob::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  transform: translateX(-50%) rotate(calc(var(--knob-angle, 0) * 1deg));
  transform-origin: center 18px;
  background: var(--row-accent, #1b1714);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 0 8px rgba(255,255,255,0.12);
  opacity: 0.98;
  will-change: transform;
}

.part-row.swatch-pink   { --row-accent: #818cf8; }
.part-row.swatch-violet { --row-accent: #a78bfa; }
.part-row.swatch-indigo { --row-accent: #c084fc; }
.part-row.swatch-blue   { --row-accent: #f472b6; }
.part-row.swatch-cyan   { --row-accent: #f87171; }

.bottom-rail {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.bottom-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.bottom-right-cluster {
  flex: 1 1 auto;
  min-width: 0;
}


.footer-brand {
  display: grid;
  align-content: end;
  gap: 2px;
  color: #4d4640;
}

.footer-brand-title-wrap {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}

.footer-brand-title {
  font-size: 2.35rem;
  line-height: 0.92;
  letter-spacing: -0.08em;
  font-weight: 100;
}


.footer-brand-subtitle {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.sync-toggle {
  display: flex;
  align-items: center;
  background: rgba(0,0,0,0.1);
  border-radius: 999px;
  padding: 3px;
  gap: 1px;
  touch-action: none;
  user-select: none;
}

.sync-opt {
  width: 32px;
  height: 20px;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(0,0,0,0.35);
  transition: background 150ms ease, color 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.sync-opt:disabled {
  cursor: not-allowed;
  opacity: 0.3;
  pointer-events: none;
}

.sync-opt[data-mode="null"].is-active {
  background: rgba(0,0,0,0.1);
  color: rgba(0,0,0,0.55);
}

.sync-opt[data-mode="master"].is-active,
.sync-opt[data-mode="follow"].is-active {
  background: #1b1714;
  color: #fff;
}
.footer-logo {
  display: flex;
  align-items: baseline;
  gap: 0.18em;
  line-height: 0.9;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  font-weight: 100;
  text-transform: uppercase;
  color: #4d4640;
}

.footer-logo span {
  display: inline-block;
}

.macro-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0 24px;
}

.footer-knob-wrap {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.footer-knob-label {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #4d4640;
}

.footer-knob {
  touch-action: none;
  width: 47px;
  height: 47px;
  border: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 30%, rgba(255,255,255,0.08) 0 9%, transparent 10%),
    radial-gradient(circle at 50% 54%, #1f1714 0%, #17120f 58%, #0f0b0a 100%);
  box-shadow:
    0 7px 14px rgba(57,42,31,0.18),
    inset 0 1px 2px rgba(255,255,255,0.08),
    inset 0 -4px 8px rgba(0,0,0,0.26);
  position: relative;
  flex: 0 0 auto;
}

.footer-knob::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 4px;
  height: 18px;
  border-radius: 999px;
  transform: translateX(-50%) rotate(calc(var(--knob-angle, 0) * 1deg));
  transform-origin: center 18px;
  background: var(--footer-accent, #f7ede2);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05), 0 0 8px rgba(255,255,255,0.12);
  opacity: 0.98;
  will-change: transform;
}

.footer-knob-wrap:nth-child(1) { --footer-accent: #818cf8; }
.footer-knob-wrap:nth-child(2) { --footer-accent: #a78bfa; }
.footer-knob-wrap:nth-child(3) { --footer-accent: #c084fc; }
.footer-knob-wrap:nth-child(4) { --footer-accent: #f472b6; }
.footer-knob-wrap:nth-child(5) { --footer-accent: #f87171; }

.sync-rail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 2px;
}

@media (max-width: 440px) {
  body {
    background:
      linear-gradient(180deg, rgba(255,255,255,0.58), rgba(255,255,255,0.16)),
      linear-gradient(180deg, #f7eedf 0%, #f1e3d0 100%);
  }
  .app-shell { padding: 0; }
  .palette-card { width: 100vw; max-width: none; padding: 24px; border-radius: 0; box-shadow: none; background: transparent; }
  .part-header-row,
  .part-row { grid-template-columns: 16px minmax(0, 1fr) auto; gap: 6px; }
  .part-pad-strip { gap: 8px; }
  .part-pad { aspect-ratio: 1 / 1; }
  .part-knob { width: 38px; height: 38px; }
  .part-knob-strip { gap: 8px; }
  .control-left { gap: 8px; }
  .macro-strip { gap: 8px; margin: 14px 0 18px; flex-wrap: nowrap; }
  .bottom-rail { gap: 12px; }
  .bottom-controls { gap: 8px; }
  .footer-knobs { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
  .part-header-knobs span { width: 38px; }
  .footer-knob { width: 38px; height: 38px; }
  .power-knob { width: 52px; height: 52px; }
  .power-knob::after { top: 7px; width: 3px; height: 14px; transform-origin: center 18px; }
  .part-knob::after,
  .footer-knob::after { top: 5px; width: 3px; height: 14px; transform-origin: center 16px; }
  .footer-logo { font-size: 1.45rem; }
}

#generateBtn, #playButton { font-size: 1.6rem; }

.panel-button svg { width: 22px; height: 22px; display: block; fill: currentColor; }
.panel-button svg path { vector-effect: non-scaling-stroke; }

@keyframes pad-flash {
  0%   { filter: brightness(2.2) saturate(1.4); transform: translateY(-3px) scale(1.05); }
  15%  { filter: brightness(1.6) saturate(1.2); transform: translateY(-2.5px) scale(1.02); }
  100% { filter: brightness(1)   saturate(1);   transform: translateY(-2px) scale(1); }
}

.part-pad.is-active.is-playing {
  animation: pad-flash var(--pad-decay, 0.6s) ease-out forwards;
}
