:root {
  --bg: #f4efe6;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --ink: #171717;
  --muted: #6e655f;
  --line: rgba(23, 23, 23, 0.1);
  --shadow: 0 20px 60px rgba(63, 44, 21, 0.13);
  --good: #17338f;
  --aa: #0bbf83;
  --fail: #ff4d43;
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --page-bg:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 26%),
    linear-gradient(145deg, #efefef 0%, #f6f6f6 45%, #ececec 100%);
}

body[data-canvas-bg="black"] {
  --bg-elevated: rgba(28, 28, 28, 0.84);
  --ink: #f4f1eb;
  --muted: rgba(244, 241, 235, 0.68);
  --line: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --page-bg:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.05), transparent 24%),
    linear-gradient(145deg, #0a0a0a 0%, #121212 45%, #181818 100%);
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--ink);
  background: var(--page-bg);
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
code,
strong,
span,
p,
h1,
h2,
h3,
label {
  overflow-wrap: anywhere;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.panel {
  background: var(--bg-elevated);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.controls-panel {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 40px;
  min-width: 0;
}

.controls-panel > .panel-section:first-child {
  margin-bottom: -20px;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(420px, 1fr) auto;
  gap: 20px;
  min-width: 0;
}

.visual-panel,
.detail-panel {
  padding: 24px;
  min-width: 0;
}

.hero h1,
.panel-topbar h2,
.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--muted);
}

.hero-copy,
.section-heading p,
.section-intro,
.pair-label,
.palette-meta,
.input-label,
.legend span {
  color: var(--muted);
}

.section-intro {
  margin: 0;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.controls-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.04);
}

body[data-canvas-bg="black"] .controls-group {
  background: rgba(255, 255, 255, 0.03);
}

.module-heading {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.module-heading h2 {
  margin: 0;
}

.section-heading.compact {
  gap: 4px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: 160ms ease;
}

.segmented button.active {
  background: #171717;
  color: #fff;
  border-color: #171717;
}

body[data-canvas-bg="black"] .segmented button.active {
  background: rgba(255, 255, 255, 0.18);
  color: #f4f1eb;
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 1px rgba(244, 241, 235, 0.34);
}

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

.metric-card,
.pair-card,
.adjust-card,
.palette-item,
.insight-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-lg);
}

.metric-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.metric-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.palette-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.palette-toolbar-three {
  grid-template-columns: 38px 38px minmax(0, 1fr);
}

.palette-toolbar-four {
  grid-template-columns: 38px 38px 38px minmax(0, 1fr);
}

#image-import-button {
  white-space: nowrap;
}

.controls-panel input[type="text"],
.controls-panel select,
.simulation-control select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.controls-panel select,
.simulation-control select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-panel input[type="text"]:focus,
.controls-panel select:focus,
.simulation-control select:focus {
  border-color: rgba(23, 51, 143, 0.24);
  box-shadow: 0 0 0 3px rgba(23, 51, 143, 0.08);
}

body[data-canvas-bg="black"] .controls-panel input[type="text"],
body[data-canvas-bg="black"] .controls-panel select,
body[data-canvas-bg="black"] .simulation-control select {
  background-color: rgba(255, 255, 255, 0.06);
}

body[data-canvas-bg="black"] .controls-panel select,
body[data-canvas-bg="black"] .simulation-control select {
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(244, 241, 235, 0.86) 50%),
    linear-gradient(135deg, rgba(244, 241, 235, 0.86) 50%, transparent 50%);
}

#palette-name::placeholder {
  color: var(--muted);
}

#generator-count {
  width: 100%;
  margin: 0;
}

#generator-count-value {
  color: var(--muted);
  font-size: 0.82rem;
  align-self: flex-end;
}

