/* 深世影 OPC · 移动端
 *
 * 设计取向：极简、暗色优先、单手可达。
 * 三条与"能用"直接相关的规则，改样式前先读：
 *   1. 所有可点目标 ≥ 44×44（Apple HIG）。手机上点不中比不好看更致命。
 *   2. 高度一律用 dvh，不用 vh —— iOS Safari 地址栏收起时 vh 会让底部输入框被挡一半。
 *   3. 底部留白 = 安全区 + 导航高度，用 env(safe-area-inset-bottom) 叠加，
 *      否则 iPhone 的 Home 指示条会压住发送按钮。
 */

:root {
  --bg: #0a0e13;
  --bg-soft: #0d131a;
  --panel: #121a23;
  --panel-2: #17212c;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --txt: #e8eef6;
  --txt-2: #9aa9bb;
  --txt-3: #64748b;
  --accent: #2ee6a8;
  --accent-2: #5cf5c4;
  --accent-ink: #04180f;
  --bad: #ff6b78;
  --warn: #f5b544;
  --ok: #2ee6a8;
  --bubble-me: linear-gradient(135deg, #1f5f4a, #17453a);
  --bubble-ai: #121a23;
  --scrim: rgba(3, 6, 10, .62);
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tab-h: 56px;
  --top-h: 56px;
}

[data-theme="light"] {
  --bg: #f5f7fa;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f4f8;
  --line: rgba(15, 23, 42, .09);
  --line-strong: rgba(15, 23, 42, .16);
  --txt: #101828;
  --txt-2: #55637a;
  --txt-3: #8695a8;
  --accent: #07956a;
  --accent-2: #0bb87f;
  --accent-ink: #ffffff;
  --bad: #d92d43;
  --warn: #b25e09;
  --ok: #07956a;
  --bubble-me: linear-gradient(135deg, #d8f7ec, #c6f1e2);
  --bubble-ai: #ffffff;
  --scrim: rgba(15, 23, 42, .42);
  --shadow: 0 10px 30px rgba(16, 24, 40, .10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior-y: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.hide { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { -webkit-appearance: none; appearance: none; }

/* ==================== 启动画面 ==================== */
.splash {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background: radial-gradient(120% 80% at 50% 20%, #123026 0%, #0a0e13 60%);
  transition: opacity .45s ease, visibility .45s;
}
.splash.out { opacity: 0; visibility: hidden; }
.splash-mark { filter: drop-shadow(0 8px 30px rgba(46, 230, 168, .35)); animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.splash-brand { margin: 10px 0 0; font-size: 20px; letter-spacing: .18em; font-weight: 600; }
.splash-slogan { margin: 2px 0 0; color: var(--txt-2); font-size: 13px; letter-spacing: .06em; }
.splash-dots { display: flex; gap: 6px; margin-top: 26px; }
.splash-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .25; animation: blink 1.2s infinite; }
.splash-dots i:nth-child(2) { animation-delay: .2s; }
.splash-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ==================== 登录 ==================== */
.auth {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 24px) 22px calc(var(--safe-b) + 24px);
  background: radial-gradient(90% 60% at 50% 0%, rgba(46, 230, 168, .12), transparent 60%);
}
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head img { filter: drop-shadow(0 6px 20px rgba(46, 230, 168, .3)); }
.auth-head h1 { margin: 12px 0 4px; font-size: 22px; letter-spacing: .12em; }
.auth-head p { margin: 0; color: var(--txt-2); font-size: 13px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 22px; padding: 18px; box-shadow: var(--shadow);
}
.seg { display: flex; background: var(--panel-2); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.seg button { flex: 1; height: 38px; border-radius: 10px; color: var(--txt-2); font-size: 14px; }
.seg button.on { background: var(--bg-soft); color: var(--txt); font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--txt-3); margin: 0 0 6px 4px; letter-spacing: .04em; }
.field input, .field textarea, .field select {
  width: 100%; min-height: 46px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--txt); outline: none;
  transition: border-color .18s;
}
.field textarea { min-height: 84px; resize: none; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.auth-note { min-height: 18px; margin: 10px 0 0; font-size: 12.5px; color: var(--bad); text-align: center; }
.auth-foot { margin-top: 20px; color: var(--txt-3); font-size: 12px; letter-spacing: .04em; }

/* ==================== 按钮 ==================== */
.btn { height: 46px; padding: 0 18px; border-radius: 13px; font-size: 15px; font-weight: 600; transition: transform .12s, opacity .2s; }
.btn:active { transform: scale(.985); }
.btn.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink); }
.btn.ghost { background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); }
.btn.block { width: 100%; display: block; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 13.5px; border-radius: 11px; }
.btn[disabled] { opacity: .5; }

/* ==================== 主框架 ==================== */
.app {
  height: 100dvh; display: grid;
  grid-template-rows: auto 1fr auto auto;
  background: var(--bg);
}
.topbar {
  height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 8px 0;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 20;
}
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; color: var(--txt-2); flex: none;
}
.icon-btn:active { background: var(--panel-2); }
.brand-chip { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: 100%; }
.brand-name { font-size: 12px; letter-spacing: .16em; color: var(--txt-3); }
.device-line { display: inline-flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 600; max-width: 100%; }
.device-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-3); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.busy { background: var(--accent); animation: pulse 1.4s infinite; }
.dot.off { background: var(--bad); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.page { overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.page-head h2 { margin: 0; font-size: 20px; letter-spacing: .02em; }

/* ==================== 任务流 ==================== */
.stream { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 20px; scroll-behavior: smooth; }
.hero { padding: 26px 6px 18px; text-align: left; position: relative; }
.hero-orb {
  position: absolute; right: -60px; top: -30px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(46, 230, 168, .28), rgba(46, 230, 168, 0) 66%);
  filter: blur(6px); pointer-events: none;
}
.hero h2 { margin: 0 0 10px; font-size: 27px; line-height: 1.34; font-weight: 650; letter-spacing: .01em; }
.hero p { margin: 0; color: var(--txt-2); font-size: 13.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.chips button {
  height: 38px; padding: 0 14px; border-radius: 999px; font-size: 13px; color: var(--txt-2);
  background: var(--panel); border: 1px solid var(--line);
}
.chips button:active { border-color: var(--accent); color: var(--txt); }

.turns { display: flex; flex-direction: column; gap: 14px; }
.turn-me { align-self: flex-end; max-width: 86%; }
.turn-me .bubble {
  background: var(--bubble-me); color: var(--txt); border-radius: 18px 18px 6px 18px;
  padding: 11px 14px; font-size: 14.5px; white-space: pre-wrap; word-break: break-word;
}
.turn-me .meta { text-align: right; font-size: 11px; color: var(--txt-3); margin-top: 4px; }
.turn-ai { align-self: stretch; }
.ai-card {
  background: var(--bubble-ai); border: 1px solid var(--line); border-radius: 18px 18px 18px 6px;
  padding: 12px 14px; font-size: 14.5px;
}
.ai-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 12px; color: var(--txt-3); }
.ai-head .who { color: var(--txt-2); font-weight: 600; letter-spacing: .04em; }
.ai-head .st { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; }
.st-running { color: var(--accent); }
.st-done { color: var(--ok); }
.st-fail { color: var(--bad); }
.st-wait { color: var(--warn); }
.ai-body { white-space: pre-wrap; word-break: break-word; line-height: 1.66; }
.ai-body .cursor { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; animation: blink 1s infinite; }
.ev-log { color: var(--txt-3); font-size: 12.5px; line-height: 1.6; }
.ev-err { color: var(--bad); font-size: 12.5px; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 6px 0 0; padding: 5px 10px;
  border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; color: var(--txt-2); max-width: 100%;
}
.tool b { color: var(--txt); font-weight: 600; }
.tool span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arts { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.art {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt); text-decoration: none; font-size: 13px;
}
.art .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art .sz { color: var(--txt-3); font-size: 11.5px; }
.act-row { display: flex; gap: 8px; margin-top: 11px; }
.act-row button { height: 32px; padding: 0 12px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--txt-2); }
.act-row button.danger { color: var(--bad); }

