:root {
  color-scheme: light;
  --panel: #f8fafc;
  --ink: #171717;
  --muted: #6b7280;
  --line: #d8dee8;
  --accent: #be123c;
  --accent-dark: #8f1232;
  --surface: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

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

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  height: 100vh;
  min-height: 620px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow-y: auto;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.control-panel h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: lowercase;
}

.control-section {
  display: grid;
  gap: 16px;
  padding: 0;
}

.lower-options {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.lower-options summary {
  cursor: pointer;
  font-weight: 700;
  list-style-position: outside;
  margin-bottom: 14px;
}

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

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

.field span {
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #cfd6e1;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
}

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

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

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

.button-grid button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.button-grid button:first-child {
  border-color: #cfd6e1;
  background: #fff;
  color: var(--ink);
}

.button-grid button:hover {
  background: var(--accent-dark);
}

.button-grid button:first-child:hover {
  background: #f1f5f9;
}

.status {
  min-height: 44px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status.error {
  color: #b91c1c;
}

.status.ok {
  color: #166534;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #f3f6fa;
}

.preview-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.preview-toolbar small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

canvas {
  display: block;
  max-width: min(92%, 430px);
  max-height: calc(100vh - 88px);
  width: auto;
  height: auto;
  background: #fff;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.18);
}

.optional-background[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .control-panel,
  .preview-pane {
    height: auto;
    min-height: 100vh;
  }
}
