:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17120f;
  background: #f7efe1;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #f7efe1;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 91% 3%, rgba(216, 239, 196, 0.92), transparent 300px),
    linear-gradient(90deg, rgba(23, 18, 15, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 18, 15, 0.045) 1px, transparent 1px),
    #f7efe1;
  background-size: auto, 32px 32px, 32px 32px, auto;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.upload-zone:focus-visible,
a:focus-visible {
  outline: 3px solid #e23d31;
  outline-offset: 3px;
}

a {
  color: inherit;
}

.app {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.topbar,
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand,
.privacy-pill {
  border: 2px solid #17120f;
  background: #fffaf0;
  font-weight: 950;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  box-shadow: 4px 4px 0 #17120f;
  padding: 10px 13px;
  text-decoration: none;
}

.brand span {
  color: #e23d31;
  font-size: 19px;
}

.privacy-pill {
  border-radius: 999px;
  padding: 8px 12px;
  color: #4a4038;
  font-size: 13px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 30px;
  padding: 46px 0 26px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #e23d31;
  font-size: 13px;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(44px, 6.5vw, 78px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

h1 span {
  color: #e23d31;
}

.lead {
  max-width: 760px;
  margin: 0;
  color: #4d4239;
  font-size: 18px;
  font-weight: 720;
  line-height: 1.7;
}

.size-stamp {
  display: grid;
  min-width: 205px;
  justify-items: center;
  border: 3px solid #17120f;
  border-radius: 18px;
  background: #f5d46b;
  box-shadow: 7px 7px 0 #17120f;
  padding: 17px 19px;
  text-align: center;
  transform: rotate(2deg);
}

.size-stamp span,
.size-stamp small {
  font-weight: 950;
}

.size-stamp strong {
  margin: 3px 0;
  font-size: 31px;
  line-height: 1;
  font-weight: 1000;
  white-space: nowrap;
}

.size-stamp small {
  color: #6a5840;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(470px, 1.06fr);
  align-items: start;
  gap: 20px;
}

.panel {
  min-width: 0;
  border: 3px solid #17120f;
  border-radius: 14px;
  background: #fffaf0;
  box-shadow: 8px 8px 0 #17120f;
  padding: 22px;
}

.preview-panel {
  position: sticky;
  top: 16px;
  background: #fffdf7;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-title h2 {
  margin-bottom: 4px;
  font-size: 25px;
  line-height: 1.08;
}

.panel-title p {
  margin: 0;
  color: #70645a;
  font-size: 14px;
  font-weight: 720;
}

.step-number {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #17120f;
  border-radius: 8px;
  background: #d9f0c9;
  box-shadow: 3px 3px 0 #17120f;
  font-weight: 1000;
}

.step-number.red {
  background: #e23d31;
  color: #fffaf0;
}

.upload-zone {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  min-height: 88px;
  border: 3px dashed #17120f;
  border-radius: 12px;
  background: #f9eec3;
  padding: 14px;
  transition: transform 0.16s ease, background 0.16s ease;
}

.upload-zone:hover,
.upload-zone.dragging {
  background: #f5d46b;
  transform: translateY(-2px);
}

.upload-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid #17120f;
  border-radius: 50%;
  background: #e23d31;
  color: #fff;
  font-size: 28px;
  font-weight: 850;
}

.upload-zone strong,
.upload-zone small {
  display: block;
}

.upload-zone strong {
  font-size: 19px;
  font-weight: 1000;
}

.upload-zone small {
  margin-top: 3px;
  color: #6c6056;
  font-weight: 700;
}

.upload-zone em {
  border: 2px solid #17120f;
  border-radius: 999px;
  background: #fffaf0;
  padding: 5px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 950;
}

.photo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 9px;
}

.photo-toolbar p {
  margin: 0;
  color: #5c5047;
  font-size: 14px;
  font-weight: 800;
}

.photo-toolbar p strong {
  color: #17120f;
  font-size: 17px;
}

.photo-toolbar > div {
  display: flex;
  gap: 7px;
}

.text-button {
  border: 0;
  background: transparent;
  padding: 4px;
  color: #4e4239;
  font-size: 13px;
  font-weight: 950;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button.danger {
  color: #c92f25;
}

.photo-list {
  display: flex;
  gap: 8px;
  max-width: 100%;
  min-height: 80px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}

.photo-item {
  position: relative;
  width: 68px;
  height: 74px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid #17120f;
  border-radius: 8px;
  background: #eee;
}

.photo-item img,
.photo-item .sample-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-thumb {
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.93);
  font-size: 25px;
}

.photo-item button {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1.5px solid #17120f;
  border-radius: 50%;
  background: #fff;
  font-size: 13px;
  font-weight: 1000;
}

.photo-empty {
  display: grid;
  width: 100%;
  place-items: center;
  border: 2px dashed #b7a99b;
  border-radius: 8px;
  color: #776b61;
  font-size: 13px;
  font-weight: 800;
}

.control-block {
  margin: 20px 0 0;
  border: 0;
  border-top: 2px solid #17120f;
  padding: 16px 0 0;
}

.control-block legend {
  padding: 0 9px 0 0;
  font-size: 15px;
  font-weight: 1000;
}

.segmented {
  display: grid;
  gap: 9px;
}

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

.segmented.compact {
  margin-top: 9px;
}

.choice,
.preset-row button,
.square-button,
.page-controls button,
.secondary-button,
.primary-button {
  border: 2px solid #17120f;
  border-radius: 8px;
  background: #fff;
  color: #17120f;
  font-weight: 950;
}

.choice {
  min-height: 48px;
  padding: 8px 10px;
}

.choice strong,
.choice small {
  display: block;
}

.choice small {
  margin-top: 2px;
  color: #6d6258;
  font-size: 11px;
}

.choice.active,
.preset-row button.active {
  background: #e23d31;
  color: #fffaf0;
  box-shadow: 3px 3px 0 #17120f;
}

.choice.active small {
  color: #fff3de;
}

.dimension-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: end;
  gap: 8px;
}

