:root {
  color-scheme: light;
  --ink: #17191c;
  --ink-2: #25282d;
  --muted: #73787e;
  --line: #d8d9d6;
  --line-strong: #aeb2b2;
  --surface: #f5f5f2;
  --surface-2: #ecece8;
  --paper: #ffffff;
  --cyan: #1fc7c9;
  --cyan-dark: #087d80;
  --yellow: #f4bd34;
  --danger: #c43a43;
  --radius: 6px;
  --shadow: 0 10px 28px rgba(23, 25, 28, 0.1);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--surface-2);
  color: var(--ink);
}

body {
  min-height: 100vh;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 64px;
  padding: 10px 18px;
  background: var(--ink);
  color: #fff;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  border-bottom: 3px solid var(--cyan);
  position: relative;
  z-index: 10;
}

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

.brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  background: var(--cyan);
  color: var(--ink);
  font: 800 16px/1 Inter, sans-serif;
  clip-path: polygon(0 0, 100% 0, 100% 74%, 76% 100%, 0 100%);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-copy small,
.eyebrow {
  font: 700 9px/1.4 Inter, sans-serif;
  letter-spacing: 0;
  color: #93999f;
}

.mode-switch,
.segmented {
  display: inline-flex;
  padding: 3px;
  background: #31343a;
  border-radius: var(--radius);
}

.mode-button,
.segment {
  border: 0;
  background: transparent;
  color: #b9bdc1;
  min-height: 34px;
  padding: 0 18px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.mode-button.is-active {
  color: var(--ink);
  background: var(--paper);
  font-weight: 700;
}

.mode-badge {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-left: 5px;
  place-items: center;
  border-radius: 9px;
  background: #555a61;
  color: #fff;
  font-size: 10px;
}

.mode-button.is-active .mode-badge {
  background: var(--cyan);
  color: var(--ink);
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-state {
  color: #888e94;
  font-size: 11px;
  margin-right: 4px;
}

.button,
.icon-button,
.tool-button,
.text-button {
  border: 0;
  cursor: pointer;
}

.button {
  min-height: 38px;
  padding: 0 16px;
  border-radius: 4px;
  font-weight: 700;
  white-space: nowrap;
}

.button-primary {
  background: var(--cyan);
  color: #10282a;
}

.button-primary:hover,
.button-convert:hover:not(:disabled) {
  background: #36d5d7;
}

.button-secondary {
  background: #35383e;
  color: #f3f4f4;
  border: 1px solid #4a4e54;
}

.icon-button,
.tool-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 4px;
  background: #33363b;
  color: #f4f4f3;
  font-size: 22px;
}

.icon-button:hover:not(:disabled),
.tool-button:hover {
  background: #44484e;
}

.icon-button:disabled,
.button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-button.small {
  width: 32px;
  height: 32px;
  font-size: 18px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(250px, 288px) minmax(460px, 1fr) minmax(300px, 340px);
  background: var(--surface-2);
}

.side-panel {
  min-height: 0;
  overflow: auto;
  background: var(--surface);
  scrollbar-color: #b5b8b7 transparent;
  scrollbar-width: thin;
}

.source-panel {
  border-right: 1px solid var(--line);
}

.tool-panel {
  border-left: 1px solid var(--line);
}

.panel-heading,
.board-heading,
.progress-heading,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  min-height: 72px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.progress-heading h2,
.board-heading h1 {
  margin: 2px 0 0;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.text-button {
  color: var(--cyan-dark);
  background: transparent;
  font-weight: 700;
  padding: 6px 0;
}

.source-stage {
  position: relative;
  aspect-ratio: 1.6;
  margin: 16px;
  background: #25282c;
  border: 1px solid #111315;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.source-stage.is-dragging {
  cursor: grabbing;
}

#sourceCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.source-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  color: #fff;
  background: #25282c;
  pointer-events: none;
}

.source-empty.is-hidden {
  display: none;
}

.source-empty strong {
  font-size: 14px;
}

.source-empty small {
  color: #9ba0a5;
  font-size: 10px;
}

.upload-symbol {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid #676c71;
  border-radius: 50%;
  color: var(--cyan);
  font-size: 24px;
}

.crop-frame {
  position: absolute;
  width: 62.5%;
  aspect-ratio: 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 100vmax rgba(10, 12, 14, 0.26);
  pointer-events: none;
}

.crop-frame::before,
.crop-frame::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.26);
}

.crop-frame::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
}

.crop-frame::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
}

