:root {
  --bg: #0f1012;
  --panel: #18191c;
  --panel-2: #1f2024;
  --line: rgba(255,255,255,.08);
  --line-2: rgba(255,255,255,.14);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --soft: #27292f;
  --accent: #f8fafc;
  --ok: #22c55e;
  --bad: #ef4444;
  --sidebar: 270px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 99px; }
body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  background: #0d0e11;
  color: var(--text);
  font-family: var(--font);
}

.sidebar {
  min-height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: #111215;
  position: sticky;
  top: 0;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 6px 22px; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #111215;
  font-size: 20px;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.nav-item {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font: 600 13px/1.2 var(--font);
}
.nav-item.active, .nav-item:hover { background: var(--soft); color: var(--text); }
.nav-item strong { font-size: 11px; color: var(--muted); font-weight: 700; }
.service-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15161a;
}
.dot { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); box-shadow: 0 0 0 4px rgba(34,197,94,.12); }
.service-card b { display: block; font-size: 12px; }
.service-card small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.main { min-width: 0; padding: 22px 24px 28px; }
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.header h2 { margin: 0; font-size: 24px; letter-spacing: 0; }
.header p { margin: 6px 0 0; max-width: 820px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.header a, .downloads a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  background: #15161a;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}
.step {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 14px;
  background: #15161a;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.step b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: var(--soft);
  color: var(--text);
  font-size: 11px;
}
.step.active { color: var(--text); background: #1b1c20; }
.step.active b { background: var(--accent); color: #101114; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.form-panel, .result-panel { padding: 16px; width: 100%; }
.result-panel { order: 2; }
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 800;
}
.module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}
.module-head.tight { margin-top: 8px; }
.module-head.inline { margin: 0; padding: 0; border: 0; }
.module-head h3 {
  margin: 2px 0 0;
  font-size: 15px;
  letter-spacing: 0;
}
.module-head > i {
  color: var(--muted);
  font-size: 20px;
}
.kicker {
  color: var(--muted);
  font: 700 10px/1 var(--mono);
  letter-spacing: .08em;
}
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.four { grid-template-columns: 1.2fr .6fr .7fr .7fr; }
.grid.compact label { margin-bottom: 0; }
.style-row { display: grid; grid-template-columns: 1.3fr .7fr; gap: 12px; }
label { display: block; margin-bottom: 12px; }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  outline: none;
  background: #101114;
  color: var(--text);
  font: 13px/1.45 var(--font);
}
textarea { min-height: 136px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--line-2); background: #0d0e10; }
.style-preview {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.style-preview img {
  flex: 0 0 112px;
  width: 112px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #0b0c0f;
}
.style-preview b { display: block; font-size: 13px; }
.style-preview span, .style-preview small { color: var(--muted); font-size: 12px; }
.gallery-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 0 8px;
}
.gallery-head span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}
.gallery-head small {
  color: var(--muted);
  font-size: 12px;
}
.template-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  max-height: 520px;
  overflow: auto;
  padding-right: 2px;
}
.template-tile {
  min-height: 168px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  overflow: hidden;
  background: #141519;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.template-tile:hover,
.template-tile.selected {
  border-color: var(--line-2);
  background: #202126;
}
.template-tile.selected { outline: 2px solid rgba(248,250,252,.32); outline-offset: -2px; }
.template-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0b0c0f;
  border-bottom: 1px solid var(--line);
}
.tile-copy { padding: 10px; }
.template-tile b {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 34px;
  font-size: 12px;
  line-height: 1.35;
}
.template-tile span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font: 700 10px/1 var(--mono);
  text-transform: uppercase;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 14px;
  color: var(--muted);
  font-size: 13px;
}
.check input { width: 16px; min-height: 16px; }
.check span { margin: 0; }
.primary {
  width: 100%;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 8px;
  color: #101114;
  background: var(--accent);
  font: 800 13px/1 var(--font);
  cursor: pointer;
}
.primary:disabled { opacity: .55; cursor: not-allowed; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pill {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.pill[data-state="done"] { color: var(--ok); }
.pill[data-state="failed"] { color: var(--bad); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.metrics div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141519;
}
.metrics b { display: block; font-size: 22px; }
.metrics span { color: var(--muted); font-size: 12px; }
.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(154px, 1fr)); gap: 10px; margin-bottom: 12px; }
.previews img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0c0f;
}
pre {
  min-height: 300px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0c0f;
  color: #d1d5db;
  font: 12px/1.55 var(--mono);
}

@media (max-width: 1040px) {
  body { display: block; }
  .sidebar { position: static; min-height: auto; }
  .service-card { position: static; margin-top: 18px; }
  .layout, .grid.two, .grid.four, .style-row, .workflow-strip, .template-gallery { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .header { display: block; }
  .header a { margin-top: 12px; }
}
