/* AI传家书 —— 温暖 / 纸质 / 家庭相册风格 */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #3d3229;
  --ink-soft: #7a6a58;
  --brown: #7c4f2e;
  --brown-dark: #5f3b21;
  --gold: #c9a25e;
  --gold-soft: #efe3c8;
  --line: #e5dbc8;
  --green: #5d7a52;
  --red: #a6533f;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(95, 59, 33, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.boot { padding: 60px; text-align: center; color: var(--ink-soft); }

.container { max-width: 760px; margin: 0 auto; padding: 14px 14px 96px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, #fbf7ee, #f6f1e7);
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .brand { font-size: 1.15rem; font-weight: 700; color: var(--brown-dark); letter-spacing: 1px; }
.topbar .brand small { display: block; font-size: 0.7rem; color: var(--gold); font-weight: 400; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 0.8rem; color: var(--ink-soft); }
.top-logout { flex-shrink: 0; border: 0; border-radius: 999px; padding: 7px 11px; background: #f7e8e4; color: var(--red); font-family: inherit; font-size: 0.78rem; cursor: pointer; }
.back-btn { flex-shrink:0; border:1px solid var(--line); border-radius:999px; background:#fffdf8; color:var(--brown); cursor:pointer; padding:8px 11px; font:700 .8rem/1.1 inherit; box-shadow:0 2px 8px rgba(75,44,25,.05); }
.admin-preview-bar { position:sticky; top:62px; z-index:19; max-width:760px; margin:0 auto; padding:9px 12px; display:flex; align-items:center; justify-content:space-between; gap:10px; border:1px solid #d3a75f; border-width:0 1px 1px; background:#fff2d7; box-shadow:0 5px 18px rgba(79,50,27,.1); color:var(--brown-dark); }
.admin-preview-bar span { display:block; margin-top:2px; color:var(--ink-soft); font-size:.72rem; }
.admin-preview-bar button { flex-shrink:0; border:0; border-radius:999px; padding:9px 12px; background:var(--brown); color:#fff; font:700 .78rem inherit; cursor:pointer; }

/* 卡片 */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--brown-dark); margin-bottom: 10px; }

/* 按钮 —— 大、清晰 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 12px; cursor: pointer;
  font-size: 1rem; font-weight: 600; padding: 12px 20px;
  transition: transform 0.05s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--brown); color: #fff; }
.btn-gold { background: var(--gold); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--brown); color: var(--brown); }
.btn-ghost { background: #f1eadd; color: var(--brown-dark); }
.btn-danger { background: #f7e8e4; color: var(--red); }
.btn-big { width: 100%; padding: 18px; font-size: 1.2rem; border-radius: 16px; }
.btn-record { background: #b04a37; color: #fff; width: 100%; padding: 22px; font-size: 1.35rem; border-radius: 20px; box-shadow: 0 4px 14px rgba(176, 74, 55, 0.3); }
.btn-record.recording { background: #d9534f; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(217,83,79,.4);} 50% { box-shadow: 0 0 0 12px rgba(217,83,79,0);} }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.88rem; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 1rem;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font-family: inherit;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.field input[readonly], .field textarea[readonly] { background: #f7f3eb; color: var(--ink-soft); }
.check-row { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 0.86rem; margin: 0 0 16px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--brown); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #fff9eb, var(--bg) 65%); }
.login-card { width: min(100%, 420px); padding: 34px 26px; text-align: center; }
.login-card .field { text-align: left; }
.login-card h1 { color: var(--brown-dark); margin: 6px 0; }
.login-mark { font-size: 3rem; }
.form-error { color: var(--red); background: #faece7; border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: 0.86rem; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 8px; text-align: center;
}
.stat .num { font-size: 1.5rem; font-weight: 800; color: var(--brown); }
.stat .lbl { font-size: 0.75rem; color: var(--ink-soft); margin-top: 2px; }

/* 项目列表 */
.project-item { display: flex; gap: 12px; align-items: center; }
.avatar {
  width: 62px; height: 62px; border-radius: 50%; flex-shrink: 0;
  background: var(--gold-soft); color: var(--brown);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 700; overflow: hidden;
  border: 2px solid var(--gold-soft);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.project-item .info { flex: 1; min-width: 0; }
.project-item .name { font-size: 1.08rem; font-weight: 700; }
.project-item .meta { font-size: 0.78rem; color: var(--ink-soft); margin-top: 3px; line-height: 1.5; }

/* 进度条 */
.progress { height: 8px; background: #ede4d3; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--brown)); border-radius: 99px; }

/* 徽章 */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.72rem; font-weight: 600; }
.badge.not_started { background: #eee7da; color: var(--ink-soft); }
.badge.in_progress { background: #f5e6c8; color: #8a6d1f; }
.badge.pending_organize { background: #e8dfc5; color: #7a6210; }
.badge.pending_review { background: #f3d9c2; color: #9c5211; }
.badge.done { background: #dde8d5; color: var(--green); }
.badge.interviewing { background: #f5e6c8; color: #8a6d1f; }
.badge.ai_processing { background: #e8dfc5; color: #7a6210; }
.badge.reviewing { background: #f3d9c2; color: #9c5211; }
.badge.book_ready { background: #dde8d5; color: var(--green); }
.badge.printing { background: #e0d6ef; color: #5b4a86; }
.badge.pending { background: #f3d9c2; color: #9c5211; }
.badge.layout, .badge.to_print { background: #e8dfc5; color: #7a6210; }
.badge.shipped { background: #d5e3ee; color: #33597a; }
.badge.draft { background: #eee7da; color: var(--ink-soft); }
.badge.approved { background: #dde8d5; color: var(--green); }
.badge.changes_requested { background: #f7e8e4; color: var(--red); }

.consent-card { border-color: var(--gold); background: #fff9ec; }
.consent-card p { color: var(--ink-soft); line-height: 1.75; margin: 8px 0 14px; }
.privacy-actions, .review-actions { flex-wrap: wrap; }
.save-state { font-size: 0.76rem; color: var(--ink-soft); line-height: 1.5; }
.review-card { border-left: 4px solid var(--gold); }
.review-note { background: #f7f1e5; border-radius: 8px; padding: 10px; margin: 12px 0; line-height: 1.6; }
.version-list { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 6px; }
.version-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.version-item div { min-width: 0; }
.version-item b, .version-item span { display: block; font-size: 0.76rem; }
.version-item span { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 440px; }

/* 主题卡片（两列） */
.topic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topic-card {
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 16px 12px; text-align: center; cursor: pointer;
}
.topic-card:active { transform: scale(0.97); }
.topic-card .tname { font-weight: 700; font-size: 0.95rem; margin-bottom: 8px; }
.topic-card.done { border-color: var(--green); background: #f4f8f0; }
.topic-card.current { border-color: var(--gold); }

.onboarding-preview { padding-bottom: 8px; }
.onboarding-preview .topic-card { min-height: 104px; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; }
.onboarding-preview .topic-card .tname { font-size:1.02rem; color:var(--brown-dark); }
.onboarding-modal { position:fixed; inset:0; z-index:2000; display:grid; place-items:center; padding:20px; background:rgba(42,28,18,.48); backdrop-filter:blur(2px); }
.onboarding-dialog { position:relative; width:min(100%,520px); margin:0; padding:38px 26px 28px; text-align:center; animation:onboarding-in .18s ease-out; }
.onboarding-dialog .card-title { font-size:1.25rem; margin:8px 0 12px; }
.onboarding-dialog .hint { font-size:.96rem; line-height:1.8; margin-bottom:22px; }
.onboarding-icon { font-size:3.5rem; }
.onboarding-close { position:absolute; top:10px; right:12px; width:36px; height:36px; border:0; border-radius:50%; background:transparent; color:var(--muted); font-size:1.8rem; line-height:1; cursor:pointer; }
@keyframes onboarding-in { from { opacity:0; transform:translateY(12px) scale(.98); } to { opacity:1; transform:none; } }

/* AI 问题区 */
.ai-box {
  background: linear-gradient(160deg, #fbf5e6, #f7eeda);
  border: 1.5px solid var(--gold-soft); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.ai-box .ai-label { font-size: 0.78rem; color: var(--gold); font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.ai-question { font-size: 1.18rem; font-weight: 700; color: var(--brown-dark); line-height: 1.6; min-height: 56px; }
.question-count { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 0.78rem; }
.question-count input { width: 58px; padding: 7px 5px; border: 1px solid var(--line); border-radius: 8px; text-align: center; color: var(--ink); background: #fff; }
.followup-label { margin-bottom: 4px; }
.followup-option { display: block; width: 100%; border: 0; border-bottom: 1px dashed var(--gold-soft); background: transparent; color: var(--brown-dark); padding: 8px 4px; text-align: left; font: inherit; font-size: .88rem; line-height: 1.45; cursor: pointer; }
.followup-option:active { background: rgba(177,132,54,.12); }
.question-actions { flex-wrap: wrap; }
.question-actions .btn { flex: 1; min-width: 0; }
.profile-actions { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.topic-more-open { display: none; }
.topic-secondary-head { display: none; }

/* 录音列表 */
.audio-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.audio-item:last-child { border-bottom: none; }
.audio-item audio { flex: 1; height: 36px; min-width: 0; }
.audio-main { flex: 1; min-width: 0; }
.audio-main audio { width: 100%; }
.audio-transcript { margin-top: 5px; color: var(--ink-soft); font-size: .78rem; line-height: 1.55; white-space: pre-wrap; }
.audio-transcript.done { color: var(--brown-dark); }
.audio-transcript.failed { color: var(--red); }

/* 照片网格 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-cell { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #efe8da; }
.photo-cell img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-cell .cap { font-size: 0.68rem; padding: 4px 6px; color: var(--ink-soft); background: var(--paper); }

/* 步骤进度 */
.steps { padding: 8px 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 0.95rem; color: var(--ink-soft); }
.step.active { color: var(--brown); font-weight: 700; }
.step.finished { color: var(--green); }
.step .dot { width: 12px; height: 12px; border-radius: 50%; background: #ddd; flex-shrink: 0; }
.step.active .dot { background: var(--gold); animation: pulse 1.2s infinite; }
.step.finished .dot { background: var(--green); }

/* Tab */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.tab { padding: 8px 14px; border-radius: 99px; font-size: 0.85rem; background: #eee6d6; color: var(--ink-soft); border: none; cursor: pointer; white-space: nowrap; }
.tab.on { background: var(--brown); color: #fff; }

/* 时间线 */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--gold-soft); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item::before { content: ''; position: absolute; left: -22px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--gold); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--gold-soft); }
.tl-item .year { font-weight: 800; color: var(--brown); }
.tl-item .age { font-size: 0.78rem; color: var(--gold); margin-left: 8px; }
.tl-item .ttl { font-weight: 700; margin-top: 2px; }
.tl-item .desc { font-size: 0.85rem; color: var(--ink-soft); margin-top: 2px; line-height: 1.6; }
.tl-item .src { font-size: 0.72rem; color: var(--gold); margin-top: 3px; }

/* 编辑器 */
.editor-layout { display: flex; gap: 12px; }
.chapter-list { width: 200px; flex-shrink: 0; }
.chapter-list .ch { padding: 10px 12px; border-radius: 10px; font-size: 0.85rem; cursor: pointer; margin-bottom: 6px; background: #f1eadd; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-list .ch.on { background: var(--brown); color: #fff; }
@media (max-width: 640px) {
  .editor-layout { flex-direction: column; }
  .chapter-list { width: 100%; display: flex; overflow-x: auto; gap: 6px; }
  .chapter-list .ch { white-space: nowrap; margin-bottom: 0; }
}

/* 书页预览（打印） */
.book-page { position: relative; background: #fff; max-width: 680px; margin: 0 auto; padding: 48px 40px; box-shadow: var(--shadow); overflow: hidden; }
.sample-watermark { position: absolute; right: -38px; top: 28px; transform: rotate(35deg); color: rgba(166,83,63,.34); border: 2px solid rgba(166,83,63,.25); padding: 6px 42px; font-weight: 800; letter-spacing: 2px; pointer-events: none; }
.book-page h1 { text-align: center; font-size: 2rem; color: var(--brown-dark); margin: 40px 0 8px; }
.book-page .subtitle { text-align: center; color: var(--gold); margin-bottom: 60px; }
.book-page h2 { font-size: 1.4rem; color: var(--brown-dark); margin: 36px 0 16px; border-bottom: 1px solid var(--gold-soft); padding-bottom: 8px; }
.book-page p { line-height: 2; margin-bottom: 14px; text-indent: 2em; }
.book-page figure { text-align: center; margin: 20px 0; }
.book-page figure img { max-width: 70%; border: 6px solid #fff; box-shadow: var(--shadow); }
.book-page figcaption { font-size: 0.8rem; color: var(--ink-soft); margin-top: 6px; }
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .book-page { box-shadow: none; max-width: 100%; padding: 0; }
  .sample-watermark { position: fixed; z-index: 99; top: 46%; left: 17%; right: auto; transform: rotate(-30deg); font-size: 28pt; color: rgba(166,83,63,.16); border: 3px solid rgba(166,83,63,.12); }
  .book-page h2 { page-break-before: always; }
  .book-page h2:first-of-type { page-break-before: avoid; }
}

/* 表格 */
table.admin { width: 100%; border-collapse: collapse; font-size: 0.85rem; background: var(--paper); }
table.admin th, table.admin td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.admin th { color: var(--brown); font-size: 0.78rem; }
.table-wrap { overflow-x: auto; }

/* 底部导航 */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--paper); border-top: 1px solid var(--line);
  display: flex; max-width: 760px; margin: 0 auto;
}
.bottom-nav a, .bottom-nav button {
  flex: 1; text-align: center; padding: 10px 0 12px; text-decoration: none;
  color: var(--ink-soft); font-size: 0.72rem; border: 0; background: transparent; font-family: inherit;
}
.bottom-nav a .ico, .bottom-nav button .ico { font-size: 1.3rem; display: block; margin-bottom: 2px; }
.bottom-nav a.on { color: var(--brown); font-weight: 700; }

/* 提示 */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 99;
  background: var(--brown-dark); color: #fff; padding: 10px 22px; border-radius: 99px;
  font-size: 0.9rem; box-shadow: var(--shadow); animation: fadein 0.2s;
}
@keyframes fadein { from { opacity: 0; top: 8px; } to { opacity: 1; top: 20px; } }
.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; font-size: 0.9rem; }
.hint { font-size: 0.8rem; color: var(--ink-soft); line-height: 1.6; }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
pre.text-block { white-space: pre-wrap; font-family: inherit; font-size: 0.92rem; line-height: 1.9; background: #fbf8f0; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }

@media (max-width: 520px) {
  .topbar { padding: 10px 12px; gap: 7px; }
  .topbar .brand { font-size: 1rem; min-width: 0; }
  .topbar .user { display: none; }
  .topbar a { white-space: nowrap; }
  .admin-preview-bar { top:58px; }
  .admin-preview-bar span { display:none; }
  .top-logout { padding: 7px 10px; }
  .question-toolbar { align-items: flex-start; flex-direction: column; }
  .question-count { width: 100%; justify-content: flex-end; }
  .profile-actions { grid-template-columns: 1fr; }
  .topic-focus {
    height: calc(100vh - 66px); height: calc(100dvh - 66px);
    overflow: hidden; padding: 8px 10px 76px; display: flex; flex-direction: column; gap: 8px;
  }
  .topic-focus > .card, .topic-focus > .ai-box { margin: 0; }
  .topic-focus .topic-summary { padding: 10px 12px; flex: 0 0 auto; }
  .topic-focus .topic-summary .card-title { font-size: .98rem; }
  .topic-focus .topic-summary .hint { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topic-focus .interview-assistant { flex: 1 1 auto; min-height: 190px; padding: 11px 12px; overflow: hidden; display: flex; flex-direction: column; }
  .topic-focus .question-toolbar { flex-direction: row; align-items: center; }
  .topic-focus .question-count { width: auto; justify-content: flex-end; }
  .topic-focus .question-count label { display: none; }
  .topic-focus .question-count input { width: 45px; padding: 5px 3px; }
  .topic-focus .question-count .btn { padding: 7px 9px; }
  .topic-focus #q-progress { margin-top: 4px; font-size: .72rem; }
  .topic-focus .ai-question { flex: 1 1 auto; min-height: 58px; max-height: none; overflow-y: auto; font-size: 1.08rem; line-height: 1.45; padding-top: 5px; }
  .topic-focus .interview-assistant > .row.mt { margin-top: 5px; }
  .topic-focus .interview-assistant .btn { min-height: 42px; padding: 9px 10px; }
  .topic-focus .interview-assistant .question-actions .btn { padding: 8px 6px; font-size: .86rem; }
  .topic-focus #follow-list { max-height: 82px; overflow-y: auto; margin-top: 4px; font-size: .78rem; }
  .topic-focus .followup-option { padding: 7px 3px; font-size: .8rem; }
  .topic-focus .record-card { flex: 0 0 auto; padding: 10px 12px; }
  .topic-focus .btn-record { padding: 13px; font-size: 1.12rem; border-radius: 14px; }
  .topic-focus .record-card > .row.mt { margin-top: 6px; }
  .topic-focus .record-card label.btn { padding: 10px; }
  .topic-focus #upload-state { max-height: 34px; overflow-y: auto; margin-top: 5px; font-size: .72rem; }
  .topic-more-open { display: inline-flex; width: 100%; flex: 0 0 auto; min-height: 40px; padding: 8px 10px; font-size: .86rem; }
  .topic-secondary {
    position: fixed; inset: 0; z-index: 60; background: var(--bg); padding: 10px; overflow-y: auto;
    transform: translateY(105%); transition: transform .2s ease; -webkit-overflow-scrolling: touch;
  }
  .topic-secondary.open { transform: translateY(0); }
  .topic-secondary-head { position: sticky; top: -10px; z-index: 2; display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 10px 2px 12px; color: var(--brown-dark); }
  .privacy-actions .btn, .review-actions .btn { width: 100%; }
  .book-page { padding: 34px 20px; }
}
