:root {
  color-scheme: light;
  --paper: #f8f4ec;
  --paper-deep: #eee5d7;
  --surface: #fffdf8;
  --surface-soft: #f3ecdf;
  --ink: #252b29;
  --ink-soft: #59605c;
  --ink-faint: #868b87;
  --line: #ded5c7;
  --brand: #a54a37;
  --brand-deep: #7f3428;
  --brand-soft: #f1dfd8;
  --pine: #4d7464;
  --pine-soft: #dfeae4;
  --amber: #a96f26;
  --amber-soft: #f5e8d1;
  --shadow: 0 24px 70px rgba(63, 48, 32, .17);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 11px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #e9dfd0; }

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 18%, rgba(255,255,255,.8), transparent 30%),
    linear-gradient(135deg, #e4d6c2 0%, #f1e9dc 48%, #ded1be 100%);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(165, 74, 55, .32);
  outline-offset: 2px;
}

.ambient {
  position: fixed;
  border-radius: 50%;
  filter: blur(4px);
  pointer-events: none;
  opacity: .5;
}
.ambient-one { width: 280px; height: 280px; background: rgba(165,74,55,.13); left: -80px; top: 18%; }
.ambient-two { width: 360px; height: 360px; background: rgba(77,116,100,.13); right: -120px; bottom: 8%; }

.prototype-note {
  position: fixed;
  left: 24px;
  top: 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #514b43;
  font-size: 13px;
  letter-spacing: .02em;
  z-index: 3;
}
.prototype-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 5px rgba(165,74,55,.1); }

.device-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 64px 24px 32px;
}

