/* ============================================================
   AI 查询系统 —— 用户端样式
   ============================================================ */

:root {
  --bg: #ffffff;
  --panel: #f7f8fa;
  --side: #fbfbfc;
  --line: #e9ebef;
  --line-soft: #f0f1f4;
  --text: #14161a;
  --text-2: #5c6270;
  --text-3: #8d929d;
  --accent: #2f6bff;
  --accent-ink: #1f56e0;
  --accent-soft: #eef3ff;
  --danger: #d33b3b;
  --ok: #0f7b3e;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d9dbe0; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #c3c6cd; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------ 登录 */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, #eef3ff 0%, rgba(255, 255, 255, 0) 62%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 372px;
  padding: 34px 30px 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.brand-mark {
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 21px;
  color: #fff;
  background: linear-gradient(140deg, #4f83ff, #2f6bff);
  box-shadow: 0 6px 16px rgba(47, 107, 255, .28);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .2px;
}

.login-sub {
  margin: 0 0 22px;
  font-size: 13px;
  color: var(--text-3);
}

.field { display: block; margin-bottom: 12px; }

.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  letter-spacing: .6px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  text-align: center;
}

.field input::placeholder { color: #b8bcc5; letter-spacing: 1px; }

.field input:focus {
  border-color: #c2d4ff;
  box-shadow: 0 0 0 4px rgba(47, 107, 255, .1);
}

.btn-primary {
  position: relative;
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background .15s, transform .06s;
}

.btn-primary:hover { background: var(--accent-ink); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: .7; cursor: default; }

.btn-spin {
  position: absolute;
  right: 16px;
  top: 50%;
  width: 15px;
  height: 15px;
  margin-top: -7.5px;
  border: 2px solid rgba(255, 255, 255, .4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.login-err {
  min-height: 18px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.5;
}

.login-foot {
  margin-top: 14px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--text-3);
}

.login-foot .sep { margin: 0 6px; }

/* 登录页公告 */
.login-stack {
  width: 100%;
  max-width: 372px;
}

.login-stack .login-card { max-width: none; }

.login-notice {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.ln-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text);
}

.ln-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ln-body {
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 侧栏公告 */
.notice-box {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px 14px;
}

.notice-item {
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.notice-item.pinned {
  border-color: #c2d4ff;
  background: #f9fbff;
}

.notice-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 3px;
}

.notice-title {
  flex: 1;
  min-width: 0;
  font-size: 12.8px;
  font-weight: 650;
  line-height: 1.5;
  word-break: break-word;
}

.notice-pin {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  line-height: 1.6;
  white-space: nowrap;
}

.notice-time {
  display: block;
  margin-bottom: 6px;
  font-size: 10.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.notice-body {
  font-size: 12.4px;
  line-height: 1.8;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.notice-empty {
  padding: 30px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.8;
}

.tab-badge {
  display: inline-block;
  min-width: 15px;
  height: 15px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 9.5px;
  line-height: 15px;
  text-align: center;
  vertical-align: middle;
}

/* ------------------------------------------------------------ 布局 */
.app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* ------------------------------------------------------------ 侧栏 */
.sidebar {
  width: 268px;
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--line);
}

.side-head {
  padding: 18px 18px 14px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: .3px;
}

.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(140deg, #4f83ff, #2f6bff);
}

#siteName {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 4px;
  margin: 0 14px 12px;
  padding: 4px;
  background: #f0f1f5;
  border-radius: 10px;
}

.tab {
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.8px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.tab-ink { display: none; }

.panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
}

.new-chat {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 8px;
  border: 1px dashed #d9dce4;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.new-chat:hover {
  border-color: #bcccff;
  color: var(--accent);
  background: #f6f9ff;
}

.new-chat .plus { font-size: 14px; line-height: 1; }

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 10px;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13.2px;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}

.conv-item:hover { background: #f1f2f6; }

.conv-item.active {
  background: #fff;
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.conv-item .t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-item .del {
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.conv-item:hover .del { opacity: 1; }
.conv-item .del:hover { color: var(--danger); }

.conv-empty {
  padding: 18px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.7;
}

/* 我的 */
.me-box {
  padding: 4px 2px 14px;
  overflow-y: auto;
}

.me-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  margin-bottom: 12px;
}

.me-card-head {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.me-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  font-size: 12.8px;
  border-bottom: 1px solid var(--line-soft);
}

.me-row:last-child { border-bottom: 0; }
.me-row .k { color: var(--text-3); flex: 0 0 auto; }
.me-row .v { text-align: right; font-weight: 550; word-break: break-all; }
.me-row .v.num { font-variant-numeric: tabular-nums; }
.me-row .v.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.8px; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #e8f7ee;
  color: var(--ok);
}

.badge.warn { background: #fff5e6; color: #b45309; }
.badge.off { background: #fdecec; color: #c02626; }

.me-note {
  padding: 11px 13px;
  border-radius: 10px;
  background: #f7f8fa;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-3);
}

.side-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--text-3);
}

.key-chip {
  padding: 3px 8px;
  border-radius: 6px;
  background: #eff0f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 0;
}

.link-btn:hover { color: var(--danger); }

/* ------------------------------------------------------------ 主区 */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 54px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-soft);
  flex: 0 0 auto;
}

.topbar h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  flex: 0 0 auto;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c9ccd3;
  transition: background .2s;
}

