:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --user: #1c1917;
  --user-text: #fafaf9;
  --accent: #b45309;
  --card: #f5f5f4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917; --surface: #292524; --text: #f5f5f4; --muted: #a8a29e;
    --border: #44403c; --user: #f5f5f4; --user-text: #1c1917; --accent: #f59e0b; --card: #292524;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  display: flex; flex-direction: column;
}
.top { padding: 14px 16px 10px; text-align: center; border-bottom: 1px solid var(--border); }
.top h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .08em; }

#chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; max-width: 760px; width: 100%; margin: 0 auto; }
.msg { max-width: 100%; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-text); padding: 9px 14px; border-radius: 18px 18px 4px 18px; max-width: 85%; white-space: pre-wrap; }
.msg.bot { align-self: stretch; }
.msg.bot p { margin: 0 0 .6em; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg.bot ul, .msg.bot ol { margin: .2em 0 .6em; padding-left: 1.3em; }
.msg.bot table { border-collapse: collapse; font-size: 14px; }
.msg.bot th, .msg.bot td { border: 1px solid var(--border); padding: 4px 8px; }
.msg.error { color: #b91c1c; font-size: 14px; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.card .note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.imgs figure { margin: 0; cursor: zoom-in; }
.imgs img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: center 55%; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }
.imgs.single { grid-template-columns: 1fr; }
.imgs.single img { aspect-ratio: auto; object-fit: contain; max-height: 70vh; }
.imgs figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.price-wrap { overflow-x: auto; }
.price { border-collapse: collapse; font-size: 13px; width: 100%; min-width: 420px; }
.price th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--border); padding: 6px; white-space: nowrap; }
.price td { border-bottom: 1px solid var(--border); padding: 6px; white-space: nowrap; }
.price td.num { text-align: right; font-variant-numeric: tabular-nums; }
.price .strong { font-weight: 600; }