.crop-frame i {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: var(--cyan);
  border-style: solid;
}

.crop-frame i:nth-child(1) { left: -1px; top: -1px; border-width: 2px 0 0 2px; }
.crop-frame i:nth-child(2) { right: -1px; top: -1px; border-width: 2px 2px 0 0; }
.crop-frame i:nth-child(3) { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }
.crop-frame i:nth-child(4) { left: -1px; bottom: -1px; border-width: 0 0 2px 2px; }

.source-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 14px;
}

.segmented.compact {
  flex: 1;
  background: #e1e2df;
}

.compact .segment {
  flex: 1;
  min-height: 28px;
  padding: 0 10px;
  color: #666b70;
  font-size: 12px;
}

.segment.is-active {
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(23, 25, 28, 0.12);
  font-weight: 700;
}

.source-toolbar .icon-button {
  background: #dfe0dd;
  color: var(--ink);
}

.zoom-readout {
  width: 38px;
  text-align: right;
  font: 700 10px/1 Inter, sans-serif;
  color: var(--muted);
}

.control-stack {
  padding: 14px 16px 4px;
  border-top: 1px solid var(--line);
}

.range-control {
  display: block;
  margin-bottom: 13px;
}

.range-control > span,
.field-row,
.select-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #50555a;
  font-size: 12px;
}

.range-control output {
  color: var(--ink);
  font: 700 11px/1 Inter, sans-serif;
}

input[type="range"] {
  width: 100%;
  height: 18px;
  margin: 5px 0 0;
  accent-color: var(--cyan-dark);
}

.convert-block {
  margin-top: 4px;
  padding: 15px 16px 18px;
  border-top: 1px solid var(--line);
}

.value-chip {
  padding: 3px 7px;
  border-radius: 3px;
  background: #dcdfdc;
  color: var(--ink);
  font: 700 11px/1.2 Inter, sans-serif;
}

.select-field {
  margin: 12px 0;
}

.select-field select {
  min-width: 112px;
  padding: 7px 28px 7px 9px;
  border: 1px solid #c8cac7;
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
}

.button-convert {
  width: 100%;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: var(--cyan);
  color: #10282a;
}

.button-convert small {
  opacity: 0.72;
  font-size: 10px;
  font-weight: 600;
}

.board-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #f0f0ec;
  background-image:
    linear-gradient(#dedfdb 1px, transparent 1px),
    linear-gradient(90deg, #dedfdb 1px, transparent 1px);
  background-size: 24px 24px;
}

.board-heading {
  min-height: 72px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 245, 242, 0.94);
}

.board-options {
  display: flex;
  align-items: center;
  gap: 14px;
}

.switch-label,
.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #565b60;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
}

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

.switch {
  width: 29px;
  height: 16px;
  padding: 2px;
  border-radius: 8px;
  background: #b8bbb9;
  transition: background 150ms ease;
}

.switch::after {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 150ms ease;
}

.switch-label input:checked + .switch {
  background: var(--cyan-dark);
}

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

.board-wrap {
  --ruler-size: 25px;
  flex: 1;
  min-height: 0;
  width: min(100%, calc(100vh - 180px));
  max-width: 790px;
  margin: auto;
  padding: 18px 20px 14px 12px;
  display: grid;
  grid-template-columns: var(--ruler-size) minmax(0, 1fr);
  grid-template-rows: var(--ruler-size) minmax(0, 1fr);
}

.ruler-corner,
.column-ruler,
.row-ruler {
  color: #73787c;
  font: 600 8px/1 Inter, sans-serif;
  user-select: none;
}

.ruler-corner {
  display: grid;
  place-items: center;
}

.column-ruler {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: center;
}

.row-ruler {
  display: grid;
  grid-template-rows: repeat(24, 1fr);
  align-items: center;
  justify-items: center;
}

.column-ruler span,
.row-ruler span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.column-ruler span:nth-child(6n),
.row-ruler span:nth-child(6n) {
  color: var(--ink);
  font-weight: 800;
}

.column-ruler span.is-active,
.row-ruler span.is-active {
  background: var(--cyan);
  color: var(--ink);
}