.phone-frame {
  position: relative;
  width: min(100%, 430px);
  height: min(850px, calc(100vh - 96px));
  min-height: 680px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid rgba(83, 68, 49, .13);
  border-radius: 34px;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.mini-header {
  min-height: 62px;
  padding: 13px 16px 9px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  background: rgba(248,244,236,.95);
  border-bottom: 1px solid rgba(222,213,199,.7);
  z-index: 4;
}

.mini-title { display: flex; align-items: center; justify-content: center; gap: 9px; font-weight: 600; letter-spacing: .08em; }
.brand-mark {
  width: 28px; height: 28px; display: grid; place-items: center;
  color: #fff9f1; background: var(--brand); border-radius: 9px 9px 9px 3px;
  font-family: STKaiti, KaiTi, serif; font-weight: 700; letter-spacing: 0;
}

.icon-button, .mini-menu {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.icon-button:hover, .mini-menu:hover { background: var(--surface-soft); }
.icon-button svg { width: 23px; height: 23px; }
.mini-menu { gap: 3px; grid-auto-flow: column; align-content: center; justify-content: center; }
.mini-menu span { width: 4px; height: 4px; background: currentColor; border-radius: 50%; }
.is-hidden { display: none !important; }
.back-button.is-hidden { display: grid !important; visibility: hidden; pointer-events: none; }

.progress-wrap { padding: 9px 20px 8px; background: rgba(248,244,236,.95); z-index: 3; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 6px; color: var(--ink-faint); font-size: 12px; }
.progress-track { height: 4px; background: #e4dccf; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), #c5785e); transition: width .45s ease; }

.app-main {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px calc(24px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: #d8cdbd transparent;
}
.app-main::-webkit-scrollbar { width: 5px; }
.app-main::-webkit-scrollbar-thumb { background: #d8cdbd; border-radius: 10px; }

.screen { min-height: 100%; display: flex; flex-direction: column; animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.eyebrow { margin: 0 0 9px; color: var(--brand); font-size: 13px; font-weight: 700; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-family: STKaiti, KaiTi, serif; font-size: 34px; line-height: 1.22; font-weight: 700; letter-spacing: .03em; }
h2 { margin-bottom: 10px; font-family: STKaiti, KaiTi, serif; font-size: 27px; line-height: 1.3; font-weight: 700; }
h3 { margin-bottom: 7px; font-size: 17px; line-height: 1.45; font-weight: 650; }
p { margin-bottom: 14px; color: var(--ink-soft); font-size: 16px; line-height: 1.75; }
.lead { font-size: 18px; line-height: 1.7; color: var(--ink); }
.small { font-size: 13px; line-height: 1.6; color: var(--ink-faint); }
.spacer { flex: 1; min-height: 18px; }

.hero-seal {
  width: 78px; height: 78px; display: grid; place-items: center; margin: 12px 0 26px;
  color: var(--brand); border: 1px solid rgba(165,74,55,.25); border-radius: 25px 25px 25px 8px;
  background: linear-gradient(145deg, #fff9ef, var(--brand-soft)); box-shadow: 0 12px 24px rgba(127,52,40,.1);
  font-family: STKaiti, KaiTi, serif; font-size: 38px; font-weight: 700;
}

.privacy-strip {
  display: flex; gap: 10px; align-items: flex-start; margin: 10px 0 22px; padding: 13px 14px;
  color: var(--pine); background: var(--pine-soft); border-radius: var(--radius-md); font-size: 14px; line-height: 1.55;
}
.privacy-strip svg { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 1px; }

.choice-stack { display: grid; gap: 12px; }
.choice-card {
  width: 100%; min-height: 78px; padding: 15px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  display: grid; grid-template-columns: 44px 1fr 22px; gap: 13px; align-items: center; text-align: left;
  background: var(--surface); color: var(--ink); cursor: pointer; transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.choice-card:hover { transform: translateY(-1px); border-color: rgba(165,74,55,.48); box-shadow: 0 9px 22px rgba(74,54,35,.07); }
.choice-card.is-selected { border-color: var(--brand); background: linear-gradient(135deg, #fffdf8, #f7e8e1); box-shadow: inset 0 0 0 1px var(--brand); }
.choice-card.is-disabled { opacity: .56; cursor: not-allowed; background: rgba(247,243,234,.72); }
.choice-card.is-disabled:hover { transform: none; border-color: var(--line); box-shadow: none; }
.choice-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); border-radius: 14px; }
.choice-icon svg { width: 23px; height: 23px; }
.choice-copy strong { display: block; margin-bottom: 3px; font-size: 17px; font-weight: 650; }
.choice-copy span { display: block; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.choice-chevron { width: 20px; height: 20px; color: var(--ink-faint); }

.button-row { display: flex; gap: 10px; margin-top: 20px; }
.primary-button, .secondary-button, .ghost-button, .voice-button {
  min-height: 50px; border-radius: 15px; border: 0; padding: 0 18px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; font-weight: 650;
  transition: transform .15s ease, filter .15s ease, opacity .15s ease;
}
.primary-button { flex: 1; color: #fffaf3; background: var(--brand); box-shadow: 0 9px 18px rgba(165,74,55,.2); }
.primary-button:hover { filter: brightness(.97); transform: translateY(-1px); }
.primary-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; transform: none; }
.secondary-button { color: var(--ink); background: var(--surface); border: 1px solid var(--line); }
.ghost-button { min-height: 44px; padding: 0 10px; color: var(--brand); background: transparent; }
.primary-button svg, .secondary-button svg, .ghost-button svg { width: 19px; height: 19px; }
.full { width: 100%; }

.prompt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.prompt-card {
  min-height: 112px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  text-align: left; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; justify-content: space-between;
}
.prompt-card:hover { border-color: rgba(165,74,55,.55); }
.prompt-card.is-supported { border-color: var(--brand); background: linear-gradient(145deg, #fffdf8, #f7e8e1); box-shadow: inset 0 0 0 1px rgba(165,74,55,.35); }
.prompt-card.is-disabled { opacity: .5; cursor: not-allowed; background: rgba(247,243,234,.72); }
.prompt-card.is-disabled:hover { border-color: var(--line); }
.prompt-card-top { display: flex !important; align-items: center; justify-content: space-between; width: 100%; }
.prompt-symbol { color: var(--brand); font-family: STKaiti, KaiTi, serif; font-size: 28px; }
.prompt-card strong { font-size: 16px; }
.prompt-card span { color: var(--ink-faint); font-size: 12px; line-height: 1.45; }
.path-notice {
  display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 16px; padding: 12px 14px;
  color: var(--brand-deep); background: var(--brand-soft); border: 1px solid rgba(165,74,55,.16); border-radius: var(--radius-md);
  font-size: 14px; line-height: 1.55;
}
.path-notice svg { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 1px; }
.path-badge, .inline-badge {
  display: inline-flex !important; align-items: center; width: fit-content; padding: 3px 7px; border-radius: 999px;
  color: #fffaf3 !important; background: var(--brand); font-family: system-ui, sans-serif; font-size: 10px !important; font-weight: 650; line-height: 1.2 !important;
}
.inline-badge { margin-left: 5px; vertical-align: 2px; }
.path-badge.is-muted, .inline-badge.is-muted { color: var(--ink-faint) !important; background: #e8e2d7; }

.chat-stream { display: flex; flex-direction: column; gap: 14px; padding-bottom: 14px; }
.message { max-width: 89%; padding: 13px 15px; border-radius: 18px; font-size: 16px; line-height: 1.7; animation: enter .25s ease both; }
.message.ai { align-self: flex-start; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-top-left-radius: 6px; }
.message.user { align-self: flex-end; color: #fffaf3; background: var(--brand); border-top-right-radius: 6px; }
.message-label { margin-bottom: 5px; color: var(--ink-faint); font-size: 12px; }
.message.user .message-label { color: rgba(255,250,243,.72); }

.voice-dock { margin-top: auto; padding-top: 18px; }
.voice-button { width: 100%; min-height: 58px; color: #fffaf3; background: var(--brand); box-shadow: 0 10px 20px rgba(165,74,55,.2); }
.voice-button svg { width: 22px; height: 22px; }
.voice-button.is-recording { background: var(--brand-deep); }
.wave { display: none; align-items: center; gap: 3px; height: 22px; }
.is-recording .wave { display: flex; }
.is-recording .mic-label, .is-recording > svg { display: none; }
.wave i { width: 3px; height: 8px; background: currentColor; border-radius: 4px; animation: wave .7s ease-in-out infinite alternate; }
.wave i:nth-child(2) { animation-delay: -.3s; height: 16px; }
.wave i:nth-child(3) { animation-delay: -.1s; height: 12px; }
.wave i:nth-child(4) { animation-delay: -.45s; height: 19px; }
.wave i:nth-child(5) { animation-delay: -.2s; height: 10px; }
@keyframes wave { to { transform: scaleY(.45); } }

.status-card, .paper-card, .source-card, .conflict-card, .check-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
.status-card { padding: 18px; margin: 8px 0 14px; }
.status-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.status-count { color: var(--pine); font-size: 13px; font-weight: 700; }
.status-list { display: grid; gap: 10px; }
.status-item { display: grid; grid-template-columns: 24px 1fr; gap: 9px; align-items: start; color: var(--ink-soft); font-size: 15px; line-height: 1.55; }
.status-check { width: 21px; height: 21px; display: grid; place-items: center; color: var(--pine); background: var(--pine-soft); border-radius: 50%; }
.status-check svg { width: 14px; height: 14px; }
.next-question { padding: 17px; margin-top: 12px; background: var(--amber-soft); border-radius: var(--radius-lg); }
.next-question .small { color: var(--amber); font-weight: 700; }
.next-question p { margin: 5px 0 0; color: var(--ink); }

.source-link { width: 100%; padding: 12px 2px; border: 0; color: var(--brand); background: transparent; display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.source-link span { display: inline-flex; align-items: center; gap: 8px; }
.source-link svg { width: 19px; height: 19px; }

.photo-frame { margin: 12px 0 16px; padding: 9px 9px 34px; background: #eee4d0; box-shadow: 0 12px 26px rgba(68,52,35,.13); transform: rotate(-1deg); }
.photo-frame img { display: block; width: 100%; aspect-ratio: 1.45; object-fit: cover; filter: sepia(.4) contrast(.9); background: #cbbb9c; }
.photo-note { margin: 7px 4px -22px; color: #655b4c; font-family: STKaiti, KaiTi, serif; text-align: right; font-size: 15px; }
.upload-actions { display: grid; gap: 10px; }
.file-input { position: absolute; opacity: 0; pointer-events: none; }

.analysis-row { display: flex; align-items: center; gap: 10px; padding: 13px 14px; margin: 12px 0; color: var(--pine); background: var(--pine-soft); border-radius: var(--radius-md); font-size: 14px; }
.spinner { width: 17px; height: 17px; border: 2px solid rgba(77,116,100,.25); border-top-color: var(--pine); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.conflict-card { padding: 16px; margin: 12px 0; }
.conflict-head { display: flex; align-items: center; gap: 9px; margin-bottom: 13px; color: var(--amber); font-weight: 700; }
.source-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.source-card { padding: 13px; border-radius: var(--radius-md); background: #fbf7ef; }
.source-card .source-type { margin-bottom: 7px; color: var(--ink-faint); font-size: 12px; }
.source-card strong { font-size: 17px; }
.resolution-stack { display: grid; gap: 9px; margin-top: 14px; }
.resolution-button {
  width: 100%; min-height: 53px; padding: 11px 13px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; line-height: 1.45;
}
.resolution-button:hover, .resolution-button.is-selected { border-color: var(--brand); background: var(--brand-soft); }
.resolution-button strong { display: block; font-size: 15px; }
.resolution-button span { color: var(--ink-soft); font-size: 13px; }

.ready-list { margin: 10px 0 18px; padding: 0; list-style: none; display: grid; gap: 11px; }
.ready-list li { display: flex; align-items: flex-start; gap: 10px; color: var(--ink-soft); line-height: 1.55; }
.ready-list svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--pine); margin-top: 2px; }

.paper-card { padding: 22px 20px; box-shadow: 0 10px 30px rgba(67,51,33,.07); }
.story-kicker { color: var(--brand); font-size: 12px; letter-spacing: .13em; font-weight: 700; }
.story-title { margin: 8px 0 6px; font-family: STSong, SimSun, serif; font-size: 27px; line-height: 1.35; }
.story-meta { margin-bottom: 19px; color: var(--ink-faint); font-size: 13px; }
.story-body p { color: #353936; font-family: STSong, SimSun, serif; font-size: 17px; line-height: 1.95; text-align: justify; }
.editable-sentence { padding: 2px 4px; background: linear-gradient(transparent 58%, #f0d9b5 58%); cursor: pointer; }
.review-prompt { margin: 14px 0; padding: 15px; background: var(--amber-soft); border-radius: var(--radius-md); }
.review-prompt p { margin-bottom: 10px; color: var(--ink); font-size: 15px; line-height: 1.55; }
.compact-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.compact-actions button { min-height: 43px; padding: 0 13px; border: 1px solid rgba(169,111,38,.3); border-radius: 12px; background: #fffaf0; color: var(--ink); cursor: pointer; }

.tone-options { display: grid; gap: 9px; margin-top: 11px; }
.tone-option { padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); text-align: left; cursor: pointer; color: var(--ink); line-height: 1.55; }
.tone-option:hover { border-color: var(--brand); }
.tone-option.is-recommended::after { content: "更接近原话"; float: right; color: var(--pine); font-size: 12px; }

.check-stack { display: grid; gap: 10px; margin: 12px 0; }
.check-card { display: grid; grid-template-columns: 27px 1fr; gap: 10px; align-items: start; padding: 14px; cursor: pointer; }
.check-card input { width: 21px; height: 21px; margin: 1px 0 0; accent-color: var(--brand); }
.check-card strong { display: block; margin-bottom: 3px; }
.check-card span { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

.completion-seal { width: 82px; height: 82px; margin: 8px auto 18px; display: grid; place-items: center; color: var(--pine); background: var(--pine-soft); border-radius: 50%; }
.completion-seal svg { width: 42px; height: 42px; }
.center { text-align: center; }
.complete-card { margin-top: 14px; transform: none; }
.complete-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.complete-actions .primary-button { grid-column: 1 / -1; }

.sheet-backdrop { position: absolute; inset: 0; background: rgba(31,30,27,.35); z-index: 8; }
.bottom-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 9; max-height: 78%; overflow-y: auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 25px 25px 0 0;
  box-shadow: 0 -15px 50px rgba(41,34,27,.16); animation: sheetUp .24s ease both;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 18px; background: var(--line); border-radius: 10px; }
.sheet-title { margin-bottom: 6px; font-family: STKaiti, KaiTi, serif; font-size: 24px; }
.sheet-source { padding: 13px 0; border-bottom: 1px solid var(--line); }
.sheet-source:last-child { border-bottom: 0; }
.sheet-source strong { display: block; margin-bottom: 4px; }
.sheet-close { margin-top: 15px; }

.toast {
  position: absolute; left: 50%; bottom: 28px; z-index: 12; transform: translateX(-50%);
  max-width: calc(100% - 42px); padding: 11px 16px; color: #fff; background: rgba(37,43,41,.92); border-radius: 12px;
  font-size: 14px; text-align: center; box-shadow: 0 8px 20px rgba(0,0,0,.18); animation: toastIn .2s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.menu-panel { display: grid; gap: 4px; }
.menu-item { width: 100%; min-height: 48px; border: 0; border-radius: 12px; padding: 0 12px; background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.menu-item:hover { background: var(--surface-soft); }
.danger { color: #9c382e; }

@media (max-width: 560px) {
  html, body { background: var(--paper); }
  .ambient, .prototype-note { display: none; }
  .device-stage { min-height: 100dvh; display: block; padding: 0; }
  .phone-frame { width: 100%; height: 100dvh; min-height: 620px; border: 0; border-radius: 0; box-shadow: none; }
  .mini-header { padding-top: max(13px, env(safe-area-inset-top)); }
}

@media (max-width: 360px) {
  .app-main { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 30px; }
  .prompt-grid { grid-template-columns: 1fr; }
  .source-compare { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: #fff; }
  .prototype-note, .mini-header, .progress-wrap, .button-row, .complete-actions, .ambient { display: none !important; }
  .device-stage { padding: 0; display: block; }
  .phone-frame { width: auto; height: auto; min-height: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  .app-main { overflow: visible; padding: 0; }
  .paper-card { border: 0; box-shadow: none; }
}
