:root {
  color-scheme: light;
  --ink: #46566b;
  --muted: #7f8da1;
  --subtle: #9aa7b8;
  --line: rgba(151, 163, 181, 0.28);
  --line-strong: rgba(122, 137, 158, 0.36);
  --panel: #e4eaf3;
  --surface: #dfe6f0;
  --surface-strong: #d9e1ec;
  --brand-yellow: #f2b928;
  --brand-yellow-dark: #c88a12;
  --brand-yellow-soft: #fff7dc;
  --teal: var(--brand-yellow);
  --teal-soft: var(--brand-yellow-soft);
  --blue: var(--brand-yellow);
  --rose: var(--brand-yellow);
  --amber: var(--brand-yellow-dark);
  --gray-70: #4d4d4d;
  --radius: 8px;
  --shadow-raised: 12px 12px 24px rgba(118, 133, 153, 0.42), -12px -12px 24px rgba(255, 255, 255, 0.9);
  --shadow-soft: 7px 7px 15px rgba(118, 133, 153, 0.36), -7px -7px 15px rgba(255, 255, 255, 0.88);
  --shadow-tight: 4px 4px 9px rgba(118, 133, 153, 0.34), -4px -4px 9px rgba(255, 255, 255, 0.86);
  --shadow-inset: inset 5px 5px 11px rgba(118, 133, 153, 0.34), inset -5px -5px 11px rgba(255, 255, 255, 0.92);
  --shadow-inset-deep: inset 7px 7px 14px rgba(118, 133, 153, 0.38), inset -7px -7px 14px rgba(255, 255, 255, 0.94);
  --font-ui:
    "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui,
    sans-serif;
  --font-mono:
    "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--surface);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.68), transparent 28%),
    var(--surface);
  font-family: var(--font-ui);
  font-size: 15px;
}

button,
input,
textarea,
select {
  font: inherit;
  max-width: 100%;
}

button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-weight: 850;
  transition:
    background 120ms ease,
    box-shadow 120ms ease,
    color 120ms ease,
    transform 120ms ease;
}

button:hover {
  background: #e9eff7;
  box-shadow: 9px 9px 18px rgba(118, 133, 153, 0.42), -9px -9px 18px rgba(255, 255, 255, 0.94);
}

button:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-inset);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(242, 185, 40, 0.42);
  outline-offset: 2px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-inset);
}

input,
select {
  min-height: 34px;
  padding: 0 10px;
}

textarea {
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
  font-family: var(--font-mono);
  font-size: 13px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 176px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mascot {
  flex: 0 0 auto;
  width: 104px;
  height: 104px;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  justify-items: start;
  gap: 2px;
  min-width: 0;
  width: max-content;
}

.brand-hero {
  width: 100%;
  height: clamp(118px, 13vw, 176px);
  object-fit: cover;
  object-position: center 48%;
  border-radius: 5px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}

.eyebrow {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.5em;
  width: 100%;
  margin: 0 0 2px;
  color: var(--gray-70);
  font-size: clamp(16px, 1.86vw, 24px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow-word {
  display: inline-block;
}

h1 {
  margin: 0;
  color: var(--brand-yellow);
  font-size: clamp(38px, 4.4vw, 58px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  color: #53657b;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: 0;
}

.header-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

.header-stats span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 22px;
  align-items: start;
  width: min(100%, 1920px);
  margin: 0 auto;
  padding: 26px 28px 32px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-raised);
}

.panel section {
  padding: 20px;
  border-bottom: 1px solid rgba(151, 163, 181, 0.16);
}

.panel section:last-child {
  border-bottom: 0;
}

.section-heading,
.canvas-toolbar,
.replace-bar,
.palette-imports,
.filter-actions,
.export-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-inset-deep);
  cursor: pointer;
  transition:
    background 120ms ease,
    box-shadow 120ms ease;
}

.drop-zone:hover {
  background: #eef3f8;
  box-shadow: inset 5px 5px 12px rgba(118, 133, 153, 0.28), inset -5px -5px 12px rgba(255, 255, 255, 0.96), 0 0 0 2px rgba(242, 185, 40, 0.18);
}

.drop-zone input,
.file-button input {
  display: none;
}

.drop-zone span {
  color: var(--brand-yellow-dark);
  font-weight: 850;
}

.drop-zone small,
.status-text {
  color: var(--muted);
  font-size: 13px;
}

