/* 语音助手 · 手机端样式
   目标：单手持机、一根大拇指能按到所有东西；深色为主，夜里看不刺眼。 */

:root {
  --bg: #0b1020;
  --bg-soft: #131a2e;
  --bg-card: #171f36;
  --line: #253052;
  --text: #e8ecf8;
  --muted: #8d9ac0;
  --accent: #4c8dff;
  --accent-soft: #2a4a8f;
  --ok: #33d17a;
  --warn: #ffb454;
  --err: #ff6b6b;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
    overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); font-size: 14px; }

/* ---------- 顶栏 ---------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: rgba(11, 16, 32, .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.bar-left, .bar-right { display: flex; align-items: center; gap: 8px; }
#title { font-weight: 600; letter-spacing: .5px; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 rgba(51, 209, 122, .6);
}
.dot.on { background: var(--ok); animation: pulse 2s infinite; }
.dot.off { background: var(--err); }
.dot.busy { background: var(--warn); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(51, 209, 122, .5); }
  70% { box-shadow: 0 0 0 8px rgba(51, 209, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(51, 209, 122, 0); }
}

.icon-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; padding: 6px 8px; border-radius: 10px; cursor: pointer;
}
.icon-btn:active { background: var(--bg-soft); }
.icon-btn.big { font-size: 22px; padding: 10px; }

/* ---------- 屏幕 ---------- */

