:root {
  color-scheme: light;
  --page: #f4f7f8;
  --panel: #ffffff;
  --text: #182026;
  --muted: #5f6b73;
  --border: #d9e0e4;
  --accent: #0b6bcb;
  --accent-hover: #0959a8;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(24, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.container {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  padding: 32px 0 18px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 760;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 18px 0 32px;
}

.form-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

label {
  color: var(--text);
  font-weight: 650;
}

input,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 9px 12px;
}

input:disabled,
select:disabled {
  background: #edf1f3;
  color: #7a858c;
  cursor: not-allowed;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(11, 107, 203, 0.22);
  outline-offset: 2px;
}

.inline-controls {
  display: grid;
  grid-template-columns: 1fr 140px;
  gap: 10px;
}

.color-controls {
  grid-template-columns: 1fr 56px;
}

input[type="color"] {
  width: 56px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  padding: 4px;
  cursor: pointer;
}

input[type="color"]:disabled {
  background: #edf1f3;
  cursor: not-allowed;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.message {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
}

.message.error {
  color: var(--danger);
  font-weight: 650;
}

.preview-panel {
  min-width: 0;
  padding: 24px;
}

.preview-header {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  padding: 10px 16px;
  cursor: pointer;
}

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

button:disabled {
  background: #aab5bd;
  cursor: not-allowed;
}

.preview-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background-color: #f9fbfc;
  background-image:
    linear-gradient(45deg, #e7ecef 25%, transparent 25%),
    linear-gradient(-45deg, #e7ecef 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7ecef 75%),
    linear-gradient(-45deg, transparent 75%, #e7ecef 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  overflow: auto;
  padding: 24px;
}

canvas {
  display: none;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  box-shadow: 0 2px 10px rgba(24, 32, 38, 0.14);
}

canvas.is-visible {
  display: block;
}

.empty-preview {
  margin: 0;
  color: var(--muted);
  text-align: center;
}

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

.site-footer {
  display: flex;
  justify-content: center;
  padding: 20px 16px 32px;
}

.site-footer a {
  color: var(--accent);
  font-weight: 650;
}

@media (max-width: 760px) {
  .site-header {
    padding-top: 24px;
  }

  .app-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .form-panel,
  .preview-panel {
    padding: 18px;
  }

  .preview-header {
    align-items: stretch;
    flex-direction: column;
  }

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

  .color-controls {
    grid-template-columns: 1fr 56px;
  }

  .preview-box {
    min-height: 280px;
    padding: 16px;
  }
}