.usage-summary {
  margin: -2px 0 10px;
  color: var(--brand-yellow-dark);
  font-size: 14px;
  font-weight: 850;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-grid h2,
.field-grid .primary-action {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  color: var(--ink);
}

.inline-check input[type="checkbox"] {
  position: relative;
  flex: 0 0 auto;
  width: 56px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  appearance: none;
  background: linear-gradient(145deg, #d3dce8, #edf3f8);
  box-shadow:
    inset 2px 2px 4px rgba(91, 105, 125, 0.42),
    inset -2px -2px 4px rgba(255, 255, 255, 0.96),
    1px 1px 2px rgba(118, 133, 153, 0.16),
    -1px -1px 2px rgba(255, 255, 255, 0.72);
  cursor: pointer;
  transition:
    background 140ms ease,
    box-shadow 140ms ease;
}

.inline-check input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 4px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 50%;
  background: linear-gradient(145deg, #f3f7fb, #d7e0eb);
  box-shadow:
    2px 2px 4px rgba(91, 105, 125, 0.36),
    -2px -2px 4px rgba(255, 255, 255, 0.92);
  transition:
    transform 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

.inline-check input[type="checkbox"]:checked {
  border-color: rgba(255, 228, 150, 0.88);
  background: linear-gradient(145deg, #d99b12, var(--brand-yellow));
  box-shadow:
    inset 2px 2px 4px rgba(137, 92, 7, 0.38),
    inset -2px -2px 4px rgba(255, 238, 177, 0.78),
    1px 1px 2px rgba(118, 133, 153, 0.16),
    -1px -1px 2px rgba(255, 255, 255, 0.72);
}

.inline-check input[type="checkbox"]:checked::before {
  transform: translateX(25px);
  background: linear-gradient(145deg, #f3f7fb, #d7e0eb);
  box-shadow:
    2px 2px 4px rgba(91, 105, 125, 0.36),
    -2px -2px 4px rgba(255, 255, 255, 0.92);
}

.preprocess-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 8px 12px;
  align-items: center;
  padding: 10px 14px;
  border-top: 1px solid rgba(151, 163, 181, 0.2);
  background: var(--panel);
}

.preprocess-panel .section-heading {
  grid-column: 1 / -1;
  min-width: 128px;
  gap: 10px;
}

.preprocess-panel h2 {
  margin: 0;
  white-space: nowrap;
}

.preprocess-panel button {
  min-height: 32px;
  padding: 0 10px;
}

.slider-field {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 40px;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.slider-field label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.slider-field input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  accent-color: var(--blue);
}

.slider-field input[type="range"]::-webkit-slider-runnable-track {
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-yellow), #4c5664);
  box-shadow: var(--shadow-inset);
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5.5px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: linear-gradient(145deg, #edf3f8, #d8e1ec);
  box-shadow: var(--shadow-tight);
}

.slider-field input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: var(--shadow-tight);
}

.slider-field .value-input {
  appearance: textfield;
  -moz-appearance: textfield;
  width: 40px;
  min-height: 30px;
  padding: 0 2px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
  background: linear-gradient(145deg, #eef3f8, #d9e2ec);
  box-shadow:
    inset 2px 2px 5px rgba(141, 153, 174, 0.22),
    inset -2px -2px 5px rgba(255, 255, 255, 0.86);
}

.slider-field .value-input::-webkit-outer-spin-button,
.slider-field .value-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.primary-action {
  border-color: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  background: var(--brand-yellow);
  box-shadow: 8px 8px 16px rgba(178, 136, 31, 0.3), -8px -8px 16px rgba(255, 255, 255, 0.9);
}

.primary-action:hover {
  background: #e7aa20;
}

.palette-imports {
  flex-wrap: wrap;
  margin: 8px 0;
}

.palette-setting {
  margin-bottom: 8px;
}

.palette-scope {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.filter-actions {
  flex-wrap: wrap;
}

.filter-actions button {
  min-height: 30px;
  padding: 0 9px;
  color: var(--ink);
  font-size: 13px;
  background: var(--panel);
}

.filter-actions button:focus,
.filter-actions button:active {
  color: var(--brand-yellow-dark);
}

.grid-filter-toggle {
  gap: 6px;
  min-height: 30px;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.grid-filter-toggle input[type="checkbox"] {
  width: 44px;
  height: 24px;
  min-height: 24px;
}

.grid-filter-toggle input[type="checkbox"]::before {
  width: 16px;
  height: 16px;
}

.grid-filter-toggle input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.series-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.series-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.series-chip input {
  width: auto;
  min-height: auto;
  accent-color: var(--blue);
  box-shadow: none;
}

.series-chip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.file-button {
  display: inline-grid;
  place-items: center;
  width: 54px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-weight: 800;
}

.add-color {
  display: grid;
  grid-template-columns: 0.8fr 1fr 1fr auto;
  gap: 6px;
  margin-top: 8px;
}

.palette-list,
.usage-list {
  display: grid;
  gap: 6px;
  max-height: 250px;
  overflow: auto;
  padding-right: 4px;
}

.swatch-row {
  display: grid;
  grid-template-columns: 24px 58px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 4px;
  background: var(--panel);
  box-shadow: var(--shadow-tight);
  font-size: 13px;
}

.palette-list .swatch-row {
  grid-template-columns: 26px 60px minmax(0, 1fr) auto;
  border-left: 3px solid var(--brand-yellow);
  font-family: var(--font-mono);
}

.swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(15, 23, 42, 0.18);
  border-radius: 50%;
  box-shadow: 2px 2px 6px rgba(131, 146, 165, 0.28), -2px -2px 6px rgba(255, 255, 255, 0.72);
}

.canvas-panel {
  overflow: hidden;
}

.canvas-toolbar {
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 14px;
  border-bottom: 1px solid rgba(151, 163, 181, 0.2);
  background: var(--panel);
}

.canvas-toolbar > * {
  min-width: 0;
}

.tool-group {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-inset);
}

.tool {
  min-height: 34px;
  padding: 0 14px;
  border-color: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  background: var(--panel);
  box-shadow:
    3px 3px 7px rgba(118, 133, 153, 0.28),
    -3px -3px 7px rgba(255, 255, 255, 0.86);
}

.tool:hover {
  color: var(--ink);
  background: #e9eff7;
  box-shadow:
    4px 4px 8px rgba(118, 133, 153, 0.3),
    -4px -4px 8px rgba(255, 255, 255, 0.88);
}

.tool.active {
  color: var(--ink);
  background: var(--brand-yellow);
  border-color: rgba(255, 228, 150, 0.88);
  box-shadow:
    inset 2px 2px 4px rgba(137, 92, 7, 0.34),
    inset -2px -2px 4px rgba(255, 238, 177, 0.72),
    1px 1px 2px rgba(118, 133, 153, 0.14);
}

.tool.active:hover {
  background: var(--brand-yellow);
}

.tool:active {
  transform: translateY(0);
}

.selected-color {
  width: min(260px, 36vw);
}

.canvas-shell {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 560px;
  max-width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    linear-gradient(90deg, rgba(151, 163, 181, 0.12) 1px, transparent 1px),
    linear-gradient(0deg, rgba(151, 163, 181, 0.12) 1px, transparent 1px),
    var(--surface-strong);
  background-size: 20px 20px;
  box-shadow: var(--shadow-inset-deep);
}

#patternCanvas {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 860px);
  height: auto;
  image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.empty-canvas {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.empty-canvas strong {
  color: var(--brand-yellow-dark);
  font-size: 18px;
}

.replace-bar {
  flex-wrap: nowrap;
  padding: 14px;
  border-top: 1px solid rgba(151, 163, 181, 0.2);
  background: var(--panel);
}

.replace-bar span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.replace-bar select {
  flex: 0 1 132px;
  min-width: 96px;
  max-width: 142px;
}

.replace-bar button {
  flex: 0 0 auto;
  min-width: 64px;
  padding-inline: 12px;
}

.board-heading {
  gap: 12px;
}

.board-size-control {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.board-size-control input {
  appearance: textfield;
  -moz-appearance: textfield;
  width: 64px;
  min-height: 30px;
  padding: 0 6px;
  color: var(--ink);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.board-size-control input::-webkit-outer-spin-button,
.board-size-control input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#boardCanvas {
  width: 100%;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 4px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-inset);
}

.usage-list .swatch-row {
  grid-template-columns: 22px 58px minmax(0, 1fr) 54px;
}

.count-pill {
  justify-self: end;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--brand-yellow);
  box-shadow: 2px 2px 6px rgba(178, 136, 31, 0.18), -2px -2px 6px rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.export-actions {
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-inset);
}

.export-actions button {
  width: 100%;
}

.separation-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow-inset);
}

.separation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.separation-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.separation-title strong {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--brand-yellow);
  box-shadow: var(--shadow-tight);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.separation-heading div {
  display: flex;
  gap: 6px;
}

.separation-heading button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 12px;
}

.separation-color-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 7px;
  max-height: 180px;
  overflow: auto;
  padding: 2px 4px 4px 2px;
}

