:root {
  --bg: #f4f2ec;
  --surface: rgba(255, 255, 255, 0.72);
  --line: rgba(20, 22, 18, 0.08);
  --line-strong: rgba(20, 22, 18, 0.14);
  --ink: #171814;
  --muted: #6f7268;
  --accent: #5a7a12;
  --accent-soft: #dff08a;
  --accent-ink: #12140a;
  --glow: rgba(90, 122, 18, 0.12);
  --radius: 14px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 10% -10%, rgba(223, 240, 138, 0.55), transparent 55%),
    radial-gradient(700px 480px at 100% 0%, rgba(190, 210, 255, 0.28), transparent 50%),
    linear-gradient(180deg, #faf8f2 0%, #f1eee6 48%, #ebe7de 100%);
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 72px;
  animation: fade-up 0.6s ease both;
}

.top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
  animation: fade-up 0.7s ease both;
}

.brand {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--ink);
}

.tagline {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 0.92fr) minmax(0, 1.2fr);
  gap: 28px;
  align-items: start;
  animation: fade-up 0.8s ease both;
}

.rail, .main {
  display: grid;
  gap: 22px;
}

.block-label {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.block-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.block-label-row .block-label {
  margin: 0;
}

.file-tile {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.file-tile:hover {
  border-color: rgba(90, 122, 18, 0.45);
  background: rgba(223, 240, 138, 0.25);
  transform: translateY(-1px);
}

.file-tile-title {
  font-size: 15px;
  font-weight: 500;
}

.file-tile-desc,
.material-info,
#materialInfo,
#musicInfo {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.material-info.ready,
#materialInfo.ready,
#musicInfo.ready {
  color: var(--accent);
}

.sticker-box {
  display: grid;
  gap: 10px;
}

.sticker-box input[type="text"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border-radius: 10px;
  padding: 12px 14px;
  font: 500 14px/1.4 var(--font);
  outline: none;
}

.sticker-box input[type="text"]:focus {
  border-color: rgba(90, 122, 18, 0.45);
  box-shadow: 0 0 0 3px var(--glow);
}

.emoji-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.emoji-bar button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.emoji-bar button:hover {
  border-color: rgba(90, 122, 18, 0.4);
  background: #f7fbe8;
}

.sticker-editor {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  align-items: start;
}

.sticker-stage {
  width: 132px;
  background:
    linear-gradient(180deg, rgba(40,40,40,0.95), rgba(20,20,20,0.98)),
    #222;
}

.sticker-stage .stage-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
}

.sticker-drag {
  position: absolute;
  left: 0;
  top: 0;
  width: auto;
  height: auto;
  max-width: none;
  cursor: grab;
  display: none;
  user-select: none;
  touch-action: none;
}

.sticker-drag.dragging { cursor: grabbing; }

.sticker-stage.has-sticker .sticker-drag { display: block; }
.sticker-stage.has-sticker .stage-empty { display: none; }

.inline-field {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.inline-field input,
textarea,
input[type="url"] {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  outline: none;
  font: 400 14px/1.45 var(--font);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.inline-field input {
  border-radius: 10px;
  padding: 11px 14px;
}

textarea {
  resize: vertical;
  min-height: 168px;
  border-radius: 14px;
  padding: 16px 18px;
}

.inline-field input:focus,
textarea:focus {
  border-color: rgba(90, 122, 18, 0.45);
  box-shadow: 0 0 0 3px var(--glow);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font: 500 13px/1 var(--font);
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--accent-ink);
  color: #f7f6f1;
  padding: 14px 28px;
  font-size: 14px;
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #000;
}

.btn.soft {
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.btn.soft:hover:not(:disabled) {
  border-color: rgba(20, 22, 18, 0.22);
  background: #fff;
}

.btn.text {
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
}

.btn.text:hover:not(:disabled) {
  color: var(--ink);
}

.btn.compact {
  padding: 8px 12px;
  font-size: 12px;
}

label.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--accent);
}

.overlay-layout {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 14px;
  align-items: start;
}

.stage {
  position: relative;
  width: 132px;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), rgba(230,228,220,0.9)),
    #e8e5dc;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
}

#overlayStage {
  /* 有明暗层次，方便看出「叠加」混合效果 */
  background:
    radial-gradient(120px 80px at 30% 25%, #6a7a8a, transparent 60%),
    radial-gradient(100px 120px at 80% 70%, #3a3030, transparent 55%),
    linear-gradient(165deg, #2a3340 0%, #1a1e24 50%, #12151a 100%);
}

.stage-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(20,22,18,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20,22,18,0.05) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
}

#overlayStage .stage-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
}

.overlay-img {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: auto;
  cursor: grab;
  display: none;
  max-width: none;
  will-change: left, top, opacity, width;
  mix-blend-mode: overlay;
  transform-origin: top left;
}

.overlay-img.dragging { cursor: grabbing; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  pointer-events: none;
}

.stage.has-image .stage-empty { display: none; }
.stage.has-image .overlay-img { display: block; }

.overlay-side {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.slider-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.slider-row b {
  color: var(--ink);
  font-weight: 500;
}

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

.micro,
.folder-tip {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.run-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.auto-fields {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  margin-top: 4px;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(20, 22, 18, 0.06);
}

.mode-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.mode-tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 22, 18, 0.08);
}

#urlInput {
  width: 100%;
  min-height: 110px;
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  resize: vertical;
  line-height: 1.5;
}

#urlInput:focus {
  outline: none;
  border-color: rgba(90, 122, 18, 0.45);
  box-shadow: 0 0 0 3px var(--glow);
}

.auto-fields .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.auto-fields .field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
}

.auto-fields .field input:focus {
  outline: none;
  border-color: rgba(90, 122, 18, 0.45);
  box-shadow: 0 0 0 3px var(--glow);
}

@media (max-width: 720px) {
  .auto-fields {
    grid-template-columns: 1fr;
  }
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 180px;
}

.progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(20, 22, 18, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5a7a12, #9bc43a);
  transition: width 0.35s ease;
}

.progress-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  min-width: 3.2em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#folderTip {
  margin-top: 10px;
}

.log {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}

.results:empty {
  border: 0;
}

.results li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.results .meta { min-width: 0; }

.results .name {
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

.results .size {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.results a {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}

.results a:hover { opacity: 0.8; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .shell {
    width: calc(100% - 24px);
    padding-top: 24px;
  }

  .overlay-layout {
    grid-template-columns: 120px 1fr;
  }
}
