:root {
  --bg: #eef2f1;
  --surface: #ffffff;
  --surface-2: #f6f8f8;
  --ink: #0e1a1f;
  --ink-2: #33454c;
  --muted: #71838a;
  --line: #e3e9e8;
  --accent: #0aa574;
  --accent-soft: #e3f7ef;
  --accent-ink: #06704f;
  --mine: #d6f5e7;
  --mine-ink: #0b3a2a;
  --danger: #e8523f;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(13, 42, 36, .06), 0 4px 14px rgba(13, 42, 36, .05);
  --shadow-lg: 0 12px 40px rgba(13, 42, 36, .13);
  font-synthesis-weight: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", "Noto Sans Arabic", "Noto Sans Thai", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 20% -10%, #d8f3e8 0%, transparent 55%),
    radial-gradient(900px 500px at 110% 10%, #e2eef9 0%, transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(14, 26, 31, .04), 0 24px 80px rgba(14, 26, 31, .1);
}
@media (min-width: 560px) {
  .app { height: min(880px, 100dvh); margin: 0 auto; border-radius: 22px; align-self: center; }
  body { display: flex; align-items: center; justify-content: center; padding: 20px; }
}

.view { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--surface); }
.view.hidden { display: none; }

/* ---------------- 登录 ---------------- */
.auth-view { overflow-y: auto; background: linear-gradient(180deg, #f2fbf7 0%, #ffffff 42%); padding: 0 22px 28px; }
.auth-hero { padding: 54px 2px 26px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: linear-gradient(145deg, #0fbf86, #059c6d); color: #fff;
  box-shadow: 0 8px 22px rgba(10, 165, 116, .3);
}
.brand h1 { margin: 0; font-size: 26px; letter-spacing: .5px; font-weight: 700; }
.brand-en { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: 1.6px; text-transform: uppercase; }
.hero-line { margin: 22px 0 6px; font-size: 19px; line-height: 1.45; font-weight: 650; color: var(--ink); }
.hero-sub { margin: 0; font-size: 13px; color: var(--muted); }

.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 18px; box-shadow: var(--shadow-sm);
}
.segmented { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented.small { margin-bottom: 12px; }
.seg {
  flex: 1; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px;
  font-size: 14px; color: var(--muted); font-weight: 550; transition: .18s;
}
.seg.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(14, 26, 31, .1); }

.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 550; }
.field.tight { margin-top: 10px; }
.field input, .input-full, .select-full {
  width: 100%; padding: 12px 13px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 15px; outline: none; transition: .18s;
}
.field input:focus, .input-full:focus, .select-full:focus {
  border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(10, 165, 116, .12);
}
.select-full { margin-top: 10px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371838a' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; padding-right: 34px; }

.btn-primary {
  width: 100%; margin-top: 18px; padding: 13px; border: 0; border-radius: 12px;
  background: linear-gradient(145deg, #0dbd85, #069e6b); color: #fff; font-size: 15.5px; font-weight: 650;
  box-shadow: 0 8px 20px rgba(10, 165, 116, .26); transition: .18s;
}
.btn-primary:active { transform: translateY(1px); }
.btn-primary.slim { width: auto; margin: 0; padding: 11px 20px; font-size: 14.5px; }
.btn-ghost {
  padding: 11px 18px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px; color: var(--ink-2); font-weight: 550;
}
.btn-ghost:active { background: var(--surface-2); }
.btn-danger {
  width: 100%; margin-top: 12px; padding: 12px; border-radius: 11px; border: 1px solid #f4d3ce;
  background: #fdf3f2; color: var(--danger); font-weight: 600; font-size: 14.5px;
}
.row-btns { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; }
.auth-hint { margin: 12px 2px 0; font-size: 12.5px; color: var(--muted); text-align: center; }

.demo-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.demo-strip > span { font-size: 12px; color: var(--muted); width: 100%; }
.chip {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2);
  padding: 6px 11px; border-radius: 999px; font-size: 12.5px;
}
.chip:active { background: var(--accent-soft); border-color: #b8ecd9; }
.server-link {
  display: flex; align-items: center; gap: 6px; margin: 12px auto 0; padding: 6px 10px;
  border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font-size: 11.5px; max-width: 100%; overflow: hidden;
}
.server-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-link:active { background: var(--surface-2); color: var(--ink-2); }

/* ---------------- 顶部栏 ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 12px; border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(12px);
}
.topbar-title { display: flex; align-items: center; gap: 9px; }
.topbar-title h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .4px; }
.logo-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.my-lang { font-size: 11.5px; color: var(--accent-ink); background: var(--accent-soft); padding: 3px 9px; border-radius: 999px; font-weight: 600; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 11px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.accent { color: var(--accent); background: var(--accent-soft); }

.search-row {
  display: flex; align-items: center; gap: 8px; margin: 10px 14px 4px; padding: 9px 12px;
  background: var(--surface-2); border-radius: 11px; color: var(--muted);
}
.search-row input { flex: 1; border: 0; background: transparent; outline: none; font-size: 14.5px; color: var(--ink); }

/* ---------------- 会话列表 ---------------- */
.list { flex: 1; overflow-y: auto; padding: 6px 8px 90px; }
.conv-item {
  display: flex; gap: 12px; align-items: center; padding: 12px 10px; border-radius: 13px; transition: .15s;
}
.conv-item:active { background: var(--surface-2); }
.conv-main { flex: 1; min-width: 0; }
.conv-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.conv-name { font-size: 15.5px; font-weight: 620; }
.conv-time { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.conv-preview { margin-top: 3px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview .tr { color: var(--ink-2); }
.badge {
  min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.avatar {
  display: grid; place-items: center; width: 48px; height: 48px; border-radius: 15px;
  color: #fff; font-weight: 650; font-size: 17px; flex-shrink: 0; letter-spacing: .5px;
}
.avatar.sm { width: 36px; height: 36px; border-radius: 12px; font-size: 14px; }
.avatar.lg { width: 84px; height: 84px; border-radius: 28px; font-size: 32px; }

.empty-state { flex: 1; display: grid; place-content: center; text-align: center; gap: 8px; padding: 40px; }
.empty-state p { margin: 0; font-size: 16px; font-weight: 620; }
.empty-state span { font-size: 13px; color: var(--muted); line-height: 1.6; }

.fab {
  position: absolute; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 56px; height: 56px; border-radius: 20px; border: 0; color: #fff;
  background: linear-gradient(145deg, #0fbf86, #069e6b); box-shadow: 0 10px 26px rgba(10, 165, 116, .34);
  display: grid; place-items: center;
}
.fab:active { transform: scale(.96); }

/* ---------------- 聊天 ---------------- */
.chat-topbar {
  display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
}
.chat-peer { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.peer-name { font-size: 15.5px; font-weight: 650; }
.peer-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.messages {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px;
  background:
    radial-gradient(700px 300px at 100% 0%, #f4fbf8 0%, transparent 60%),
    var(--surface-2);
}
.msg { display: flex; max-width: 100%; }
.msg.mine { justify-content: flex-end; }
.bubble {
  max-width: 84%; padding: 9px 12px; border-radius: 15px; background: var(--surface);
  box-shadow: var(--shadow-sm); border: 1px solid var(--line); position: relative;
}
.msg.mine .bubble { background: var(--mine); border-color: #c0ead8; color: var(--mine-ink); }
.bubble.rtl { direction: rtl; text-align: right; }
.bubble .txt { font-size: 15px; line-height: 1.48; white-space: pre-wrap; word-break: break-word; }
.bubble .orig {
  margin-top: 7px; padding-top: 7px; border-top: 1px dashed rgba(14, 26, 31, .12);
  font-size: 12.5px; line-height: 1.45; color: var(--muted); white-space: pre-wrap; word-break: break-word;
}
.msg.mine .bubble .orig { border-top-color: rgba(11, 58, 42, .15); color: #47806a; }
.bubble .meta-line {
  display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 4px;
  font-size: 10.5px; color: var(--muted); opacity: .85;
}
.msg.mine .bubble .meta-line { color: #4c8a72; }
.tag {
  font-size: 10px; padding: 1.5px 6px; border-radius: 6px; background: var(--accent-soft);
  color: var(--accent-ink); font-weight: 650; letter-spacing: .2px;
}
.bubble.pending { opacity: .6; }
.bubble.error { border-color: #f2c9c2; background: #fdf4f2; }

.voice-row { display: flex; align-items: center; gap: 10px; min-width: 172px; }
.voice-play {
  width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: #fff; flex-shrink: 0;
}
.msg.mine .voice-play { background: #0b9668; }
.voice-bars { display: flex; align-items: center; gap: 2.5px; height: 22px; flex: 1; }
.voice-bars i { width: 2.5px; border-radius: 2px; background: currentColor; opacity: .35; }
.voice-bars.playing i { animation: pulse 1.1s infinite ease-in-out; opacity: .7; }
@keyframes pulse { 0%, 100% { transform: scaleY(.55); } 50% { transform: scaleY(1.25); } }
.voice-dur { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.speak-btn {
  margin-top: 7px; border: 1px solid var(--line); background: #fff; color: var(--accent-ink);
  font-size: 11.5px; padding: 4px 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 4px;
}
.msg.mine .speak-btn { display: none; }

.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.75); padding: 3px 10px; border-radius: 999px; }
.sys-line { align-self: center; font-size: 11.5px; color: var(--muted); text-align: center; max-width: 84%; line-height: 1.5; }

/* ---------------- 输入区 ---------------- */
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 9px 10px calc(env(safe-area-inset-bottom) + 9px);
  border-top: 1px solid var(--line); background: var(--surface);
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; padding: 10px 13px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-2); outline: none; font-size: 15px; line-height: 1.4;
}
.composer textarea:focus { border-color: var(--accent); background: #fff; }
.send-btn {
  width: 40px; height: 40px; border-radius: 13px; border: 0; display: grid; place-items: center;
  background: var(--accent); color: #fff; flex-shrink: 0;
}
.composer .icon-btn { width: 40px; height: 40px; border-radius: 13px; background: var(--surface-2); }

.recorder {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
  border-top: 1px solid var(--line); background: #fff8f7;
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 14px; }
.rec-hint { flex: 1; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-cancel { border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 8px; }
.rec-send { border: 0; background: var(--accent); color: #fff; padding: 9px 16px; border-radius: 11px; font-weight: 620; font-size: 14px; }

/* ---------------- 设置 ---------------- */
.settings-view { overflow: hidden; }
.settings-body { flex: 1; overflow-y: auto; padding: 14px 14px calc(env(safe-area-inset-bottom) + 24px); display: flex; flex-direction: column; gap: 12px; background: var(--surface-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 650; }
.card-desc { margin: 0 0 10px; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.card-head { display: flex; align-items: center; gap: 12px; }
.me-name { font-size: 16px; font-weight: 650; }
.me-email { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.switch-row input { width: 44px; height: 26px; appearance: none; background: #dbe3e1; border-radius: 999px; position: relative; transition: .2s; outline: none; }
.switch-row input:checked { background: var(--accent); }
.switch-row input::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s;
}
.switch-row input:checked::after { transform: translateX(18px); }
.provider-status { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---------------- 弹层 ---------------- */
.sheet-mask {
  position: absolute; inset: 0; background: rgba(11, 26, 24, .38); display: flex; align-items: flex-end;
  z-index: 40; backdrop-filter: blur(2px);
}
.sheet { width: 100%; background: var(--surface); border-radius: 22px 22px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px); animation: sheetUp .24s ease; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } }
.sheet-handle { width: 38px; height: 4px; border-radius: 2px; background: var(--line); margin: 2px auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: 16.5px; }
.sheet-error { margin: 10px 0 0; font-size: 12.5px; color: var(--danger); }

/* ---------------- 通话 ---------------- */
.call-overlay {
  position: absolute; inset: 0; z-index: 60; display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 40px) 20px calc(env(safe-area-inset-bottom) + 28px);
  background: linear-gradient(180deg, #eafaf3 0%, #f7fbfa 45%, #eef5f8 100%);
}
.call-head { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.call-name { font-size: 21px; font-weight: 700; }
.call-status { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.captions { flex: 1; margin-top: 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; }
.caption {
  background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 13px; box-shadow: var(--shadow-sm); animation: capIn .2s ease;
}
@keyframes capIn { from { opacity: 0; transform: translateY(6px); } }
.caption .tr { font-size: 17px; line-height: 1.45; font-weight: 560; }
.caption .src { margin-top: 5px; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.caption.interim { opacity: .72; }
.caption.me { background: #f0fbf6; }
.captions-empty { margin: auto; text-align: center; font-size: 13px; color: var(--muted); line-height: 1.7; padding: 20px; }
.call-actions { display: flex; justify-content: center; gap: 26px; margin-top: 12px; }
.call-btn {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  color: var(--ink-2); display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.call-btn.on { background: var(--accent); color: #fff; border-color: transparent; }
.call-btn.danger { background: var(--danger); color: #fff; border-color: transparent; box-shadow: 0 10px 24px rgba(232, 82, 63, .3); }
.call-tip { text-align: center; font-size: 11.5px; color: var(--muted); margin: 16px 0 0; }

.incoming {
  position: absolute; inset: 0; z-index: 70; display: grid; place-items: center;
  background: rgba(11, 26, 24, .42); backdrop-filter: blur(4px); padding: 24px;
}
.incoming-card {
  width: 100%; max-width: 330px; background: #fff; border-radius: 22px; padding: 26px 22px 20px;
  text-align: center; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.incoming-name { font-size: 19px; font-weight: 700; }
.incoming-sub { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.incoming-card .row-btns { width: 100%; justify-content: center; margin-top: 10px; }

.toast {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: rgba(14, 26, 31, .9); color: #fff; font-size: 13px; padding: 9px 15px; border-radius: 11px;
  z-index: 90; max-width: 86%; text-align: center; line-height: 1.45;
  animation: toastIn .18s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------------- 群聊 ---------------- */
.avatar.group { background: #e8f1ee; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 5px; border: 1px solid var(--line); overflow: hidden; }
.avatar.group i {
  display: grid; place-items: center; border-radius: 5px; color: #fff;
  font-style: normal; font-size: 10px; font-weight: 650; min-width: 0; overflow: hidden;
}
.avatar.lg.group { padding: 6px; gap: 4px; border-radius: 26px; }
.avatar.lg.group i { border-radius: 12px; font-size: 18px; }
.avatar.group:has(i:only-child) { grid-template-columns: 1fr; }
.sender-line { font-size: 11px; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.member-pick { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pick-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.pick-item:last-child { border-bottom: 0; }
.pick-item input { width: 17px; height: 17px; accent-color: var(--accent); }
.pick-item .pick-name { font-size: 14px; font-weight: 560; flex: 1; }
.pick-item .pick-tag { font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; }
.member-list { max-height: 300px; overflow-y: auto; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px dashed var(--line); }
.member-row:last-child { border-bottom: 0; }
.member-row .mr-name { font-size: 14px; font-weight: 560; flex: 1; }
.member-row .mr-role { font-size: 10.5px; color: #b8860b; background: #fdf6e3; padding: 1px 6px; border-radius: 6px; }
.member-row .mr-lang { font-size: 11px; color: var(--accent-ink); background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; }
.call-avatars { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.call-avatars .mini { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; color: #fff; font-size: 12px; font-weight: 650; }

.spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; display: inline-block; vertical-align: -2px; margin-right: 6px; }
@keyframes sp { to { transform: rotate(360deg); } }