.palette-item {
  padding: 16px;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  grid-template-areas:
    "swatch code"
    "swatch meta";
  gap: 10px 16px;
  align-items: center;
  min-width: 0;
  position: relative;
  transition: border-color 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.palette-item.is-dragging {
  opacity: 0.42;
}

.palette-item.drop-target {
  border-color: rgba(23, 51, 143, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(23, 51, 143, 0.14),
    0 8px 24px rgba(23, 51, 143, 0.08);
}

.palette-item:focus-visible {
  outline: 3px solid rgba(23, 51, 143, 0.32);
  outline-offset: 3px;
}

.color-swatch-input {
  grid-area: swatch;
  width: 84px;
  height: 84px;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid rgba(23, 23, 23, 0.08);
  padding: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  justify-self: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.color-swatch-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.color-swatch-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-swatch-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.palette-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  align-items: start;
}

.palette-meta-row {
  grid-area: meta;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.palette-index {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.palette-code-wrap {
  grid-area: code;
  min-width: 0;
}

.palette-code-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  max-width: 100%;
}

.palette-hex-prefix {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1;
}

.palette-hex-input {
  font-size: 0.94rem;
  min-height: 38px;
  max-width: 100%;
  border-color: rgba(23, 23, 23, 0.08);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 8px 12px;
}

.palette-hex-input:disabled,
.color-swatch-input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.palette-hex-input:focus {
  outline: none;
  border-color: rgba(23, 51, 143, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 0 0 3px rgba(23, 51, 143, 0.08);
}

.palette-hex-input[aria-invalid="true"] {
  border-color: rgba(255, 77, 67, 0.55);
  box-shadow: 0 0 0 3px rgba(255, 77, 67, 0.1);
}

body[data-canvas-bg="black"] .palette-hex-input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.palette-name-input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.palette-name-input::placeholder {
  color: var(--muted);
}

.palette-name-input:focus {
  border-color: rgba(23, 51, 143, 0.24);
  box-shadow: 0 0 0 3px rgba(23, 51, 143, 0.08);
}

body[data-canvas-bg="black"] .palette-name-input {
  background: rgba(255, 255, 255, 0.04);
}

.palette-swatch-wrap {
  grid-area: swatch;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.palette-copy-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.06);
  color: var(--ink);
  border-radius: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.palette-copy-button.copied {
  background: rgba(11, 191, 131, 0.14);
  color: var(--aa);
}

.palette-fields input,
.adjust-card select,
.adjust-card input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
}

.palette-fields input {
  text-overflow: ellipsis;
}

.palette-actions {
  display: flex;
  gap: 10px;
  min-width: 0;
  justify-content: flex-end;
}

.palette-lock-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(23, 23, 23, 0.06);
  color: var(--muted);
  border-radius: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
  font-size: 0.92rem;
  line-height: 1;
}

.palette-lock-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.palette-lock-button.is-locked {
  background: rgba(23, 51, 143, 0.1);
  color: var(--good);
  border-color: rgba(23, 51, 143, 0.18);
}

.palette-item.is-selected-foreground,
.palette-item.is-selected-background {
  box-shadow: inset 0 0 0 1px rgba(23, 23, 23, 0.04);
}

body[data-canvas-bg="black"] .palette-item {
  background: rgba(255, 255, 255, 0.06);
}

.palette-item.is-selected-foreground {
  border-color: rgba(11, 191, 131, 0.28);
}

.palette-item.is-selected-background {
  border-color: rgba(23, 51, 143, 0.24);
}

.palette-item.is-selected-foreground.is-selected-background {
  border-color: rgba(23, 51, 143, 0.24);
  box-shadow:
    inset 0 0 0 1px rgba(23, 51, 143, 0.14),
    0 0 0 1px rgba(11, 191, 131, 0.14);
}

.ghost-button,
.primary-button,
.remove-button {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
  line-height: 1.25;
  text-align: center;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.ghost-button:disabled,
.primary-button:disabled,
.remove-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.primary-button {
  background: #171717;
  color: #fff;
}

body[data-canvas-bg="black"] .primary-button {
  background: #f4f1eb;
  color: #111111;
}

.ghost-button {
  background: rgba(23, 23, 23, 0.08);
  color: var(--ink);
}

body[data-canvas-bg="black"] .ghost-button {
  background: rgba(255, 255, 255, 0.08);
}

.remove-button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  background: transparent;
  color: #bf342d;
  border: 1px solid transparent;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  position: absolute;
  top: 6px;
  left: 6px;
  opacity: 0.72;
}

.ghost-button:hover,
.primary-button:hover,
.remove-button:hover,
.segmented button:hover {
  transform: translateY(-1px);
}

.remove-button:hover {
  background: rgba(255, 77, 67, 0.08);
  border-color: rgba(255, 77, 67, 0.12);
  opacity: 1;
}

.panel-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

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

.compact-button {
  width: auto;
  white-space: nowrap;
}

.panel-topbar > * {
  min-width: 0;
}

.matrix-header-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 12px;
}

.matrix-settings-panel {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(23, 23, 23, 0.04);
}

body[data-canvas-bg="black"] .matrix-settings-panel {
  background: rgba(255, 255, 255, 0.06);
}

.matrix-settings-copy {
  min-width: 0;
}

.matrix-settings-copy .eyebrow {
  margin-bottom: 6px;
}

.matrix-settings-text {
  margin: 0;
  color: var(--muted);
  max-width: 34ch;
  line-height: 1.45;
}

.matrix-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.simulation-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.target-ratio-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 110px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

body[data-canvas-bg="black"] .target-ratio-card {
  background: rgba(255, 255, 255, 0.08);
}

.segmented-icons button {
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.legend-dot.pass {
  background: var(--good);
}

.legend-dot.aa {
  background: var(--aa);
}

.legend-dot.fail {
  background: var(--fail);
}

.matrix-insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 0.58fr)) minmax(360px, 2.7fr);
  gap: 12px;
  margin-bottom: 18px;
}