.screen { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* ---------- 配对 ---------- */

#screenPair { justify-content: center; padding: 24px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card h2 { margin: 0 0 8px; font-size: 20px; }

.pin {
  width: 100%;
  margin: 16px 0 6px;
  padding: 14px 16px;
  font-size: 24px;
  letter-spacing: 8px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
}
.pin:focus { outline: none; border-color: var(--accent); }

.selfcert { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.selfcert summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.selfcert summary:active { color: var(--text); }
.selfcert p { margin: 10px 0 0; }
.selfcert .dl {
  display: inline-block;
  margin-top: 4px;
  padding: 9px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}

button.primary {
  width: 100%;
  margin-top: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
button.primary:active { background: var(--accent-soft); }
button.primary.small { width: auto; margin: 0; padding: 10px 16px; font-size: 15px; }

/* ---------- 对话记录 ---------- */

.log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.empty {
  margin: auto;
  text-align: center;
  padding: 20px;
  max-width: 340px;
}

.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.note { align-self: center; background: transparent; color: var(--muted); font-size: 13px; padding: 4px; }
.msg.err { align-self: center; background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .35); color: var(--err); font-size: 14px; }
.msg .meta { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.typing::after {
  content: '…';
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- 确认条 ---------- */

.confirm-wrap { padding: 0 16px 8px; }
.confirm {
  background: rgba(255, 180, 84, .12);
  border: 1px solid rgba(255, 180, 84, .5);
  border-radius: 14px;
  padding: 14px;
}
.confirm h4 { margin: 0 0 6px; font-size: 15px; color: var(--warn); }
.confirm p { margin: 0 0 12px; font-size: 14px; word-break: break-all; }
.confirm-row { display: flex; gap: 10px; }
.confirm-row button { flex: 1; padding: 11px; border-radius: 10px; border: none; font-size: 15px; font-weight: 600; cursor: pointer; }
.confirm-row .yes { background: var(--warn); color: #3a2400; }
.confirm-row .no { background: var(--bg-soft); color: var(--text); }

/* ---------- 底部操作区 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 8px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: rgba(11, 16, 32, .9);
  backdrop-filter: blur(12px);
}

.status {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  min-height: 20px;
  margin-bottom: 8px;
}
.status.active { color: var(--accent); }

.composer-row { display: flex; align-items: center; justify-content: center; gap: 22px; }

.call {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(76, 141, 255, .35);
  transition: transform .12s ease, box-shadow .2s ease;
}
.call:active { transform: scale(.94); }
.call.rec { background: linear-gradient(160deg, #ff6b6b, #d64545); box-shadow: 0 10px 30px rgba(255, 107, 107, .4); }
.call.busy { background: linear-gradient(160deg, #6b7280, #4b5563); box-shadow: none; }

.call-ring {
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(255, 107, 107, .7);
  opacity: 0;
}
.call.rec .call-ring { animation: ring 1.4s ease-out infinite; opacity: 1; }
@keyframes ring {
  0% { transform: scale(.9); opacity: .9; }
  100% { transform: scale(1.25); opacity: 0; }
}

.text-row { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.text-row textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.text-row textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- 设置抽屉 ---------- */

.drawer {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, .96);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 0 0;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h3 { margin: 0; font-size: 17px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv .k { color: var(--muted); flex: 0 0 auto; }
.kv .v { text-align: right; word-break: break-all; }

.group { margin-bottom: 22px; }
.group h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

select, input.plain {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: rgba(51, 209, 122, .15); color: var(--ok); }
.badge.bad { background: rgba(255, 107, 107, .15); color: var(--err); }
.badge.warn { background: rgba(255, 180, 84, .15); color: var(--warn); }

.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row button {
  flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 15px; cursor: pointer;
}
.btn-row button.danger { border-color: rgba(255, 107, 107, .5); color: var(--err); }

a.dl {
  display: inline-block;
  padding: 10px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent);
  text-decoration: none;
  font-size: 15px;
}

/* ---------- 打字开关 ---------- */

.text-toggle {
  display: block;
  margin: 10px auto 0;
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.text-toggle:active { color: var(--text); }

/* ---------- 附件 ---------- */

.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.attach-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 210px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 13px;
}
.chip.uploading { opacity: .6; }
.chip.failed { border-color: rgba(255,107,107,.5); }
.chip img { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; flex: 0 0 auto; }
.chip .chip-icon { font-size: 20px; flex: 0 0 auto; }
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .chip-size { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.chip .chip-x {
  flex: 0 0 auto; width: 20px; height: 20px; line-height: 18px; text-align: center;
  border-radius: 50%; background: var(--bg-soft); color: var(--muted);
  border: none; font-size: 13px; cursor: pointer; padding: 0;
}

/* 消息里带的附件说明 */
.msg .attach-note {
  display: block; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12px; opacity: .85;
}

/* 模型发过来的文件卡片 */
.file-card {
  align-self: flex-start;
  display: flex; align-items: center; gap: 12px;
  max-width: 88%;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--accent-soft);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
}
.file-card:active { background: var(--bg-soft); }
.file-card .card-icon { font-size: 26px; flex: 0 0 auto; }
.file-card .card-body { min-width: 0; flex: 1 1 auto; }
.file-card .card-name { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .card-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.file-card .card-action { flex: 0 0 auto; color: var(--accent); font-size: 13px; }

/* ---------- 登录 ---------- */

/* 登录页不列账号：账号名、口令都手输。 */

#setupBox, #registerBox { margin-top: 4px; }

/* .pin 是给"6 位数字口令"调的（24px、字距 8px），账号口令是普通文本，
   照搬那套会又大又散，这里改回正常输入框的样子。 */
#loginBox .pin, #setupBox .pin, #registerBox .pin, #passwordBox .pin {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: normal;
  text-align: left;
}

#accountName { margin-bottom: 10px; }

/* 改口令成功后的提示：绿一点，跟错误提示区分开 */
#passwordOk { color: var(--ok, #4ec9a0); margin-bottom: 10px; }

.plain {
  width: 100%; padding: 13px 15px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font: inherit; font-size: 16px;
}
.plain:focus { outline: none; border-color: var(--accent); }

/* ===========================================================================
   浮层对话框（新建账号等表单用）

   为什么单独做一套而不是复用 .drawer：
     drawer 是整屏的（inset:0），适合"看信息"；
     而建账号这种是"填完就走"的小表单，整屏会显得很重，
     而且会盖住背后的列表 —— 用户填的时候还想对照着看。
     所以做成居中的浮层卡片。
   =========================================================================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, .72);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  /* 手机上键盘弹出来时，让内容能滚上去，不然输入框会被挡住 */
  overflow-y: auto;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h3 { margin: 0 0 6px; font-size: 18px; }
.modal-box p { margin: 0 0 12px; }
.modal-box input.plain,
.modal-box input.pin {
  margin: 8px 0;
  /* 复用了 .pin 的样式（它是给验证码用的，字大间距宽），
     但这里要输的是普通密码，改回正常字号 */
  font-size: 16px;
  letter-spacing: normal;
  text-align: left;
}
.modal-box .btn-row { margin-top: 16px; display: flex; gap: 10px; justify-content: flex-end; }
.modal-box .btn-row button { min-width: 88px; }

/* ===========================================================================
   对话功能关闭时的覆盖层

   z-index 取 40，故意低于抽屉的 50 ——
   这样"打开设置"之后抽屉盖在上面，账号和存储管理照常能用。
   =========================================================================== */
.chat-off-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.chat-off-box {
  max-width: 460px;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 26px;
}
.chat-off-icon { font-size: 42px; line-height: 1; margin-bottom: 14px; }
.chat-off-box h3 { margin: 0 0 12px; font-size: 19px; }
.chat-off-box p { margin: 0 0 10px; font-size: 14px; line-height: 1.65; }
.chat-off-box .chat-off-ok { color: var(--muted); }
.chat-off-box code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.chat-off-box button { margin-top: 16px; min-width: 120px; }