/* ==================== 输入区 ==================== */
.composer-wrap { padding: 6px 12px 8px; background: linear-gradient(180deg, transparent, var(--bg) 40%); }
.attachments { display: flex; gap: 8px; padding: 0 4px 8px; overflow-x: auto; }
.attachments:empty { display: none; }
.att {
  position: relative; height: 58px; min-width: 58px; border-radius: 11px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--txt-2); padding: 4px; text-align: center;
}
.att img { width: 58px; height: 58px; object-fit: cover; }
.att button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; line-height: 18px; }
.composer {
  display: flex; align-items: flex-end; gap: 2px; padding: 5px 6px 5px 4px;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 24px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}
.composer textarea {
  flex: 1; min-height: 40px; max-height: 132px; padding: 10px 4px; resize: none; border: 0; outline: none;
  background: transparent; font-size: 15.5px; line-height: 1.45;
}
.composer textarea::placeholder { color: var(--txt-3); }
.send {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  transition: opacity .2s, transform .12s;
}
.send:active { transform: scale(.94); }
.send.idle { opacity: .35; pointer-events: none; }
.send.stop { background: var(--panel-2); color: var(--bad); border: 1px solid var(--line-strong); }
.mic.rec { color: var(--bad); }

/* ==================== 底部导航 ==================== */
.tabbar {
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line); backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--txt-3); font-size: 10.5px; letter-spacing: .04em; }
.tab.on { color: var(--accent); }
.tab:active { opacity: .7; }