.insight-card {
  padding: 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body[data-canvas-bg="black"] .insight-card {
  background: rgba(255, 255, 255, 0.06);
}

.insight-card-wide {
  min-width: 0;
}

#matrix-summary {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.matrix-wrapper {
  overflow: auto;
  border-radius: 24px;
}

.matrix {
  display: grid;
  grid-auto-columns: minmax(148px, 1fr);
  min-width: max-content;
}

.matrix-header,
.matrix-column {
  display: grid;
}

.matrix-header-cell {
  min-height: 96px;
  padding: 16px;
  color: rgba(255, 255, 255, 0.92);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.matrix-cell {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  min-height: 126px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  margin: 0;
  padding: 0;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.matrix-cell.selected {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.7);
  z-index: 1;
}

.matrix-cell:hover {
  transform: scale(0.985);
}

.contrast-chip {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 1.05rem;
}

.contrast-chip.fail {
  font-size: 2rem;
  line-height: 1;
}

.pair-score {
  min-width: 0;
  max-width: 100%;
  padding: 12px 14px;
  text-align: center;
  border-radius: 16px;
  background: rgba(23, 23, 23, 0.08);
  font-weight: 700;
}

body[data-canvas-bg="black"] .pair-score {
  background: rgba(255, 255, 255, 0.08);
}

.pair-score.status-aaa,
.pair-status.status-aaa {
  color: var(--good);
}

.pair-score.status-aa,
.pair-status.status-aa {
  color: var(--aa);
}

.pair-score.status-fail,
.pair-status.status-fail {
  color: var(--fail);
}

.pair-score.status-aaa {
  background: rgba(23, 51, 143, 0.12);
}

.pair-score.status-aa {
  background: rgba(11, 191, 131, 0.12);
}

.pair-score.status-fail {
  background: rgba(255, 77, 67, 0.12);
}

body[data-canvas-bg="black"] .pair-score.status-aaa {
  background: rgba(23, 51, 143, 0.22);
}

body[data-canvas-bg="black"] .pair-score.status-aa {
  background: rgba(11, 191, 131, 0.2);
}

body[data-canvas-bg="black"] .pair-score.status-fail {
  background: rgba(255, 77, 67, 0.2);
}

.pair-preview {
  min-height: 180px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}

.pair-guidance {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(23, 23, 23, 0.05);
  color: var(--ink);
  line-height: 1.45;
}

body[data-canvas-bg="black"] .pair-guidance {
  background: rgba(255, 255, 255, 0.08);
}

.pair-preview-text {
  font-size: clamp(2rem, 7vw, 4.8rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.pair-grid,
.adjust-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pair-card,
.adjust-card {
  padding: 16px;
  min-width: 0;
}

body[data-canvas-bg="black"] .pair-card,
body[data-canvas-bg="black"] .adjust-card {
  background: rgba(255, 255, 255, 0.06);
}

.pair-card code,
#selected-fg-hex,
#selected-bg-hex,
#selected-threshold {
  font-family: "IBM Plex Mono", monospace;
}

.pair-card strong,
.pair-card code,
.matrix-header-cell strong,
.matrix-header-cell span,
.hero h1,
.hero-copy,
.section-heading p {
  word-break: break-word;
}

.adjust-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.adjust-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.slider-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-section[hidden] {
  display: none;
}

#manual-color {
  width: 56px;
  min-width: 56px;
  height: 56px;
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  border: 2px solid rgba(23, 23, 23, 0.08);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  align-self: center;
  justify-self: end;
  overflow: hidden;
}

#manual-color::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 999px;
}