.live-dot.busy { background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.live-dot.err { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}

/* 消息区 */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 24px 6px;
  scroll-behavior: auto;
  overscroll-behavior: contain;
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 800px;
  margin: 0 auto 20px;
  animation: rise .22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.msg.user { justify-content: flex-end; }

.msg-avatar {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  margin-top: 2px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

.bubble-user {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-ai {
  max-width: calc(100% - 40px);
  padding: 12px 15px;
  border-radius: 4px 14px 14px 14px;
  background: var(--panel);
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  word-break: break-word;
}

.bubble-ai p { margin: 0 0 10px; }
.bubble-ai p:last-child { margin-bottom: 0; }
.bubble-ai ul { margin: 6px 0 10px; padding-left: 20px; }
.bubble-ai li { margin: 3px 0; }
.bubble-ai strong { font-weight: 650; }
.bubble-ai code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #eef0f3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .92em;
}
.bubble-ai pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef0f3;
  overflow-x: auto;
}
.bubble-ai pre code { padding: 0; background: transparent; font-size: 12.5px; }

.bubble-ai.error {
  background: #fff5f5;
  color: #a82323;
}

/* 工具调用卡片 */
.tool-wrap { max-width: 800px; margin: 0 auto 14px; display: flex; gap: 10px; }

.tool-card {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}

.tool-head { display: flex; align-items: center; gap: 8px; }

.tool-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
}

.tool-name { font-size: 12.8px; font-weight: 600; }
.tool-detail { font-size: 12px; color: var(--text-3); margin-left: auto; text-align: right; }

