:root {
  --bg: #f4f4f7;
  --card: #ffffff;
  --text: #111114;
  --sub: #8a8a94;
  --line: #e8e8ee;
  --blue: #0a84ff;
  --danger: #e5484d;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #000;
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; border: 0; background: none; color: inherit; padding: 0; cursor: pointer; }
input { font-family: inherit; }
svg { display: block; }

/* ================= 计算器 · iOS ================= */
.calc { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 1; }
.calc[hidden] { display: none !important; }
.calc.ios { background: #000; color: #fff; padding: calc(var(--safe-top) + 8px) 10px calc(var(--safe-bottom) + 10px); }
.calc-display { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-end; padding: 12px 10px 14px; min-height: 96px; }
.calc-expr { font-size: 20px; color: #9a9a9f; min-height: 24px; letter-spacing: .5px; }
.calc-result { font-size: clamp(40px, 17vw, 76px); font-weight: 300; line-height: 1.06; letter-spacing: -1px; word-break: break-all; text-align: right; }
.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.calc.ios .key {
  height: clamp(60px, 19vw, 82px); border-radius: 50%; font-size: clamp(24px, 7.4vw, 34px);
  background: #333; color: #fff; display: flex; align-items: center; justify-content: center;
  transition: filter .12s ease, transform .08s ease;
}
.calc.ios .key:active { filter: brightness(1.35); transform: scale(.97); }
.calc.ios .key.fn { background: #a5a5a5; color: #000; }
.calc.ios .key.op { background: #ff9f0a; font-size: clamp(28px, 8vw, 38px); }
.calc.ios .key.zero { grid-column: span 2; border-radius: 999px; justify-content: flex-start; padding-left: 30px; }

/* ================= 计算器 · Android ================= */
.calc.android { background: #f7f8fa; color: #16181c; padding: calc(var(--safe-top) + 4px) 0 0; }
.acalc-bar { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px 2px; font-size: 15px; color: #444; }
.acalc-dots { font-size: 20px; line-height: 1; color: #666; }
.acalc-display { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-end; padding: 10px 20px 6px; min-height: 110px; }
.calc.android .calc-expr { font-size: 18px; color: #7c808a; min-height: 22px; }
.calc.android .calc-result { font-size: clamp(40px, 16vw, 70px); font-weight: 400; color: #14161a; }
.sci-row { display: flex; gap: 6px; overflow-x: auto; padding: 6px 14px 10px; scrollbar-width: none; }
.sci-row::-webkit-scrollbar { display: none; }
.sci { flex: 0 0 auto; min-width: 46px; height: 38px; border-radius: 10px; background: #e8ebf0; color: #3b4250; font-size: 15px; }
.sci:active { filter: brightness(.94); }
.acalc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 12px calc(var(--safe-bottom) + 12px); }
.calc.android .key { height: clamp(56px, 15.5vw, 72px); border-radius: 16px; background: #fff; font-size: clamp(22px, 6.6vw, 30px); color: #1a1d22; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.calc.android .key.fn { background: #e9edf3; color: #3b4250; font-size: 20px; }
.calc.android .key.op { background: #dfe8f8; color: #1a56c4; }
.calc.android .key.eq { background: #1a73e8; color: #fff; }
.calc.android .key:active { filter: brightness(.95); }

/* 切后台时的隐私遮罩：直接把计算器盖在最上层 */
.calc.as-mask { position: fixed !important; inset: 0; z-index: 9999; }

/* ================= 应用 ================= */
.app { position: fixed; inset: 0; z-index: 2; background: var(--bg); color: var(--text); }
.app[hidden] { display: none !important; }
.shell { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: rgba(244,244,247,.92); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 3;
}
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.4px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #3c3c43; }
.icon-btn:active { background: rgba(0,0,0,.06); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.tabs { display: flex; gap: 18px; padding: 4px 16px 0; }
.tab { font-size: 15px; color: var(--sub); padding: 6px 0 9px; position: relative; }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 2px; width: 20px; height: 3px; border-radius: 2px; background: var(--blue); }

.notice { margin: 8px 14px 2px; padding: 8px 11px; border-radius: 10px; background: #eceff5; color: #6b7280; font-size: 12px; display: flex; align-items: center; gap: 7px; }
.notice svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.list { flex: 1; overflow-y: auto; padding: 6px 10px calc(var(--safe-bottom) + 74px); -webkit-overflow-scrolling: touch; }
.list.pad { padding-bottom: 24px; }
.row { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 11px 10px; border-radius: 12px; }
.row:active { background: rgba(0,0,0,.04); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.row-top b { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top i { font-style: normal; font-size: 12px; color: #a0a0a8; flex: 0 0 auto; }
.row-sub { font-size: 13px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: #ff3b30; color: #fff; font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; }

.av { width: 46px; height: 46px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.av svg { width: 78%; height: 78%; }
.av.sm { width: 34px; height: 34px; }
.av.lg { width: 68px; height: 68px; }

.bottom-nav { position: absolute; left: 0; right: 0; bottom: 0; display: flex; border-top: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(14px); padding-bottom: var(--safe-bottom); }
.nav-item { flex: 1; height: 55px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; color: #8e8e93; }
.nav-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.nav-item.active { color: var(--blue); }

.empty { padding: 48px 24px; text-align: center; color: #9a9aa2; font-size: 14px; line-height: 1.9; }
.empty span { font-size: 12px; color: #b3b3ba; }
.empty.small { padding: 22px; }

/* 搜索 */
.search-box { flex: 1; display: flex; align-items: center; gap: 7px; background: #e9e9ee; border-radius: 10px; padding: 8px 11px; }
.search-box svg { width: 16px; height: 16px; fill: none; stroke: #8e8e93; stroke-width: 1.9; }
.search-box input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; color: var(--text); }
.search-box.inline { margin: 10px 14px 0; }
.user-card { display: flex; align-items: center; gap: 11px; background: var(--card); border-radius: 13px; padding: 11px 12px; margin-bottom: 8px; }
.user-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.user-main b { font-size: 15px; }
.user-main span { font-size: 12px; color: var(--sub); }
.user-actions { display: flex; gap: 6px; }

/* 表单与按钮 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin: 0 2px 6px; }
.field input { width: 100%; height: 46px; border-radius: 11px; border: 1px solid var(--line); background: #fff; padding: 0 13px; font-size: 16px; outline: none; }
.field input:focus { border-color: #b9cdf3; box-shadow: 0 0 0 3px rgba(10,132,255,.1); }
.btn { height: 34px; padding: 0 13px; border-radius: 9px; background: #ececf1; font-size: 13px; font-weight: 600; color: #2c2c30; }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.ghost { background: #f1f1f5; color: #55555c; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.wide { width: 100%; height: 46px; font-size: 16px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.link { color: var(--blue); font-size: 13px; }
.muted { color: var(--sub); font-size: 13px; }

/* 认证 */
.auth { height: 100%; overflow-y: auto; padding: calc(var(--safe-top) + 44px) 26px calc(var(--safe-bottom) + 28px); background: var(--bg); }
.auth-head h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -.8px; }
.auth-head p { margin: 0 0 26px; color: var(--sub); font-size: 14px; }
.auth-body { max-width: 420px; }
.auth-links { display: flex; justify-content: space-between; margin-top: 14px; }
.note { margin-top: 18px; font-size: 12px; line-height: 1.7; color: #9a9aa2; }
.btn.primary.wide { margin-top: 6px; }

/* 聊天 */
.chat-shell { background: #eef0f4; }
.chat-top { gap: 8px; }
.chat-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-who b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who span { font-size: 11px; color: var(--sub); }
.msg-list { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 8px; align-items: flex-end; }
.msg.mine { flex-direction: row-reverse; }
.msg-body { max-width: 74%; display: flex; flex-direction: column; gap: 3px; }
.sender { font-size: 11px; color: #8a8a92; margin-left: 4px; }
.bubble { padding: 9px 12px; border-radius: 16px; background: #fff; font-size: 15px; line-height: 1.45; word-break: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.msg.mine .bubble { background: #0a84ff; color: #fff; }
.meta { font-size: 10px; color: #a4a4ac; padding: 0 5px; }
.msg.mine .meta { text-align: right; }
.composer { display: flex; gap: 8px; align-items: center; padding: 8px 12px calc(var(--safe-bottom) + 8px); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); }
.composer input { flex: 1; height: 40px; border-radius: 20px; border: 1px solid var(--line); background: #f5f5f8; padding: 0 14px; font-size: 15px; outline: none; }
.send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--blue); display: flex; align-items: center; justify-content: center; }
.send-btn svg { width: 19px; height: 19px; fill: #fff; stroke: none; }

/* 建群 */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 2px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #e8eefb; color: #2b5fd0; border-radius: 999px; padding: 5px 9px; font-size: 12px; }
.chip button { color: #2b5fd0; font-size: 14px; line-height: 1; }

/* 设置 / 管理 */
.profile { display: flex; align-items: center; gap: 14px; padding: 20px 18px; }
.profile div { display: flex; flex-direction: column; gap: 3px; }
.profile b { font-size: 19px; }
.profile span { font-size: 13px; color: var(--sub); }
.settings { background: var(--card); margin: 4px 14px; border-radius: 14px; overflow: hidden; }
.setting { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px; text-align: left; }
.setting:last-child { border-bottom: 0; }
.setting i { font-style: normal; font-size: 12px; color: var(--sub); text-align: right; }
.setting.tap:active { background: #f7f7fa; }
.setting.danger span { color: var(--danger); }
.foot { margin: 18px 24px; font-size: 12px; line-height: 1.7; color: #a0a0a8; text-align: center; }
.admin-card { background: var(--card); margin: 14px; padding: 18px; border-radius: 14px; }
.admin-card h2 { margin: 0 0 6px; font-size: 17px; }
.admin-card p { margin: 0 0 14px; font-size: 13px; line-height: 1.7; color: var(--sub); }

/* 提示 */
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 76px); transform: translateX(-50%); z-index: 99999; background: rgba(28,28,32,.92); color: #fff; font-size: 13px; padding: 9px 15px; border-radius: 999px; max-width: 82vw; text-align: center; }
.toast[hidden] { display: none !important; }
