:root {
  --ink: #10241c;
  --ink-soft: #2a4a3c;
  --fog: #edf3ef;
  --paper: #f7faf8;
  --line: rgba(16, 36, 28, 0.12);
  --accent: #e85d04;
  --accent-deep: #c44900;
  --ok: #1b7f5a;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(16, 36, 28, 0.12);
  --font-brand: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #d7ebe0 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #ffe2c8 0%, transparent 45%),
    linear-gradient(180deg, #f3f7f4 0%, #e7efe9 100%);
  min-height: 100vh;
}

.bg-orb {
  position: fixed;
  inset: auto -10% -20% auto;
  width: 42vw;
  height: 42vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 93, 4, 0.18), transparent 70%);
  filter: blur(8px);
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 30% 20%, #000 20%, transparent 70%);
  opacity: 0.35;
  pointer-events: none;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-4%, -3%, 0); }
}

.shell { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.auth-shell { display: grid; gap: 2rem; min-height: 100vh; align-content: center; }
.brand { font-family: var(--font-brand); font-weight: 800; letter-spacing: 0.04em; font-size: 1.75rem; margin: 0; }
.brand.sm { font-size: 1.15rem; }
.brand-block h1 {
  font-family: var(--font-brand);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  margin: 0.4rem 0 0.6rem;
  max-width: 14ch;
  animation: rise 0.7s ease both;
}
.lede { color: var(--ink-soft); margin: 0; max-width: 42ch; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.auth-form, .stage {
  background: color-mix(in srgb, var(--paper) 88%, white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: rise 0.55s ease both;
}
.auth-form { display: grid; gap: 0.85rem; max-width: 420px; }
label { display: grid; gap: 0.35rem; font-size: 0.9rem; font-weight: 500; min-width: 0; }
input, textarea, select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
textarea { resize: vertical; line-height: 1.55; }
.auth-actions, .actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.4rem; }
.hint { color: var(--ink-soft); font-size: 0.8rem; margin: 0.2rem 0 0; }
.err {
  color: var(--danger);
  background: #fff1f0;
  border: 1px solid #f3c1bc;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.user-line { margin: 0.15rem 0 0; color: var(--ink-soft); font-size: 0.85rem; }
.tabs { display: flex; gap: 0.35rem; background: rgba(255,255,255,0.55); padding: 0.3rem; border-radius: 999px; border: 1px solid var(--line); }
.tab {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
}
.tab.on { background: var(--ink); color: #fff; }

.tab-panel { display: none; }
.tab-panel.on { display: block; animation: rise 0.4s ease both; }
.stage-head { margin-bottom: 1rem; }
.stage-head h2 { font-family: var(--font-brand); margin: 0 0 0.35rem; font-size: 1.45rem; }
.field-row, .persona-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
/* 人设五列：窄屏自动换行，避免「语气」等输入框撑出卡片 */
.persona-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
@media (max-width: 900px) {
  .persona-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 560px) {
  .persona-grid,
  .field-row {
    grid-template-columns: 1fr;
  }
}
.stage {
  overflow-x: clip;
}

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 0.85rem;
  margin-top: 1rem;
}
@media (max-width: 720px) {
  .result-grid { grid-template-columns: 1fr; }
}
.result-grid article, .package-preview {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 1rem;
}
.result-grid textarea {
  width: 100%;
  min-height: 7rem;
  resize: vertical;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.55;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  box-sizing: border-box;
}
.decision-card label { display: grid; gap: 0.25rem; margin-bottom: 0.55rem; font-size: 0.85rem; }
.decision-card input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
}
.craft-warn { color: #9a3412; font-size: 0.85rem; margin: 0.2rem 0 0; }
.draft-actions { margin-top: 0.7rem; }
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.55;
  max-height: 220px;
  overflow: auto;
}

.media-bar { margin-top: 0.85rem; }
.media-results { margin-top: 1rem; }
#audio-player, #video-player { width: 100%; margin-top: 0.75rem; border-radius: 12px; background: #000; }
#video-box { display: grid; gap: 0.6rem; margin-top: 0.75rem; }

.orch-cta {
  margin: 0.85rem 0 0.4rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}
.orch-cta .hint { margin: 0.45rem 0 0; }
.step-actions {
  margin-top: 0.75rem;
  align-items: center;
}
.step-actions-label {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-right: 0.25rem;
}
.orch-panel {
  margin: 0.9rem 0 0.4rem;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  gap: 0.65rem;
}
.orch-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.orch-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}
.orch-steps li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  background: #f7faf8;
  color: var(--ink-soft);
}
.orch-steps li .n {
  display: inline-block;
  width: 1.15rem;
  height: 1.15rem;
  line-height: 1.15rem;
  text-align: center;
  border-radius: 99px;
  background: #e6eee9;
  font-size: 0.7rem;
  margin-right: 0.25rem;
}
.orch-steps li.done {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
  color: var(--ink);
  background: color-mix(in srgb, var(--ok) 10%, #fff);
}
.orch-steps li.done .n { background: var(--ok); color: #fff; }
.orch-steps li.running {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
.orch-steps li.fail {
  border-color: #e8a0a0;
  background: #fff5f5;
  color: #8a2b2b;
}
@media (max-width: 720px) {
  .orch-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.checklist {
  margin: 1rem 0 0;
  padding: 0 0 0 1.2rem;
  display: grid;
  gap: 0.55rem;
}
.checklist li {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  list-style-position: outside;
}
.checklist a { color: var(--accent-deep); }

.billing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1rem;
}
.meter {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
}
.meter .k { font-size: 0.8rem; color: var(--ink-soft); }
.meter .v { font-family: var(--font-brand); font-size: 1.35rem; margin-top: 0.2rem; }
.meter .bar {
  margin-top: 0.55rem;
  height: 6px;
  border-radius: 99px;
  background: #e6eee9;
  overflow: hidden;
}
.meter .bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ok), var(--accent));
  width: 0%;
  transition: width 0.45s ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  z-index: 20;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
}

