:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #6f746c;
  --paper: #f6f1e7;
  --surface: #fffdf8;
  --line: #d9d5ca;
  --accent: #ec6146;
  --accent-dark: #c94430;
  --mint: #4b9b7d;
  --yellow: #efbf45;
  --blue: #427ca4;
  --shadow: 0 18px 50px rgba(45, 38, 26, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 12%, rgba(239, 191, 69, 0.13), transparent 23rem),
    radial-gradient(circle at 90% 19%, rgba(75, 155, 125, 0.09), transparent 24rem),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(66, 124, 164, 0.35);
  outline-offset: 2px;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 12px max(24px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(79, 75, 65, 0.13);
  background: rgba(246, 241, 231, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand > span:last-child {
  display: grid;
  line-height: 1;
}

.brand b {
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
  font-size: 23px;
  letter-spacing: 0.08em;
}

.brand small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

.brand-mark {
  display: grid;
  width: 37px;
  height: 37px;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  transform: rotate(-4deg);
}

.brand-mark i {
  border-radius: 3px;
  background: var(--ink);
}

.brand-mark i:nth-child(2),
.brand-mark i:nth-child(4),
.brand-mark i:nth-child(6),
.brand-mark i:nth-child(8) {
  background: var(--accent);
}

.brand-mark i:nth-child(5) {
  background: var(--yellow);
}

.privacy-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  padding: 8px 13px;
  border: 1px solid rgba(75, 155, 125, 0.25);
  border-radius: 99px;
  color: #38795f;
  background: rgba(75, 155, 125, 0.07);
  font-size: 12px;
  font-weight: 700;
}

.privacy-pill span,
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px rgba(75, 155, 125, 0.12);
}

.icon-button {
  width: 34px;
  height: 34px;
  margin-left: 12px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
}

body.editing main {
  width: 100%;
  max-width: none;
}

.hero {
  display: grid;
  min-height: calc(100vh - 76px);
  padding: clamp(48px, 8vh, 96px) clamp(24px, 5vw, 84px) 36px;
  grid-template-columns: minmax(340px, 0.9fr) minmax(430px, 1.1fr);
  gap: clamp(44px, 8vw, 130px);
  align-items: center;
}

.hero-copy {
  align-self: center;
  max-width: 590px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.hero h1,
.work-head h1 {
  margin: 0;
  font-family: "Arial Rounded MT Bold", "PingFang SC", sans-serif;
  font-size: clamp(42px, 5vw, 72px);
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.hero h1 strong {
  position: relative;
  color: var(--accent);
  font-weight: inherit;
  white-space: nowrap;
}

.hero h1 strong::after {
  position: absolute;
  right: 0;
  bottom: -7px;
  left: 0;
  height: 5px;
  border-radius: 99px;
  background: var(--yellow);
  content: "";
  transform: rotate(-1deg);
}

.hero-desc {
  max-width: 510px;
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
}

.upload-card {
  position: relative;
  display: flex;
  min-height: 470px;
  padding: 42px;
  overflow: hidden;
  border: 2px dashed #c8c3b5;
  border-radius: 28px;
  background: rgba(255, 253, 248, 0.78);
  box-shadow: var(--shadow);
  align-items: center;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  transition: 180ms ease;
}

.upload-card::before {
  position: absolute;
  width: 150px;
  height: 150px;
  top: -88px;
  right: -70px;
  border-radius: 40px;
  background: var(--mint);
  content: "";
  opacity: 0.16;
  transform: rotate(24deg);
}

.upload-card.dragging {
  border-color: var(--accent);
  background: #fffaf3;
  transform: translateY(-3px);
}

.upload-visual {
  display: grid;
  width: 142px;
  height: 142px;
  margin-bottom: 26px;
  border-radius: 34px;
  background: #efe9dd;
  place-items: center;
  transform: rotate(3deg);
}

.mini-pattern {
  display: grid;
  width: 96px;
  height: 96px;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  transform: rotate(-3deg);
}

.mini-pattern i {
  border-radius: 4px;
  background: #ddd5c8;
}

.mini-pattern i:nth-child(3),
.mini-pattern i:nth-child(7),
.mini-pattern i:nth-child(8),
.mini-pattern i:nth-child(9),
.mini-pattern i:nth-child(11),
.mini-pattern i:nth-child(13),
.mini-pattern i:nth-child(15),
.mini-pattern i:nth-child(17),
.mini-pattern i:nth-child(18),
.mini-pattern i:nth-child(19),
.mini-pattern i:nth-child(23) {
  background: var(--accent);
}

.mini-pattern i:nth-child(12),
.mini-pattern i:nth-child(14) {
  background: var(--yellow);
}

.upload-card h2 {
  margin: 0 0 9px;
  font-size: 24px;
}

.upload-card p {
  margin: 0 0 24px;
  color: var(--muted);
}

.upload-card > small {
  margin-top: 18px;
  color: #94968f;
  font-size: 11px;
}

.clipboard-card {
  display: grid;
  width: min(460px, 100%);
  min-height: 64px;
  margin-top: 22px;
  padding: 8px 9px;
  border: 1px solid rgba(75, 155, 125, 0.24);
  border-radius: 15px;
  background: rgba(75, 155, 125, 0.07);
  align-items: center;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  text-align: left;
}

.clipboard-card.ready {
  border-color: rgba(236, 97, 70, 0.34);
  background: rgba(236, 97, 70, 0.07);
}

.clipboard-preview {
  display: grid;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 10px;
  color: #39795f;
  background: #fffdf8;
  box-shadow: inset 0 0 0 1px rgba(54, 58, 52, 0.1);
  font-size: 13px;
  font-weight: 900;
  place-items: center;
}

.clipboard-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.clipboard-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.clipboard-copy b,
.clipboard-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipboard-copy b {
  font-size: 12px;
}

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

.clipboard-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(75, 155, 125, 0.28);
  border-radius: 10px;
  color: #39795f;
  background: #fffdf8;
  cursor: pointer;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.clipboard-card.ready .clipboard-button {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
  transition: 150ms ease;
}

.primary-button {
  color: white;
  background: var(--ink);
  box-shadow: 0 7px 18px rgba(32, 35, 31, 0.2);
}

.primary-button:hover {
  background: #090a09;
  transform: translateY(-1px);
}

.primary-button span {
  color: var(--yellow);
}

.primary-button.compact {
  min-height: 42px;
  background: var(--accent);
  box-shadow: 0 6px 16px rgba(236, 97, 70, 0.25);
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
}

.secondary-button:hover {
  border-color: #aaa69b;
}

.text-button {
  background: transparent;
}

.full {
  width: 100%;
}

.feature-strip {
  display: grid;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, 1fr);
}

.feature-strip div {
  position: relative;
  display: grid;
  min-height: 64px;
  padding: 0 24px 0 55px;
  border-right: 1px solid var(--line);
  align-content: center;
}

.feature-strip div:last-child {
  border-right: 0;
}

.feature-strip span {
  position: absolute;
  top: 5px;
  left: 10px;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 24px;
  font-style: italic;
}

.feature-strip b {
  font-size: 14px;
}

.feature-strip small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.workspace {
  min-height: calc(100vh - 76px);
  padding: 0 0 42px;
}

.work-head {
  display: flex;
  min-height: 86px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.9);
  align-items: center;
  justify-content: space-between;
}

