:root {
  --navy: #1f3a5f;
  --navy-deep: #16293f;
  --purple: #5b63e8;
  --purple-soft: #6f78f0;
  --lav: #ececfb;
  --ink: #1d2030;
  --muted: #6b7186;
  --line: #e4e6f5;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  color: var(--ink);
  background: #f4f5fb;
  line-height: 1.5;
}
.app {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 24px;
  padding: 24px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

/* ============ 表单 ============ */
.form-pane {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 8px 30px rgba(60, 66, 120, 0.08);
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.form-head h1 { font-size: 21px; }
.form-head p { color: var(--muted); font-size: 13px; margin: 6px 0 18px; }
.group { margin-bottom: 22px; }
.group h2 {
  font-size: 15px; color: var(--purple); margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 2px solid var(--lav);
}
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .full, label.full { grid-column: 1 / -1; }
input, textarea {
  width: 100%; margin-top: 4px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fbfbfe;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--purple-soft);
  box-shadow: 0 0 0 3px rgba(111, 120, 240, .15); background: #fff;
}
.timeline-rows { display: flex; flex-direction: column; gap: 8px; }
.tl-row { display: grid; grid-template-columns: 80px 1fr 28px; gap: 8px; align-items: center; }
.tl-row input { margin-top: 0; }
.tl-del { border: none; background: var(--lav); color: var(--purple); border-radius: 8px; height: 36px; cursor: pointer; font-size: 16px; }
.tl-del:hover { background: #dcdcfb; }
.add-btn { margin-top: 10px; border: 1px dashed var(--purple-soft); background: #fff; color: var(--purple); border-radius: 9px; padding: 8px 14px; cursor: pointer; font-size: 13px; }
.add-btn:hover { background: var(--lav); }

.gen-btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--purple-soft));
  color: #fff; font-size: 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 6px 18px rgba(91, 99, 232, .35);
}
.gen-btn:hover { filter: brightness(1.05); }
.gen-btn:disabled { opacity: .6; cursor: not-allowed; }
.ghost-btn {
  width: 100%; margin-top: 10px; padding: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); border-radius: 12px; font-size: 14px; cursor: pointer;
}
.ghost-btn:hover { background: #fafaff; }
.status { text-align: center; color: var(--muted); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ============ 结果区 ============ */
.result-pane { min-width: 0; }
.result-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.result-toolbar .hint { color: var(--muted); font-size: 13px; }
.dl-btn { border: none; background: var(--purple); color: #fff; padding: 10px 18px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.dl-btn.small { padding: 7px 14px; font-size: 13px; }
.dl-btn:disabled { opacity: .45; cursor: not-allowed; }
.dl-btn:not(:disabled):hover { background: var(--purple-soft); }

/* AI 海报展示 */
.poster-box {
  background: var(--navy-deep);
  border-radius: 18px;
  min-height: 540px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 16px;
}
.poster-box img { max-width: 100%; max-height: 78vh; border-radius: 10px; display: none; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.poster-box img.ready { display: block; }
.poster-ph { color: #aab4d4; font-size: 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.poster-ph span { font-size: 13px; color: #7e8ab0; }

/* 折叠预览 */
.preview-wrap { margin-top: 22px; background: #fff; border-radius: 14px; padding: 6px 16px 16px; box-shadow: 0 4px 16px rgba(60,66,120,.06); }
.preview-wrap summary { cursor: pointer; padding: 12px 0; font-size: 14px; color: var(--purple); font-weight: 600; }
.preview-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* HTML 卡片 */
.card { display: flex; gap: 14px; background: var(--navy); padding: 14px; border-radius: 18px; }
.col { flex: 1; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel { background: #fff; border-radius: 14px; padding: 16px 18px; }
.panel-title { font-size: 16px; color: var(--purple); margin-bottom: 12px; display: inline-block; padding-bottom: 4px; border-bottom: 3px solid var(--lav); }
.basic-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.portrait { width: 84px; height: 84px; flex-shrink: 0; border-radius: 16px; overflow: hidden; background: var(--lav); display: flex; align-items: center; justify-content: center; }
.portrait-ph2 { font-size: 40px; font-weight: 700; color: var(--purple); }
.card-title { font-size: 19px; }
.card-name { font-size: 14px; color: var(--muted); margin-top: 6px; }
.basic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.basic-grid > div { font-size: 14px; display: flex; gap: 8px; }
.basic-grid b { color: var(--purple); font-weight: 600; min-width: 30px; }
.basic-grid .full { grid-column: 1 / -1; }
.basic-grid span { color: var(--ink); word-break: break-all; }
.tag-line { font-size: 14px; margin-bottom: 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.tag-line b { color: var(--purple); font-weight: 600; }
.tag-line > span { color: var(--ink); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--lav); color: var(--purple); border-radius: 999px; padding: 3px 12px; font-size: 13px; font-weight: 500; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-item { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.tl-time-badge { background: var(--purple); color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; flex-shrink: 0; }
.tl-act-text { color: var(--ink); }
.tl-empty { color: var(--muted); font-size: 13px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .form-pane { position: static; max-height: none; }
  .card { flex-direction: column; }
}