.mode-banner {
  margin-bottom: 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid #f0c36d;
  background: #fff8e8;
  color: #6b4a00;
  font-size: 0.88rem;
  line-height: 1.45;
}

.mode-banner.ok {
  border-color: #9ad4b8;
  background: #eefaf3;
  color: #1b5c3f;
}

.works-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.works-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
}
.works-list .meta { display: grid; gap: 0.15rem; }
.works-list .title { font-weight: 600; }
.works-list .sub { font-size: 0.8rem; color: var(--ink-soft); }
.works-list .active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.status-line {
  margin: 0.45rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.status-line.warn { color: #8a5a00; }
.status-line.ok { color: var(--ok); }

.quota-guide {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid #f0b4ae;
  background: #fff5f4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.quota-guide p { margin: 0; color: var(--danger); font-size: 0.9rem; }

.studio-secure-banner {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid #f0c987;
  background: #fff8eb;
  color: #7a4b00;
  font-size: 0.88rem;
  line-height: 1.45;
}
.studio-secure-banner strong { color: #5c3600; }
.studio-secure-banner[hidden] { display: none !important; }

.studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.studio-card {
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
}
.studio-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; }
.record-box {
  margin: 0.65rem 0 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, #fff);
  display: grid;
  gap: 0.5rem;
}
.record-box .actions { margin-top: 0; }
.rec-live, .rec-preview {
  width: 100%;
  max-height: 280px;
  border-radius: 12px;
  background: #0b1220;
  object-fit: cover;
}
#voice-rec-preview { width: 100%; }
@media (max-width: 720px) {
  .studio-grid { grid-template-columns: 1fr; }
  .record-box .btn {
    flex: 1 1 auto;
    min-height: 44px;
    font-size: 1rem;
  }
  .studio-card input[type="file"] {
    font-size: 0.95rem;
  }
}
.profile-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.profile-list li {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.88rem;
}
.profile-list .meta { color: var(--ink-soft); font-size: 0.78rem; margin-top: 0.2rem; }
.profile-list .meta.warn { color: var(--danger); line-height: 1.45; }
.profile-list .meta.ok { color: var(--ok); }
.profile-list .btn.sm { margin-top: 0.35rem; padding: 0.35rem 0.75rem; font-size: 0.82rem; }

.template-picker-wrap {
  margin: 0.85rem 0 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.4);
}
.template-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  font-size: 0.92rem;
}
.template-active {
  color: var(--accent-deep);
  font-size: 0.82rem;
  white-space: nowrap;
}
.template-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
}
.template-card {
  display: grid;
  gap: 0.25rem;
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.template-card:hover {
  border-color: rgba(232, 93, 4, 0.45);
  transform: translateY(-1px);
}
.template-card.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 93, 4, 0.18);
  background: #fff;
}
.template-card .swatch {
  width: 100%;
  height: 44px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 -12px 20px rgba(0, 0, 0, 0.28);
}
.template-card .tpl-name {
  font-weight: 600;
  font-size: 0.9rem;
}
.template-card .tpl-desc {
  font-size: 0.75rem;
  color: var(--ink-soft);
  line-height: 1.35;
}

