/* ============================================================
   审批台 · 白底优雅
   设计语言：纯白底 / 墨色文字 / 靛蓝点缀 / 发丝线边框 / 轻投影
   ============================================================ */
:root {
  --bg: #fafafa;
  --card: #ffffff;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #a1a1aa;
  --line: #e8e8ec;
  --line-2: #f1f1f4;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0fe;
  --accent-hover: #4338ca;
  --ok: #16a34a;
  --warn: #dc2626;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .04), 0 4px 16px rgba(24, 24, 27, .05);
  --shadow-lift: 0 2px 6px rgba(24, 24, 27, .06), 0 12px 32px rgba(24, 24, 27, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* 防止组件级 display 规则覆盖 hidden 属性（遮罩层泄漏问题） */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d9d9de; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c4c4cb; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; }
input, select, textarea { font-family: inherit; color: var(--ink); }

/* ------------------------------------------------------------ 通用按钮 */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--radius-s);
  padding: 8px 16px;
  font-size: 13.5px;
  cursor: pointer;
  transition: all .16s ease;
}
.btn:hover { border-color: #c9c9d1; background: #f7f7f9; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 3px rgba(79, 70, 229, .3);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.wide { width: 100%; }

/* ------------------------------------------------------------ 登录层 */
.login-layer {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 340px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px 32px;
  text-align: center;
  animation: rise .4s ease;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-card h1 { font-size: 20px; font-weight: 650; letter-spacing: .02em; margin-top: 18px; }
.login-sub { color: var(--ink-3); font-size: 12.5px; margin: 4px 0 26px; }
#login-token {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 14px; font-size: 14px; outline: none; text-align: center;
  letter-spacing: .06em; transition: border-color .16s, box-shadow .16s;
}
#login-token:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#login-btn { margin-top: 14px; }
.login-err { color: var(--warn); font-size: 12.5px; min-height: 18px; margin-top: 12px; }

/* ------------------------------------------------------------ 史莱姆 */
/* 半圆身 + 白眼底黑瞳，浅色主题下用柔和粉彩 */
.login-slime, .logo-slime, .im-empty-slime {
  width: 72px; height: 40px; margin: 0 auto;
  background: linear-gradient(180deg, #a5b4fc 0%, #818cf8 100%);
  border-radius: 72px 72px 14px 14px / 100% 100% 18% 18%;
  border: 2px solid #6366f1;
  position: relative;
  box-shadow: inset 0 -6px 12px rgba(67, 56, 202, .18);
}
.logo-slime { width: 30px; height: 17px; border-width: 1.5px; margin: 0; }
.im-empty-slime { width: 96px; height: 54px; border-radius: 96px 96px 18px 18px / 100% 100% 18% 18%; }
.eyes { position: absolute; left: 0; right: 0; top: 38%; display: flex;
        justify-content: center; gap: 26%; }
.logo-slime .eyes { gap: 24%; }
.eyes i {
  width: 7px; height: 9px; background: #fff; border-radius: 50%;
  position: relative; overflow: hidden;
  box-shadow: inset 0 0 0 1.5px rgba(24, 24, 27, .12);
  transition: transform .9s cubic-bezier(.4, .1, .3, 1);
}
.eyes i::after {
  content: ""; position: absolute; left: 18%; top: 22%;
  width: 58%; height: 60%; background: #18181b; border-radius: 50%;
}
.logo-slime .eyes i { width: 5px; height: 6px; }
.im-empty-slime .eyes i { width: 9px; height: 12px; }

/* 会话头像（好友栏） */
.avatar.slime {
  width: 44px; height: 25px; flex: none;
  border-radius: 44px 44px 8px 8px / 100% 100% 20% 20%;
  border: 1.5px solid rgba(24, 24, 27, .35);
  position: relative;
}
.avatar.slime .eyes { gap: 24%; top: 34%; }
.avatar.slime .eyes i { width: 6px; height: 8px; }
.avatar.sm { width: 34px; height: 20px; border-radius: 34px 34px 6px 6px / 100% 100% 20% 20%; }
.avatar.sm .eyes i { width: 5px; height: 6px; }

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

/* 侧栏 */
.side {
  width: 328px; flex: none; display: flex; flex-direction: column;
  background: var(--card); border-right: 1px solid var(--line);
}
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 12px;
}
.side-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 650; letter-spacing: .01em;
}
.daemon-dot {
  font-size: 11.5px; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 5px;
}
.daemon-dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #d4d4d8; transition: background .3s;
}
.daemon-dot.on { color: var(--ok); }
.daemon-dot.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.daemon-dot.off::before { background: #f59e0b; }

.side-search { padding: 0 14px 8px; }
.side-search input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 8px 12px; font-size: 13px; outline: none; background: #fafafa;
  transition: border-color .16s, background .16s, box-shadow .16s;
}
.side-search input:focus {
  border-color: var(--accent); background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.side-filters {
  display: flex; gap: 8px; padding: 0 14px 10px;
}
.side-filters select {
  flex: 1; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font-size: 12px; color: var(--ink-2);
  background: #fff; outline: none; cursor: pointer;
  max-width: 50%;
}

/* 好友列表 */
.buddy-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.buddy {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 10px; border-radius: var(--radius-s);
  cursor: pointer; position: relative;
  transition: background .14s;
  border: 1px solid transparent;
}
.buddy:hover { background: #f6f6f8; }
.buddy.active { background: var(--accent-soft); border-color: #dfe3fd; }
.buddy-ava {
  width: 48px; height: 40px; flex: none;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 4px;
  position: relative;
}
.buddy.unread .buddy-ava::after {
  content: ""; position: absolute; right: 2px; top: 0;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--warn); border: 2px solid #fff;
}
.buddy-mid { flex: 1; min-width: 0; }
.buddy-name {
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.buddy-sub { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.buddy-prev {
  font-size: 12px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.buddy-prev .kind { margin-right: 4px; }
.buddy-time { font-size: 11px; color: var(--ink-3); flex: none; align-self: flex-start; margin-top: 2px; }
.side-empty { color: var(--ink-3); font-size: 12.5px; text-align: center; padding: 40px 0; }

/* ------------------------------------------------------------ 会话区 */
.im-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--bg);
}
.im-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  color: var(--ink-3);
}
.im-empty-sub { font-size: 12.5px; }

.im-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 14px 24px;
}
.im-head .avatar.slime { align-self: flex-end; margin-bottom: 2px; }
.im-title-box { flex: 1; min-width: 0; }
.im-title { font-size: 15.5px; font-weight: 650; white-space: nowrap; overflow: hidden; }
.im-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; }
.im-status {
  flex: none; font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: #fef2f2; color: var(--warn); font-weight: 550;
}
.im-status.ok { background: #f0fdf4; color: var(--ok); }

.ctx-card {
  margin: 14px 24px 0; padding: 10px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s);
  font-size: 12px; color: var(--ink-2);
  display: flex; gap: 18px; flex-wrap: wrap;
}
.ctx-card .k { color: var(--ink-3); margin-right: 4px; }