.separation-chip {
  display: grid;
  grid-template-columns: 41px minmax(0, 1fr) auto 24px;
  gap: 5px;
  align-items: center;
  min-height: 30px;
  padding: 4px 6px;
  border-radius: 5px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow-tight);
  font-family: var(--font-mono);
  font-size: 12px;
}

.separation-check {
  display: grid;
  grid-template-columns: 18px 18px;
  gap: 5px;
  align-items: center;
}

.separation-chip input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  box-shadow: none;
  accent-color: var(--brand-yellow);
}

.separation-chip .swatch {
  width: 16px;
  height: 16px;
}

.separation-chip strong,
.separation-chip small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.separation-chip small {
  color: var(--muted);
  font-weight: 900;
}

.delete-color-button {
  position: relative;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border-radius: 50%;
  color: var(--muted);
  background: var(--panel);
  box-shadow:
    2px 2px 5px rgba(118, 133, 153, 0.24),
    -2px -2px 5px rgba(255, 255, 255, 0.82);
}

.delete-color-button::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 7px;
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  box-shadow: 0 3px 0 -1px currentColor;
}

.delete-color-button span {
  position: absolute;
  left: 8px;
  top: 10px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 1px 1px 3px 3px;
}

.delete-color-button:hover {
  color: var(--ink);
}

