:root {
  color-scheme: light;
  --page: #f3f3f0;
  --surface: #ffffff;
  --surface-soft: #f7f7f5;
  --text: #171717;
  --muted: #666662;
  --line: #d9d9d4;
  --line-strong: #b8b8b1;
  --focus: #0b57d0;
  --danger: #a52222;
  --success: #176735;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  line-height: 1.55;
}

button, input, summary { font: inherit; }

button, label, summary { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0 80px;
}

h1 {
  margin: 0 0 32px;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 0.98;
  letter-spacing: -0.055em;
  font-weight: 760;
  max-width: 900px;
}

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

.service {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.06);
}

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

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

.section-heading {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 24px;
}

.step-number {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.section-heading h2 {
  margin-bottom: 4px;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.section-heading p, .hint, small {
  color: var(--muted);
}

.section-heading p { margin-bottom: 0; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
  border: 0;
}

.choice-grid.compact { max-width: 820px; }

.choice-card {
  position: relative;
  display: block;
  cursor: pointer;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-card > span {
  display: flex;
  flex-direction: column;
  min-height: 106px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice-card strong { margin-bottom: 6px; }
.choice-card small { line-height: 1.45; }
.choice-card input:checked + span {
  border-color: var(--text);
  background: var(--surface-soft);
  box-shadow: inset 0 0 0 1px var(--text);
}
.choice-card input:focus-visible + span { outline: 3px solid rgba(11, 87, 208, 0.2); }

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

.upload-field {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 150px;
  padding: 22px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.upload-field:hover, .upload-field.dragover { border-color: var(--text); background: #f0f0ed; }
.upload-field.has-file { border-style: solid; border-color: var(--text); }
.upload-field input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.upload-title { font-weight: 700; font-size: 17px; }
.upload-help { color: var(--muted); margin-top: 3px; }
.file-name {
  display: block;
  margin-top: 12px;
  max-width: 100%;
  font-size: 13px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  max-width: 620px;
  font-weight: 650;
}
.text-field input, .color-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: white;
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}
.text-field input:focus, .color-field input[type="text"]:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(11,87,208,.12); }

.variant-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}
.variant-tab, .preset-button, .text-button {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: white;
  color: var(--text);
  cursor: pointer;
}
.variant-tab { padding: 8px 13px; }
.variant-tab.active { background: var(--text); color: white; border-color: var(--text); }

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .75fr);
  gap: 24px;
  align-items: start;
}

.canvas-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: #eee;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
#crop-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}
.canvas-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.text-button { padding: 6px 10px; color: var(--muted); }
.text-button:hover { color: var(--text); border-color: var(--text); }
.hint { font-size: 13px; margin: 8px 0 0; }

.controls-column {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
.range-field { display: flex; flex-direction: column; gap: 10px; }
.range-field > span { display: flex; justify-content: space-between; gap: 12px; }
.range-field output { color: var(--muted); font-variant-numeric: tabular-nums; }
.range-field input { width: 100%; accent-color: var(--text); }
.background-controls { display: flex; flex-direction: column; gap: 12px; }
.switch-row { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.switch-row input { margin-top: 4px; accent-color: var(--text); }
.color-field {
  display: grid;
  grid-template-columns: 1fr 44px 104px;
  align-items: center;
  gap: 8px;
}
.color-field span { font-weight: 650; }
.color-field input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: white;
}
.color-field input[type="text"] { padding: 9px; font-family: ui-monospace, monospace; text-transform: uppercase; }

.preview-block { margin-top: 28px; }
.preview-block h3 { margin-bottom: 12px; font-size: 17px; }
.background-previews { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.background-preview {
  display: flex;
  min-height: 190px;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.background-preview img { width: 116px; height: 116px; object-fit: contain; }
.background-preview span {
  position: absolute;
  left: 12px;
  bottom: 9px;
  font-size: 12px;
  font-weight: 650;
}
.light-background { background: white; color: #222; }
.dark-background { background: #151515; color: white; border-color: #151515; }

.mask-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(90px, 1fr));
  gap: 12px;
}
.mask-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 12px;
  text-align: center;
}
.mask {
  display: block;
  width: 74px;
  height: 74px;
  overflow: hidden;
  background-color: white;
  background-image:
    linear-gradient(45deg, #eee 25%, transparent 25%),
    linear-gradient(-45deg, #eee 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eee 75%),
    linear-gradient(-45deg, transparent 75%, #eee 75%);
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
}
.mask img { width: 100%; height: 100%; object-fit: contain; }
.mask.circle { border-radius: 50%; }
.mask.squircle { border-radius: 31%; }
.mask.android-round { border-radius: 22%; }
.mask.android-soft { border-radius: 38% 38% 30% 30%; }
.mask.teardrop { border-radius: 50% 50% 50% 15%; }

.small-size-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafafa;
}
.small-preview-item { display: grid; grid-template-columns: 52px auto; align-items: center; gap: 10px; min-width: 130px; }
.small-preview-canvas {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: white;
}
.small-preview-item img { display: block; image-rendering: auto; }
.small-preview-item b { font-size: 13px; }
.small-preview-item small { display: block; font-size: 11px; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.preset-button {
  padding: 12px 15px;
  border-radius: 11px;
  text-align: left;
  font-weight: 650;
}
.preset-button:hover { border-color: var(--text); }
.preset-button.active { background: var(--text); color: white; border-color: var(--text); }

.platform-details {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  overflow: hidden;
}
.platform-details summary {
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 680;
  background: var(--surface-soft);
}
.platform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
}
.platform-grid label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 74px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.platform-grid label:nth-child(odd) { border-right: 1px solid var(--line); }
.platform-grid label:nth-last-child(-n+2) { border-bottom: 0; }
.platform-grid input { margin-top: 4px; accent-color: var(--text); }
.platform-grid span { display: flex; flex-direction: column; }
.platform-grid small { line-height: 1.35; margin-top: 2px; }
.selection-summary { margin: 13px 0 0; color: var(--muted); font-size: 14px; }

.final-section { background: var(--surface-soft); }
.primary-button {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  background: var(--text);
  color: white;
  font-weight: 720;
  cursor: pointer;
}
.primary-button:hover { background: #333; }
.primary-button:disabled { cursor: wait; opacity: .55; }
.form-status { min-height: 24px; margin-top: 12px; font-size: 14px; }
.form-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }
.form-status.loading { color: var(--muted); }

.description {
  max-width: 850px;
  margin: 56px auto 0;
}
.description h2 {
  margin: 34px 0 10px;
  font-size: 25px;
  letter-spacing: -0.025em;
}
.description p { color: #3f3f3c; font-size: 17px; line-height: 1.72; }

.hidden { display: none !important; }

button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(11, 87, 208, 0.24);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .page-shell { width: min(100% - 20px, 720px); padding-top: 32px; }
  h1 { margin-bottom: 24px; }
  .form-section { padding: 24px 18px; }
  .choice-grid, .upload-grid, .editor-layout, .background-previews, .platform-grid { grid-template-columns: 1fr; }
  .platform-grid label:nth-child(odd) { border-right: 0; }
  .platform-grid label:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .platform-grid label:last-child { border-bottom: 0; }
  .preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mask-grid { grid-template-columns: repeat(3, 1fr); }
  .color-field { grid-template-columns: 1fr 44px 100px; }
}

@media (max-width: 520px) {
  .page-shell { width: 100%; padding-top: 22px; }
  h1 { padding: 0 16px; font-size: 42px; }
  .service { border-radius: 0; border-left: 0; border-right: 0; }
  .section-heading { grid-template-columns: 30px 1fr; gap: 10px; }
  .step-number { width: 28px; height: 28px; }
  .section-heading h2 { font-size: 21px; }
  .preset-grid { grid-template-columns: 1fr; }
  .mask-grid { grid-template-columns: repeat(2, 1fr); }
  .color-field { grid-template-columns: 1fr 44px; }
  .color-field input[type="text"] { grid-column: 1 / -1; }
  .description { padding: 0 18px; margin-top: 42px; }
  .description p { font-size: 16px; }
}