/* ==================== 列表 / 卡片 ==================== */
.list { flex: 1; overflow-y: auto; padding: 4px 14px 24px; display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.card-row { display: flex; align-items: center; gap: 10px; }
.card-row .grow { flex: 1; min-width: 0; }
.card h3 { margin: 0 0 3px; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card p { margin: 0; color: var(--txt-2); font-size: 12.5px; }
.card .sub { color: var(--txt-3); font-size: 11.5px; margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 7px; background: var(--panel-2); font-size: 11px; color: var(--txt-2); }
.tag.on { color: var(--ok); }
.tag.off { color: var(--bad); }
.tip { margin: 6px 18px 18px; color: var(--txt-3); font-size: 12px; line-height: 1.7; }
.empty { text-align: center; color: var(--txt-3); font-size: 13px; padding: 48px 20px; line-height: 1.8; }

/* ==================== 抽屉 ==================== */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; transition: opacity .25s; }
.scrim.on { opacity: 1; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(84vw, 340px); z-index: 50;
  background: var(--bg-soft); border-right: 1px solid var(--line);
  transform: translateX(-102%); transition: transform .28s cubic-bezier(.22, .8, .3, 1);
  display: flex; flex-direction: column; padding: calc(var(--safe-t) + 10px) 14px calc(var(--safe-b) + 14px);
}
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.search {
  width: 100%; height: 40px; margin: 10px 0; padding: 0 13px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line); outline: none; font-size: 14px;
}
.drawer-list { flex: 1; overflow-y: auto; margin: 0 -4px; }
.ditem { display: flex; align-items: center; gap: 9px; padding: 11px 8px; border-radius: 11px; }
.ditem:active { background: var(--panel-2); }
.ditem .t { flex: 1; min-width: 0; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ditem .h { font-size: 11px; color: var(--txt-3); flex: none; }
.ditem .pin { color: var(--accent); font-size: 11px; }
.dgroup { color: var(--txt-3); font-size: 11px; letter-spacing: .08em; padding: 12px 8px 4px; }

/* ==================== 底部弹层 ==================== */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: var(--bg-soft); border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  transform: translateY(102%); transition: transform .3s cubic-bezier(.22, .8, .3, 1);
  max-height: 86dvh; display: flex; flex-direction: column;
  padding-bottom: calc(var(--safe-b) + 12px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .4);
}
.sheet.on { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; font-size: 15px; font-weight: 600; }
.sheet-head::before { content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 36px; height: 4px; border-radius: 3px; background: var(--line-strong); }
.sheet-body { padding: 0 16px 8px; overflow-y: auto; }
#deviceSheetList, #pairBody { padding: 0 12px 8px; overflow-y: auto; }
.drow { display: flex; align-items: center; gap: 11px; padding: 13px 10px; border-radius: 13px; }
.drow:active { background: var(--panel-2); }
.drow .ic { width: 38px; height: 38px; border-radius: 11px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--txt-2); flex: none; }
.drow .grow { flex: 1; min-width: 0; }
.drow .nm { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drow .st { font-size: 11.5px; color: var(--txt-3); margin-top: 2px; }
.drow.sel { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.pair-code {
  font: 600 30px/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .22em;
  text-align: center; padding: 16px 0 10px; color: var(--accent);
}
.pair-cmd {
  font: 12px/1.6 ui-monospace, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; color: var(--txt-2); word-break: break-all; margin: 8px 0;
}
.row { display: flex; gap: 10px; }
.row .field { flex: 1; }

/* ==================== 语音浮层 / 提示 ==================== */
.rec {
  position: fixed; inset: 0; z-index: 70; background: var(--scrim); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px;
}
.rec-wave { display: flex; align-items: flex-end; gap: 5px; height: 64px; }
.rec-wave i { width: 6px; border-radius: 4px; background: var(--accent); animation: wave 0.9s ease-in-out infinite; }
.rec-wave i:nth-child(1) { height: 22px; animation-delay: 0s; }
.rec-wave i:nth-child(2) { height: 40px; animation-delay: .1s; }
.rec-wave i:nth-child(3) { height: 58px; animation-delay: .2s; }
.rec-wave i:nth-child(4) { height: 34px; animation-delay: .3s; }
.rec-wave i:nth-child(5) { height: 50px; animation-delay: .4s; }
.rec-wave i:nth-child(6) { height: 26px; animation-delay: .5s; }
.rec-wave i:nth-child(7) { height: 44px; animation-delay: .6s; }
@keyframes wave { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }
.rec p { margin: 0; color: #fff; font-size: 14px; letter-spacing: .06em; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 92px); transform: translate(-50%, 12px);
  background: rgba(20, 26, 34, .96); color: #fff; border: 1px solid rgba(255, 255, 255, .12);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 80; max-width: 86vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 宽屏（iPad / 桌面预览）时收窄，避免一行字太长 */
@media (min-width: 720px) {
  .app, .auth { max-width: 520px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .drawer { left: calc(50% - 260px); }
}

/* ============ 微信登录入口 ============
 * 用主题里的 --accent（薄荷）而不是微信绿：这是深世影的登录页，
 * 微信只是登录方式之一，不该让整个页面看起来像微信的产品。
 * 但保留一个可识别的小标记（.wx-ic），不然用户会不知道这条路通向微信。
 */
.wx-login { margin-bottom: 14px; }
.btn.wx {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  font-weight: 600;
  box-shadow: 0 8px 22px -12px var(--accent);
}
.btn.wx:active { transform: scale(.99); }
.btn.wx[disabled] { opacity: .5; pointer-events: none; }
.wx-ic {
  width: 22px; height: 22px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .18); color: var(--accent-ink);
  font-size: 12px; font-weight: 700; letter-spacing: -.5px;
}
.wx-tip { margin: 8px 2px 0; font-size: 12px; color: var(--txt-3); text-align: center; line-height: 1.5; }

/* 「或使用邮箱」分隔线：有微信入口时才出现 */
.auth-div {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 12px; color: var(--txt-3); font-size: 12px;
}
.auth-div::before, .auth-div::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

/* 微信授权结果提示条（回调回来时用一次，不占常驻空间） */
.wx-banner {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.5;
  border: 1px solid var(--line); background: var(--panel);
}
.wx-banner.ok { border-color: var(--accent); color: var(--accent); }
.wx-banner.bad { border-color: var(--bad); color: var(--bad); }
