:root {
  --ink: #16161a;
  --ink-soft: #5a5a66;
  --line: #e6e6ec;
  --bg: #f6f6f9;
  --card: #ffffff;
  --accent: #5b4dff;
  --accent-soft: #ecebff;
  --green: #16a34a;
  --red: #dc2626;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Inter", "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* Hero */
.hero { text-align: center; margin-bottom: 32px; }
.hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.hero h1 { font-size: 30px; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.01em; }
.hero-sub { color: var(--ink-soft); font-size: 15px; margin: 0; }

/* Card sections */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(20,20,30,0.04);
}
.card-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.step-num {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.card-head h2 { font-size: 17px; margin: 0 0 2px; }
.card-sub { color: var(--ink-soft); font-size: 13px; margin: 0; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
}
.req { color: var(--red); font-weight: 600; font-size: 12px; }

input[type="text"], input[type="file"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fafafe;
  color: var(--ink);
}
input[type="text"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
textarea { min-height: 64px; resize: vertical; }

.hint { color: var(--ink-soft); font-size: 12px; margin: 6px 0 0; line-height: 1.4; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) { .grid-3 { grid-template-columns: 1fr; } }

/* Submit button */
#submit-btn {
  width: 100%;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .1s ease, opacity .15s ease;
}
#submit-btn:hover { opacity: .92; }
#submit-btn:active { transform: scale(0.99); }
#submit-btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { font-size: 16px; }

/* Progress */
#progress {
  display: none;
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  align-items: center;
  gap: 12px;
}
#progress.error { background: #fde8e8; color: var(--red); }
.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid rgba(0,0,0,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
#progress.error .spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Result */
#result { display: none; margin-top: 28px; }
#result h2 { font-size: 19px; }
.link-btn {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
#thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; }
#thumbs img {
  width: 84px; height: 84px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
}
#preview {
  width: 100%;
  height: 700px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

/* Result head */
.result-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.result-head h2 { margin: 0; }
.accent-edit { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; }
.accent-edit input[type="color"] { width: 32px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }

/* Editor */
#editor { margin-top: 24px; }
#editor h3 { font-size: 16px; margin: 0 0 4px; }
#sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.sec-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sec-tag { font-size: 12px; font-weight: 700; color: var(--ink-soft); letter-spacing: .02em; }
.sec-img-wrap { width: 100%; aspect-ratio: 1/1; border-radius: 8px; overflow: hidden; background: #f1f1f6; }
.sec-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sec-noimg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 12px; font-size: 12px; color: var(--ink-soft);
}
.sec-card input[type="text"], .sec-card .sec-header, .sec-card .sec-instr, .sec-card textarea { font-size: 13px; padding: 8px 10px; }
.sec-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sec-row label { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 500; font-size: 12px; }
.ed-btn {
  background: var(--ink); color: #fff; border: none; border-radius: 8px;
  padding: 8px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.ed-btn:hover { opacity: .9; }
.upload-lbl { display: inline-flex; align-items: center; }
.sec-status { font-size: 12px; color: var(--accent); min-height: 16px; }

/* History */
.hist-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 2px;
  border-bottom: 1px solid var(--line);
}
.hist-row:last-child { border-bottom: none; }
.hist-info { display: flex; align-items: baseline; gap: 10px; min-width: 260px; flex: 1; }
.hist-name { font-size: 14px; font-weight: 600; }
.hist-date { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.hist-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hist-actions .link-btn { background: none; border: none; padding: 0; cursor: pointer; font-family: inherit; }
.hist-status { flex-basis: 100%; }

/* Design editor block */
.sec-design { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: #fafafe; }
.sec-design summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft); user-select: none; }
.sec-design > input, .sec-design > textarea { margin-top: 6px; font-size: 12px; padding: 6px 8px; }
.sec-design .sec-row { margin-top: 6px; }
.sec-design .d-theme { width: auto; flex: none; padding: 6px 8px; font-size: 12px; }
.sec-design .hint { font-size: 11px; margin-top: 6px; }
