:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #282523;
  --muted: #88817b;
  --line: #e7e1dc;
  --paper: #fbfaf8;
  --sand: #f2ede7;
  --sage: #74957f;
  --sage-dark: #537260;
  --peach: #e8a27f;
  --red: #d45a4b;
  --shadow: 0 24px 80px rgba(66, 52, 44, .13);
}

* { box-sizing: border-box; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
body { margin: 0; min-height: 100vh; overflow: hidden; color: var(--ink); background: linear-gradient(135deg, #eee7df, #f8f5f1 52%, #e7efe9); }
.hidden { display: none !important; }

.app { width: min(1180px, calc(100vw - 48px)); height: min(820px, calc(100vh - 48px)); margin: 24px auto; display: grid; grid-template-columns: 330px 1fr; overflow: hidden; border: 1px solid rgba(72, 61, 52, .1); border-radius: 28px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.contact-pane { display: flex; min-width: 0; flex-direction: column; background: #f7f3ef; border-right: 1px solid var(--line); }
.brand-row { min-height: 92px; display: flex; align-items: center; gap: 13px; padding: 18px 20px; }
.brand-row > div:nth-child(2) { display: grid; gap: 3px; }
.brand-row strong { font-size: 21px; letter-spacing: .02em; }
.brand-row span { color: var(--muted); font-size: 12px; }
.brand-mark, .avatar { flex: 0 0 auto; display: grid; place-items: center; color: white; background: linear-gradient(145deg, #9e806e, #5d7565); box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.brand-mark { width: 44px; height: 44px; border-radius: 15px; font-weight: 800; }
.icon-button { border: 0; width: 42px; height: 42px; border-radius: 14px; color: #59534e; background: transparent; font-size: 21px; display: grid; place-items: center; transition: .18s ease; }
.icon-button:hover, .icon-button:focus-visible { background: #ebe5df; outline: none; }
.brand-row .icon-button { margin-left: auto; background: #ebe5df; }
.search-box { height: 42px; display: flex; align-items: center; gap: 8px; margin: 0 18px 14px; padding: 0 13px; border: 1px solid transparent; border-radius: 13px; color: var(--muted); background: #ebe6e1; }
.search-box:focus-within { border-color: #a8b9ae; background: white; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.contact-list { flex: 1; min-height: 0; overflow: auto; padding: 0 10px; }
.contact { width: 100%; display: grid; grid-template-columns: 54px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 13px 11px; border: 0; border-radius: 18px; text-align: left; color: inherit; background: transparent; }
.contact.active, .contact:hover { background: white; box-shadow: 0 8px 26px rgba(57, 48, 41, .07); }
.avatar { width: 44px; height: 44px; border-radius: 16px; font-weight: 750; }
.contact-copy { display: grid; min-width: 0; gap: 6px; }
.contact-copy strong { font-size: 15px; }
.contact-copy small { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.contact time { align-self: start; padding-top: 3px; color: #aaa39d; font-size: 11px; }
.empty-search { padding: 50px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.connection-note { margin: 14px 18px 18px; color: var(--muted); font-size: 11px; }
.connection-note span { display: inline-block; width: 7px; height: 7px; margin-right: 4px; border-radius: 50%; background: #d79a72; }

.chat-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: 80px auto 1fr auto auto auto auto; background: var(--paper); }
.chat-header { min-width: 0; display: flex; align-items: center; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(251,250,248,.94); backdrop-filter: blur(16px); }
.profile-button { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 0; border: 0; color: inherit; text-align: left; background: transparent; }
.profile-button > span:last-child { min-width: 0; display: grid; gap: 4px; }
.profile-button strong { font-size: 16px; }
.profile-button small { color: var(--muted); font-size: 12px; }
.online-dot { display: inline-block; width: 7px; height: 7px; margin-right: 2px; border-radius: 50%; background: #70a57e; }
.header-actions { display: flex; gap: 4px; margin-left: auto; }
.back-button { display: none; margin-right: 3px; }
.demo-ribbon { padding: 7px 18px; color: #7b6d63; background: #f3ebe3; text-align: center; font-size: 11px; }
.messages { min-height: 0; overflow-y: auto; padding: 24px clamp(18px, 4vw, 54px) 18px; scroll-behavior: smooth; background: radial-gradient(circle at 90% 0, rgba(116,149,127,.08), transparent 28%), linear-gradient(#fbfaf8, #f8f5f1); }
.message-row { display: flex; align-items: flex-end; gap: 9px; margin: 14px 0; }
.message-row.user { justify-content: flex-end; }
.message-avatar { width: 34px; height: 34px; border-radius: 12px; font-size: 12px; }
.message-row.user .message-avatar { background: linear-gradient(145deg, #c29479, #8c6450); }
.bubble-stack { max-width: min(68%, 560px); display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.message-row.user .bubble-stack { align-items: flex-end; }
.bubble-stack > time { padding: 0 3px; color: #aaa39d; font-size: 10px; }
.message-bubble { border-radius: 6px 18px 18px 18px; color: #34302d; background: white; box-shadow: 0 7px 22px rgba(62,49,41,.06); }
.message-row.user .message-bubble { border-radius: 18px 6px 18px 18px; color: white; background: var(--sage-dark); }
.text-bubble { padding: 11px 15px; line-height: 1.65; white-space: pre-wrap; }
.preset-label { padding: 0 3px; color: #99908a; font-size: 10px; }
.voice-bubble { min-width: 210px; padding: 10px; }
.voice-play { width: 100%; display: flex; align-items: center; gap: 9px; border: 0; color: inherit; background: transparent; }
.voice-play .play-symbol { width: 24px; }
.voice-play strong { margin-left: auto; font-size: 12px; }
.wave { height: 22px; display: flex; align-items: center; gap: 3px; }
.wave i { width: 3px; height: 8px; border-radius: 4px; background: currentColor; opacity: .55; }
.wave i:nth-child(2), .wave i:nth-child(4) { height: 15px; }
.wave i:nth-child(3) { height: 20px; }
.voice-play.playing .wave i { animation: wave .7s ease-in-out infinite alternate; }
.voice-play.playing .wave i:nth-child(2) { animation-delay: .15s; }
.voice-play.playing .wave i:nth-child(3) { animation-delay: .3s; }
.voice-bubble > small { display: block; padding: 5px 6px 0; color: var(--muted); font-size: 10px; }
.message-image { display: block; max-width: min(320px, 58vw); overflow: hidden; padding: 0; border: 0; border-radius: 16px; background: #e9e3dd; box-shadow: 0 7px 22px rgba(62,49,41,.1); }
.message-image img { display: block; max-width: 100%; max-height: 320px; object-fit: cover; }
.redpacket-message { width: 285px; display: grid; grid-template-columns: 44px 1fr; gap: 0 12px; padding: 14px 14px 10px; border-radius: 18px 6px 18px 18px; color: white; background: linear-gradient(145deg, #e1735c, #cb5044); box-shadow: 0 12px 30px rgba(179,68,54,.18); }
.packet-icon { grid-row: 1 / 3; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; color: #a63f35; background: #f7c986; font-weight: 800; }
.redpacket-message div:nth-child(2) { display: grid; gap: 3px; }
.redpacket-message span { font-size: 12px; opacity: .88; }
.redpacket-message small { grid-column: 1 / -1; margin-top: 12px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.18); font-size: 10px; opacity: .75; }
.typing { display: flex; gap: 5px; padding: 15px 18px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #aaa29b; animation: typing 1s infinite alternate; }
.typing i:nth-child(2) { animation-delay: .18s; }.typing i:nth-child(3) { animation-delay: .36s; }
.message-error { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px; color: #a4493f; font-size: 12px; }
.message-error button { border: 0; color: #a4493f; background: transparent; text-decoration: underline; }

.image-preview, .record-panel, .voice-turn-panel { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--line); background: #f6f0ea; }
.image-preview img { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; }
.image-preview > div, .record-panel > div:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.image-preview strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-preview small, .record-panel small { color: var(--muted); font-size: 11px; }
.text-button { margin-left: auto; border: 0; color: #9a5147; background: transparent; }
.record-pulse { width: 14px; height: 14px; border-radius: 50%; background: #d75f50; box-shadow: 0 0 0 6px rgba(215,95,80,.12); }
.secondary-button { margin-left: auto; padding: 8px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.record-copy { flex: 1; }
.record-copy audio { width: min(360px, 100%); height: 34px; margin-top: 5px; }
.record-transcript { margin: 4px 0 0; color: var(--ink); font-size: 12px; line-height: 1.5; }
.record-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.record-actions .text-button, .record-actions .secondary-button { margin-left: 0; white-space: nowrap; }
.voice-turn-pulse { width: 14px; height: 14px; flex: 0 0 auto; border-radius: 50%; background: var(--sage-dark); box-shadow: 0 0 0 6px rgba(70,92,76,.12); }
.voice-turn-panel[data-stage="recording"] .voice-turn-pulse { background: #d75f50; animation: pulse 1s ease-in-out infinite alternate; }
.voice-turn-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.voice-turn-copy small { color: var(--muted); font-size: 11px; }
.voice-turn-actions { display: flex; align-items: center; gap: 6px; }
.voice-turn-open { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; white-space: nowrap; }
.emoji-panel { display: grid; grid-template-columns: repeat(8, minmax(36px, 1fr)); gap: 5px; padding: 9px 16px; border-top: 1px solid var(--line); background: white; }
.emoji-panel button { height: 38px; border: 0; border-radius: 10px; background: transparent; font-size: 21px; }
.emoji-panel button:hover { background: var(--sand); }
.composer { padding: 10px 16px 14px; border-top: 1px solid var(--line); background: rgba(255,255,255,.96); }
.tool-row { display: flex; align-items: center; gap: 2px; margin-bottom: 5px; }
.tool-row .icon-button { width: 38px; height: 34px; font-size: 19px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.redpack-button { margin-left: auto; padding: 7px 12px; border: 0; border-radius: 11px; color: #bc4c42; background: #f9e5df; font-size: 12px; }
.input-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.input-row textarea { max-height: 110px; min-height: 44px; width: 100%; resize: none; padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px; outline: 0; color: var(--ink); background: #f8f6f3; line-height: 1.5; }
.input-row textarea:focus { border-color: #9fb2a5; background: white; box-shadow: 0 0 0 3px rgba(116,149,127,.12); }
.send-button { min-height: 44px; padding: 0 19px; border: 0; border-radius: 14px; color: white; background: var(--sage-dark); font-weight: 700; }

.character-entry { position: fixed; right: 22px; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: 10px; max-width: 58px; overflow: hidden; padding: 7px; border: 1px solid rgba(67,58,51,.1); border-radius: 22px; color: var(--ink); background: rgba(255,255,255,.94); box-shadow: 0 12px 40px rgba(53,43,36,.18); transition: max-width .28s ease, border-radius .28s ease; backdrop-filter: blur(14px); }
.character-entry.expanded { max-width: 270px; border-radius: 22px; }
.character-orbit { position: relative; flex: 0 0 auto; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 16px; color: white; background: linear-gradient(145deg, #a98470, #5e7766); }
.character-orbit::after { content: ""; position: absolute; inset: -3px; border: 1px solid rgba(116,149,127,.4); border-radius: 19px; }
.character-copy { width: 172px; display: grid; gap: 3px; text-align: left; white-space: nowrap; }
.character-copy small { color: var(--muted); font-size: 10px; }
.entry-arrow { margin-right: 4px; color: var(--muted); }

.life-drawer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.drawer-scrim { position: absolute; inset: 0; opacity: 0; background: rgba(39,34,31,.26); transition: opacity .24s ease; }
.drawer-card { position: absolute; top: 0; right: 0; width: min(440px, 94vw); height: 100%; overflow-y: auto; padding: 26px; transform: translateX(102%); background: #fbfaf8; box-shadow: -24px 0 70px rgba(49,40,34,.18); transition: transform .3s ease; }
.life-drawer.open { pointer-events: auto; }
.life-drawer.open .drawer-scrim { opacity: 1; }
.life-drawer.open .drawer-card { transform: translateX(0); }
.drawer-card > header, .redpacket-modal header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.drawer-card h2, .redpacket-modal h2 { margin: 5px 0 18px; font-size: 23px; }
.eyebrow { color: var(--sage-dark); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.activity-card { position: relative; overflow: hidden; min-height: 250px; border-radius: 24px; background: #e8dfd5; }
.activity-card img { width: 100%; height: 250px; object-fit: cover; object-position: 63% center; filter: saturate(.78) contrast(.94); }
.activity-card::after { content: ""; position: absolute; inset: 35% 0 0; background: linear-gradient(transparent, rgba(33,29,26,.72)); }
.asset-label { position: absolute; top: 12px; left: 12px; z-index: 2; padding: 6px 9px; border-radius: 9px; color: #665d56; background: rgba(255,255,255,.84); font-size: 10px; }
.activity-copy { position: absolute; left: 18px; right: 18px; bottom: 17px; z-index: 2; display: grid; gap: 5px; color: white; }
.activity-copy span, .activity-copy small { font-size: 11px; opacity: .82; }
.energy-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 20px 2px; font-size: 12px; }
.meter { height: 7px; overflow: hidden; border-radius: 10px; background: #e8e1db; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8ca797, #e2a07d); }
.drawer-section { padding: 16px 0; border-top: 1px solid var(--line); }
.drawer-section h3, .unset-card h3 { margin: 0 0 12px; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { padding: 7px 11px; border-radius: 999px; color: #5f6f64; background: #e8f0eb; font-size: 12px; }
.schedule-list { display: grid; gap: 8px; }
.schedule-list div { display: grid; grid-template-columns: 52px 1fr; padding: 10px 12px; border-radius: 13px; background: #f3efeb; font-size: 12px; }
.schedule-list time { color: var(--sage-dark); font-weight: 800; }
.moment-list { display: grid; gap: 12px; }
.moment-list > div { display: grid; grid-template-columns: 34px 1fr; gap: 10px; }
.moment-list > div > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 12px; background: #f0ebe5; }
.moment-list p { margin: 0; font-size: 12px; line-height: 1.55; }
.moment-list time { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.wallet-card { padding: 18px; border-radius: 20px; color: white; background: linear-gradient(145deg, #566f60, #3f5549); }
.wallet-card > div:first-child { display: grid; gap: 4px; margin-bottom: 13px; }
.wallet-card > div:first-child > span, .wallet-card small { font-size: 10px; opacity: .75; }
.wallet-card > div:first-child > strong { font-size: 26px; }
#ledgerList { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.14); }
#ledgerList > div { display: flex; justify-content: space-between; font-size: 11px; }
#ledgerList .out { color: #ffd7c2; } #ledgerList .in { color: #cdebd5; }
.unset-card { margin-top: 16px; padding: 16px 18px; border: 1px dashed #d9d0c9; border-radius: 18px; color: var(--muted); }
.unset-card p { margin: 0; font-size: 12px; }

.modal { width: min(440px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 28px; color: var(--ink); background: transparent; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(30,27,25,.52); backdrop-filter: blur(5px); }
.call-surface { min-height: 520px; display: flex; flex-direction: column; align-items: center; padding: 64px 28px 26px; border-radius: 28px; color: white; background: radial-gradient(circle at 50% 10%, #8ba191, #4b5d52 48%, #2f3933); }
.call-avatar { position: relative; width: 120px; height: 120px; display: grid; place-items: center; border-radius: 42px; color: white; background: linear-gradient(145deg, #b58c76, #667f6e); font-size: 38px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.call-avatar i { position: absolute; right: 1px; bottom: 4px; width: 20px; height: 20px; border: 4px solid #52665a; border-radius: 50%; background: #77c28b; }
.call-surface h2 { margin: 23px 0 8px; font-size: 26px; }
.call-surface > p { margin: 0; opacity: .76; }
.call-actions { width: 100%; display: flex; justify-content: center; gap: 24px; margin-top: auto; }
.call-control { display: grid; gap: 7px; place-items: center; border: 0; color: white; background: transparent; }
.call-control > span { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 22px; background: rgba(255,255,255,.14); font-size: 22px; }
.call-control.active > span { color: #304238; background: white; }
.call-control.hangup > span { background: #dc5e55; font-size: 34px; }
.call-control small { font-size: 11px; opacity: .8; }
.call-note { margin-top: 28px; opacity: .55; }
.redpacket-modal form { padding: 26px; border-radius: 28px; background: #fffaf6; }
.warning-note { padding: 10px 12px; border-radius: 12px; color: #8e5e3c; background: #fff0d8; font-size: 12px; }
.packet-balance { margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.packet-balance strong { color: var(--ink); }
.redpacket-modal label { display: grid; gap: 7px; margin-top: 16px; font-size: 12px; font-weight: 700; }
.redpacket-modal input { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 13px; outline: none; background: white; }
.packet-submit { width: 100%; margin-top: 22px; padding: 13px; border: 0; border-radius: 14px; color: white; background: var(--red); font-weight: 700; }
.image-modal { width: auto; max-width: 92vw; max-height: 90vh; border-radius: 20px; background: #161413; }
.image-modal img { display: block; max-width: 88vw; max-height: 86vh; object-fit: contain; }
.image-close { position: fixed; top: 18px; right: 18px; z-index: 2; width: 44px; height: 44px; border: 0; border-radius: 50%; color: white; background: rgba(0,0,0,.58); font-size: 25px; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; max-width: calc(100vw - 32px); opacity: 0; transform: translate(-50%, 12px); padding: 10px 15px; border-radius: 12px; color: white; background: rgba(38,34,31,.9); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes typing { to { opacity: .28; transform: translateY(-2px); } }
@keyframes wave { to { height: 5px; opacity: .3; } }

@media (max-width: 760px) {
  body { background: var(--paper); }
  .app { width: 100vw; height: 100dvh; margin: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; box-shadow: none; }
  .contact-pane, .chat-pane { grid-column: 1; grid-row: 1; }
  .app[data-screen="chat"] .contact-pane { display: none; }
  .app[data-screen="contacts"] .chat-pane { display: none; }
  .brand-row { min-height: 78px; padding-top: max(14px, env(safe-area-inset-top)); }
  .chat-pane { grid-template-rows: 68px auto 1fr auto auto auto auto; }
  .chat-header { padding: max(4px, env(safe-area-inset-top)) 9px 0; }
  .back-button { display: grid; }
  .header-actions .icon-button { width: 38px; }
  .header-actions .icon-button:last-child { display: none; }
  .messages { padding: 16px 12px 12px; }
  .bubble-stack { max-width: calc(100vw - 92px); }
  .message-bubble { font-size: 14px; }
  .message-image { max-width: 64vw; }
  .composer { padding: 7px 10px max(9px, env(safe-area-inset-bottom)); }
  .emoji-panel { grid-template-columns: repeat(8, minmax(28px, 1fr)); padding: 7px 8px; }
  .emoji-panel button { height: 34px; font-size: 19px; }
  .image-preview, .record-panel, .voice-turn-panel { padding: 8px 12px; }
  .record-panel, .voice-turn-panel { align-items: flex-start; flex-wrap: wrap; }
  .record-actions { width: 100%; padding-left: 26px; }
  .voice-turn-actions { width: 100%; justify-content: flex-end; padding-left: 26px; }
  .character-entry { right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); }
  .character-entry.expanded { max-width: 245px; }
  .drawer-card { width: 100%; padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
  .call-surface { min-height: min(620px, 86vh); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* Mature chat layout refresh */
:root {
  --wx-page: #e9e9e9;
  --wx-panel: #f7f7f7;
  --wx-chat: #ededed;
  --wx-line: #d8d8d8;
  --wx-text: #191919;
  --wx-muted: #8a8a8a;
  --wx-green: #95ec69;
  --wx-action: #07c160;
}

body {
  color: var(--wx-text);
  background: var(--wx-page);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

.app {
  width: min(1280px, calc(100vw - 16px));
  height: calc(100dvh - 16px);
  margin: 8px auto;
  grid-template-columns: 320px 1fr;
  border: 1px solid #d4d4d4;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 38px rgba(0, 0, 0, .1);
}

.contact-pane { grid-template-rows: auto auto 1fr auto; border-color: var(--wx-line); background: #f5f5f5; }
.brand-row { min-height: 72px; padding: 14px 16px; gap: 12px; }
.brand-row strong { font-size: 18px; }
.brand-row span, .contact-copy small { color: var(--wx-muted); font-size: 12px; }
.brand-mark, .avatar { border-radius: 7px; background: #5f7567; box-shadow: none; }
.brand-mark { width: 40px; height: 40px; }
.avatar { width: 44px; height: 44px; }
.message-avatar { width: 38px; height: 38px; border-radius: 6px; }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 7px; color: #343434; }
.icon-button:hover { background: rgba(0, 0, 0, .055); }
.icon-button svg, .attachment-action svg, .call-control svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand-row .icon-button { background: #e8e8e8; }
.search-box { height: 36px; margin: 0 14px 12px; padding: 0 11px; border-radius: 5px; background: #e8e8e8; }
.search-box svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.contact-list { padding: 0 8px; }
.contact { min-height: 68px; padding: 9px 10px; border-radius: 7px; background: transparent; }
.contact:hover { background: #e9e9e9; }
.contact.active { background: #dedede; }
.contact-copy { gap: 5px; }
.contact time { color: #aaa; }
.sidebar-footer { padding: 8px 18px 15px; border-top: 1px solid rgba(0,0,0,.035); }
.connection-note { width: 100%; margin: 0; padding: 6px 0; border: 0; color: #888; text-align: left; background: transparent; cursor: pointer; }
.connection-note strong { font-size: 11px; font-weight: 500; }
.about-entry { min-height: 34px; margin-top: 2px; padding: 0; border: 0; color: #555; background: transparent; font-size: 12px; text-align: left; }
.about-entry:hover { color: var(--wx-action); }
body[data-mode="real"] .connection-note span { background: var(--wx-action); }
.tts-action { align-self: flex-start; margin: 2px 0 0; padding: 3px 0; border: 0; color: #66756d; background: transparent; font-size: 10px; cursor: pointer; }
.tts-action[data-status="preparing"] { color: #967044; }
.tts-action[data-status="failed"] { color: #a4493f; }
.evidence-redaction { margin: auto; color: #999; font-size: 12px; }
.attachment-action.unavailable { opacity: .46; cursor: help; }
.connection-modal form { padding: 26px; border-radius: 10px; background: #fff; }
.connection-modal header, .about-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.connection-modal h2 { margin: 4px 0 0; font-size: 22px; }
.connection-copy { margin: 18px 0; color: var(--wx-muted); font-size: 12px; line-height: 1.7; }
.connection-modal label { display: grid; gap: 8px; font-size: 12px; font-weight: 700; }
.connection-modal input { width: 100%; padding: 12px 13px; border: 1px solid var(--wx-line); border-radius: 5px; outline: 0; }
.connection-modal input:focus { border-color: #9e9e9e; }
.connection-error { margin: 10px 0 0; color: #a4493f; font-size: 12px; }
.primary-connect, .demo-connect, .logout-connect { width: 100%; margin-top: 12px; padding: 12px; border-radius: 5px; font-weight: 700; cursor: pointer; }
.primary-connect { border: 0; color: white; background: var(--wx-action); }
.primary-connect:disabled { opacity: .55; cursor: wait; }
.demo-connect { border: 1px solid var(--wx-line); color: #444; background: #f7f7f7; }
.connection-modal details { margin-top: 14px; border-top: 1px solid var(--wx-line); padding-top: 12px; }
.connection-modal summary { color: #777; font-size: 12px; cursor: pointer; }
.connection-modal details label { margin-top: 12px; }
.logout-connect { border: 1px solid #e4c8c4; color: #9d4a42; background: #fff; }
.connection-modal input:disabled, .primary-connect:disabled { color: #999; background: #f1f1f1; }

.chat-pane { grid-template-rows: 64px auto 1fr auto auto auto auto; background: var(--wx-chat); }
.chat-header { position: relative; z-index: 30; padding: 0 14px 0 18px; border-color: var(--wx-line); background: rgba(247,247,247,.98); }
.profile-button strong { font-size: 16px; }
.profile-button small { color: var(--wx-muted); }
.header-actions { gap: 3px; }
.more-menu { position: absolute; top: 54px; right: 10px; z-index: 15; width: 190px; overflow: hidden; padding: 5px; border: 1px solid #d5d5d5; border-radius: 7px; background: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.14); }
.more-menu button { width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 5px; color: #333; background: transparent; text-align: left; }
.more-menu button:hover, .more-menu button:focus-visible { background: #f1f1f1; outline: none; }
.demo-ribbon { padding: 5px 12px; color: #746657; background: #f4eee5; font-size: 10px; }
.messages { padding: 22px 24px 28px; }
.welcome-panel { width: min(420px, 100%); min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: auto; padding: 34px 24px; color: #555; text-align: center; }
.welcome-avatar { width: 66px; height: 66px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: #607668; font-size: 24px; font-weight: 700; box-shadow: 0 10px 28px rgba(69,91,77,.18); }
.welcome-panel h1 { margin: 18px 0 7px; color: var(--wx-text); font-size: 24px; }
.welcome-panel p { margin: 0; color: #727272; font-size: 14px; line-height: 1.7; }
.welcome-actions { width: min(300px, 100%); display: grid; gap: 10px; margin-top: 24px; }
.welcome-actions button, .welcome-actions a { min-height: 44px; display: grid; place-items: center; padding: 0 18px; border-radius: 6px; font-size: 14px; font-weight: 700; text-decoration: none; }
.welcome-primary { border: 0; color: #fff; background: var(--wx-action); }
.welcome-secondary { border: 1px solid #d6d6d6; color: #444; background: #fff; }
.welcome-panel > small { max-width: 320px; margin-top: 16px; color: #999; font-size: 11px; line-height: 1.6; }
.message-row { gap: 10px; margin-bottom: 18px; }
.bubble-stack { max-width: min(68%, 560px); }
.bubble-stack > time { margin-top: 5px; color: #aaa; font-size: 9px; }
.message-bubble {
  position: relative;
  padding: 10px 13px;
  border: 1px solid rgba(0,0,0,.04);
  border-radius: 5px;
  color: var(--wx-text);
  background: #fff;
  box-shadow: 0 1px 1px rgba(0,0,0,.025);
  font-size: 14px;
  line-height: 1.65;
}
.message-row.user .message-bubble { background: var(--wx-green); }
.text-bubble::before { content: ""; position: absolute; top: 12px; left: -6px; width: 10px; height: 10px; transform: rotate(45deg); background: inherit; }
.message-row.user .text-bubble::before { right: -6px; left: auto; }
.preset-label { color: #969696; font-size: 9px; }
.voice-bubble { min-width: 210px; }
.voice-play { color: var(--wx-text); }
.message-image { border-radius: 6px; }
.redpacket-message { width: 280px; padding: 13px 13px 9px; border-radius: 6px; background: #f18d48; box-shadow: none; }
.packet-icon { width: 42px; height: 42px; border-radius: 5px; }

.image-preview, .record-panel, .voice-turn-panel { padding: 10px 14px; border-color: var(--wx-line); background: #fafafa; }
.voice-turn-open { border-color: var(--wx-line); border-radius: 5px; color: var(--wx-text); background: #f7f7f7; }
.image-preview img { width: 46px; height: 46px; border-radius: 5px; }
.secondary-button { border-radius: 5px; }
.emoji-panel { grid-template-columns: repeat(8, minmax(36px, 1fr)); gap: 6px; padding: 12px 3px 2px; border: 0; background: transparent; }
.emoji-panel button { height: 38px; border-radius: 5px; }
.emoji-panel button:hover { background: #e7e7e7; }

.composer { padding: 9px 12px max(10px, env(safe-area-inset-bottom)); border-color: #d5d5d5; background: #f7f7f7; }
.compose-line { display: grid; grid-template-columns: auto 1fr auto auto auto; align-items: end; gap: 7px; }
.compose-tool { width: 38px; height: 42px; color: #343434; }
.compose-line textarea { min-height: 42px; max-height: 110px; width: 100%; resize: none; padding: 9px 11px; border: 1px solid #dedede; border-radius: 5px; outline: 0; color: var(--wx-text); background: #fff; line-height: 1.55; }
.compose-line textarea:focus { border-color: #bcbcbc; box-shadow: none; }
.send-button { min-height: 42px; padding: 0 16px; border-radius: 5px; background: var(--wx-action); }
.send-button:hover { background: #06ad56; }
.attachment-panel { display: flex; gap: 18px; padding: 16px 4px 4px; }
.attachment-action { width: 70px; display: grid; justify-items: center; gap: 6px; padding: 0; border: 0; color: #555; background: transparent; }
.attachment-action > span { width: 48px; height: 48px; display: grid; place-items: center; border: 1px solid #dedede; border-radius: 8px; background: #fff; }
.attachment-action small { font-size: 11px; }
.attachment-action:hover > span { background: #f1f1f1; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.packet-tool { color: #d85d4b; font-size: 18px; font-weight: 800; }
.icon-button:focus-visible, .send-button:focus-visible, .attachment-action:focus-visible, .character-entry:focus-visible { outline: 3px solid rgba(7,193,96,.28); outline-offset: 2px; }

.character-entry {
  right: auto;
  left: max(18px, calc((100vw - min(1280px, calc(100vw - 16px))) / 2 + 18px));
  bottom: 94px;
  width: 48px;
  max-width: none;
  height: 48px;
  gap: 8px;
  padding: 4px;
  border-color: #d2d2d2;
  border-radius: 24px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 5px 18px rgba(0,0,0,.13);
  transition: width .2s ease, opacity .2s ease;
}
.character-entry.expanded { width: 222px; max-width: none; border-radius: 24px; }
.character-orbit { width: 38px; height: 38px; border-radius: 19px; background: #607668; }
.character-orbit::after { display: none; }
.character-copy { width: 144px; gap: 1px; }
.character-copy strong { font-size: 13px; }
.character-copy small { color: var(--wx-muted); font-size: 9px; }
.entry-arrow { color: #999; font-size: 20px; }
.composer-panel-open .character-entry { opacity: 0; pointer-events: none; }

.drawer-card { width: min(430px, 94vw); padding: 24px; background: #fafafa; box-shadow: -12px 0 38px rgba(0,0,0,.14); }
.drawer-card h2, .redpacket-modal h2 { font-size: 22px; }
.activity-card { height: 230px; min-height: 230px; border-radius: 8px; }
.activity-card img { position: absolute; left: 50%; top: calc(50% - 8px); width: 155%; max-width: none; height: auto; object-fit: initial; transform: translate(-50%, -50%); }
.wallet-card { border-radius: 8px; background: #4f6859; }
.unset-card { border-radius: 7px; }
.modal { border-radius: 10px; }
.call-surface { min-height: 500px; border-radius: 10px; background: linear-gradient(160deg,#657b6d,#29352e); }
.call-control > span { border-radius: 50%; }
.redpacket-modal form { border-radius: 10px; background: #fff; }
.warning-note, .redpacket-modal input, .packet-submit { border-radius: 5px; }
.about-card { padding: 26px; border-radius: 10px; background: #fff; }
.about-card h2 { margin: 4px 0 0; font-size: 22px; }
.about-card > p { margin: 18px 0; color: #666; font-size: 13px; line-height: 1.7; }
.download-list { display: grid; gap: 9px; }
.download-list a { display: grid; gap: 4px; min-height: 62px; padding: 12px 14px; border: 1px solid #ddd; border-radius: 7px; color: #333; text-decoration: none; }
.download-list a:hover, .download-list a:focus-visible { border-color: #8ec9a9; background: #f6fbf8; outline: none; }
.download-list small { color: #888; font-size: 11px; }
.web-address { display: block; margin-top: 18px; color: #4d745e; font-size: 11px; line-height: 1.6; overflow-wrap: anywhere; }

@media (min-width: 761px) and (max-width: 900px) {
  .app { grid-template-columns: 252px minmax(0, 1fr); }
  .contact { grid-template-columns: 46px minmax(0, 1fr); gap: 8px; }
  .contact time { display: none; }
  .messages { padding-inline: 18px; }
}

@media (max-width: 760px) {
  body { background: var(--wx-chat); }
  .app { width: 100vw; height: 100dvh; margin: 0; grid-template-columns: 1fr; border: 0; border-radius: 0; box-shadow: none; }
  .brand-row { min-height: 66px; padding-top: max(11px, env(safe-area-inset-top)); }
  .chat-pane { grid-template-rows: 58px auto 1fr auto auto auto auto; }
  .chat-header { padding: max(2px, env(safe-area-inset-top)) 6px 0; }
  .profile-button .avatar { display: none; }
  .profile-button strong { font-size: 15px; }
  .profile-button small { font-size: 10px; }
  .header-actions { gap: 0; }
  .header-actions .icon-button { width: 36px; }
  .header-actions .icon-button:last-child { display: grid; }
  .back-button, #more { min-width: 44px; min-height: 44px; }
  .more-menu { top: calc(52px + env(safe-area-inset-top)); right: 8px; width: min(220px, calc(100vw - 16px)); }
  .demo-ribbon { padding: 4px 9px; font-size: 9px; }
  .messages { padding: 18px 12px 22px; }
  .welcome-panel { padding: 28px 18px; }
  .message-row { gap: 8px; margin-bottom: 16px; }
  .message-avatar { width: 36px; height: 36px; }
  .bubble-stack { max-width: calc(100vw - 86px); }
  .message-image { max-width: 66vw; }
  .composer { padding: 7px 8px max(9px, env(safe-area-inset-bottom)); }
  .compose-line { grid-template-columns: auto minmax(0, 1fr) auto auto auto; gap: 4px; }
  .compose-line .send-button { min-height: 40px; padding: 0 12px; }
  .compose-tool { width: 36px; height: 40px; }
  .compose-line textarea { min-height: 40px; padding: 8px 10px; }
  .emoji-panel { grid-template-columns: repeat(8, minmax(30px, 1fr)); padding-top: 9px; }
  .emoji-panel button { height: 34px; font-size: 19px; }
  .attachment-panel { padding: 12px 4px 2px; }
  .character-entry { right: 12px; bottom: calc(111px + env(safe-area-inset-bottom)); }
  .character-entry { left: auto; }
  .character-entry.expanded { width: 218px; max-width: none; }
  .drawer-card { width: 100%; }
}
.admin-dashboard { width: min(1050px, calc(100vw - 48px)); height: min(860px, calc(100dvh - 48px)); max-width: none; max-height: none; padding: 0; border: 1px solid #dce4df; border-radius: 16px; color: #263c30; background: #f6f8f6; box-shadow: 0 24px 100px #12251d40; }
.admin-dashboard[open] { display: flex; flex-direction: column; }
.admin-dashboard::backdrop { background: #17291c66; backdrop-filter: blur(3px); }
.admin-header { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px 14px; flex-shrink: 0; }
.admin-header h2 { margin: 5px 0 0; font-size: 24px; letter-spacing: -.5px; }
.admin-header .icon-button { width: 44px; height: 44px; font-size: 26px; }
.admin-syncbar { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 0 28px 16px; flex-shrink: 0; }
.admin-syncbar p { margin: 0; color: #63776a; font-size: 12px; line-height: 1.7; }
.admin-syncbar p::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #9aa69d; margin-right: 7px; }
.admin-syncbar p[data-status=live]::before { background: #17a56c; }
.admin-syncbar p[data-status=stale] { color: #a26520; }
.admin-syncbar p[data-status=stale]::before { background: #c8872b; }
.admin-syncbar > div { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.admin-syncbar button { min-height: 40px; }
.admin-tabs { display: flex; gap: 6px; border-bottom: 1px solid #dde5df; padding: 0 28px; flex-shrink: 0; }
.admin-tabs button { padding: 12px 20px; border: 0; border-bottom: 3px solid transparent; background: transparent; font-size: 14px; color: #748578; }
.admin-tabs button[aria-pressed=true] { color: #1b6b46; border-bottom-color: #239660; font-weight: 700; }
.admin-content { overflow-y: auto; overscroll-behavior: contain; flex: 1; min-height: 0; padding: 24px 28px; }
.admin-state-grid { display: grid; grid-template-columns: 1fr 1.45fr 1fr; gap: 12px; }
.admin-state-grid article { padding: 19px; background: #fff; border: 1px solid #e1e9e3; border-radius: 12px; display: flex; flex-direction: column; gap: 9px; }
.admin-state-grid article > span { color: #758278; font-size: 12px; }
.admin-state-grid strong { font-size: 19px; line-height: 1.4; overflow-wrap: anywhere; }
.admin-state-grid small { color: #849086; font-size: 11px; }
.admin-focus { margin: 18px 0; padding: 24px; border: 1px solid #d9e6dc; border-radius: 12px; background: linear-gradient(120deg,#e9f3ec,#f1f6f0); }
.admin-focus h3 { margin: 10px 0; font-size: 21px; line-height: 1.5; overflow-wrap: anywhere; }
.admin-focus p { margin: 0; color: #6a7f70; font-size: 12px; line-height: 1.7; }
.admin-detail-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 24px; }
.admin-detail-grid h3 { font-size: 14px; margin: 8px 0 14px; }
.admin-task-list { display: grid; gap: 8px; }
.admin-task-list article { padding: 14px 16px; border: 1px solid #e3e9e4; border-radius: 8px; background: #fff; }
.admin-task-list p { margin: 6px 0; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.admin-task-list small { color: #428360; font-size: 11px; }
.admin-task-list time { color: #8d988f; font-size: 10px; }
.admin-attributes { display: grid; grid-template-columns: auto 1fr; gap: 15px 16px; padding: 20px; background: #fff; border: 1px solid #e3e9e4; border-radius: 10px; font-size: 12px; }
.admin-attributes dt { color: #7e8a81; }
.admin-attributes dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.admin-footnote { color: #839087; font-size: 11px; line-height: 1.8; margin: 18px 0 0; }
.admin-footer { flex-shrink: 0; padding: 12px 28px; border-top: 1px solid #e0e7e2; font-size: 11px; color: #7f8b83; }
.admin-log-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-log-tools label { display: flex; align-items: center; gap: 10px; color: #64776a; font-size: 13px; min-width: 0; }
.admin-log-tools select { min-height: 42px; max-width: 100%; min-width: 150px; padding: 7px 12px; border: 1px solid #d6e0d9; border-radius: 6px; background: white; color: #364e3e; }
.admin-log-tools > span { color: #809086; font-size: 11px; flex-shrink: 0; }
.admin-event-list { display: grid; gap: 12px; margin-top: 18px; }
.admin-event { padding: 18px 20px; border-radius: 10px; background: white; border: 1px solid #e0e7e2; min-width: 0; }
.admin-event header { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.admin-event time { color: #7b8a80; font-size: 11px; flex-shrink: 0; }
.admin-event-meta { display: block; color: #7e8b82; font-size: 11px; margin-top: 9px; overflow-wrap: anywhere; }
.admin-event p { color: #304536; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.85; font-size: 14px; margin: 12px 0; }
.admin-event details { margin-top: 12px; border-top: 1px solid #edf0ed; padding-top: 10px; }
.admin-event summary { cursor: pointer; color: #87938a; font-size: 11px; }
.admin-event pre { overflow-wrap: anywhere; white-space: pre-wrap; font-size: 11px; line-height: 1.7; color: #738078; }
.admin-empty { padding: 28px 14px; text-align: center; color: #819086; font-size: 13px; }
.admin-load-more { display: block; min-height: 44px; margin: 20px auto 0; padding-inline: 28px; }
.admin-entry { white-space: nowrap; }
@media (max-width: 760px) {
  .admin-dashboard { width: 100vw; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .admin-header { padding: max(18px, env(safe-area-inset-top)) 18px 12px; }
  .admin-header h2 { font-size: 21px; }
  .admin-syncbar { padding: 0 18px 12px; align-items: flex-start; }
  .admin-syncbar p { font-size: 10px; }
  .admin-syncbar > div { gap: 8px; }
  .admin-syncbar button { font-size: 11px; }
  .admin-tabs { padding-inline: 12px; }
  .admin-tabs button { padding: 11px 16px; }
  .admin-content { padding: 18px; }
  .admin-state-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .admin-state-grid article { padding: 14px; }
  .admin-state-grid article:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .admin-state-grid strong { font-size: 17px; }
  .admin-focus { padding: 18px; }
  .admin-focus h3 { font-size: 18px; }
  .admin-detail-grid { grid-template-columns: 1fr; gap: 14px; }
  .admin-event { padding: 15px; }
  .admin-event header { align-items: flex-start; }
  .admin-event time { font-size: 10px; }
  .admin-footer { padding: 10px 18px max(12px, env(safe-area-inset-bottom)); }
  .header-actions #adminEntry { padding: 5px; font-size: 12px; }
}
