* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Inter", "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: #f3f5f9; color: #0f172a; font-size: 14px; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
#loading { position: fixed; inset: 0; background: #f3f5f9; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; color: #64748b; }
#loading.hidden { display: none; }
.spinner { width: 40px; height: 40px; border: 4px solid #dbe2ef; border-top-color: #2563eb; border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#topbar { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid #e2e8f0; padding: 10px 20px 8px; z-index: 20; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.bar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.bar-sub { margin-top: 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: .2px; color: #0f172a; white-space: nowrap; }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,#2563eb,#7c3aed); display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.tabs { display: flex; gap: 2px; background: #eef2f7; padding: 3px; border-radius: 10px; }
.tab { border: none; background: transparent; color: #475569; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; }
.tab:hover { color: #0f172a; }
.tab.active { background: #fff; color: #1d4ed8; box-shadow: 0 1px 3px rgba(15,23,42,.12); }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tool-btn { border: 1px solid #e2e8f0; background: #fff; color: #334155; border-radius: 9px; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 500; transition: all .15s; }
.tool-btn:hover { border-color: #bfdbfe; color: #1d4ed8; background: #f8fbff; }
.tool-btn:active { transform: translateY(1px); }
#stats { color: #64748b; font-size: 12.5px; white-space: nowrap; padding-left: 4px; }
.select { padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff; font-size: 13px; color: #334155; min-width: 220px; max-width: 320px; cursor: pointer; }
.search { padding: 7px 12px; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff; font-size: 14px; min-width: 380px; color: #0f172a; outline: none; transition: border .15s, box-shadow .15s; }
.search:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.filters { display: flex; gap: 6px; margin-top: 9px; flex-wrap: wrap; }
.chip { border: 1px solid #e2e8f0; background: #fff; color: #475569; border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 12.5px; transition: all .15s; }
.chip:hover { border-color: #bfdbfe; color: #1d4ed8; }
.chip.active { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; font-weight: 600; }
.group-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.gtab { border: 1px solid #e2e8f0; background: #fff; border-radius: 9px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: #334155; transition: all .15s; }
.gtab:hover { border-color: #bfdbfe; }
.gtab.active { background: #eff6ff; border-color: #60a5fa; color: #1d4ed8; font-weight: 600; }
.gtab .cnt { color: #94a3b8; font-size: 11.5px; margin-left: 5px; }
#app { flex: 1; position: relative; min-height: 0; }
.pane { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 12px 0 70px; scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.pane[hidden] { display: none; }
.pane::-webkit-scrollbar { width: 8px; }
.pane::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
#panes-group { position: absolute; inset: 0; }
.list { max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.msg { display: flex; gap: 12px; padding: 9px 10px; border-radius: 12px; transition: background .12s; }
.msg:hover { background: #f8fafc; }
.msg.highlight { background: #fef9c3; transition: background 1.2s; }
.avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; object-fit: cover; background: #e2e8f0; box-shadow: 0 0 0 1px rgba(15,23,42,.05); cursor: help; }
.avatar-fallback { width: 40px; height: 40px; border-radius: 50%; flex: none; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 17px; box-shadow: 0 0 0 1px rgba(15,23,42,.05); cursor: help; }
.body { min-width: 0; flex: 1; }
.head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.name { font-weight: 600; font-size: 14px; color: #1e3a8a; cursor: help; }
.time { color: #94a3b8; font-size: 12px; }
.tag { font-size: 11.5px; color: #fff; border-radius: 999px; padding: 1.5px 9px; font-weight: 500; }
.tag.c0 { background: linear-gradient(135deg,#f59e0b,#d97706); }
.tag.c1 { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.tag.c2 { background: linear-gradient(135deg,#10b981,#059669); }
.tag.c3 { background: linear-gradient(135deg,#8b5cf6,#7c3aed); }
.tag.c4 { background: linear-gradient(135deg,#ec4899,#db2777); }
.content { margin-top: 3px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; font-size: 14.5px; color: #1e293b; }
.content a { color: #2563eb; text-decoration: none; border-bottom: 1px solid #bfdbfe; }
.content a:hover { border-bottom-color: #2563eb; }
.quote { margin: 4px 0 3px; padding: 6px 10px; border-left: 3px solid #cbd5e1; background: #f1f5f9; color: #64748b; font-size: 13px; border-radius: 6px; white-space: pre-wrap; }
.photo-wrap { display: inline-block; margin: 5px 8px 2px 0; }
.photo { max-width: 320px; max-height: 320px; border-radius: 10px; cursor: zoom-in; display: block; background: #eef2f7; box-shadow: 0 1px 3px rgba(15,23,42,.08); transition: transform .12s; }
.photo:hover { transform: scale(1.01); }
.missing { display: inline-block; padding: 12px 16px; border: 1px dashed #cbd5e1; border-radius: 10px; color: #94a3b8; font-size: 13px; background: #f8fafc; }
.sticker { max-width: 160px; max-height: 160px; border-radius: 8px; vertical-align: bottom; cursor: zoom-in; }
.face-text { display: inline-block; color: #1d4ed8; background: #eff6ff; border-radius: 6px; padding: 1px 8px; }
.card { display: inline-block; margin: 5px 0; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; max-width: 560px; }
.card .t { font-weight: 600; color: #1e293b; }
.card .d { color: #64748b; font-size: 13px; margin-top: 3px; white-space: pre-wrap; }
.card .k { color: #94a3b8; font-size: 12px; margin-top: 3px; }
.voice { margin: 5px 0; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 12px; background: #f8fafc; display: inline-block; max-width: 560px; }
.voice .vrow { display: flex; align-items: center; gap: 8px; }
.voice audio { width: 300px; height: 36px; }
.voice .dl { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #e2e8f0; background: #fff; border-radius: 8px; padding: 5px 10px; font-size: 12px; color: #475569; text-decoration: none; white-space: nowrap; }
.voice .dl:hover { border-color: #bfdbfe; color: #1d4ed8; }
.voice .vmeta { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.voice details { margin-top: 6px; font-size: 13px; }
.voice summary { cursor: pointer; color: #2563eb; font-weight: 500; }
.voice .asr-text { margin-top: 5px; color: #334155; background: #fff; border: 1px dashed #e2e8f0; border-radius: 8px; padding: 7px 10px; white-space: pre-wrap; }
.sys { text-align: center; color: #94a3b8; font-size: 12px; padding: 4px 0; white-space: pre-wrap; }
.search-info { max-width: 1040px; margin: 0 auto 4px; padding: 4px 20px 10px; color: #64748b; font-size: 13px; }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 150; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 16px; padding: 16px 18px; width: 400px; box-shadow: 0 20px 50px rgba(15,23,42,.25); }
.modal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#cal-title { flex: 1; text-align: center; font-weight: 600; font-size: 15px; }
.cal-nav, .cal-close { border: none; background: #f1f5f9; border-radius: 9px; width: 30px; height: 30px; cursor: pointer; font-size: 16px; color: #334155; }
.cal-nav:hover, .cal-close:hover { background: #e2e8f0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-cell { height: 38px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #cbd5e1; }
.cal-cell.head { color: #94a3b8; font-weight: 600; height: 28px; }
.cal-cell.has-rec { background: #eff6ff; color: #1d4ed8; cursor: pointer; font-weight: 600; }
.cal-cell.has-rec:hover { background: #dbeafe; }
.cal-cell.other-month { visibility: hidden; }
.cal-tip { color: #94a3b8; font-size: 12px; margin-top: 12px; text-align: center; }
#lightbox { position: fixed; inset: 0; background: rgba(2,6,23,.88); z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: zoom-out; backdrop-filter: blur(2px); }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 10px; }
#lightbox-cap { color: #cbd5e1; font-size: 13px; margin-top: 12px; max-width: 80vw; text-align: center; }

.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; cursor: pointer; padding: 6px 10px; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff; user-select: none; }
.toggle:hover { border-color: #bfdbfe; color: #1d4ed8; }
.toggle input { accent-color: #2563eb; cursor: pointer; }
.toggle .cnt { color: #94a3b8; font-size: 12px; }
.nobody-text { color: #94a3b8; font-size: 12.5px; }
#tip { position: fixed; display: none; z-index: 300; background: #0f172a; color: #e2e8f0; padding: 8px 12px; border-radius: 10px; font-size: 12.5px; line-height: 1.55; box-shadow: 0 8px 24px rgba(2,6,23,.28); pointer-events: none; max-width: 320px; word-break: break-all; }
#tip .hint { color: #93c5fd; margin-top: 4px; font-size: 11.5px; }
#toast { position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(2,6,23,.25); z-index: 400; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

.group-tabs.disabled .gtab { background: #f1f5f9 !important; color: #a5b0bf !important; border-color: #e5e9f0 !important; cursor: not-allowed; box-shadow: none !important; }
.group-tabs.disabled .gtab .cnt { color: #c3cad4 !important; }
.group-tabs.disabled .gtab:hover { border-color: #e5e9f0 !important; color: #a5b0bf !important; }

.combo { position: relative; }
.combo-btn { min-width: 220px; max-width: 340px; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 9px; background: #fff; font-size: 13px; color: #334155; cursor: pointer; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn:hover { border-color: #bfdbfe; color: #1d4ed8; }
.combo-panel { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; width: 460px; max-height: 380px; overflow-y: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 16px 40px rgba(15,23,42,.16); padding: 6px; }
.combo-panel[hidden] { display: none; }
.combo-head { display: grid; grid-template-columns: 1fr 110px 80px; gap: 8px; padding: 4px 10px 6px; color: #94a3b8; font-size: 12px; }
.sender-row { display: grid; grid-template-columns: 1fr 110px 80px; gap: 8px; width: 100%; align-items: center; text-align: left; border: none; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: #334155; }
.sender-row:hover { background: #f1f5f9; }
.sender-row.sel { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.sender-row .s-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-row .s-qq { color: #64748b; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-row .s-cnt { color: #94a3b8; text-align: right; font-variant-numeric: tabular-nums; }
.sender-row.sel .s-qq, .sender-row.sel .s-cnt { color: #2563eb; }

.asr { margin-top: 6px; }
.asr-text { color: #334155; background: #fff; border: 1px dashed #e2e8f0; border-radius: 8px; padding: 7px 10px; white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.55; }
.asr-text.clamp1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }
.asr-toggle { margin-top: 4px; border: none; background: none; color: #2563eb; font-size: 12.5px; cursor: pointer; padding: 0; }
.asr-toggle[hidden] { display: none; }