.im-msgs { flex: 1; overflow-y: auto; padding: 20px 24px 8px; }

/* 气泡 */
.bubble { max-width: 78%; margin-bottom: 14px; width: fit-content;
          animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }
.bubble.them { }
.bubble.me { margin-left: auto; }
.bubble-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.bubble.me .bubble-card {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 1px 3px rgba(79, 70, 229, .25);
}
.bubble-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 16px 0; font-size: 11.5px; color: var(--ink-3);
}
.bubble-head .bt { font-size: 13px; font-weight: 600; color: var(--ink); }
.bubble.me .bubble-head .bt { color: var(--accent-ink); }
.bubble-head .kind {
  padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
  background: #f4f4f5; color: var(--ink-2);
}
.bubble-head .kind.ask { background: #fef2f2; color: #dc2626; }
.bubble-head .kind.report { background: #f0fdf4; color: #16a34a; }
.bubble-body { padding: 8px 16px 12px; font-size: 13.5px; word-break: break-word; }
.bubble.me .bubble-body { padding: 10px 14px; }
.bubble-time { font-size: 10.5px; color: var(--ink-2); margin: 4px 2px 0; text-align: right; }
.bubble.me .bubble-time { color: rgba(255, 255, 255, .88); text-align: right; }

.waiting-hint {
  max-width: 78%; margin: -6px 0 14px;
  font-size: 11.5px; color: var(--warn);
  display: flex; align-items: center; gap: 6px;
}
.waiting-hint::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); animation: pulse 1.6s ease infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* 选项按钮 */
.opts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 14px; }
.opt-btn {
  border: 1px solid #dfe3fd; background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 6px 14px; font-size: 12.5px; cursor: pointer;
  transition: all .15s; font-weight: 550;
}
.opt-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ------------------------------------------------------------ markdown 内容 */
.md h1, .md h2, .md h3, .md h4 { margin: 14px 0 6px; line-height: 1.4; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15.5px; } .md h3 { font-size: 14.5px; } .md h4 { font-size: 13.5px; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 2px 0; }
.md code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 12.5px; background: #f4f4f5; border-radius: 5px; padding: 1px 5px;
}
.bubble.me .md code { background: rgba(255, 255, 255, .18); }
.md pre {
  background: #fafafa; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 8px 0;
}
.md pre code { background: none; padding: 0; font-size: 12px; line-height: 1.55; }
.md blockquote {
  border-left: 3px solid var(--line); margin: 8px 0; padding: 2px 12px;
  color: var(--ink-2);
}
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid #c7cdfa; }
.bubble.me .md a { color: #fff; border-bottom-color: rgba(255, 255, 255, .5); }
.md hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }
.md strong { font-weight: 650; }

