:root {
  --bg: #f0f4f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #5b6471;
  --border: #d4dde6;
  --primary: #1768ac;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #d7f0ff 0%, transparent 40%),
    radial-gradient(circle at bottom left, #e0ffe8 0%, transparent 35%),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(12, 29, 44, 0.08);
}

.panel-section {
  border: 1px solid #e6edf5;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  background: #fbfdff;
}

.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.muted {
  color: var(--muted);
  margin: 0 0 14px;
}

.compact {
  margin: 6px 0 0;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span,
.field label > span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
}

.field textarea {
  resize: vertical;
}

.color-field {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
}

.color-field input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
}

.color-field input[type="text"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 11px;
  background: #ffffff;
  color: var(--ink);
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.inline-toggle > span {
  margin-bottom: 0;
}

.slider-field {
  display: block;
  margin-bottom: 10px;
}

.slider-field input[type="range"] {
  width: 100%;
}

.slider-field span {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

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

button {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f8fbff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.98);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: inset 0 1px 0 #ffffff;
}

.preview-toolbar {
  width: min(100%, 430px);
  display: flex;
  justify-content: center;
}

.option-subsection {
  margin-top: 12px;
  padding-top: 10px;
}

canvas {
  width: min(100%, 430px);
  height: auto;
  border-radius: 22px;
  box-shadow: 0 14px 30px rgba(17, 24, 39, 0.2);
  background: #ffffff;
  touch-action: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(1080px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.preview-item {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px;
}

.preview-item img {
  width: 100%;
  display: block;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.2);
}

.preview-item figcaption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

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

  .preview {
    order: -1;
  }
}