.work-head .eyebrow {
  margin-bottom: 6px;
}

.work-head h1 {
  max-width: 70vw;
  overflow: hidden;
  font-size: clamp(27px, 3vw, 38px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-actions {
  display: flex;
  gap: 7px;
}

.editor-layout {
  display: grid;
  min-height: calc(100vh - 162px);
  overflow: visible;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  align-items: start;
  grid-template-columns: 330px minmax(0, 1fr);
}

.controls {
  position: sticky;
  top: 76px;
  height: calc(100vh - 76px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbf8f1;
}

.mobile-control-panels {
  min-width: 0;
}

.control-section {
  border-bottom: 1px solid var(--line);
}

.section-title {
  display: flex;
  width: 100%;
  min-height: 65px;
  padding: 0 20px;
  border: 0;
  background: transparent;
  align-items: center;
  font-weight: 850;
}

.section-title span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .section-swipe-cue {
  display: none;
}

.section-title em {
  display: grid;
  width: 25px;
  height: 25px;
  border-radius: 8px;
  color: white;
  background: var(--ink);
  font-size: 11px;
  font-style: normal;
  place-items: center;
}

.section-body {
  padding: 0 20px 22px;
}

.source-thumb {
  position: relative;
  height: 250px;
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(45deg, #e8e5de 25%, transparent 25%),
    linear-gradient(-45deg, #e8e5de 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e5de 75%),
    linear-gradient(-45deg, transparent 75%, #e8e5de 75%);
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  background-size: 12px 12px;
}

.source-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.source-thumb canvas:focus-visible {
  outline: 3px solid rgba(66, 124, 164, 0.45);
  outline-offset: -3px;
}

.frame-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: end;
}

.mode-field {
  display: grid;
  flex: 1;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.mode-field select {
  width: 100%;
  height: 36px;
  padding: 0 30px 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-weight: 700;
}

.frame-reset {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: nowrap;
}

.calibration-note {
  display: grid;
  margin: 1px 0 14px;
  padding: 1px 0 1px 10px;
  border-left: 2px solid rgba(66, 124, 164, 0.65);
  color: var(--muted);
  gap: 4px;
  line-height: 1.5;
}

.calibration-note b {
  color: var(--blue);
  font-size: 10px;
}

.calibration-note span {
  font-size: 10px;
}

.frame-hint {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.frame-hint b {
  color: var(--accent-dark);
}

.crop-grid {
  display: grid;
  margin-bottom: 12px;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.crop-grid label {
  position: relative;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.crop-grid input,
.field-row input {
  width: 100%;
  height: 34px;
  padding: 0 20px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  font-weight: 750;
}

.crop-grid label span {
  position: absolute;
  right: 7px;
  bottom: 9px;
  font-size: 9px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 18px 1fr;
  gap: 6px;
  align-items: end;
}

.grid-number-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.grid-number-label {
  display: flex;
  color: var(--muted);
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.grid-number-label small {
  color: #a09f99;
  font-size: 8px;
}

.grid-stepper {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
}

.grid-stepper button {
  display: none;
}

.grid-detect-row {
  display: grid;
  margin-bottom: 10px;
  align-items: end;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
}

.detect-compact {
  display: inline-flex;
  min-height: 34px;
  padding: 0 8px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 10px;
}

.detect-compact svg {
  width: 14px;
  height: 14px;
  fill: none;
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.field-row > span {
  padding-bottom: 9px;
  color: var(--muted);
  text-align: center;
}

.hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.range-field {
  display: block;
  margin-bottom: 22px;
}

.range-field > span,
.number-field,
.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 750;
}

.range-field output {
  color: var(--accent-dark);
  font-size: 11px;
}

.range-track-wrap {
  position: relative;
  display: block;
  height: 17px;
  margin: 12px 0 7px;
}

.range-field input {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 5px;
  margin: 6px 0 0;
  accent-color: var(--accent);
}

.range-ticks {
  position: absolute;
  z-index: 1;
  top: 4px;
  right: 8px;
  left: 8px;
  display: flex;
  pointer-events: none;
  justify-content: space-between;
}

.range-ticks i {
  width: 2px;
  height: 9px;
  border-radius: 99px;
  background: rgba(201, 68, 48, 0.62);
  box-shadow: 0 0 0 1px rgba(255, 253, 248, 0.7);
}

.range-field > small {
  display: flex;
  color: #a09f99;
  font-size: 9px;
  font-style: normal;
  justify-content: space-between;
}

.range-field > small i {
  font-style: normal;
}

.number-field {
  margin-bottom: 17px;
}

.number-field > span:first-child {
  display: grid;
  gap: 4px;
}

.number-field small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

.color-count-output {
  display: flex;
  min-width: 76px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(236, 97, 70, 0.22);
  border-radius: 10px;
  color: var(--accent-dark);
  background: rgba(236, 97, 70, 0.07);
  align-items: baseline;
  justify-content: center;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 38px;
}

.color-count-output i {
  margin-left: 4px;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
}

.number-input {
  display: flex;
  align-items: center;
  min-width: 92px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  overflow: hidden;
}

.number-input input {
  width: 64px;
  min-width: 0;
  height: 100%;
  padding: 0 4px 0 9px;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
}

.number-input i {
  padding-right: 9px;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 500;
}

.toggle-field {
  gap: 12px;
}

.toggle-field > span {
  display: grid;
  gap: 4px;
}

.toggle-field small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

.toggle-field input {
  position: relative;
  width: 39px;
  min-width: 39px;
  height: 22px;
  border-radius: 20px;
  appearance: none;
  background: #cbc9c1;
  cursor: pointer;
  transition: 150ms ease;
}

.toggle-field input::after {
  position: absolute;
  width: 16px;
  height: 16px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  content: "";
  transition: 150ms ease;
}

.toggle-field input:checked {
  background: var(--mint);
}

.toggle-field input:checked::after {
  transform: translateX(17px);
}

.palette-summary {
  margin: 0 0 12px;
  padding: 9px 10px;
  border-radius: 9px;
  color: #49695d;
  background: rgba(110, 183, 148, 0.11);
  font-size: 10px;
  line-height: 1.55;
}

.palette-guide {
  display: grid;
  padding: 0 9px 5px;
  color: #96968f;
  font-size: 8px;
  font-weight: 750;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 11px;
}

.palette-list {
  display: grid;
  padding: 1px;
  gap: 8px;
}

.palette-mapping {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 10px 9px 31px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: white;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr);
  gap: 11px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.palette-mapping.active {
  border-color: rgba(66, 124, 164, 0.76);
  box-shadow: inset 0 0 0 1px rgba(66, 124, 164, 0.42);
}

.palette-mapping.drop-target {
  border-color: var(--mint);
  background: rgba(110, 183, 148, 0.1);
  box-shadow: inset 0 0 0 2px rgba(77, 155, 124, 0.28);
}

.palette-target,
.palette-matches {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
}

.palette-target {
  padding-right: 10px;
  border-right: 1px solid #ebe8e0;
}

.mapping-label {
  color: #8c8c85;
  font-size: 8px;
  font-weight: 800;
}

.target-color-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.target-color-button {
  position: relative;
  display: grid;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 3px;
  border: 1px solid rgba(39, 38, 34, 0.2);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  place-items: stretch;
}

.target-color-button i {
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 5px;
}

.target-color-button::after {
  position: absolute;
  right: -3px;
  bottom: -3px;
  display: grid;
  width: 14px;
  height: 14px;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  background: var(--blue);
  box-shadow: 0 1px 4px rgba(24, 30, 28, 0.24);
  content: "✎";
  font-size: 7px;
  place-items: center;
}

.target-color-row span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.target-color-row b,
.target-color-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-color-row b {
  color: var(--ink);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.target-color-row small {
  color: var(--muted);
  font-size: 8px;
}

.palette-code-field {
  display: grid;
  gap: 4px;
}

.palette-code-field span {
  color: var(--muted);
  font-size: 8px;
}

.palette-code-field input {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fbfaf6;
  font-size: 10px;
  font-weight: 800;
}

.matches-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.matches-header button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(66, 124, 164, 0.3);
  border-radius: 7px;
  color: var(--blue);
  background: rgba(66, 124, 164, 0.08);
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.match-color-list {
  display: flex;
  max-height: 102px;
  padding-right: 2px;
  overflow-y: auto;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 5px;
}

.match-color-chip {
  display: grid;
  min-width: 0;
  height: 25px;
  padding: 0 3px 0 4px;
  border: 1px solid #e3e0d8;
  border-radius: 7px;
  background: #faf9f5;
  grid-template-columns: 13px minmax(0, 1fr) 17px;
  align-items: center;
  cursor: grab;
  gap: 4px;
  touch-action: none;
  user-select: none;
}

.match-color-chip:active {
  cursor: grabbing;
}

.match-color-chip.dragging {
  opacity: 0.28;
}

.match-color-chip > i {
  width: 13px;
  height: 13px;
  border: 1px solid rgba(0, 0, 0, 0.13);
  border-radius: 4px;
}

.match-color-chip > b {
  overflow: hidden;
  color: #6f706b;
  font-size: 7px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.match-color-chip button {
  display: grid;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #92928c;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  place-items: center;
}

.match-color-chip button:hover {
  color: white;
  background: var(--accent);
}

.empty-matches {
  color: #aaa9a2;
  font-size: 9px;
}

.palette-remove {
  position: absolute;
  right: 8px;
  bottom: 6px;
  min-height: 22px;
  padding: 0 5px;
  border: 0;
  color: #a76457;
  background: transparent;
  cursor: pointer;
  font-size: 8px;
}

.palette-actions {
  display: grid;
  margin-top: 9px;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.9fr);
  gap: 7px;
}

.palette-add-button,
.palette-reset-button {
  min-height: 34px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.palette-add-button {
  border: 1px dashed rgba(66, 124, 164, 0.42);
  color: var(--blue);
  background: rgba(66, 124, 164, 0.05);
}

.palette-reset-button {
  border: 1px solid var(--line);
  color: #7d6d62;
  background: #f5f2eb;
}

.palette-reset-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.match-drag-ghost {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  display: grid;
  height: 29px;
  padding: 0 7px;
  border: 1px solid rgba(66, 124, 164, 0.5);
  border-radius: 8px;
  background: white;
  box-shadow: 0 10px 26px rgba(27, 33, 30, 0.24);
  grid-template-columns: 14px auto;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}

.match-drag-ghost > i {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 4px;
}

.match-drag-ghost > b {
  color: var(--ink);
  font-size: 8px;
}

.preview-panel {
  display: grid;
  min-width: 0;
  min-height: calc(100vh - 162px);
  background: #eae7df;
  grid-template-rows: 54px minmax(400px, 1fr) auto 38px;
}

.preview-panel.source-active {
  min-height: 0;
  grid-template-rows: 54px auto auto 38px;
}

.preview-toolbar {
  display: flex;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  align-items: center;
  justify-content: space-between;
}

.view-tabs {
  display: flex;
  padding: 3px;
  border-radius: 9px;
  background: #ece9e1;
}

.view-tabs button {
  min-width: 64px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.view-tabs button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 7px rgba(34, 31, 25, 0.1);
}

.toolbar-actions {
  display: flex;
  align-items: center;
}

.toolbar-actions button {
  display: grid;
  width: 31px;
  height: 31px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  place-items: center;
}

.toolbar-actions button:hover {
  background: #eeeae2;
}

.toolbar-actions button:disabled {
  cursor: default;
  opacity: 0.25;
}

.toolbar-actions output {
  width: 48px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.divider {
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: var(--line);
}

.canvas-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  padding: 34px;
  overflow: auto;
  background:
    linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px),
    #e5e2da;
  background-size: 24px 24px;
  place-items: center;
  touch-action: pan-x pan-y;
}

.preview-panel.source-active .canvas-stage {
  display: block;
  padding: 0;
  overflow: hidden;
  background-color: #dedbd3;
  place-items: initial;
  touch-action: none;
}

.canvas-stage canvas {
  display: block;
  max-width: none;
  border: 1px solid rgba(48, 44, 37, 0.18);
  background: white;
  box-shadow: 0 14px 35px rgba(52, 47, 38, 0.15);
  image-rendering: pixelated;
}

#patternCanvas {
  image-rendering: auto;
}

.source-editor {
  position: absolute;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(45deg, #d9d6cf 25%, transparent 25%),
    linear-gradient(-45deg, #d9d6cf 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d9d6cf 75%),
    linear-gradient(-45deg, transparent 75%, #d9d6cf 75%);
  background-color: #eeeae2;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  box-shadow: none;
}

#sourceCanvas {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  image-rendering: auto;
  touch-action: none;
  user-select: none;
}

#sourceCanvas:active {
  cursor: grabbing;
}

#sourceCanvas:focus-visible {
  outline: 3px solid rgba(66, 124, 164, 0.52);
  outline-offset: -3px;
}

.editor-tip {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 12px;
  display: flex;
  max-width: calc(100% - 24px);
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  color: white;
  background: rgba(22, 25, 22, 0.68);
  backdrop-filter: blur(8px);
  gap: 8px;
  font-size: 10px;
  pointer-events: none;
}

.editor-tip span {
  opacity: 0.72;
}

.source-editor.color-picking #sourceCanvas,
.source-editor.color-picking #sourceCanvas:active {
  cursor: crosshair;
}

.source-editor.color-picking .editor-tip {
  display: none;
}

.color-pick-banner {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  display: flex;
  max-width: min(360px, calc(100% - 24px));
  padding: 9px 10px 9px 12px;
  border: 1px solid rgba(25, 221, 255, 0.7);
  border-radius: 11px;
  color: white;
  background: rgba(16, 25, 28, 0.86);
  box-shadow: 0 10px 28px rgba(8, 14, 17, 0.28);
  backdrop-filter: blur(9px);
  align-items: center;
  gap: 12px;
}

.color-pick-banner[hidden] {
  display: none;
}

.color-pick-banner span {
  display: grid;
  gap: 2px;
}

.color-pick-banner b {
  font-size: 10px;
}

.color-pick-banner small {
  color: rgba(255, 255, 255, 0.7);
  font-size: 8px;
}

.color-pick-banner button {
  min-width: 42px;
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 7px;
  color: white;
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
  font-size: 9px;
}

.live-pattern-preview {
  position: fixed;
  z-index: 45;
  top: calc(env(safe-area-inset-top, 0px) + 78px);
  right: 18px;
  display: grid;
  width: clamp(160px, 19vw, 220px);
  max-height: calc(100dvh - 24px);
  padding: 10px;
  border: 1px solid rgba(27, 31, 29, 0.2);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 12px 30px rgba(24, 28, 25, 0.22);
  backdrop-filter: blur(12px);
  gap: 8px;
  overflow: auto;
  pointer-events: auto;
  user-select: none;
}

.live-pattern-preview.dragging {
  box-shadow: 0 17px 38px rgba(24, 28, 25, 0.3);
}

.live-pattern-preview header {
  display: flex;
  color: var(--ink);
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  gap: 8px;
  touch-action: none;
}

.live-pattern-preview.dragging header {
  cursor: grabbing;
}

.live-pattern-preview header span {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.live-pattern-preview header b {
  font-size: 11px;
}

.live-pattern-preview header small {
  color: var(--muted);
  font-size: 8px;
}

.live-pattern-preview header button {
  min-width: 36px;
  min-height: 26px;
  padding: 0 7px;
  border: 1px solid rgba(66, 124, 164, 0.24);
  border-radius: 7px;
  color: var(--blue);
  background: rgba(66, 124, 164, 0.07);
  cursor: pointer;
  font-size: 8px;
  font-weight: 800;
  touch-action: manipulation;
}

.live-pattern-preview > div {
  display: grid;
  min-height: 0;
  padding: 7px;
  border-radius: 9px;
  background: #dfdcd4;
  place-items: center;
}

#livePatternCanvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  border: 1px solid rgba(31, 35, 32, 0.22);
  background: #fffefb;
  box-shadow: none;
  image-rendering: pixelated;
}

.live-pattern-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.live-pattern-preview.collapsed {
  width: auto;
  min-width: 128px;
  padding: 7px 8px;
}

.live-pattern-preview.collapsed > div,
.live-pattern-preview.collapsed > p {
  display: none;
}

.live-pattern-preview.color-picking {
  opacity: 0;
  pointer-events: none;
}

.calibration-bar {
  display: grid;
  min-height: 92px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
  align-items: center;
  grid-template-columns: auto minmax(250px, 1fr) auto;
  gap: 18px;
}

.frame-mode-control {
  display: grid;
  gap: 6px;
}

.frame-mode-control > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.segmented-control {
  display: flex;
  padding: 3px;
  border-radius: 10px;
  background: #ece9e1;
}

.segmented-control button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.segmented-control button.active {
  color: var(--ink);
  background: white;
  box-shadow: 0 2px 8px rgba(34, 31, 25, 0.11);
}

.rotation-control {
  display: grid;
  gap: 6px;
}

.rotation-control > span:first-child,
.rotation-control > small {
  display: flex;
  justify-content: space-between;
}

.rotation-control > span:first-child {
  font-size: 11px;
}

.rotation-control output {
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.rotation-track {
  position: relative;
  display: grid;
  align-items: center;
}

.rotation-track i {
  position: absolute;
  z-index: 0;
  left: 50%;
  width: 1px;
  height: 17px;
  background: rgba(32, 35, 31, 0.35);
  pointer-events: none;
}

.rotation-track input {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.rotation-control > small {
  color: #9a9b94;
  font-size: 8px;
}

.rotation-reset {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.processing {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  background: rgba(246, 241, 231, 0.74);
  backdrop-filter: blur(4px);
  align-items: center;
  flex-direction: column;
  justify-content: center;
}

.processing[hidden] {
  display: none;
}

.processing b {
  margin-top: 13px;
  font-size: 13px;
}

.spinner {
  width: 35px;
  height: 35px;
  border: 4px solid rgba(236, 97, 70, 0.17);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

.statusbar {
  display: flex;
  min-width: 0;
  padding: 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
  align-items: center;
  gap: 22px;
  font-size: 10px;
}

.statusbar span {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

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

.statusbar .confidence {
  margin-left: auto;
}

.modal {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(22, 19, 14, 0.28);
}

.modal:not([open]) {
  display: none;
}

.modal::backdrop {
  background: rgba(31, 29, 24, 0.55);
  backdrop-filter: blur(4px);
}

.modal form {
  position: relative;
  padding: 34px;
}

.modal h2 {
  margin: 0 0 25px;
  font-size: 27px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: #ece9e2;
  cursor: pointer;
  font-size: 20px;
}

.modal ol {
  margin: 0;
  padding-left: 22px;
}

.modal li {
  margin-bottom: 17px;
  padding-left: 5px;
  color: var(--muted);
  line-height: 1.7;
}

.modal li b {
  color: var(--ink);
}

.notice {
  margin: 22px 0;
  padding: 15px;
  border-radius: 12px;
  color: #39755e;
  background: rgba(75, 155, 125, 0.1);
  font-size: 12px;
  line-height: 1.6;
}

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

.export-mobile-note {
  display: none;
}

.export-options button {
  display: grid;
  min-height: 125px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  cursor: pointer;
  text-align: left;
}

.export-options button:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.export-options button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.export-options span {
  width: fit-content;
  padding: 4px 7px;
  border-radius: 5px;
  color: white;
  background: var(--accent);
  font-size: 9px;
  font-weight: 900;
}

.export-options b {
  margin-top: 13px;
  font-size: 14px;
}

.export-options small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.export-recovery {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(212, 83, 55, 0.25);
  border-radius: 14px;
  background: rgba(255, 244, 238, 0.86);
}

.export-recovery[hidden],
.export-inline-preview[hidden] {
  display: none;
}

.export-recovery > strong {
  font-size: 13px;
}

.export-recovery > p {
  margin: 5px 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.export-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.export-recovery-actions button,
.export-diagnostics button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: white;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.export-recovery-actions button:disabled {
  opacity: 0.48;
}

.export-inline-preview {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.export-inline-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 55dvh;
  object-fit: contain;
  image-rendering: pixelated;
}

.export-inline-preview img[hidden],
.export-inline-preview pre[hidden] {
  display: none;
}

.export-inline-preview pre {
  max-height: 42dvh;
  margin: 0;
  overflow: auto;
  color: #2a2c28;
  font: 10px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre;
}

.export-inline-preview small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.export-diagnostics {
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.export-diagnostics summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 750;
}

.export-diagnostics pre {
  max-height: 190px;
  margin: 8px 0;
  padding: 9px;
  overflow: auto;
  border-radius: 8px;
  color: #4b4d47;
  background: rgba(32, 35, 31, 0.06);
  font: 9px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: text;
}

.print-sheet {
  display: none;
}

.color-editor-dialog {
  width: min(430px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(22, 19, 14, 0.3);
}

.color-editor-dialog:not([open]) {
  display: none;
}

.color-editor-dialog::backdrop {
  background: rgba(24, 23, 20, 0.58);
  backdrop-filter: blur(5px);
}

.color-editor-sheet {
  display: grid;
  padding: 22px;
  gap: 17px;
}

.color-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.color-editor-head > span {
  display: grid;
  gap: 2px;
}

.color-editor-head small {
  color: var(--accent-dark);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.color-editor-head b {
  font-size: 20px;
}

.color-editor-head button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #686761;
  background: #ece9e2;
  cursor: pointer;
  font-size: 20px;
  place-items: center;
}

.color-sv-field {
  position: relative;
  height: clamp(190px, 38vh, 260px);
  border: 1px solid rgba(25, 24, 20, 0.22);
  border-radius: 15px;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, transparent),
    hsl(var(--picker-hue, 0) 100% 50%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: crosshair;
  overflow: hidden;
  touch-action: none;
}

.color-sv-field:focus-visible {
  outline: 3px solid rgba(66, 124, 164, 0.42);
  outline-offset: 3px;
}

.color-sv-field > i {
  position: absolute;
  top: var(--picker-y, 0%);
  left: var(--picker-x, 100%);
  width: 20px;
  height: 20px;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow:
    0 0 0 2px rgba(12, 13, 12, 0.74),
    0 2px 8px rgba(0, 0, 0, 0.38);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.color-hue-field {
  display: grid;
  gap: 8px;
}

.color-hue-field > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.color-hue-field input {
  width: 100%;
  height: 28px;
  margin: 0;
  border-radius: 99px;
  appearance: none;
  background:
    linear-gradient(
      90deg,
      #f33,
      #ff3,
      #3f3,
      #3ff,
      #33f,
      #f3f,
      #f33
    );
  cursor: pointer;
}

.color-hue-field input::-webkit-slider-runnable-track {
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 99px;
  background: transparent;
}

.color-hue-field input::-webkit-slider-thumb {
  width: 20px;
  height: 34px;
  margin-top: -4px;
  border: 3px solid white;
  border-radius: 8px;
  appearance: none;
  background: transparent;
  box-shadow: 0 0 0 2px rgba(22, 23, 21, 0.72);
}

.color-hue-field input::-moz-range-track {
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 99px;
  background: transparent;
}

.color-hue-field input::-moz-range-thumb {
  width: 16px;
  height: 30px;
  border: 3px solid white;
  border-radius: 8px;
  background: transparent;
  box-shadow: 0 0 0 2px rgba(22, 23, 21, 0.72);
}

.color-editor-value {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: end;
  gap: 12px;
}

.color-editor-value > i {
  display: block;
  width: 52px;
  height: 44px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.44);
}

.color-editor-value label {
  display: grid;
  gap: 5px;
}

.color-editor-value label span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.color-editor-value input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: #fbfaf6;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.color-editor-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 9px;
}

.color-editor-actions button {
  min-height: 46px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.color-editor-actions button:first-child {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f0ede6;
}

.color-editor-actions button:last-child {
  border: 1px solid var(--accent);
  color: white;
  background: var(--accent);
  box-shadow: 0 7px 18px rgba(201, 68, 48, 0.2);
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: calc(100vw - 48px);
  padding: 12px 17px;
  border-radius: 10px;
  color: white;
  background: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  .hero {
    padding-top: 50px;
    grid-template-columns: minmax(0, 1fr);
    gap: 38px;
  }

  .hero-copy {
    max-width: 680px;
  }

  .upload-card {
    min-height: 390px;
  }

  .feature-strip {
    grid-template-columns: 1fr 1fr;
    row-gap: 22px;
  }

  .feature-strip div:nth-child(2) {
    border-right: 0;
  }

  .editor-layout {
    grid-template-columns: 285px minmax(0, 1fr);
  }
}

@media (max-width: 680px) {
  body.editing {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.editing main {
    height: auto;
    overflow: visible;
  }

  .topbar {
    position: static;
    min-height: 64px;
    padding: 10px 16px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .brand b {
    font-size: 19px;
  }

  .privacy-pill {
    padding: 7px 9px;
    font-size: 10px;
  }

  .icon-button {
    margin-left: 7px;
  }

  .hero {
    min-height: calc(100vh - 64px);
    padding: 42px 18px 28px;
  }

  .hero h1 {
    font-size: clamp(38px, 12vw, 54px);
  }

  .hero-desc {
    margin-top: 24px;
    font-size: 14px;
  }

  .upload-card {
    min-height: 360px;
    padding: 28px 18px;
    border-radius: 21px;
  }

  .upload-visual {
    width: 110px;
    height: 110px;
    border-radius: 28px;
  }

  .mini-pattern {
    width: 76px;
    height: 76px;
  }

  .feature-strip {
    padding-top: 22px;
  }

  .feature-strip div {
    padding: 0 8px 0 42px;
  }

  .feature-strip span {
    left: 3px;
    font-size: 20px;
  }

  .workspace {
    height: auto;
    min-height: 0;
    padding: 0;
    overflow: visible;
  }

  .work-head {
    height: 72px;
    min-height: 72px;
    padding: 8px 12px;
    gap: 10px;
  }

  .work-head > div:first-child {
    min-width: 0;
    flex: 1;
  }

  .work-head .eyebrow {
    margin-bottom: 3px;
    font-size: 8px;
  }

  .work-head h1 {
    display: -webkit-box;
    max-width: none;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.18;
    overflow-wrap: anywhere;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .head-actions {
    flex: 0 0 auto;
  }

  .head-actions .text-button {
    min-height: 42px;
    padding: 0 9px;
    font-size: 11px;
  }

  .head-actions .primary-button {
    min-height: 42px;
    padding: 0 11px;
    font-size: 11px;
  }

  .editor-layout {
    display: flex;
    height: auto;
    min-height: 0;
    padding-bottom: calc(64px + env(safe-area-inset-bottom));
    overflow: visible;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0;
    flex-direction: column;
  }

  .controls {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
    max-height: none;
    overflow: visible;
    border-right: 0;
    order: 5;
  }

  .preview-panel,
  .preview-panel.source-active {
    display: contents;
    min-height: 0;
  }

  .preview-toolbar {
    width: 100%;
    min-height: 44px;
    padding: 0 9px;
    order: 1;
  }

  .calibration-bar {
    width: 100%;
    min-height: 0;
    padding: 7px 10px 8px;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 7px 8px;
    order: 2;
  }

  .canvas-stage {
    position: sticky;
    z-index: 30;
    top: env(safe-area-inset-top, 0px);
    width: 100%;
    height: clamp(380px, 52dvh, 470px);
    min-height: 0;
    padding: 14px;
    flex: 0 0 auto;
    order: 3;
  }

  .statusbar {
    width: 100%;
    min-height: 32px;
    order: 4;
  }

  .frame-mode-control {
    min-width: 0;
    gap: 4px;
  }

  .frame-mode-control > span {
    font-size: 8px;
  }

  .segmented-control {
    width: 100%;
    padding: 2px;
  }

  .segmented-control button {
    min-width: 0;
    min-height: 38px;
    padding: 0 8px;
    flex: 1 1 0;
    font-size: 11px;
  }

  .rotation-control {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 3px;
  }

  .rotation-control > span:first-child {
    font-size: 10px;
  }

  .rotation-control > small {
    font-size: 7px;
  }

  .rotation-reset {
    min-width: 44px;
    min-height: 38px;
    padding: 0 8px;
    align-self: end;
    font-size: 10px;
  }

  .mobile-control-panels {
    display: flex;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fbf8f1;
    align-items: flex-start;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    transition: height 220ms ease;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-control-panels::-webkit-scrollbar {
    display: none;
  }

  .mobile-control-panels input[type="range"] {
    touch-action: none;
  }

  .control-section {
    display: block;
    width: 100%;
    min-width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border-bottom: 0;
    flex: 0 0 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
  }

  .control-section.mobile-active {
    display: block;
    height: auto;
    overflow: visible;
  }

  .control-section .section-title {
    display: flex;
    position: relative;
    min-height: 60px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
  }

  .section-title .section-swipe-cue {
    display: block;
    position: absolute;
    z-index: 1;
    top: 50%;
    right: 16px;
    width: 40px;
    height: 18px;
    margin: 0;
    pointer-events: none;
    transform: translateY(-50%);
  }

  .section-swipe-cue .swipe-cue-track {
    position: absolute;
    top: 8px;
    left: 4px;
    width: 32px;
    height: 2px;
    border-radius: 99px;
    background: linear-gradient(90deg, transparent, #b7b1a5 25%, #b7b1a5 75%, transparent);
    opacity: 0.55;
  }

  .section-swipe-cue .swipe-cue-dot {
    position: absolute;
    top: 4px;
    width: 10px;
    height: 10px;
    border: 2px solid #fbf8f1;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 1px 4px rgba(32, 35, 31, 0.2);
  }

  [data-control-panel="0"] .swipe-cue-dot {
    left: 26px;
  }

  [data-control-panel="1"] .swipe-cue-dot {
    left: 15px;
  }

  [data-control-panel="2"] .swipe-cue-dot {
    left: 4px;
  }

  .control-section.mobile-active .section-swipe-cue {
    animation: section-swipe-cue-fade 3.6s ease 450ms both;
  }

  .control-section.mobile-active[data-control-panel="0"] .swipe-cue-dot {
    animation: section-swipe-cue-left 3.6s ease-in-out 450ms both;
  }

  .control-section.mobile-active[data-control-panel="1"] .swipe-cue-dot {
    animation: section-swipe-cue-both 3.6s ease-in-out 450ms both;
  }

  .control-section.mobile-active[data-control-panel="2"] .swipe-cue-dot {
    animation: section-swipe-cue-right 3.6s ease-in-out 450ms both;
  }

  .control-section .section-body {
    padding: 15px 16px calc(24px + env(safe-area-inset-bottom));
  }

  .grid-detect-row {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 7px;
  }

  .field-row {
    grid-template-columns: minmax(0, 1fr) 13px minmax(0, 1fr);
    gap: 4px;
  }

  .grid-number-label small {
    display: none;
  }

  .grid-stepper {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    grid-template-columns: 42px minmax(38px, 1fr) 42px;
  }

  .grid-stepper button {
    display: grid;
    min-width: 42px;
    height: 44px;
    padding: 0;
    border: 0;
    color: var(--ink);
    background: #f2efe8;
    cursor: pointer;
    font-size: 18px;
    font-weight: 750;
    place-items: center;
    touch-action: manipulation;
  }

  .grid-stepper button:active {
    background: #e5e1d8;
  }

  .grid-stepper input {
    height: 44px;
    padding: 0 2px;
    border-top: 0;
    border-bottom: 0;
    border-radius: 0;
    text-align: center;
    -moz-appearance: textfield;
    appearance: textfield;
  }

  .grid-stepper input::-webkit-inner-spin-button,
  .grid-stepper input::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
  }

  .field-row > span {
    display: grid;
    height: 44px;
    padding: 0;
    align-self: end;
    place-items: center;
  }

  .detect-compact {
    width: 44px;
    min-height: 44px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .detect-compact svg {
    width: 18px;
    height: 18px;
  }

  .preview-panel.source-active .canvas-stage,
  #sourceCanvas {
    touch-action: none;
  }

  .live-pattern-preview {
    top: calc(env(safe-area-inset-top, 0px) + 292px);
    right: 8px;
    width: min(42vw, 150px);
    padding: 7px;
    border-radius: 11px;
    gap: 6px;
  }

  .live-pattern-preview > div {
    padding: 5px;
  }

  .live-pattern-preview header button {
    min-width: 38px;
    min-height: 30px;
  }

  .live-pattern-preview p {
    display: none;
  }

  .live-pattern-preview.collapsed {
    width: auto;
    min-width: 118px;
  }

  .palette-list {
    max-height: none;
    overflow: visible;
  }

  .matches-header button {
    min-height: 34px;
  }

  .match-color-chip {
    height: 32px;
    grid-template-columns: 16px minmax(0, 1fr) 24px;
  }

  .match-color-chip > i {
    width: 16px;
    height: 16px;
  }

  .match-color-chip button {
    width: 24px;
    height: 24px;
  }

  .palette-remove {
    min-height: 28px;
    font-size: 9px;
  }

  .statusbar {
    gap: 12px;
    overflow: hidden;
    touch-action: pan-y;
  }

  .statusbar .confidence {
    display: none;
  }

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

  .color-editor-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: 0;
    border-radius: 22px 22px 0 0;
  }

  .color-editor-sheet {
    max-height: calc(100dvh - 16px);
    padding: 19px 16px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    gap: 14px;
  }

  .color-sv-field {
    height: clamp(180px, 32dvh, 250px);
  }

  .color-editor-actions button {
    min-height: 50px;
  }
}

@media (max-width: 420px) {
  .privacy-pill {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .feature-strip small {
    display: none;
  }

  .feature-strip div {
    min-height: 48px;
  }

  .clipboard-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .clipboard-preview {
    width: 42px;
    height: 42px;
  }

  .clipboard-button {
    min-height: 34px;
    grid-column: 1 / -1;
  }

  .editor-tip span {
    display: none;
  }

  .palette-guide {
    display: none;
  }

  .palette-mapping {
    padding: 12px 11px 38px;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .palette-target {
    padding: 0 0 12px;
    border-right: 0;
    border-bottom: 1px solid #ebe8e0;
  }

  .palette-code-field input {
    height: 36px;
    font-size: 12px;
  }

  .target-color-button {
    width: 46px;
    min-width: 46px;
    height: 46px;
    border-radius: 10px;
  }

  .palette-actions {
    grid-template-columns: 1fr;
  }

  .palette-add-button,
  .palette-reset-button {
    min-height: 42px;
  }

  .view-tabs button {
    min-width: 56px;
  }

  .toolbar-actions button {
    width: 28px;
  }

  .toolbar-actions output {
    width: 38px;
  }

  .toolbar-actions .divider {
    display: none;
  }

  .export-options {
    grid-template-columns: 1fr;
  }

  .export-modal {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .export-mobile-note {
    display: block;
    margin: -13px 0 18px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
  }

  .export-options button {
    min-height: 94px;
  }

  .export-recovery-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .export-recovery-actions button:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 380px) {
  .privacy-pill {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }

  .icon-button {
    margin-left: 4px;
  }

  .work-head {
    padding-right: 8px;
    padding-left: 8px;
    gap: 6px;
  }

  .head-actions {
    gap: 3px;
  }

  .head-actions .text-button,
  .head-actions .primary-button {
    padding-right: 7px;
    padding-left: 7px;
    font-size: 10px;
  }

  .live-pattern-preview {
    right: 6px;
    max-width: calc(100vw - 12px);
  }

  .live-pattern-preview.collapsed {
    min-width: 108px;
  }

}

@page {
  size: auto;
  margin: 10mm;
}

@media print {
  html,
  body {
    margin: 0;
    background: white;
  }

  body > :not(.print-sheet) {
    display: none !important;
  }

  .print-sheet {
    display: grid !important;
    width: 100%;
    min-height: 0;
    place-items: center;
  }

  .print-sheet canvas {
    display: block;
    width: auto !important;
    height: auto !important;
    max-width: 100%;
    max-height: 270mm;
    border: 0;
    box-shadow: none;
  }
}

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

@keyframes section-swipe-cue-fade {
  0%,
  100% {
    opacity: 0.5;
  }

  8%,
  82% {
    opacity: 0.82;
  }
}

@keyframes section-swipe-cue-left {
  0%,
  12%,
  48%,
  100% {
    transform: translateX(0);
  }

  30%,
  66% {
    transform: translateX(-22px);
  }
}

@keyframes section-swipe-cue-both {
  0%,
  12%,
  50%,
  88%,
  100% {
    transform: translateX(0);
  }

  30% {
    transform: translateX(-11px);
  }

  70% {
    transform: translateX(11px);
  }
}

@keyframes section-swipe-cue-right {
  0%,
  12%,
  48%,
  100% {
    transform: translateX(0);
  }

  30%,
  66% {
    transform: translateX(22px);
  }
}