.contact h3 { margin: 0 0 6px; font-size: 16px; }
.contact .broker { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.contact .broker img.photo { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; flex: none; }
.contact .sub { color: var(--muted); font-size: 13px; }
.contact .intro { font-size: 14px; margin: 0 0 10px; }
.contact .qr-wrap { text-align: center; margin-bottom: 10px; }
.contact img.qr { width: 160px; height: auto; border-radius: 8px; background: #fff; padding: 6px; }
.contact form { display: grid; gap: 8px; }
.contact input, .contact textarea { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.contact button { font: inherit; padding: 9px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; cursor: pointer; }
.contact .ok { color: var(--accent); }


#lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .92); z-index: 10; display: flex; flex-direction: column; }
#lightbox[hidden] { display: none; }
#lightbox .lb-scroll { flex: 1; overflow: auto; display: flex; align-items: flex-start; justify-content: center; touch-action: pinch-zoom pan-x pan-y; }
#lightbox img { max-width: 100%; height: auto; }
#lightbox img.zoomed { max-width: none; width: 200%; }
#lightbox .close { position: absolute; top: 10px; right: 14px; font-size: 32px; color: #fff; background: none; border: 0; cursor: pointer; z-index: 1; }
#lightbox .lb-caption { color: #d6d3d1; font-size: 13px; text-align: center; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); margin: 0; }


/* --- */
/* ChatGPT 式首页：空对话时标题和输入框居中；第一个问题发出后输入框落到底部 */
#hero { display: none; }
body.empty .top { visibility: hidden; }
body.empty #chat { display: none; }
body.empty #hero { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; padding: 0 16px 20px; text-align: center; }
body.empty #hero h1 { margin: 0; font-size: 30px; font-weight: 600; letter-spacing: .1em; }
body.empty #hero p { margin: 8px 0 0; color: var(--muted); font-size: 17px; }
body.empty #composer { max-width: 680px; margin-bottom: 36vh; }
/* 正在输入：三个跳动圆点 */
.dots { display: inline-flex; gap: 5px; padding: 6px 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.typing::after { content: none; }

/* ChatGPT 式输入框：上面打字，下面一排右侧是麦克风和黑色圆按钮 */
#composer { max-width: 760px; width: 100%; margin: 0 auto; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); }
#composer .box { background: var(--surface); border: 1px solid var(--border); border-radius: 26px; padding: 12px 12px 8px 18px; box-shadow: 0 2px 16px rgba(0, 0, 0, .06); }
#input { display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; line-height: 1.5; max-height: 160px; padding: 2px 0 6px; }
#composer .row { display: flex; align-items: center; gap: 6px; }
#composer .grow { flex: 1; }
.icon { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.icon:hover { background: var(--card); color: var(--text); }
.icon:disabled { opacity: .4; cursor: not-allowed; }
.round { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--user); color: var(--user-text); display: grid; place-items: center; cursor: pointer; }
.round[hidden], .icon[hidden] { display: none; }
.round:disabled { opacity: .35; cursor: not-allowed; }
#mic .i-stop { display: none; }
#mic.recording { background: var(--user); color: var(--user-text); }
#mic.recording .i-mic { display: none; }
#mic.recording .i-stop { display: block; }
#mic.busy { opacity: .45; pointer-events: none; }
/* 听写中：左边取消、中间声波、右边停止和发送（ChatGPT 式） */
.icon.soft { background: var(--card); color: var(--text); }
#composer .grow { display: flex; align-items: center; min-width: 0; height: 40px; padding: 0 6px; }
#wave { width: 100%; height: 32px; display: block; }
#wave[hidden] { display: none; }
#mic.recording { background: var(--card); color: var(--text); }

/* 语音模式：光球悬浮在语音条上方，上下漂浮，随声音大幅缩放、发光；对话照常显示，不被挡住 */
#voice { display: flex; flex-direction: column; align-items: center; gap: 18px; --s: 1; --glow: rgba(140, 110, 255, .45); --lv: 0; }
#voice[hidden] { display: none; }
body.in-call #composer .box { display: none; }
#voice .v-ball { position: relative; width: 110px; height: 110px; margin-top: 40px; z-index: 2; animation: v-float 3.4s ease-in-out infinite; }
#voice .v-ball::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: -16px; height: 10px; border-radius: 50%;
                        background: radial-gradient(closest-side, rgba(30, 20, 70, .28), transparent); animation: v-shadow 3.4s ease-in-out infinite; }
#voice .v-sphere { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; transform: scale(var(--s));
                   background: radial-gradient(circle at 38% 30%, #2a2f5c 0%, #0d0e1f 62%, #05050c 100%);
                   transform-origin: 50% 85%; box-shadow: 0 0 calc(20px + 110px * var(--lv)) calc(2px + 26px * var(--lv)) var(--glow), 0 14px 30px rgba(20, 15, 60, .35); will-change: transform; }
#voice .v-sphere::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
                          background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, .28), transparent 34%); }
#voice .v-sphere { position: relative; }
@keyframes v-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes v-shadow { 0%, 100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.75); opacity: .55; } }
#orb { width: 100%; height: 100%; display: block; }
#voice .v-bar { align-self: stretch; display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 18px; border-radius: 26px;
                background: var(--surface); border: 1px solid var(--border); box-shadow: 0 2px 12px rgba(0, 0, 0, .06); }
#voice .v-status { flex: 1; font-size: 15px; color: var(--muted); }
#voice .v-bar button { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--card); color: var(--text); }
#voice .v-mute.off { background: var(--user); color: var(--user-text); }
#voice .v-end { background: #e5484d !important; color: #fff !important; }

/* 分享 */
.card { position: relative; }
.card.has-share { padding-top: 42px; }
.card .share { position: absolute; top: 8px; right: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--border);
               border-radius: 999px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); z-index: 1; }
#lightbox .lb-share { position: absolute; top: 14px; left: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 0; border-radius: 999px;
                      background: rgba(255, 255, 255, .16); color: #fff; font-size: 14px; cursor: pointer; z-index: 1; }
#lightbox .lb-share[hidden] { display: none; }
#toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); max-width: min(90vw, 420px);
         padding: 10px 16px; border-radius: 12px; background: rgba(28, 25, 23, .92); color: #fff; font-size: 14px; line-height: 1.5; text-align: center;
         opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }