/* TickTack IM · 公共样式（参考微信的视觉风格） */
:root {
  --brand: #07c160;
  --brand-dark: #06ad56;
  --chat-bg: #ededed;
  --panel: #ffffff;
  --text: #191919;
  --sub: #7f7f7f;
  --muted: #b2b2b2;
  --line: #e5e5e5;
  --mine: #95ec69;
  --mine-text: #191919;
  --theirs: #ffffff;
  --burn: #fa9d3b;
  --danger: #fa5151;
  --link: #576b95;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-size: 14px; }
[hidden] { display: none !important; }
small { color: var(--sub); }

/* ---------------------------------------------------------------- 图标 & 按钮 */
.ic { width: 1.2em; height: 1.2em; flex: none; display: block; }

button {
  font: inherit; color: inherit; cursor: pointer;
  border: 0; background: none; padding: 0;
}
button:disabled { opacity: .45; cursor: default; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 18px; border-radius: 4px; font-size: 14px;
  background: #f2f2f2; color: var(--text); transition: background .15s;
}
.btn:hover:not(:disabled) { background: #e6e6e6; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; height: 42px; font-size: 15px; }
.btn.small { height: 28px; padding: 0 12px; font-size: 13px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 34px; height: 34px; padding: 0 6px; border-radius: 6px; color: #4c4c4c;
  transition: background .15s, color .15s;
}
.icon-btn .ic { width: 22px; height: 22px; }
.icon-btn:hover:not(:disabled) { background: rgba(0, 0, 0, .06); color: #191919; }
.icon-btn.on { color: var(--burn); }
.icon-btn.armed { color: #fff; background: var(--danger); padding: 0 10px; font-size: 13px; }
.icon-btn.armed:hover { background: #e94545; color: #fff; }
.icon-btn.armed .ic { width: 18px; height: 18px; }

.status { font-size: 12px; color: var(--sub); display: inline-flex; align-items: center; gap: 5px; }
.status.ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.status.warn { color: var(--burn); }
.status.bad { color: var(--danger); }

/* 开关（iOS 风格） */
input.switch {
  appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 42px; height: 26px; border-radius: 13px; background: #e5e5e5;
  position: relative; transition: background .2s;
}
input.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
input.switch:checked { background: var(--brand); }
input.switch.burn:checked { background: var(--burn); }
input.switch:checked::after { transform: translateX(16px); }

/* ---------------------------------------------------------------- 头像 */
.avatar {
  --av: 36px;
  width: var(--av); height: var(--av); border-radius: 4px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: #c8c8c8; color: #fff; font-weight: 600; font-size: calc(var(--av) * .4);
  user-select: none; overflow: hidden; letter-spacing: -.02em;
}
.avatar .ic { width: 62%; height: 62%; }
.avatar.agent { background: var(--brand); }
.avatar.self { background: #b9bec7; }

/* ---------------------------------------------------------------- 消息列表 */
.list {
  flex: 1; overflow-y: auto; padding: 14px 14px 18px; background: var(--chat-bg);
  display: flex; flex-direction: column; gap: 16px;
}
.list::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, .15); border-radius: 3px; }

.time-sep { align-self: center; font-size: 12px; color: #9a9a9a; margin: 2px 0 -4px; }

.notice {
  align-self: center; max-width: 86%; text-align: center;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: #9a9a9a; line-height: 1.5;
}
.notice .ic { width: 13px; height: 13px; }
.notice.burnt { color: var(--burn); }
.notice.error { color: var(--danger); }
.notice.secure { background: rgba(0, 0, 0, .05); padding: 3px 10px; border-radius: 4px; }

.msg { display: flex; align-items: flex-start; gap: 10px; }
.msg.me { flex-direction: row-reverse; }
.msg-main { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: calc(100% - 96px); }
.msg.me .msg-main { align-items: flex-end; }
.msg .who { font-size: 12px; color: var(--sub); margin: -2px 0 4px; }

.bubble {
  position: relative; max-width: 100%;
  padding: 9px 12px; border-radius: 4px; min-height: 38px;
  font-size: 15px; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
  background: var(--theirs); color: var(--text);
}
.msg.me .bubble { background: var(--mine); color: var(--mine-text); }
/* 气泡尖角 */
.bubble::before {
  content: ""; position: absolute; top: 13px; width: 0; height: 0;
  border: 6px solid transparent;
}
.msg.them .bubble::before { left: -11px; border-right-color: var(--theirs); }
.msg.me .bubble::before { right: -11px; border-left-color: var(--mine); }
.bubble.err { color: var(--sub); font-style: italic; font-size: 13px; }
.msg.burn .bubble:not(.image) { box-shadow: 0 0 0 1.5px rgba(250, 157, 59, .55); }

.meta { display: flex; align-items: center; gap: 3px; margin-top: 4px; font-size: 11px; color: var(--burn); }
.meta .ic { width: 12px; height: 12px; }

/* 阅后即焚（未查看） */
.bubble.locked {
  display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center;
  background: #fff !important; color: var(--text) !important; cursor: pointer; user-select: none;
  padding: 10px 16px 10px 12px; min-width: 190px;
}
.msg.me .bubble.locked::before { border-left-color: #fff; }
.bubble.locked .lock-flame { grid-row: span 2; width: 30px; height: 30px; color: var(--burn); }
.locked-title { font-size: 14px; }
.locked-sub { font-size: 12px; color: var(--sub); }
.bubble.locked:hover { background: #fffaf3 !important; }

/* 图片 */
.bubble.image { padding: 0; background: transparent !important; min-height: 0; }
.bubble.image::before { display: none; }
.bubble.image img {
  display: block; max-width: 200px; max-height: 220px; border-radius: 4px; cursor: zoom-in;
  background: #fff;
}
.img-holder {
  width: 140px; height: 100px; border-radius: 4px; background: #f7f7f7; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 12px;
}
.img-holder .ic { width: 22px; height: 22px; }

/* 文件卡片 */
.bubble.file {
  display: flex; align-items: center; gap: 14px; width: 240px; padding: 12px 14px;
  background: #fff !important; color: var(--text) !important; cursor: pointer;
}
.msg.me .bubble.file::before { border-left-color: #fff; }
.bubble.file:hover { background: #fafafa !important; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.file-info strong {
  font-weight: 400; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all;
}
.file-info small { font-size: 12px; color: var(--muted); }
.file-icon {
  position: relative; width: 38px; height: 44px; flex: none; border-radius: 3px;
  background: #5b8def; color: rgba(255, 255, 255, .9);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.file-icon .ic { width: 20px; height: 20px; }
.file-icon span { font-size: 9px; font-weight: 700; letter-spacing: .02em; color: #fff; margin-top: 1px; }

/* 大图 */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .9);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
  animation: fade .15s ease-out;
}
.lightbox img { max-width: 94vw; max-height: 90vh; }
.lightbox-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
  color: #fff; background: rgba(255, 255, 255, .15); display: flex; align-items: center; justify-content: center;
}
.lightbox-close .ic { width: 20px; height: 20px; }
@keyframes fade { from { opacity: 0; } }

/* 阅后即焚提示条 */
.burn-bar {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  background: #fff7ec; color: #d9822b; font-size: 12px; padding: 6px 10px;
}
.burn-bar .ic { width: 14px; height: 14px; }

.dragging { outline: 2px dashed var(--brand); outline-offset: -8px; }

/* 消息右键菜单（撤回） */
.ctx-menu {
  position: fixed; z-index: 120; min-width: 120px; padding: 4px; border-radius: 6px;
  background: #4c4c4c; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); animation: fade .1s ease-out;
}
.ctx-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; border-radius: 4px;
  color: #fff; font-size: 13px; text-align: left;
}
.ctx-item .ic { width: 16px; height: 16px; }
.ctx-item:hover, .ctx-item:focus-visible { background: rgba(255, 255, 255, .12); outline: none; }