.dimension-row > span {
  align-self: center;
  padding-top: 22px;
  font-size: 20px;
  font-weight: 1000;
}

.dimension-row label,
.number-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.dimension-row label > span,
.number-grid label > span:first-child {
  color: #554941;
  font-size: 13px;
  font-weight: 950;
}

.dimension-row label {
  position: relative;
}

.dimension-row input,
.number-input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 2px solid #17120f;
  border-radius: 8px;
  background: #fff;
}

.dimension-row input {
  padding: 10px 45px 10px 12px;
  font-size: 18px;
  font-weight: 950;
}

.dimension-row label > em {
  position: absolute;
  right: 10px;
  bottom: 14px;
  color: #74685e;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.square-button {
  width: 48px;
  height: 48px;
  background: #dceff2;
  font-size: 20px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.preset-row button {
  min-height: 38px;
  padding: 6px 4px;
  font-size: 12px;
}

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

.number-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  overflow: hidden;
}

.number-input input {
  width: 100%;
  min-width: 0;
  height: 44px;
  border: 0;
  padding: 8px 4px 8px 11px;
  font-weight: 950;
}

.number-input em {
  padding-right: 10px;
  color: #74685e;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  cursor: pointer;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
}

.toggle-row > span {
  position: relative;
  width: 44px;
  height: 25px;
  flex: 0 0 auto;
  border: 2px solid #17120f;
  border-radius: 999px;
  background: #e5ddd1;
}

.toggle-row > span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border: 1.5px solid #17120f;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 0.15s ease;
}

.toggle-row input:checked + span {
  background: #d9f0c9;
}

.toggle-row input:checked + span::after {
  transform: translateX(18px);
}

.toggle-row strong {
  font-size: 14px;
}

.layout-result {
  margin-top: 20px;
  border: 2px solid #17120f;
  border-radius: 10px;
  background: #d9f0c9;
  padding: 14px;
}

.layout-result span {
  color: #5e554c;
  font-size: 12px;
  font-weight: 950;
}

.layout-result strong {
  display: block;
  margin: 3px 0 5px;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 1000;
}

.layout-result p {
  margin: 0;
  color: #4f453d;
  font-size: 13px;
  font-weight: 750;
}

.form-error {
  margin: 10px 0 0;
  border: 2px solid #b6271e;
  border-radius: 8px;
  background: #ffe1db;
  padding: 10px;
  color: #9a2018;
  font-size: 13px;
  font-weight: 900;
}

.secondary-button,
.primary-button {
  display: inline-grid;
  place-items: center;
  min-height: 50px;
  padding: 11px 14px;
}

.input-panel > .secondary-button {
  width: 100%;
  margin-top: 10px;
  background: #dceff2;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.preview-toolbar > span {
  border: 2px solid #17120f;
  border-radius: 999px;
  background: #f9eec3;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 950;
}

.page-controls {
  display: grid;
  grid-template-columns: 36px auto 36px;
  align-items: center;
  gap: 8px;
}

.page-controls button {
  width: 36px;
  height: 34px;
  background: #fff;
}

.page-controls button:disabled {
  cursor: default;
  opacity: 0.35;
}

