:root {
  color-scheme: light;
  --accent: #1f6feb;
  --accent-dark: #185abc;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #d0d7de;
  --border-light: #e9e9e9;
}
body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f5f5f5;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  min-height: 100vh;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}
.noscript-note {
  flex-basis: 100%;
  max-width: 720px;
  margin: 0 auto 16px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}
.app {
  width: min(100%, 1400px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  padding: 24px;
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.sidebar {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding-right: 4px;
}
.canvas-panel {
  flex: 1;
  min-width: 0;
}

/* Sidebar groups */
.group {
  padding: 16px 0;
  border-top: 1px solid var(--border-light);
}
.group:first-child {
  border-top: none;
  padding-top: 0;
}
.group-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}
.field:last-child {
  margin-bottom: 0;
}
.field label {
  font-size: 13px;
  font-weight: 600;
}
.label-hint {
  font-weight: 400;
  color: #888;
  display: none;
}
.field-hint {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}
.field-hint code {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 11px;
  background: #f2f2f2;
  border-radius: 3px;
  padding: 1px 4px;
}
.field input,
.field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
  width: 100%;
}
.field textarea {
  font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
}

/* Label-left rows */
.inline-field {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.inline-field > label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}
.inline-field input[type="number"] {
  width: 70px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}
.range-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1.3;
}
input[type="range"] {
  padding: 0;
  border: none;
  accent-color: var(--accent);
  flex: 1;
  min-width: 0;
}
.range-value {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 22px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Checkboxes */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  padding: 5px 0;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  margin: 0;
  flex-shrink: 0;
}

/* Advanced settings */
details.advanced {
  margin-top: 4px;
}
details.advanced summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  padding: 4px 0;
}
details.advanced summary:hover {
  color: var(--text);
}
.advanced-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px;
}
.advanced-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.advanced-row label {
  flex: 1;
  color: var(--text-muted);
}
.advanced-row input[type="number"] {
  width: 70px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
}

/* Buttons */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
button {
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  background: var(--accent);
  width: 100%;
}
button:hover {
  background: var(--accent-dark);
}
button.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
}
button.btn-secondary:hover {
  background: #f2f4f7;
}
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-grid button {
  padding: 9px 6px;
}
button.btn-text {
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-decoration: underline;
  padding: 6px;
  width: auto;
  align-self: center;
}
button.btn-text:hover {
  background: none;
  color: var(--text);
}

:is(button, input, textarea, summary):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Messages */
.status {
  min-height: 18px;
  margin-top: 10px;
  color: #b00020;
  font-size: 13px;
  line-height: 1.4;
  font-weight: 600;
}
.stats {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 8px 2px;
  min-height: 18px;
  font-variant-numeric: tabular-nums;
}

/* Canvas */
.canvas-wrap {
  overflow: auto;
  border: 1px solid var(--border-light);
  border-radius: 10px;
}
canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 800px) {
  body {
    padding: 10px;
  }
  .app {
    flex-direction: column;
    gap: 16px;
    padding: 16px;
  }
  .sidebar {
    width: 100%;
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}
@media print {
  body {
    background: #fff;
    padding: 0;
  }
  .sidebar,
  .stats {
    display: none !important;
  }
  .app {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    display: block;
  }
  .canvas-wrap {
    border: none;
    overflow: visible;
  }
  canvas {
    width: 100% !important;
  }
}
