:root {
  --brand: #0b737b;
  --brand-deep: #075b62;
  --brand-soft: #e7f4f4;
  --blue-soft: #eef6ff;
  --ink: #122d35;
  --muted: #5d7076;
  --line: #d9e5e7;
  --paper: #fff;
  --page: #edf3f4;
  --success: #287d49;
  --warning: #a85a20;
  --danger: #b23a3a;
  --composer-height: 274px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--page); color: var(--ink); font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible { outline: 3px solid rgba(27, 154, 164, .32); outline-offset: 2px; }

.phone-shell { width: min(100%, 440px); height: 100dvh; min-height: 650px; margin: 0 auto; background: #f6f9f9; position: relative; overflow: hidden; isolation: isolate; }
.topbar { height: 70px; padding: 10px 14px; background: rgba(255,255,255,.97); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; position: absolute; inset: 0 0 auto; z-index: 10; }
.brand-logo { width: 44px; height: 44px; object-fit: cover; border-radius: 11px; border: 1px solid #d9e4e6; }
.brand-title { min-width: 0; flex: 1; line-height: 1.25; }
.brand-title strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-title span { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--success); font-weight: 700; }
.brand-title i { width: 8px; height: 8px; border-radius: 50%; background: #42aa68; box-shadow: 0 0 0 4px rgba(66,170,104,.12); }
.plain-button { border: 0; background: transparent; color: var(--brand-deep); font-weight: 800; }
.font-button { min-width: 51px; height: 42px; border: 1px solid #9fc8cb; border-radius: 11px; background: #fff; }

.conversation { position: absolute; inset: 70px 0 var(--composer-height); overflow-y: auto; overscroll-behavior: contain; padding: 16px 15px 24px; scroll-behavior: smooth; }
.welcome-card { padding: 21px 20px 18px; border-radius: 23px; color: white; background: radial-gradient(circle at 92% 8%, rgba(75,190,197,.55), transparent 35%), linear-gradient(145deg, #0a6b72, #064e55); box-shadow: 0 15px 36px rgba(7,91,98,.18); }
.welcome-eyebrow { font-size: 14px; color: #c9eeee; font-weight: 800; letter-spacing: .03em; }
.welcome-card h1 { margin: 8px 0 10px; font-size: 28px; line-height: 1.34; letter-spacing: -.035em; }
.welcome-card p { margin: 0; font-size: 16px; line-height: 1.72; color: #e2f3f4; }
.trust-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.trust-row span { padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.12); font-size: 12px; color: #effafa; }

.message-list { display: grid; gap: 12px; padding-top: 17px; }
.message { display: flex; gap: 8px; align-items: flex-start; animation: rise .22s ease both; }
.message.user { justify-content: flex-end; }
.avatar { width: 31px; height: 31px; flex: 0 0 auto; border-radius: 9px; object-fit: cover; border: 1px solid #d7e4e6; }
.bubble { max-width: calc(100% - 45px); padding: 13px 15px; border-radius: 7px 18px 18px 18px; background: white; border: 1px solid var(--line); font-size: 18px; line-height: 1.65; box-shadow: 0 5px 15px rgba(18,45,53,.045); white-space: pre-wrap; }
.message.user .bubble { border: 0; border-radius: 18px 7px 18px 18px; background: var(--brand-deep); color: white; box-shadow: none; }
.message-card { margin: -2px 0 2px 39px; border: 1px solid var(--line); border-radius: 17px; background: white; overflow: hidden; box-shadow: 0 5px 16px rgba(18,45,53,.045); animation: rise .22s ease both; }
.card-head { padding: 14px 15px 12px; border-bottom: 1px solid #e7eeee; }
.card-kicker { display: flex; align-items: center; gap: 7px; color: var(--brand-deep); font-size: 13px; font-weight: 900; }
.card-kicker i { width: 8px; height: 8px; border-radius: 50%; background: #42a866; }
.card-head h3 { margin: 5px 0 2px; font-size: 19px; line-height: 1.42; }
.card-head p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.card-body { padding: 12px 15px 14px; }
.plan-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; }
.plan-steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 9px; align-items: center; padding: 7px 0; font-size: 15px; }
.plan-steps li::before { content: counter(step); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); font-weight: 900; }
.report-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid #ebf0f1; }
.report-row:last-child { border-bottom: 0; }
.report-row b { display: block; font-size: 15px; }
.report-row small { display: block; margin-top: 3px; color: var(--muted); }
.flag { align-self: center; padding: 5px 8px; border-radius: 8px; background: #fff2e8; color: var(--warning); font-size: 12px; font-weight: 900; }
.flag.ok { background: #eaf6ed; color: var(--success); }
.reason-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.reason-tags span { padding: 6px 8px; border-radius: 8px; background: #fff2e8; color: #8f4d1e; font-size: 12px; font-weight: 700; }
.one-x { display: grid; gap: 8px; }
.one-x-row { display: grid; grid-template-columns: 42px 1fr; gap: 9px; padding: 10px; border-radius: 12px; background: #f4f8f8; }
.one-x-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-deep); color: white; display: grid; place-items: center; font-size: 20px; font-weight: 900; }
.one-x-mark.x { background: #1a87af; }
.one-x-row b { display: block; font-size: 15px; }
.one-x-row small { display: block; margin-top: 3px; color: var(--muted); line-height: 1.5; }
.simple-list { margin: 0; padding-left: 22px; color: var(--muted); font-size: 14px; line-height: 1.85; }
.slot-list { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-list span { padding: 8px 12px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-deep); font-weight: 900; }
.notice { margin: 11px 0 0; padding-top: 10px; border-top: 1px dashed #cfdcdf; color: #687a7f; font-size: 12px; line-height: 1.6; }

.approval-card { margin: 0 0 2px 39px; border: 2px solid var(--brand); border-radius: 19px; padding: 16px; background: white; box-shadow: 0 11px 25px rgba(7,91,98,.12); animation: rise .22s ease both; }
.approval-card .approval-kicker { color: var(--warning); font-size: 13px; font-weight: 900; }
.approval-card h3 { margin: 6px 0 5px; font-size: 21px; }
.approval-card > p { margin: 0; color: var(--ink); font-size: 17px; font-weight: 800; line-height: 1.55; }
.approval-card ul { margin: 11px 0 0; padding-left: 22px; color: var(--muted); line-height: 1.75; font-size: 14px; }
.approval-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; margin-top: 14px; }
.approval-actions button { min-height: 54px; border-radius: 13px; font-size: 17px; font-weight: 900; }
.reject-button { border: 1px solid #aebfc2; background: white; color: var(--muted); }
.approve-button { border: 0; background: var(--brand-deep); color: white; }
.emergency-card { border-color: #e3b1b1; background: #fff7f7; }
.emergency-card .card-kicker { color: var(--danger); }

.thinking { margin: 13px 0 0 39px; display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 13px; }
.thinking[hidden] { display: none; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: bounce 1s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .13s; }
.thinking span:nth-child(3) { animation-delay: .26s; }
.thinking b { margin-left: 5px; }

.composer { position: absolute; inset: auto 0 0; z-index: 12; min-height: var(--composer-height); padding: 10px 13px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.98); border-top: 1px solid var(--line); box-shadow: 0 -9px 28px rgba(18,45,53,.07); }
.quick-replies { min-height: 45px; max-height: 92px; overflow-x: auto; overflow-y: hidden; display: flex; gap: 7px; padding: 1px 0 8px; scrollbar-width: none; }
.quick-replies::-webkit-scrollbar { display: none; }
.quick-replies button { flex: 0 0 auto; max-width: 245px; min-height: 42px; padding: 8px 12px; border: 1px solid #98c3c7; border-radius: 12px; background: white; color: var(--brand-deep); font-size: 14px; font-weight: 800; }
.voice-button { width: 100%; min-height: 70px; display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 13px; border: 0; border-radius: 16px; color: white; background: var(--brand-deep); box-shadow: 0 7px 16px rgba(7,91,98,.18); }
.voice-button.listening { background: #a65420; }
.voice-icon { width: 49px; height: 49px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: white; color: var(--brand-deep); }
.voice-button.listening .voice-icon { color: #a65420; animation: pulse 1s infinite; }
.voice-icon svg { width: 25px; height: 25px; }
.voice-button b { display: block; font-size: 20px; }
.voice-button small { display: block; margin-top: 4px; color: #d7eff0; font-size: 12px; line-height: 1.4; }
.text-row { display: grid; grid-template-columns: 1fr 72px; gap: 8px; margin-top: 8px; }
.text-row input { min-width: 0; height: 48px; border: 1px solid #aebfc2; border-radius: 12px; padding: 0 12px; background: #f9fbfb; color: var(--ink); font-size: 16px; }
.text-row button { height: 48px; border: 0; border-radius: 12px; background: #dcedee; color: var(--brand-deep); font-weight: 900; }
.service-row { height: 35px; display: flex; align-items: flex-end; justify-content: space-between; gap: 5px; }
.service-link { border: 0; background: transparent; color: var(--brand-deep); padding: 7px 2px 3px; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }

.connection-state { position: absolute; left: 50%; top: 82px; z-index: 20; transform: translateX(-50%); padding: 9px 13px; border-radius: 999px; background: #293d43; color: white; font-size: 13px; white-space: nowrap; }
.drawer { display: none; position: absolute; inset: 0; z-index: 40; }
.drawer.show { display: block; }
.drawer-backdrop { position: absolute; inset: 0; border: 0; background: rgba(9,30,35,.55); }
.drawer-panel { position: absolute; inset: auto 0 0; max-height: 82%; overflow-y: auto; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); border-radius: 25px 25px 0 0; background: white; animation: drawer .23s ease both; }
.drawer-handle { width: 44px; height: 5px; border-radius: 99px; background: #c8d4d6; margin: 2px auto 14px; }
.drawer-panel header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.drawer-eyebrow { color: var(--brand-deep); font-size: 12px; font-weight: 900; letter-spacing: .08em; }
.drawer-panel h2 { margin: 5px 0 0; font-size: 22px; }
.close-button { min-height: 40px; }
.mode-card { margin-top: 15px; display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 14px; background: var(--brand-soft); }
.mode-card > span { width: 13px; height: 13px; flex: 0 0 auto; border-radius: 50%; background: #42a866; box-shadow: 0 0 0 5px rgba(66,168,102,.12); }
.mode-card b, .mode-card small { display: block; }
.mode-card b { font-size: 15px; }
.mode-card small { margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.trace-list { list-style: none; padding: 0; margin: 15px 0; }
.trace-list li { display: grid; grid-template-columns: 23px 1fr auto; gap: 8px; padding: 9px 0; border-bottom: 1px solid #edf1f2; align-items: start; }
.trace-check { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #e8f5eb; color: var(--success); font-weight: 900; font-size: 12px; }
.trace-check.waiting { background: #fff1e5; color: var(--warning); }
.trace-check.blocked { background: #fbeaea; color: var(--danger); }
.trace-copy b { display: block; font-size: 14px; }
.trace-copy small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.trace-list time { color: #829196; font-size: 11px; }
.reset-button { width: 100%; min-height: 51px; border: 1px solid var(--brand); border-radius: 13px; background: white; color: var(--brand-deep); font-weight: 900; }
.drawer-note { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.65; }

.large-text .bubble { font-size: 21px; }
.large-text .welcome-card p { font-size: 18px; }
.large-text .quick-replies button { font-size: 16px; min-height: 48px; }
.large-text { --composer-height: 288px; }

@keyframes rise { from { opacity: 0; transform: translateY(7px); } }
@keyframes bounce { 50% { transform: translateY(-4px); opacity: .6; } }
@keyframes pulse { 50% { transform: scale(.9); box-shadow: 0 0 0 8px rgba(255,255,255,.2); } }
@keyframes drawer { from { transform: translateY(30px); opacity: .5; } }

@media (min-width: 600px) {
  body { display: grid; place-items: center; padding: 20px; background: linear-gradient(140deg,#eef4f5,#dce8e9); }
  .phone-shell { height: min(920px, calc(100vh - 40px)); min-height: 690px; border: 1px solid #cbdadc; border-radius: 28px; box-shadow: 0 26px 70px rgba(18,45,53,.2); }
  .drawer-panel { border-radius: 25px; bottom: 10px; left: 10px; right: 10px; }
}

@media (max-width: 355px) {
  :root { --composer-height: 267px; }
  .composer { padding-left: 10px; padding-right: 10px; }
  .voice-button b { font-size: 18px; }
  .voice-button small { font-size: 11px; }
  .welcome-card h1 { font-size: 25px; }
}

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