/* —— W4 新手引导 —— */
.btn.sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}
.journey {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, #fff);
  box-shadow: 0 8px 24px rgba(16, 36, 28, 0.06);
  animation: rise 0.45s ease both;
}
.journey[hidden] { display: none !important; }
.journey-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.journey-title {
  margin: 0;
  font-family: var(--font-brand);
  font-weight: 700;
  font-size: 1.05rem;
}
.journey-sub {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.journey-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.journey-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.4rem;
}
.journey-steps .step-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.35rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}
.journey-steps .step-btn:hover {
  border-color: rgba(232, 93, 4, 0.4);
  transform: translateY(-1px);
}
.journey-steps .n {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 36, 28, 0.08);
}
.journey-steps .t { font-size: 0.78rem; font-weight: 500; }
.journey-steps li.done .step-btn {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--line));
  background: color-mix(in srgb, #e8f6ef 70%, white);
}
.journey-steps li.done .n {
  background: var(--ok);
  color: #fff;
}
.journey-steps li.current .step-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 93, 4, 0.15);
  background: #fff;
}
.journey-steps li.current .n {
  background: var(--accent);
  color: #fff;
}
@media (max-width: 720px) {
  .journey-steps { grid-template-columns: repeat(3, 1fr); }
}

.guide-callout {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: linear-gradient(135deg, #fff7f0 0%, #fff 70%);
}

.today-topic {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.today-topic[hidden] { display: none !important; }
.today-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}
.today-topic h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.4;
}
.today-topic .hint { margin: 0 0 0.75rem; }
.today-topic .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.guide-callout p { margin: 0 0 0.65rem; font-size: 0.92rem; color: var(--ink-soft); }
.guide-callout p:last-child { margin-bottom: 0; }
.guide-callout .actions { margin-top: 0.35rem; }
.guide-callout[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(16, 36, 28, 0.45);
  backdrop-filter: blur(4px);
  animation: rise 0.35s ease both;
}
.modal[hidden] { display: none !important; }
.modal-card {
  width: min(420px, 100%);
  padding: 1.35rem 1.4rem 1.25rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow);
}
.modal-card h2 {
  font-family: var(--font-brand);
  font-size: 1.45rem;
  margin: 0.35rem 0 0.85rem;
  line-height: 1.25;
}
.welcome-list {
  margin: 0 0 1.1rem;
  padding-left: 1.15rem;
  color: var(--ink-soft);
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
}
.welcome-list strong { color: var(--ink); }

[hidden] { display: none !important; }
