:root {
  --bg: #eef0f7;
  --card: #ffffff;
  --line: #e2e6f1;
  --text: #171c28;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(23, 28, 40, .07), 0 10px 28px rgba(23, 28, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.wrap { max-width: 1200px; margin: 0 auto; padding: 18px 16px 50px; }

.topbar {
  background: #1e1b4b;
  color: #fff;
}
.topbar .wrap { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding-top: 14px; padding-bottom: 14px; }
.topbar strong { font-size: 17px; letter-spacing: .02em; }
.topbar .muted { color: rgba(255, 255, 255, .72); font-size: 13px; }

.layout { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 18px; }
@media (max-width: 920px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h2 {
  font-size: 12.5px;
  margin: 4px 0 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
}
.card .options { padding-bottom: 22px; }

.field { display: block; margin-bottom: 13px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 12px; }
.field .req { color: var(--bad); }

input[type="text"], input[type="url"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  background: #fbfcff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79, 70, 229, .22); border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }

input[type="color"] { width: 100%; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; }

input[type="range"] { width: 100%; accent-color: var(--accent); }

input[type="file"] { width: 100%; font-size: 13px; padding: 5px 0; }

.chk {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  margin: 9px 0 13px;
  cursor: pointer;
}
.chk input { width: 16px; height: 16px; accent-color: var(--accent); }

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

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 11px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(79, 70, 229, .28);
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: #e9ebf6; color: var(--text); box-shadow: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* панель предпросмотра */
.preview-pane { position: sticky; top: 14px; text-align: center; }
.preview-box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 320px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
#preview-img { max-width: 100%; max-height: 440px; width: auto; height: auto; image-rendering: pixelated; }
.preview-status { font-size: 13.5px; color: var(--muted); }
.preview-status.busy { color: var(--accent); }
.preview-error { font-size: 13px; color: var(--bad); background: #fef2f2; border: 1px solid #fecaca; border-radius: 9px; padding: 9px 12px; }
#preview-meta { margin: 10px 0 0; }

/* результат */
.alert { border-radius: 10px; padding: 12px 14px; margin-top: 16px; font-size: 14px; }
.alert-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.result { margin-top: 16px; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 720px) { .result-grid { grid-template-columns: 1fr; } }
.result figure { margin: 0; text-align: center; }
.result figcaption { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: var(--muted); }
.result img { max-width: 320px; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.result .dl { margin: 12px 0 0; }
.result .again { text-align: center; margin-top: 18px; }
.result .again a { color: var(--accent); }

footer.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 28px; }
