:root {
  --bg: #f3f4f1;
  --panel: #fff;
  --line: #dfe1da;
  --text: #1d1f1a;
  --muted: #6b6f64;
  --brand: #8fa51c;
  --brand-ink: #1d1f1a;
  --danger: #b3261e;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar-actions { display: flex; gap: 8px; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.editor fieldset {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.editor legend { padding: 0 6px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

.field { display: block; margin-bottom: 12px; min-width: 0; }
.field > span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.field input:not([type=range]):not([type=color]), .field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  font: inherit;
  color: inherit;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.field input[type=range] { width: 100%; }
.field.color input { width: 100%; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.check { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.hint { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.hint.error { color: var(--danger); }
[hidden] { display: none !important; }

.image-field {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.image-field:last-of-type { border-bottom: 0; }
.thumb {
  flex: none;
  width: 84px; height: 56px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: repeating-conic-gradient(#f0f0f0 0 25%, #fff 0 50%) 0 0 / 12px 12px;
  overflow: hidden;
  font-size: 11px;
  color: var(--muted);
}
.thumb-photo { width: 56px; height: 72px; }
.thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumb-photo img { width: 100%; height: 100%; object-fit: cover; }
.thumb.loading { opacity: .4; }
.image-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.image-meta small { color: var(--muted); font-size: 12px; }
.image-actions { display: flex; gap: 6px; margin-top: 6px; }

.photo-tools { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; margin-bottom: 12px; }
.photo-tools .check { margin: 0; }
.bg-samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.bg-sample {
  width: 60px; height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: none;
}
.bg-sample:hover { outline: 2px solid var(--brand); }
.bg-sample img { display: block; width: 100%; height: 100%; object-fit: cover; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--text);
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { opacity: .88; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-block { width: 100%; padding: 11px; }

.preview-sticky { position: sticky; top: 80px; }
.preview h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.preview-face { margin-bottom: 24px; }
.preview-face .face {
  border-radius: 1.2mm;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.10);
}
.warnings:empty { display: none; }
.warning {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #e8d48a;
  border-radius: 8px;
  background: #fdf7df;
  font-size: 14px;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .preview { order: -1; }
  .preview-sticky { position: static; }
  .topbar { padding: 12px 16px; }
}