.tool-card.error { border-color: #f4d0d0; background: #fffafa; }
.tool-card.error .tool-icon { color: var(--danger); background: #fdecec; }
.tool-card.error .tool-detail { color: var(--danger); }

.tool-args {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}

.mini-spin {
  width: 11px;
  height: 11px;
  border: 2px solid #d7e2ff;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

/* 附件 */
.attach-grid {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.attach-img {
  display: block;
  max-width: 340px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: zoom-in;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  text-decoration: none;
  transition: border-color .15s, color .15s, box-shadow .15s;
}

.file-chip:hover { border-color: #bfd2ff; color: var(--accent); box-shadow: 0 2px 10px rgba(47,107,255,.08); }
.file-chip .fi { font-size: 14px; }
.file-chip .fs { color: var(--text-3); font-size: 11.5px; }
.file-chip .fd { color: var(--text-3); font-size: 11.5px; margin-left: 4px; }

/* 输入中 */
.typing { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #b6bcc8;
  animation: blink 1.1s infinite;
}
.typing i:nth-child(2) { animation-delay: .16s; }
.typing i:nth-child(3) { animation-delay: .32s; }

@keyframes blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* 空状态 */
.empty {
  max-width: 560px;
  margin: 9vh auto 0;
  text-align: center;
  padding: 0 10px;
}

.empty-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: var(--accent);
  background: var(--accent-soft);
}

.empty h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 650;
}

.empty p {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.8;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 22px;
}

.chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 12.8px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}

.chip:hover { border-color: #c2d4ff; color: var(--accent); background: #f8faff; }

/* 输入框 */
.composer {
  flex: 0 0 auto;
  padding: 8px 24px 16px;
  background: linear-gradient(to top, #fff 62%, rgba(255, 255, 255, 0));
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 800px;
  margin: 0 auto;
  padding: 7px 8px 7px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}

.composer-box:focus-within {
  border-color: #c2d4ff;
  box-shadow: 0 0 0 4px rgba(47, 107, 255, .08);
}

.composer-box textarea {
  flex: 1;
  min-height: 24px;
  max-height: 168px;
  padding: 6px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.composer-box textarea::placeholder { color: #b3b8c2; }

.send {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.send:hover { background: var(--accent-ink); }
.send[disabled] { background: #e6e8ed; color: #b9bdc6; cursor: default; }

.composer-tip {
  max-width: 800px;
  margin: 6px auto 0;
  font-size: 11px;
  color: #b3b8c2;
  text-align: center;
  user-select: none;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 12px);
  padding: 9px 16px;
  border-radius: 10px;
  background: rgba(20, 22, 26, .92);
  color: #fff;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 80vw;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 图片放大 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 14, 18, .86);
  display: grid;
  place-items: center;
  padding: 30px;
  cursor: zoom-out;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 820px) {
  .app { flex-direction: column; }

  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-head { padding: 12px 14px 10px; }
  .tabs { margin: 0 12px 10px; }

  .panel { padding: 0 8px; flex: 0 0 auto; }
  #panelChat { max-height: 30vh; }
  #panelMe { max-height: 42vh; }

  .conv-list { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding-bottom: 8px; }
  .conv-item { flex: 0 0 auto; max-width: 190px; background: #fff; border: 1px solid var(--line); }
  .conv-item.active { border-color: #c2d4ff; }
  .conv-item .del { opacity: 1; }
  .new-chat { margin-bottom: 6px; }

  .side-foot { display: none; }

  .topbar { height: 48px; padding: 0 16px; }
  .messages { padding: 18px 14px 4px; }
  .composer { padding: 6px 14px 12px; }
  .bubble-user { max-width: 88%; }
  .bubble-ai { max-width: calc(100% - 36px); }
  .empty { margin-top: 4vh; }
  .attach-img { max-width: 100%; }
}

/* ============================================================
   授权码浮层（简约版）/ 公告弹窗 / 移动端抽屉
   后置覆盖，前面的 .login-* 旧样式已不再使用
   ============================================================ */
body.locked { overflow: hidden; }

.side-mask {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(18, 22, 30, .34);
}

.nav-toggle,
.side-close {
  display: none;
}

.veil {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(22, 26, 36, .34);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: veilIn .16s ease-out;
}

@keyframes veilIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: 100%;
  max-width: 330px;
  padding: 22px 20px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(16, 22, 36, .22);
  animation: sheetIn .18s ease-out;
}

@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.sheet-title {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--text);
}

.lm-form { margin: 0; }

.lm-input {
  display: block;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  letter-spacing: .6px;
  color: var(--text);
  text-align: center;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.lm-input::placeholder { color: #b9bdc6; letter-spacing: 1px; }

.lm-input:focus {
  border-color: #b9cdff;
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}

.lm-btn {
  position: relative;
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.lm-btn:hover { background: var(--accent-ink); }
.lm-btn[disabled] { opacity: .65; cursor: default; }

.lm-err {
  min-height: 16px;
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
}

.lm-note-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 14px;
  padding: 10px 0 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-3);
  cursor: pointer;
}

.lm-chev {
  font-size: 10px;
  transition: transform .15s;
}

.lm-note-toggle.open .lm-chev { transform: rotate(180deg); }

.lm-note {
  margin-top: 8px;
  max-height: 30vh;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 公告弹窗 */
.sheet-ann {
  max-width: 420px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sheet-head .sheet-title { margin: 0; }

.sheet-x {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 17px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
}

.sheet-x:hover { background: #f5f6f8; color: var(--text); }

.ann-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0 -2px;
  padding: 0 2px;
}

.ann-item {
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.ann-item:first-child { padding-top: 0; border-top: 0; }

.ann-item-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ann-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.ann-item-body {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.sheet-ann .lm-btn { margin-top: 14px; }

@media (prefers-reduced-motion: reduce) {
  .veil, .sheet { animation: none; }
  .sidebar { transition: none; }
}

/* 移动端：侧栏改抽屉，登录弹窗贴合适配 */
@media (max-width: 820px) {
  .app { flex-direction: row; }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-right: 6px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
  }

  .nav-toggle:active { background: #f1f3f7; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: 84%;
    max-width: 300px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    transform: translateX(-101%);
    transition: transform .22s ease;
    box-shadow: 0 12px 40px rgba(16, 22, 36, .18);
    will-change: transform;
  }

  body.nav-open .sidebar { transform: none; }

  .side-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 8px;
    background: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-3);
    cursor: pointer;
  }

  .side-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 10px;
  }

  .panel {
    padding: 0 10px;
    flex: 1 1 auto;
    min-height: 0;
  }

  #panelChat, #panelMe, #panelNotice { max-height: none; }

  .conv-list {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 8px;
  }

  .conv-item { max-width: none; background: transparent; border: 0; }
  .conv-item.active { background: #fff; border: 1px solid var(--line); }

  .side-foot { display: flex; }

  .main { width: 100%; flex: 1 1 auto; }

  .topbar {
    height: 50px;
    padding: 0 12px;
    gap: 8px;
  }

  .topbar h2 { font-size: 14.5px; }

  .live { font-size: 11.5px; }

  .veil { padding: 16px; align-items: center; }

  .sheet {
    max-width: 340px;
    padding: 20px 18px 16px;
    border-radius: 14px;
  }

  .sheet-ann { max-width: 100%; max-height: 82vh; }

  .lm-input, .lm-btn { height: 44px; font-size: 15px; }

  .composer-tip { display: none; }
  .composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .messages { padding: 14px 12px 4px; }
  .bubble-user, .bubble-ai { max-width: 90%; }
  .attach-img { max-width: 100%; }
  .empty { margin-top: 6vh; }
}

@media (max-width: 380px) {
  .sheet { padding: 18px 14px 14px; }
  .topbar { padding: 0 10px; }
  .live span:last-child { display: none; }
}


/* 自定义头像 */
.msg-avatar.has-img { padding: 0; overflow: hidden; background: transparent; }
.msg-avatar.has-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

/* ------------------------------------------------------------
   顺滑度：只加过渡与动效，不改布局
   ------------------------------------------------------------ */
.conv-item, .chip, .tab, .btn-primary, .send-btn, .icon-btn {
  transition: background-color .16s ease, border-color .16s ease, color .16s ease,
              box-shadow .16s ease, transform .12s ease, opacity .16s ease;
}
.chip:hover { transform: translateY(-1px); }
.conv-item:active, .chip:active { transform: scale(.985); }
.msg { animation-duration: .2s; animation-timing-function: cubic-bezier(.2, .7, .3, 1); }
.bubble-ai, .bubble-user, .tool-card {
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.messages { scrollbar-gutter: stable; }
.tab { position: relative; }
.tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: -1px; width: 18px; height: 2px;
  background: var(--accent); border-radius: 2px; transform: translateX(-50%);
  animation: tabIn .18s ease-out;
}
@keyframes tabIn { from { opacity: 0; transform: translateX(-50%) scaleX(.4); } to { opacity: 1; transform: translateX(-50%) scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .conv-item, .chip, .tab, .btn-primary, .send-btn, .icon-btn, .bubble-ai, .bubble-user, .tool-card {
    transition: none;
  }
  .msg { animation: none; }
  .tab.active::after { animation: none; }
}

/* ------------------------------------------------------------
   移动端点按：去掉浏览器默认蓝色高亮闪一下（不影响键盘焦点框）
   ------------------------------------------------------------ */
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
a, button, input, select, textarea, label,
.tab, .chip, .conv-item, .send-btn, .icon-btn, .adm-nav-item, .btn-primary, .btn-ghost, .btn-danger {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, .tab, .chip, .conv-item, .send-btn, .btn-primary, .btn-ghost, .btn-danger {
  -webkit-user-select: none;
  user-select: none;
}
/* 鼠标点击不再留焦点环，键盘 Tab 仍然有 */
button:focus, a:focus, .tab:focus, .chip:focus, .conv-item:focus, input:focus, select:focus, textarea:focus {
  outline: none;
}
button:focus-visible, a:focus-visible, .tab:focus-visible, .chip:focus-visible,
.conv-item:focus-visible, .btn-primary:focus-visible, .btn-ghost:focus-visible, .btn-danger:focus-visible {
  outline: 2px solid var(--accent, #2f6bff);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; /* 输入控件已有边框高亮，避免双层 */
}

/* ------------------------------------------------------------
   登录按钮：转圈 + 校验中的实感
   ------------------------------------------------------------ */
.lm-btn { position: relative; }
.lm-btn.loading { background: #3f7bff; }
.lm-btn.loading .btn-label { opacity: .9; }
.lm-btn .btn-spin {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.lm-btn .btn-spin[hidden] { display: none; }

/* 错误提示轻微抖动 */
.lm-err.shake { animation: shake .32s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

/* ------------------------------------------------------------
   输入框：首行文字不再被裁切
   ------------------------------------------------------------ */
.composer-box { padding: 6px 8px 6px 14px; }
.composer-box textarea {
  min-height: 26px;
  padding: 7px 0;
  line-height: 1.55;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: content-box;
  -webkit-appearance: none;
}
@media (max-width: 820px) {
  .composer-box textarea { font-size: 16px; line-height: 1.5; }  /* 防 iOS 聚焦缩放 */
}