/* ------------------------------------------------------------ 媒体 */
.att-row { display: flex; flex-direction: column; gap: 8px; padding: 0 16px 12px; }
.att-img {
  max-width: 100%; max-height: 300px; border-radius: 10px; cursor: zoom-in;
  border: 1px solid var(--line-2); display: block;
  transition: opacity .15s;
}
.att-img:hover { opacity: .92; }
.att-video {
  max-width: 100%; max-height: 360px; border-radius: 10px;
  border: 1px solid var(--line-2); background: #000; display: block; outline: none;
}
.att-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #f7f7f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; color: var(--ink-2);
  align-self: flex-start; max-width: 100%;
}
.att-chip a { color: var(--accent); text-decoration: none; font-weight: 550; }
.att-chip .size { color: var(--ink-3); font-size: 11px; flex: none; }
.att-chip .ico { flex: none; }

/* ------------------------------------------------------------ 输入区 */
.im-input-wrap { padding: 12px 24px 18px; }
.pending-tip {
  font-size: 11.5px; color: var(--ink-3); margin: 0 4px 8px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pending-tip .mode-toggle {
  color: var(--accent); cursor: pointer; border-bottom: 1px dashed #c7cdfa;
  user-select: none;
}
.reply-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  transition: border-color .16s, box-shadow .16s;
}
.reply-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
#reply-input {
  width: 100%; border: none; outline: none; resize: none;
  font-size: 13.5px; line-height: 1.55; max-height: 120px;
  background: transparent; display: block;
}
#reply-input::placeholder { color: var(--ink-3); }
.reply-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.tool-btn {
  border: none; background: none; font-size: 17px; color: var(--ink-3);
  cursor: pointer; padding: 2px 6px; border-radius: 6px; line-height: 1;
  transition: all .14s;
}
.tool-btn:hover { background: #f4f4f5; color: var(--ink); }
.reply-send {
  margin-left: auto;
  border: none; background: var(--accent); color: #fff;
  border-radius: 8px; padding: 7px 18px; font-size: 13px; font-weight: 550;
  cursor: pointer; transition: all .15s;
  box-shadow: 0 1px 3px rgba(79, 70, 229, .3);
}
.reply-send:hover { background: var(--accent-hover); }
.reply-send:disabled { opacity: .4; cursor: default; box-shadow: none; }
.upload-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.upload-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f7f7f9; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 8px 4px 10px; font-size: 12px; color: var(--ink-2);
}
.upload-chip img { width: 22px; height: 22px; object-fit: cover; border-radius: 4px; }
.upload-chip .rm {
  cursor: pointer; color: var(--ink-3); font-size: 13px; line-height: 1;
  padding: 2px;
}
.upload-chip .rm:hover { color: var(--warn); }
.upload-chip.uploading { opacity: .55; }

/* ------------------------------------------------------------ 杂项 */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 9px 22px; font-size: 13px; z-index: 200;
  box-shadow: var(--shadow-lift); animation: rise .25s ease;
  max-width: 80vw;
}
.lightbox {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(24, 24, 27, .82);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out; padding: 32px;
  animation: fadein .2s ease;
}
.lightbox img {
  max-width: 100%; max-height: 100%; border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}

/* 跑马灯（名字过长时无缝滚动） */
.mq-target { position: relative; overflow: hidden; }
.mq-inner { display: inline-block; white-space: nowrap; }
.mq-run .mq-inner { animation: mq var(--mq-dur, 10s) linear infinite; }
@keyframes mq {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
/* 滚动边缘渐隐：让滚动中的文字看起来是设计而非被裁切 */
.mq-run {
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px,
    #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 14px,
    #000 calc(100% - 14px), transparent 100%);
}

/* ------------------------------------------------------------ 移动端 */
#back-btn { display: none; }
@media (max-width: 760px) {
  .side { width: 100%; }
  .im-main {
    position: fixed; inset: 0; z-index: 20; display: none;
  }
  .im-main.show { display: flex; }
  #back-btn {
    display: inline-flex; border: none; background: none; font-size: 20px;
    color: var(--ink-2); cursor: pointer; padding: 4px 8px; margin-right: 4px;
  }
  .bubble { max-width: 92%; }
  .im-msgs, .im-input-wrap, .ctx-card { padding-left: 14px; padding-right: 14px; margin-left: 14px; margin-right: 14px; }
  .im-head { padding: 12px 14px; }
}