#manual-color::-webkit-color-swatch {
  border: none;
  border-radius: 999px;
}

#manual-color::-moz-color-swatch {
  border: none;
  border-radius: 999px;
}

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

.manual-controls-row .segmented {
  min-width: 0;
}

.choice-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#generator-mode {
  min-height: 48px;
}

.choice-card {
  display: grid;
  grid-template-columns: 18px auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
}

.choice-card input[type="radio"] {
  margin: 0;
}

.choice-card.active {
  background: rgba(23, 23, 23, 0.06);
  border-color: rgba(23, 51, 143, 0.24);
  box-shadow: inset 0 0 0 1px rgba(23, 51, 143, 0.12);
}

.choice-card.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

body[data-canvas-bg="black"] .choice-card.active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(244, 241, 235, 0.18);
  box-shadow: inset 0 0 0 1px rgba(244, 241, 235, 0.26);
}

.choice-swatch {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(23, 23, 23, 0.08);
}

.choice-label {
  min-width: 0;
}

.choice-meta {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: right;
}

.slider-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.slider-key {
  color: var(--muted);
  font-size: 0.82rem;
}

.slider-row input[type="range"] {
  width: 100%;
  margin: 0;
}

.slider-row output {
  text-align: right;
  color: var(--muted);
  font-size: 0.82rem;
}

.optimization-preview {
  margin-top: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(23, 23, 23, 0.04);
}

body[data-canvas-bg="black"] .optimization-preview {
  background: rgba(255, 255, 255, 0.06);
}

.preview-topbar {
  margin-bottom: 14px;
}

.preview-delta {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(23, 23, 23, 0.08);
  font-weight: 700;
  white-space: nowrap;
}

body[data-canvas-bg="black"] .preview-delta {
  background: rgba(255, 255, 255, 0.08);
}

.preview-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.preview-stage {
  min-height: 140px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.preview-stage-text {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.preview-summary {
  margin: 14px 0 0;
  color: var(--muted);
}

.preview-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

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

  .workspace {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    gap: 14px;
    padding: 12px;
  }

  .controls-panel,
  .visual-panel,
  .detail-panel {
    padding: 18px;
  }

  .palette-toolbar-three,
  .palette-toolbar-four {
    grid-template-columns: 1fr;
  }

  .metrics,
  .matrix-insights,
  .pair-grid,
  .adjust-grid,
  .preview-split,
  .palette-fields {
    grid-template-columns: 1fr;
  }

  .panel-topbar {
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }

  .palette-item {
    grid-template-columns: 1fr;
    grid-template-areas:
      "swatch"
      "code"
      "meta";
    justify-items: stretch;
  }

  .color-swatch-input {
    width: 72px;
    height: 72px;
  }

  .palette-swatch-wrap {
    justify-content: flex-start;
  }

  .palette-meta-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .matrix-header-tools {
    justify-content: flex-start;
  }

  .matrix-settings-panel {
    flex-direction: column;
    align-items: stretch;
  }

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

  .insight-card-wide {
    grid-column: span 2;
  }

  #matrix-summary {
    white-space: normal;
  }
}
