@font-face {
  font-family: "Grid Tool Sans";
  src: local("Avenir Next"), local("Avenir"), local("Helvetica Neue");
}

:root {
  color-scheme: light;
  --canvas: #f0ede6;
  --surface: #fffdf9;
  --surface-muted: #e8e3d9;
  --ink: #202724;
  --muted: #68706b;
  --line: #d7d2c8;
  --accent: #bd593d;
  --accent-dark: #8e3c28;
  --focus: #126d73;
  --success: #32715b;
  --danger: #a53227;
  --shadow: 0 18px 46px rgb(45 39 28 / 10%);
  --radius: 16px;
  font-family: "Grid Tool Sans", "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
select {
  font: inherit;
}

button,
label,
select,
input[type="range"],
input[type="color"] {
  -webkit-tap-highlight-color: transparent;
}

.site-header,
.workspace,
footer {
  width: min(1480px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: 34px 0 24px;
}

.eyebrow,
.step-label,
.summary-label {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.88rem;
}

.privacy-note span {
  color: var(--success);
  font-size: 0.66rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 370px);
  align-items: start;
  gap: 20px;
}

.editor-panel,
.controls-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-panel {
  min-width: 0;
  padding: 22px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.panel-heading h2,
.control-section h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 740;
  letter-spacing: -0.015em;
}

.dimension-readout {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.canvas-stage {
  position: relative;
  display: grid;
  min-height: 440px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #312e29;
  border-radius: 10px;
  background-color: #292a28;
  background-image:
    linear-gradient(45deg, #30312f 25%, transparent 25%),
    linear-gradient(-45deg, #30312f 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #30312f 75%),
    linear-gradient(-45deg, transparent 75%, #30312f 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

#editorCanvas {
  display: block;
  max-width: 100%;
  max-height: min(70vh, 820px);
  width: auto;
  height: auto;
  touch-action: none;
  user-select: none;
}

.canvas-stage.is-empty #editorCanvas {
  visibility: hidden;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  max-width: 430px;
  margin: auto;
  padding: 44px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #f8f5ef;
  text-align: center;
}

.canvas-stage:not(.is-empty) .empty-state {
  display: none;
}

.completed-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  margin: 0;
  padding: 7px 11px;
  border: 1px solid rgb(255 255 255 / 38%);
  border-radius: 999px;
  color: #fff;
  background: rgb(32 105 72 / 92%);
  box-shadow: 0 4px 16px rgb(0 0 0 / 22%);
  font-size: 0.73rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.canvas-stage.is-complete {
  background: #111;
}

.empty-state h3 {
  margin: 18px 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
}

.empty-state p {
  margin: 0 0 24px;
  color: #c9cbc7;
  font-size: 0.92rem;
  line-height: 1.55;
}

.empty-mark {
  display: grid;
  width: 72px;
  height: 72px;
  grid-template-columns: 1fr 1fr;
  border: 2px solid #f4eee3;
}

.empty-mark span {
  border: 1px solid rgb(244 238 227 / 62%);
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 16px;
}

.crop-hint {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.toolbar-actions {
  display: flex;
  flex: none;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  padding: 10px 16px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 720;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button-primary {
  color: #fffaf4;
  background: var(--accent);
}

.button-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button-complete {
  color: #fff;
  background: #206948;
}

.button-complete:hover:not(:disabled) {
  background: #174f36;
}

.button-secondary {
  border-color: var(--line);
  color: var(--ink);
  background: transparent;
}

.button-secondary:hover:not(:disabled) {
  border-color: #aaa399;
  background: #f7f3ec;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.controls-panel {
  position: sticky;
  top: 16px;
  overflow: hidden;
}

.control-section {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.section-number {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #c5beb3;
  border-radius: 50%;
  color: var(--accent-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.82rem;
  font-style: italic;
}

.section-content > p {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.file-control {
  display: flex;
  min-height: 44px;
  padding: 9px 10px 9px 13px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #faf7f1;
}

.file-control span:first-child {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-control span:last-child {
  padding: 6px 8px;
  border-radius: 5px;
  color: var(--accent-dark);
  background: #efe5dc;
  font-size: 0.72rem;
  font-weight: 760;
  text-transform: uppercase;
}

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

.field {
  display: flex;
  min-width: 0;
  gap: 6px;
  flex-direction: column;
}

.field > span {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.field input[type="number"],
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.corner-picker {
  display: grid;
  margin: 0;
  padding: 0;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 0;
}

.corner-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.corner-picker span {
  position: relative;
  display: flex;
  min-height: 44px;
  padding: 9px 9px 9px 33px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  background: #fff;
}

.corner-picker input:checked + span {
  border-color: var(--accent);
  color: var(--ink);
  background: #fbf0ea;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.corner-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid #aaa399;
}

.corner-dot::after {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.dot-upper-left,
.dot-lower-left {
  left: 10px;
}

.dot-upper-right,
.dot-lower-right {
  left: 10px;
}

.dot-upper-left::after { top: 1px; left: 1px; }
.dot-upper-right::after { top: 1px; right: 1px; }
.dot-lower-left::after { bottom: 1px; left: 1px; }
.dot-lower-right::after { right: 1px; bottom: 1px; }

.line-fields {
  grid-template-columns: 1fr 64px;
}

.full-width {
  grid-column: 1 / -1;
}

.range-field input {
  width: 100%;
  min-height: 30px;
  accent-color: var(--accent);
}

.range-field output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.color-field input {
  width: 100%;
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  background: #fff;
}

.grid-summary {
  padding: 18px 20px 20px 60px;
  background: #f1eee7;
}

.grid-summary p:last-child {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.45;
}

.summary-label {
  margin-bottom: 5px;
}

.error-message {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 650;
}

footer {
  padding: 18px 0 32px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 62%, transparent);
  outline-offset: 2px;
}

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

  .controls-panel {
    position: static;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .control-section:nth-child(odd) {
    border-right: 1px solid var(--line);
  }

  .grid-summary {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .site-header,
  .workspace,
  footer {
    width: min(100% - 24px, 1480px);
  }

  .site-header {
    align-items: flex-start;
    padding-top: 24px;
    flex-direction: column;
    gap: 12px;
  }

  .editor-panel {
    padding: 13px;
  }

  .panel-heading,
  .editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

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

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .toolbar-actions .button {
    flex: 1;
  }

  .controls-panel {
    grid-template-columns: 1fr;
  }

  .control-section:nth-child(odd) {
    border-right: 0;
  }

  .grid-summary {
    grid-column: auto;
    padding-left: 60px;
  }
}

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