.page-controls strong {
  min-width: 45px;
  text-align: center;
  font-size: 13px;
}

.canvas-stage {
  display: grid;
  min-height: 340px;
  place-items: center;
  overflow: hidden;
  border: 3px solid #17120f;
  border-radius: 10px;
  background:
    linear-gradient(45deg, #e8dfd2 25%, transparent 25%),
    linear-gradient(-45deg, #e8dfd2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8dfd2 75%),
    linear-gradient(-45deg, transparent 75%, #e8dfd2 75%),
    #f3ebdf;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  padding: 18px;
}

#previewCanvas {
  display: block;
  max-width: 100%;
  max-height: min(60vh, 610px);
  border: 1px solid #c9c0b5;
  background: #fff;
  box-shadow: 0 12px 30px rgba(28, 21, 17, 0.22);
}

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

.primary-button {
  background: #e23d31;
  color: #fffaf0;
  box-shadow: 4px 4px 0 #17120f;
}

.export-grid .secondary-button {
  background: #f5d46b;
}

.primary-button span,
.primary-button small,
.secondary-button span,
.secondary-button small {
  display: block;
}

.primary-button small,
.secondary-button small {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 780;
}

button:disabled {
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.7);
  opacity: 0.48;
}

.export-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: #675b51;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.print-note {
  display: flex;
  gap: 11px;
  margin-top: 13px;
  border: 2px solid #17120f;
  border-radius: 10px;
  background: #ffd9c8;
  padding: 13px;
}

.print-note > span {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid #17120f;
  border-radius: 50%;
  background: #e23d31;
  color: #fff;
  font-weight: 1000;
}

.print-note strong {
  display: block;
  margin-bottom: 3px;
}

.print-note p {
  margin: 0;
  color: #564940;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.55;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.method-grid article {
  border: 2px solid #17120f;
  border-radius: 9px;
  background: #fff;
  padding: 10px;
}

.method-grid article > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 5px;
  background: #17120f;
  color: #fff;
  font-size: 12px;
  font-weight: 950;
}

.method-grid strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 14px;
}

.method-grid p {
  margin: 0;
  color: #6c6056;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}

.boundary-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  margin-top: 28px;
  border: 3px solid #17120f;
  border-radius: 12px;
  background: #dceff2;
  padding: 16px 18px;
}

.boundary-note strong {
  white-space: nowrap;
}

.boundary-note p {
  margin: 0;
  color: #50463f;
  font-size: 14px;
  font-weight: 720;
  line-height: 1.6;
}

.footer {
  margin-top: 24px;
  padding: 18px 2px 0;
  color: #594e45;
  font-size: 13px;
  font-weight: 850;
}

.footer > a {
  color: #17120f;
  font-weight: 1000;
}

.footer nav {
  display: flex;
  gap: 16px;
}

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

  .preview-panel {
    position: static;
  }

  .canvas-stage {
    min-height: 300px;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1220px);
    padding-top: 12px;
  }

  .topbar {
    align-items: stretch;
  }

  .brand,
  .privacy-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 9px;
    font-size: 12px;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 34px 0 20px;
  }

  h1 {
    font-size: clamp(42px, 13vw, 62px);
  }

  .lead {
    font-size: 16px;
  }

  .size-stamp {
    min-width: 0;
    width: 180px;
    justify-self: end;
    padding: 13px 15px;
  }

  .size-stamp strong {
    font-size: 27px;
  }

  .panel {
    border-width: 2px;
    box-shadow: 5px 5px 0 #17120f;
    padding: 15px;
  }

  .panel-title h2 {
    font-size: 21px;
  }

  .upload-zone {
    grid-template-columns: auto 1fr;
    min-height: 82px;
    padding: 11px;
  }

  .upload-zone em {
    display: none;
  }

  .upload-zone small {
    font-size: 11px;
  }

  .photo-toolbar {
    align-items: flex-start;
  }

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

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

  .dimension-row .square-button {
    grid-column: 1 / -1;
    width: 100%;
    height: 38px;
  }

  .canvas-stage {
    min-height: 230px;
    padding: 11px;
  }

  #previewCanvas {
    max-height: 54vh;
  }

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

  .method-grid article {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 9px;
  }

  .method-grid article > span {
    grid-row: 1 / 3;
  }

  .method-grid strong {
    margin: 0 0 2px;
  }

  .boundary-note {
    grid-template-columns: 1fr;
    gap: 5px;
    border-width: 2px;
  }

  .footer {
    align-items: flex-start;
  }

  .footer nav {
    flex-direction: column;
    gap: 7px;
    text-align: right;
  }
}

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