.canvas-frame {
  position: relative;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  align-self: center;
  width: 100%;
  max-height: 100%;
  background: #fff;
  border: 1px solid #8f9494;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#pixelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

.canvas-drop {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 210px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px dashed #aeb3b2;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  pointer-events: none;
  text-align: center;
}

.canvas-drop span {
  color: var(--muted);
  font-size: 11px;
}

.canvas-drop.is-hidden {
  display: none;
}

.canvas-status {
  min-height: 50px;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  background: rgba(245, 245, 242, 0.96);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.cursor-status,
.hover-color {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-label {
  color: var(--muted);
  font-size: 10px;
}

.cursor-status strong,
.hover-color span {
  font: 700 11px/1 Inter, sans-serif;
}

.hover-color small {
  color: var(--muted);
  font-size: 9px;
}

.mini-swatch {
  width: 18px;
  height: 18px;
  border: 1px solid rgba(23, 25, 28, 0.25);
  background: #fff;
}

.canvas-stats {
  justify-self: end;
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 10px;
}

.canvas-stats b {
  color: var(--ink);
}

.tool-heading {
  align-items: flex-end;
}

.tool-buttons {
  display: flex;
  gap: 3px;
}

.tool-button {
  width: 34px;
  height: 34px;
  background: #e2e3e0;
  color: #42464a;
  font-size: 18px;
}

.tool-button:hover {
  background: #d6d8d5;
}

.tool-button.is-active {
  background: var(--ink);
  color: var(--cyan);
}

.selected-color {
  min-height: 66px;
  margin: 15px 16px 12px;
  padding: 10px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  background: #e8e9e6;
  border-left: 3px solid var(--cyan);
}

.selected-swatch {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(23, 25, 28, 0.28);
}

.selected-color div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.selected-color strong {
  font-size: 13px;
}

.selected-color small {
  color: var(--muted);
  font-size: 9px;
}

.selected-color code {
  color: #5d6267;
  font-size: 9px;
}

.palette-header {
  padding: 0 16px 10px;
}

.palette-tabs {
  width: 100%;
  background: #e1e2df;
}

.palette-tabs .segment {
  flex: 1;
  min-height: 30px;
  padding: 0 6px;
  color: #696e72;
  font-size: 11px;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px;
}

.swatch-button {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid rgba(23, 25, 28, 0.18);
  background: var(--swatch-color);
  cursor: pointer;
}

.swatch-button::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid transparent;
  pointer-events: none;
}

.swatch-button:hover::before {
  border-color: rgba(255, 255, 255, 0.76);
}

.swatch-button.is-selected {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
  z-index: 1;
}

.swatch-button.is-selected::before {
  border-color: rgba(23, 25, 28, 0.72);
}

.swatch-button span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 16px;
  padding: 2px;
  background: rgba(23, 25, 28, 0.66);
  color: #fff;
  font: 700 8px/1 Inter, sans-serif;
  opacity: 0;
}

.swatch-button:hover span,
.swatch-button.is-selected span {
  opacity: 1;
}

.palette-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 14px 16px;
  color: var(--muted);
  font-size: 10px;
}

.note-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
}

.transfer-tools {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.transfer-progress-block {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.progress-heading strong {
  font: 800 24px/1 Inter, sans-serif;
}

.progress-track {
  height: 6px;
  margin: 13px 0 8px;
  background: #d7d9d6;
  overflow: hidden;
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan-dark);
  transition: width 180ms ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 10px;
}

.current-step {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #ebebe7;
}

.current-step-top {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
}

.large-swatch {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(23, 25, 28, 0.25);
  background: #fff;
}

.current-step-top div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-kicker,
.current-step-top small {
  color: var(--muted);
  font-size: 9px;
}

.current-step-top strong {
  font-size: 13px;
}

.cell-count {
  color: var(--ink);
  font: 800 12px/1 Inter, sans-serif;
}

.pixel-navigator {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  gap: 8px;
  align-items: center;
}

.pixel-navigator .icon-button {
  background: #d7d9d6;
  color: var(--ink);
}

.pixel-navigator > div {
  min-height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #c8cac7;
  background: var(--paper);
}

.pixel-navigator strong {
  font: 800 14px/1 Inter, sans-serif;
}

.pixel-navigator small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.runs-block,
.step-list-block {
  padding: 13px 16px 0;
}

.section-title-row h3 {
  margin: 0;
  font-size: 12px;
}

.section-title-row span {
  color: var(--muted);
  font-size: 9px;
}

.run-list {
  max-height: 150px;
  margin-top: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--paper);
}

.run-item {
  width: 100%;
  min-height: 30px;
  padding: 5px 8px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid #ebebe8;
  background: transparent;
  color: #484d51;
  text-align: left;
  cursor: pointer;
}

.run-item:last-child {
  border-bottom: 0;
}

.run-item:hover {
  background: #f0f8f7;
}

