:root {
  --paper: #f6f2e9;
  --paper-2: #fbf8f1;
  --card: #fffdf8;
  --ink: #2a2723;
  --ink-soft: #5c574e;
  --muted: #8b8378;
  --line: #e3dbcc;
  --line-soft: #eee7da;
  --gold: #b08d57;
  --gold-soft: #e9dcc4;
  --sage: #6f7d6a;
  --rose: #b98a80;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC",
           "Noto Serif CJK SC", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --shadow: 0 26px 60px -40px rgba(64, 48, 22, .55);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  background-image:
    radial-gradient(800px 460px at 82% -10%, rgba(176,141,87,.10), transparent 60%),
    radial-gradient(640px 420px at 4% 24%, rgba(111,125,106,.07), transparent 62%);
  color: var(--ink);
  font: 15px/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */
.top {
  max-width: 1080px;
  margin: 0 auto;
  padding: 34px 26px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  background: var(--card);
}
.mark svg { width: 22px; height: 22px; }
.brand h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 24px;
  margin: 0;
  letter-spacing: .01em;
}
.brand p {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted);
}
.engine-box { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.engine-box .lbl { font-size: 11px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg button {
  border: none; background: none; padding: 7px 14px;
  font-size: 12.5px; color: var(--ink-soft); cursor: pointer;
}
.seg button.on { background: var(--ink); color: var(--paper); }

/* ---------- steps ---------- */
.steps {
  max-width: 1080px;
  margin: 8px auto 0;
  padding: 0 26px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}
.step {
  border: none; background: none; cursor: pointer;
  padding: 12px 6px 14px;
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.step i {
  font-style: normal;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px;
}
.step.on { color: var(--ink); border-bottom-color: var(--gold); }
.step.on i { border-color: var(--gold); color: var(--gold); }
.step:disabled { opacity: .45; cursor: default; }

/* ---------- panel ---------- */
main { max-width: 1080px; margin: 0 auto; padding: 30px 26px 70px; }
.panel { display: none; }
.panel.on { display: block; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  margin: 0 0 6px;
}
.panel-head p { color: var(--ink-soft); margin: 0 0 24px; max-width: 720px; font-size: 14px; }
.panel-head code {
  font-family: var(--mono); font-size: 12px;
  background: #f2ece0; border-radius: 4px; padding: 1px 5px;
}

/* ---------- step 1 ---------- */
.upload-grid { display: grid; grid-template-columns: 0.9fr 1.4fr; gap: 18px; }
.drop {
  position: relative;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf8, #faf6ee);
  min-height: 300px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px;
  color: var(--gold);
  transition: border-color .2s, background .2s;
}
.drop.dragging { border-color: var(--gold); background: #fdf8ee; }
.drop svg { width: 48px; height: 48px; margin-bottom: 12px; }
.drop .t { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.drop .h { font-size: 11.5px; color: var(--muted); margin: 2px 0 16px; }

.up-state {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 14px;
  background: rgba(251, 248, 241, .96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
}
.up-state[hidden] { display: none; }
.up-title { font-family: var(--serif); font-size: 17px; color: var(--ink); }
.up-bar {
  width: 210px;
  height: 5px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
}
.up-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), #c9a86f);
  transition: width .2s ease;
}
.up-bar.indeterminate i {
  width: 38% !important;
  animation: up-slide 1.1s ease-in-out infinite;
}
@keyframes up-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}
.up-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.paste { display: flex; flex-direction: column; }
.paste-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
textarea {
  flex: 1;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 16px 18px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  color: var(--ink);
  outline: none;
}
textarea:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 3px rgba(176,141,87,.08); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: var(--sans);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--gold-soft); background: #fdf9f0; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.primary:hover { background: #3a362f; }
.btn:disabled { opacity: .45; cursor: default; }
.link {
  border: none; background: none; padding: 0; cursor: pointer;
  color: var(--gold); font-size: 12.5px; text-decoration: underline;
  text-underline-offset: 3px;
}
.actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; margin-top: 26px;
}
.actions .hint { margin-right: auto; }
.hint { font-size: 12px; color: var(--muted); }
.pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  color: var(--muted);
  background: var(--card);
}

/* ---------- step 2 ---------- */
.cast-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cast-toolbar .spacer { flex: 1; }
.char-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.char-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.char-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(150deg, #f3ead8, #e7dcc4);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  flex: none;
  overflow: hidden;
}
.avatar img { width: 36px; height: 36px; object-fit: contain; }
.char-name { font-weight: 600; font-size: 14.5px; }
.char-role { font-size: 11px; color: var(--muted); }
.field { display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-soft); }
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-2);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
}
.speed-row { display: grid; grid-template-columns: 46px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-soft); }
.speed-row input[type="range"] { width: 100%; accent-color: var(--gold); }
.speed-row b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.char-acts { display: flex; gap: 8px; margin-top: 2px; }
.char-acts .btn { padding: 5px 12px; font-size: 12px; }

/* ---------- step 3 ---------- */
.music-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.music-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 15px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.music-card:hover { border-color: var(--gold-soft); }
.music-card.on { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,87,.10); }
.music-card .radio {
  width: 15px; height: 15px; border-radius: 50%;
  border: 1.5px solid var(--line); flex: none;
}
.music-card.on .radio { border-color: var(--gold); background: radial-gradient(circle, var(--gold) 0 45%, transparent 50%); }
.music-card .info { flex: 1; min-width: 0; }
.music-title { font-weight: 600; font-size: 13.5px; }
.music-sub { font-size: 11px; color: var(--muted); }
.music-tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.music-tags span {
  font-size: 10px; color: var(--ink-soft);
  border: 1px solid var(--line-soft); border-radius: 999px; padding: 0 7px;
}
.play-mini {
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper-2);
  cursor: pointer; flex: none; color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
}
.play-mini:hover { border-color: var(--gold); color: var(--gold); }

.scene-box {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-2);
  padding: 16px 18px;
}
.scene-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-soft); }
.scene-row select, .scene-row input {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); padding: 6px 10px; font-size: 12.5px; color: var(--ink);
  outline: none;
}
.scene-row input { width: 170px; font-family: var(--mono); }
.scene-box .hint { margin: 8px 0 0; }

/* ---------- step 4 ---------- */
.progress { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 22px; }
.progress i { display: block; height: 100%; width: 0; border-radius: 3px;
  background: linear-gradient(90deg, var(--gold), #c9a86f); transition: width .4s ease; }
.progress-meta {
  display: flex; justify-content: space-between;
  font-size: 11.5px; color: var(--muted); margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.log {
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
  color: var(--ink-soft);
  max-height: 140px; overflow: auto; white-space: pre-wrap;
  margin: 14px 0 0;
}
.result {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.result-title { font-family: var(--serif); font-size: 18px; }
.result-sub { font-size: 11.5px; color: var(--muted); }
.result audio { width: 100%; }

footer {
  max-width: 1080px; margin: 0 auto;
  padding: 20px 26px 40px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  font-size: 11px; color: var(--muted);
}

@media (max-width: 900px) {
  .upload-grid, .char-grid, .music-grid { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
  .engine-box { margin-left: 0; }
  .steps { overflow-x: auto; }
}
