:root {
  --ink: #1a1f18;
  --muted: #5c6758;
  --paper: #f3efe4;
  --panel: rgba(255, 252, 245, 0.88);
  --line: #c9c0a8;
  --accent: #c45c26;
  --accent-2: #1f6f5b;
  --focus: #2a6fdb;
  --danger: #a12828;
  --radius: 14px;
  --font-display: "Segoe UI Variable", "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-body: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffe8c8 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #c8ebe0 0%, transparent 50%),
    linear-gradient(165deg, #efe8d6 0%, var(--paper) 45%, #e4ecdf 100%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(26, 31, 24, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 31, 24, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

.top {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem clamp(1rem, 4vw, 3rem);
  flex-wrap: wrap;
}
.auth-slot {
  margin: 0 0 0 auto;
  font-size: 0.9rem;
}
.auth-ok { color: var(--accent-2); font-weight: 600; }
.auth-login {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
.auth-login:hover { text-decoration: underline; }
.auth-warn { color: var(--muted); margin-left: 0.35rem; }
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.product {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto 3rem;
}

.hero-block h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}
.lead {
  margin: 0 0 1.75rem;
  color: var(--muted);
  max-width: 40rem;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
@media (max-width: 820px) {
  .workspace { grid-template-columns: 1fr; }
}

.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.9rem 0 0.35rem;
}
.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
}

input[type="text"], input[type="password"], input[type="url"], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  background: #fffdf8;
  color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }

.drop {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  min-height: 160px;
  display: grid;
  place-items: center;
  background: #fffdf8;
  overflow: hidden;
  cursor: pointer;
}
.drop.drag { border-color: var(--accent-2); background: #eef8f4; }
.drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop img {
  max-width: 100%;
  max-height: 220px;
  object-fit: contain;
}
#fileHint { color: var(--muted); pointer-events: none; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 180px;
  overflow: auto;
  padding: 0.2rem 0;
}
.chips.templates { max-height: 220px; }
.chip {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.chip.on {
  border-color: var(--accent-2);
  background: #d8f0e7;
  color: #0f3f34;
}
.chip .meta { opacity: 0.65; font-size: 0.72rem; margin-left: 0.25rem; }

.mode {
  border: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  gap: 1rem;
}
.mode legend { font-size: 0.78rem; font-weight: 600; color: var(--muted); margin-bottom: 0.35rem; }

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn.primary { background: var(--accent); color: #fff8f2; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.linkish {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
}

.status {
  margin-top: 1.5rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
}
.bar {
  height: 8px;
  background: #e2dac8;
  border-radius: 999px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.3s ease;
}
#statusText { margin: 0.75rem 0 0.5rem; font-weight: 600; }
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.85rem 0 0.5rem;
  align-items: center;
}
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.75rem;
}
.gallery-card {
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.gallery-card .meta {
  padding: 0.55rem 0.7rem 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
}
.gallery-card .engine {
  padding: 0 0.7rem 0.45rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.gallery-card a.thumb {
  display: block;
  background: #1a1f18;
  aspect-ratio: 1;
  overflow: hidden;
}
.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #1a1f18;
}
.gallery-card .err {
  padding: 0.75rem;
  color: var(--danger);
  font-size: 0.85rem;
}
.gallery-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}
#log {
  margin: 0.75rem 0 0;
  max-height: 240px;
  overflow: auto;
  font-size: 0.8rem;
  background: #1a1f18;
  color: #e8efdf;
  padding: 0.75rem;
  border-radius: 10px;
  white-space: pre-wrap;
}

