:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d8dee8;
  --panel: #ffffff;
  --surface: #f4f7fb;
  --accent: #e95f6f;
  --accent-dark: #bb3f50;
  --focus: #3b82f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  height: 100dvh;
  overflow: hidden;
}

.workspace {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 18px;
}

.canvas-wrap {
  position: relative;
  width: min(100%, 900px, calc((100dvh - 36px) * var(--canvas-ratio-value, 1)));
  max-height: calc(100dvh - 36px);
  aspect-ratio: var(--canvas-ratio, 1 / 1);
  border: 1px solid var(--line);
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-color: #fff;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
  box-shadow: 0 18px 45px rgba(31, 41, 51, 0.12);
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.empty-state strong {
  color: var(--ink);
  font-size: 24px;
}

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

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 22px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.brand p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 2px dashed #b7c2d0;
  border-radius: 8px;
  color: var(--accent-dark);
  background: #fff7f8;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-box span {
  font-weight: 700;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.5;
}

button,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

button {
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

#contactButton {
  color: var(--accent-dark);
}

.field,
.controls {
  display: grid;
  gap: 12px;
}

.field label,
.controls label,
.toggle-row label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field select {
  width: 100%;
  margin-top: 6px;
  padding: 0 10px;
}

.controls label {
  display: grid;
  gap: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.disclaimer {
  margin: auto 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal[aria-hidden="true"] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.24);
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  min-height: 36px;
  border-radius: 50%;
  line-height: 1;
}

.modal-panel h2 {
  margin: 0 0 20px;
  font-size: 24px;
}

.contact-form {
  display: grid;
  gap: 16px;
}

.contact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.contact-form input,
.contact-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.contact-form textarea {
  min-height: 118px;
  resize: vertical;
}

.contact-done {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.contact-done[hidden] {
  display: none;
}

.contact-done img {
  width: 220px;
  height: 220px;
  object-fit: contain;
  image-rendering: auto;
}

.contact-done strong {
  font-size: 28px;
}

.contact-done p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .workspace {
    padding: 14px;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    overflow-y: visible;
  }
}