.delete-color-button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.export-preview {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.export-preview:empty {
  display: none;
}

.export-preview img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 4px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.export-preview a {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: var(--radius);
  color: var(--brand-yellow-dark);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.export-preview a.download-link {
  min-height: 48px;
  color: var(--ink);
  background: var(--brand-yellow);
  box-shadow:
    6px 6px 12px rgba(178, 136, 31, 0.28),
    -6px -6px 12px rgba(255, 255, 255, 0.88);
}

@media (min-width: 1081px) {
  .controls-panel,
  .output-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 36px);
    overflow: auto;
  }
}

@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(310px, 360px) minmax(0, 1fr) minmax(310px, 360px);
  }

  .canvas-shell {
    min-height: 640px;
  }
}

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr) minmax(260px, 330px);
    gap: 18px;
    padding-inline: 20px;
  }

  .app-header {
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    padding-inline: 20px;
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
  }

  .canvas-panel {
    grid-column: 1 / -1;
    order: 3;
  }

  .output-panel {
    order: 2;
  }

  .controls-panel {
    order: 1;
  }

  .canvas-shell {
    min-height: 420px;
  }

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

  .preprocess-panel .section-heading {
    grid-column: 1 / -1;
  }

  .selected-color {
    width: min(320px, 100%);
  }
}

@media (max-width: 820px) {
  .app-header {
    grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr);
    gap: 14px;
    padding-inline: 16px;
  }

  .brand-mascot {
    width: 88px;
    height: 88px;
  }

  h1 {
    font-size: 40px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 16px max(12px, env(safe-area-inset-left)) 22px max(12px, env(safe-area-inset-right));
  }

  .canvas-panel,
  .output-panel,
  .controls-panel {
    order: initial;
  }
}