.run-item strong {
  color: var(--ink);
  font: 800 10px/1 Inter, sans-serif;
}

.run-item code {
  overflow-wrap: anywhere;
  font-size: 9px;
}

.step-list {
  max-height: 164px;
  margin-top: 8px;
  overflow: auto;
}

.step-item {
  width: 100%;
  min-height: 38px;
  padding: 4px 6px;
  display: grid;
  grid-template-columns: 24px 1fr auto 22px;
  align-items: center;
  gap: 7px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.step-item.is-current {
  background: #e3f5f3;
  box-shadow: inset 3px 0 var(--cyan-dark);
}

.step-item.is-done {
  opacity: 0.48;
}

.step-item-swatch {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(23, 25, 28, 0.2);
}

.step-item-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.step-item-copy strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-item-copy small,
.step-item-count {
  color: var(--muted);
  font-size: 8px;
}

.step-check {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border: 1px solid #afb3b1;
  color: transparent;
  font-size: 10px;
}

.step-item.is-done .step-check {
  background: var(--cyan-dark);
  border-color: var(--cyan-dark);
  color: #fff;
}

.transfer-actions {
  margin-top: auto;
  padding: 14px 16px 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.transfer-actions .button {
  min-width: 0;
  padding: 0 9px;
  font-size: 11px;
}

.transfer-actions .button-secondary {
  background: #e0e1de;
  border-color: #c7cac7;
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 8px 24px rgba(23, 25, 28, 0.28);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .mode-switch {
    grid-row: 2;
    grid-column: 1 / -1;
    width: 100%;
  }

  .mode-button {
    flex: 1;
  }

  .workspace {
    grid-template-columns: minmax(230px, 280px) minmax(420px, 1fr);
    grid-template-rows: minmax(650px, calc(100vh - 112px)) auto;
  }

  .tool-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .edit-tools {
    display: grid;
    grid-template-columns: 280px 1fr;
  }

  .edit-tools .panel-heading,
  .edit-tools .selected-color,
  .edit-tools .palette-note {
    grid-column: 1;
  }

  .palette-header,
  .palette-grid {
    grid-column: 2;
  }

  .palette-header {
    grid-row: 1;
    align-self: end;
  }

  .palette-grid {
    grid-row: 2 / 5;
    grid-template-columns: repeat(8, minmax(42px, 1fr));
    align-content: start;
    padding-bottom: 16px;
  }

  .transfer-tools {
    display: grid;
    grid-template-columns: 280px 1fr 1fr;
    grid-template-rows: auto auto;
  }

  .transfer-progress-block,
  .current-step {
    grid-column: 1;
  }

  .runs-block {
    grid-column: 2;
    grid-row: 1 / 3;
  }

  .step-list-block {
    grid-column: 3;
    grid-row: 1 / 3;
  }

  .run-list,
  .step-list {
    max-height: 260px;
  }

  .transfer-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 9px 12px;
    gap: 10px;
  }

  .brand-copy small,
  .save-state,
  .top-actions .icon-button,
  #clearButton {
    display: none;
  }

  .button {
    min-height: 36px;
    padding: 0 12px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .board-panel {
    order: 1;
    min-height: auto;
    overflow: visible;
  }

  .source-panel {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .tool-panel {
    order: 3;
  }

  .board-heading {
    min-height: 60px;
    padding: 10px 12px;
  }

  .board-wrap {
    --ruler-size: 21px;
    flex: none;
    width: 100%;
    padding: 10px 12px 12px 5px;
  }

  .canvas-frame {
    max-height: none;
  }

  .ruler-corner,
  .column-ruler,
  .row-ruler {
    font-size: 6px;
  }

  .canvas-status {
    grid-template-columns: 1fr 1fr;
    padding: 8px 12px;
  }

  .hover-color {
    justify-self: end;
  }

  .canvas-stats {
    display: none;
  }

  .source-stage {
    max-width: 520px;
    margin-inline: auto;
  }

  .source-toolbar,
  .control-stack,
  .convert-block {
    max-width: 520px;
    margin-inline: auto;
  }

  .edit-tools,
  .transfer-tools {
    display: block;
  }

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

  .transfer-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
  }

  .run-list,
  .step-list {
    max-height: 210px;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 14px;
  }

  .top-actions {
    gap: 4px;
  }

  .board-options {
    gap: 8px;
  }

  .switch-label {
    font-size: 9px;
  }

  .board-heading h1 {
    font-size: 15px;
  }

  .canvas-drop {
    min-width: 176px;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
