:root {
  color-scheme: light;
  --ink: #182235;
  --muted: #647084;
  --line: #d8dee8;
  --panel: #f8fafc;
  --surface: #ffffff;
  --accent: #d94343;
  --accent-dark: #b92f35;
  --ok: #0f7b54;
  --error: #a82020;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: #eef2f7;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr) minmax(320px, 1fr);
  width: 100vw;
  height: 100vh;
  min-width: 960px;
  overflow: hidden;
}

.control-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.puzzle-name {
  flex: 0 0 auto;
  margin: 0;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 25px;
  font-weight: 760;
  letter-spacing: 0;
}

.control-body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.control-section,
.advanced-fields {
  display: grid;
  gap: 14px;
}

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

.field span,
.advanced summary,
.preview-pane h2 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input,
select {
  padding: 0 10px;
}

textarea {
  min-height: 154px;
  resize: vertical;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 67, 67, 0.12);
}

input[type="color"] {
  padding: 4px;
}

input[type="file"] {
  padding: 7px 8px;
}

.advanced {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.advanced summary {
  cursor: pointer;
  list-style-position: inside;
}

.advanced-fields {
  padding-top: 14px;
}

.status {
  min-height: 40px;
  border-left: 3px solid var(--ok);
  padding: 8px 10px;
  background: #edf8f3;
  color: var(--ok);
  font-size: 13px;
  line-height: 1.45;
}

.status.is-error {
  border-left-color: var(--error);
  background: #fff1f1;
  color: var(--error);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 760;
}

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

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

#reset {
  background: #fff;
  color: var(--accent);
}

.preview-pane {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto 1fr;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.preview-pane h2 {
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.preview-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: 24px;
}

canvas {
  display: block;
  width: min(78%, 360px);
  height: auto;
  box-shadow: 0 18px 44px rgba(24, 34, 53, 0.18);
  background: #fff;
}
