:root {
  --bg: #0f1014;
  --bg-soft: #161922;
  --panel: rgba(22, 25, 34, 0.9);
  --panel-2: rgba(28, 32, 43, 0.92);
  --text: #f3f4f7;
  --muted: #99a2b6;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #7c8cff;
  --accent-soft: rgba(124, 140, 255, 0.16);
  --good: #42c7a5;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124, 140, 255, 0.14), transparent 30%),
    radial-gradient(circle at top right, rgba(66, 199, 165, 0.1), transparent 24%),
    linear-gradient(180deg, #0d0f14 0%, #11141b 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: none;
  color: inherit;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.app-shell {
  width: min(1360px, calc(100% - 20px));
  margin: 0 auto;
  padding: 10px 0 20px;
  display: grid;
  gap: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
}

.eyebrow,
.readout-label,
.result-label,
.mini-note {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.9rem, 3vw, 2.7rem);
  line-height: 1;
}

h2 {
  margin-top: 3px;
  font-size: 1.15rem;
  line-height: 1.1;
}

.subcopy {
  margin-top: 7px;
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.45;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.button:hover,
.segment:hover,
.swatch:hover,
.copy-chip:hover,
.saved-mix:hover,
.readout-card:hover {
  transform: translateY(-1px);
}

.button-ghost {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
}

.button-accent {
  border: 1px solid rgba(124, 140, 255, 0.4);
  background: linear-gradient(180deg, rgba(124, 140, 255, 0.34), rgba(124, 140, 255, 0.22));
}

.button-small {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 12px;
  font-size: 0.9rem;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: 12px;
}

.output-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.result-panel,
.source-panel,
.mini-panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.result-preview-wrap {
  margin-top: 14px;
}

.result-preview {
  position: relative;
  min-height: 360px;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: radial-gradient(circle at 30% 30%, #7a6d7a, #d14b63 44%, #3f9f94 100%);
  display: grid;
  place-items: center;
}

.result-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 22% 22%, rgba(255, 255, 255, 0.28), transparent 20%),
    linear-gradient(140deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.14));
}

.result-center {
  position: relative;
  z-index: 1;
  width: min(74%, 360px);
  aspect-ratio: 1;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  display: grid;
  place-content: center;
  text-align: center;
  padding: 22px;
  backdrop-filter: blur(12px);
}

.result-center strong {
  margin: 8px 0 4px;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.result-center small {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
}

.readout-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.readout-card {
  width: 100%;
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  gap: 6px;
}

.readout-card strong {
  font-size: 0.98rem;
}

.mix-balance-block,
.control-stack {
  margin-top: 12px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.between {
  justify-content: space-between;
}

.compact-row {
  margin-bottom: 8px;
}

.control-title,
.mix-balance-block label,
.overlay-wrap label {
  color: var(--muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.segment {
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.segment.active {
  border-color: rgba(124, 140, 255, 0.45);
  background: rgba(124, 140, 255, 0.14);
}

.overlay-wrap.is-hidden {
  display: none;
}

.source-wells {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.well-card {
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.well-card.active {
  border-color: rgba(124, 140, 255, 0.38);
  box-shadow: inset 0 0 0 1px rgba(124, 140, 255, 0.2);
}

.well-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.well-controls {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 10px;
}

.color-picker {
  width: 100%;
  min-height: 48px;
  padding: 0;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: transparent;
  cursor: pointer;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker::-webkit-color-swatch {
  border: 0;
  border-radius: 13px;
}

.hex-input {
  width: 100%;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 12px;
}

.family-head-row {
  margin-top: 14px;
}

.family-tabs {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.family-tab {
  white-space: nowrap;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
}

.family-tab.active {
  color: var(--text);
  border-color: rgba(124, 140, 255, 0.4);
  background: rgba(124, 140, 255, 0.13);
}

.swatch-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.swatch {
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-align: left;
  cursor: pointer;
  min-height: 128px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.swatch-chip {
  width: 100%;
  height: 54px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}

.swatch-name {
  display: block;
  margin-top: 10px;
  font-size: 0.98rem;
  font-weight: 600;
}

.swatch-hex {
  display: block;
  margin-top: 3px;
  color: inherit;
  opacity: 0.78;
  font-size: 0.82rem;
}

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

.copy-chip,
.saved-mix {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  cursor: pointer;
}

.copy-chip-swatch,
.saved-mix-swatch {
  height: 72px;
}

.copy-chip-copy,
.saved-mix-copy {
  padding: 10px;
  display: grid;
  gap: 4px;
  text-align: left;
}

.copy-chip-copy strong,
.saved-mix-copy strong {
  font-size: 0.92rem;
}

.copy-chip-copy small,
.saved-mix-copy small {
  color: var(--muted);
}

.harmony-groups {
  display: grid;
  gap: 10px;
}

.harmony-group {
  padding: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.harmony-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.harmony-group-head p {
  color: var(--muted);
  font-size: 0.84rem;
}

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

.harmony-swatch {
  min-height: 56px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

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

.empty-state {
  min-height: 92px;
  place-items: center;
}

.empty-state::before {
  content: "No saved mixes yet";
  color: var(--muted);
}

.saved-mix-actions {
  display: flex;
  gap: 6px;
}

.saved-mix-delete {
  min-height: 30px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  cursor: pointer;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid rgba(66, 199, 165, 0.24);
  background: rgba(13, 18, 22, 0.92);
  color: #eaf9f4;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1100px) {
  .workspace-grid,
  .output-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100%, calc(100% - 12px));
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1 1 calc(50% - 8px);
  }

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

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

  .saved-mixes {
    grid-template-columns: 1fr;
  }

  .segment {
    font-size: 0.9rem;
  }
}

.variant-card {
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16);
}

.variant-card .copy-chip-copy small {
  color: inherit;
  opacity: 0.76;
}
