/* ===== AI IP 绘本工厂 · 儿童友好样式 ===== */
:root {
  --bg: #fff7ef;
  --bg2: #ffeede;
  --card: #ffffff;
  --ink: #3b3030;
  --muted: #9b8f87;
  --line: #f0e3d6;
  --brand: #ff8a5b;
  --brand2: #ffb15b;
  --blue: #6ec6e8;
  --green: #6fcf97;
  --pink: #ff9ec0;
  --purple: #b39ddb;
  --radius: 22px;
  --shadow: 0 10px 28px rgba(255, 138, 91, 0.16);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 100% at 50% 0%, var(--bg2) 0%, var(--bg) 60%);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; position: sticky; top: 0; z-index: 20;
  background: rgba(255, 247, 239, 0.85); backdrop-filter: blur(8px);
}
.brand { font-size: 20px; font-weight: 800; cursor: pointer; }
.ghost {
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 16px; border-radius: 999px; font-weight: 700;
}
.ghost:hover { border-color: var(--brand2); }

#app { max-width: 980px; margin: 0 auto; padding: 18px 18px 80px; }

/* 通用卡片/按钮 */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px;
}
.btn {
  border: none; border-radius: 999px; padding: 15px 26px; font-size: 17px; font-weight: 800;
  background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff;
  box-shadow: 0 8px 18px rgba(255, 138, 91, 0.3); transition: transform .08s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.soft { background: #fff; color: var(--brand); border: 2px solid var(--brand2); box-shadow: none; }
.btn.blue { background: linear-gradient(135deg, #7fd0ee, var(--blue)); box-shadow: 0 8px 18px rgba(110,198,232,.3); }
.btn.green { background: linear-gradient(135deg, #8ad9a8, var(--green)); box-shadow: 0 8px 18px rgba(111,207,151,.3); }
.btn.lg { padding: 18px 38px; font-size: 19px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.center { text-align: center; }

h1 { font-size: 30px; margin: 6px 0; }
h2 { font-size: 23px; margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 16px; line-height: 1.6; }
.tag { display: inline-block; background: var(--bg2); color: #c2724a; border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 700; margin: 2px 4px 2px 0; }

/* 首页 */
.hero { text-align: center; padding: 40px 16px; }
.hero .emoji { font-size: 72px; }
.hero h1 { font-size: 38px; }
.hero .sub { font-size: 18px; max-width: 560px; margin: 10px auto 26px; }
.steps { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.step { background: #fff; border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); width: 150px; }
.step .n { font-size: 26px; }

/* 表单 */
.uploader {
  border: 3px dashed var(--brand2); border-radius: var(--radius); padding: 22px; text-align: center;
  background: #fff9f4; cursor: pointer; transition: background .15s;
}
.uploader:hover { background: #fff3e8; }
.uploader img { max-width: 220px; max-height: 220px; border-radius: 16px; box-shadow: var(--shadow); }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 800; margin-bottom: 7px; font-size: 16px; }
.field .hint { color: var(--muted); font-weight: 500; font-size: 13px; margin-left: 6px; }
.field input, .field textarea, .field select {
  width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 13px 15px;
  font-size: 16px; font-family: inherit; color: var(--ink); background: #fffdfb;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--brand2); }
.field textarea { min-height: 70px; resize: vertical; }
.req::after { content: " *"; color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 680px) { .grid2 { grid-template-columns: 1fr; } }
.err-text { color: #e0563b; font-size: 13px; margin-top: 5px; font-weight: 700; }

/* 确认页 */
.confirm-grid { display: grid; grid-template-columns: 240px 1fr; gap: 22px; }
@media (max-width: 680px) { .confirm-grid { grid-template-columns: 1fr; } }
.confirm-grid img { width: 100%; border-radius: 18px; box-shadow: var(--shadow); }
.kv { margin-bottom: 10px; }
.kv .k { color: var(--muted); font-size: 13px; font-weight: 700; }
.kv .v { font-size: 16px; }

/* 生成中 / 状态 */
.loading-wrap { text-align: center; padding: 40px 0; }
.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 6px solid var(--bg2); border-top-color: var(--brand); margin: 0 auto 18px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.status-text { font-size: 19px; font-weight: 800; }

/* 8 页网格 */
.page-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 760px) { .page-grid { grid-template-columns: repeat(2, 1fr); } }
.pcell { background: #fff; border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); position: relative; }
.pcell .ph { aspect-ratio: 1; background: #fbeede; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--muted); }
.pcell .ph img { width: 100%; height: 100%; object-fit: cover; }
.pcell .mini-spin { width: 30px; height: 30px; border: 4px solid #fff; border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; }
.pcell .cap { padding: 8px 10px; font-size: 13px; line-height: 1.45; }
.pcell .badge { position: absolute; top: 8px; left: 8px; font-size: 12px; font-weight: 800; padding: 3px 9px; border-radius: 999px; color: #fff; }
.b-pending { background: #c9b9ab; }
.b-generating { background: var(--blue); }
.b-success { background: var(--green); }
.b-failed { background: #e0563b; }
.pcell .retry { width: 100%; border: none; background: #fff3e8; color: var(--brand); font-weight: 800; padding: 8px; }
.fail-note { color: #e0563b; font-size: 12px; padding: 0 10px 8px; }

/* 编辑器 */
.editor { display: grid; grid-template-columns: 130px 1fr; gap: 18px; }
@media (max-width: 760px) { .editor { grid-template-columns: 1fr; } }
.thumbs { display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow: auto; }
@media (max-width: 760px) { .thumbs { flex-direction: row; max-height: none; overflow-x: auto; } }
.thumb { border: 3px solid transparent; border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; box-shadow: var(--shadow); flex: 0 0 auto; }
.thumb.active { border-color: var(--brand); }
.thumb .t-img { aspect-ratio: 1; width: 110px; background: #fbeede; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12px; }
.thumb .t-img img { width: 100%; height: 100%; object-fit: cover; }
.thumb .t-n { text-align: center; font-size: 12px; font-weight: 800; padding: 3px; }
.stage-img { width: 100%; aspect-ratio: 1; border-radius: 18px; object-fit: cover; background: #fbeede; box-shadow: var(--shadow); }
.stage-fail { width: 100%; aspect-ratio: 1; border-radius: 18px; background: #fdecea; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: #e0563b; font-weight: 800; box-shadow: var(--shadow); }

/* 封面预览 */
.cover-wrap { position: relative; max-width: 420px; margin: 0 auto; }
.cover-wrap img { width: 100%; border-radius: 18px; box-shadow: var(--shadow); display: block; }
.cover-overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px; text-align: center;
  background: linear-gradient(to top, rgba(0,0,0,.45), transparent); border-radius: 0 0 18px 18px; color: #fff; }
.cover-overlay .ct { font-size: 26px; font-weight: 900; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.cover-overlay .ca { font-size: 14px; margin-top: 6px; opacity: .95; }

/* 我的绘本 */
.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 680px) { .book-grid { grid-template-columns: repeat(2, 1fr); } }
.bookcard { background: #fff; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.bookcard .bc-img { aspect-ratio: 3/4; background: #fbeede; }
.bookcard .bc-img img { width: 100%; height: 100%; object-fit: cover; }
.bookcard .bc-b { padding: 12px; }
.bookcard .bc-b .bt { font-weight: 800; }
.bookcard .bc-b .bm { color: var(--muted); font-size: 12px; margin: 4px 0 10px; }

/* toast & modal */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%);
  background: #3b3030; color: #fff; padding: 13px 22px; border-radius: 999px; font-weight: 700;
  z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw;
}
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
.modal { background: #fff; border-radius: 22px; padding: 26px; max-width: 440px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h2 { margin-top: 0; }