@media (max-width: 640px) {
  button,
  input,
  select {
    min-height: 42px;
  }

  .app-header {
    grid-template-columns: 1fr;
    gap: 12px;
    min-height: 0;
    padding: 14px;
  }

  .brand-lockup {
    justify-content: center;
    gap: 12px;
  }

  .brand-hero {
    width: 100%;
    height: 112px;
    object-position: center;
  }

  .brand-mascot {
    width: 78px;
    height: 78px;
  }

  h1 {
    font-size: 32px;
  }

  .eyebrow {
    font-size: 13.5px;
  }

  .workspace {
    gap: 14px;
    padding: 14px max(10px, env(safe-area-inset-left)) 20px max(10px, env(safe-area-inset-right));
  }

  .panel {
    box-shadow: var(--shadow-soft);
  }

  .panel section {
    padding: 16px;
  }

  .drop-zone {
    min-height: 104px;
  }

  .add-color {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 0.76fr 0.76fr 0.84fr 0.92fr;
    gap: 8px;
    align-items: end;
  }

  .field-grid h2,
  .field-grid .primary-action {
    grid-column: 1 / -1;
  }

  .field-grid label {
    min-width: 0;
    gap: 4px;
    font-size: 11px;
    line-height: 1.15;
  }

  .field-grid input[type="number"] {
    width: 100%;
    min-width: 0;
    padding-inline: 8px;
  }

  .field-grid .inline-check {
    display: grid;
    justify-items: center;
    gap: 4px;
    min-height: 0;
    text-align: center;
    white-space: nowrap;
  }

  .field-grid .inline-check input[type="checkbox"] {
    width: 46px;
    height: 26px;
    min-height: 26px;
  }

  .field-grid .inline-check input[type="checkbox"]::before {
    width: 18px;
    height: 18px;
  }

  .field-grid .inline-check input[type="checkbox"]:checked::before {
    transform: translateX(20px);
  }

  .canvas-toolbar,
  .replace-bar {
    align-items: center;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }

  .tool-group {
    flex: 0 0 auto;
    width: auto;
    align-items: center;
    gap: 4px;
    padding: 4px;
  }

  .tool {
    flex: 0 0 auto;
    min-width: 48px;
    min-height: 34px;
    padding-inline: 8px;
  }

  .selected-color {
    display: flex;
    flex: 1 1 150px;
    width: auto;
    max-width: none;
    min-width: 138px;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
  }

  .selected-color select {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    min-height: 34px;
  }

  .canvas-toolbar > .inline-check {
    flex: 0 0 auto;
    gap: 6px;
    min-height: 42px;
    white-space: nowrap;
  }

  .tool-group {
    align-self: flex-start;
  }

  .preprocess-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px 8px;
    padding: 10px 12px;
  }

  .preprocess-panel .section-heading {
    grid-column: 1 / -1;
    min-height: 30px;
  }

  .preprocess-panel h2 {
    margin: 0;
    font-size: 14px;
  }

  .preprocess-panel button {
    min-height: 30px;
    padding: 0 10px;
  }

  .slider-field {
    grid-template-columns: 38px minmax(0, 1fr) 46px;
    gap: 4px;
    min-width: 0;
  }

  .slider-field label {
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
  }

  .slider-field input[type="range"] {
    min-height: 22px;
  }

  .slider-field input[type="range"]::-webkit-slider-runnable-track {
    height: 5px;
  }

  .slider-field input[type="range"]::-webkit-slider-thumb {
    width: 15px;
    height: 15px;
    margin-top: -5px;
  }

  .slider-field input[type="range"]::-moz-range-thumb {
    width: 15px;
    height: 15px;
  }

  .slider-field .value-input {
    width: 46px;
    min-height: 28px;
    padding-inline: 4px;
    font-size: 12px;
  }

  .replace-bar {
    gap: 6px;
  }

  .replace-bar span {
    font-size: 11px;
    white-space: nowrap;
  }

  .replace-bar select {
    flex: 0 0 92px;
    width: 92px;
    min-width: 92px;
    max-width: 92px;
  }

  .replace-bar button {
    flex: 0 0 56px;
    min-width: 56px;
    padding-inline: 8px;
  }

  .canvas-shell {
    min-height: min(360px, 78vh);
  }

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

  .separation-heading div {
    width: 100%;
  }

  .separation-heading button {
    flex: 1;
  }

  .separation-color-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 230px;
  }

  .separation-chip {
    grid-template-columns: 41px minmax(0, 1fr) auto 24px;
    min-height: 36px;
  }
}

@media (max-width: 380px) {
  body {
    font-size: 14px;
  }

  .brand-mascot {
    width: 68px;
    height: 68px;
  }

  h1 {
    font-size: 28px;
  }

  .brand-hero {
    height: 88px;
  }

  .panel section {
    padding: 14px;
  }

  .field-grid {
    gap: 6px;
  }

  .field-grid label {
    font-size: 10.5px;
  }

  .field-grid input[type="number"] {
    padding-inline: 6px;
  }

  .tool {
    min-width: 44px;
    padding-inline: 7px;
  }

  .selected-color {
    flex: 1 1 128px;
    width: auto;
    max-width: none;
    min-width: 124px;
    gap: 4px;
  }

  .replace-bar select {
    flex-basis: 82px;
    width: 82px;
    min-width: 82px;
    max-width: 82px;
  }

  .replace-bar button {
    flex-basis: 50px;
    min-width: 50px;
  }

  .preprocess-panel {
    gap: 6px;
    padding: 8px 10px;
  }

  .slider-field {
    grid-template-columns: 34px minmax(0, 1fr) 40px;
    gap: 3px;
  }

  .slider-field label {
    font-size: 10.5px;
  }

  .slider-field .value-input {
    width: 40px;
    min-height: 26px;
    font-size: 11px;
  }

  .separation-color-list {
    grid-template-columns: 1fr;
  }

  .inline-check input[type="checkbox"] {
    width: 50px;
    height: 28px;
    min-height: 28px;
  }

  .inline-check input[type="checkbox"]::before {
    width: 20px;
    height: 20px;
  }

  .inline-check input[type="checkbox"]:checked::before {
    transform: translateX(22px);
  }

  .grid-filter-toggle input[type="checkbox"] {
    width: 44px;
    height: 24px;
    min-height: 24px;
  }

  .grid-filter-toggle input[type="checkbox"]::before {
    width: 16px;
    height: 16px;
  }

  .grid-filter-toggle input[type="checkbox"]:checked::before {
    transform: translateX(20px);
  }
}
