:root {
  --bg: #0b1020;
  --bg-soft: #131a2e;
  --card: #1a2338;
  --card-2: #202b45;
  --line: #2a3654;
  --text: #e8ecf7;
  --muted: #8b96b3;
  --primary: #6d8dff;
  --primary-2: #8fa8ff;
  --danger: #ff6b7a;
  --ok: #49d18a;
  --warn: #f5b84d;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* 登录 */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-wrap { width: 100%; max-width: 340px; text-align: center; }
.brand-logo {
  width: 76px; height: 76px; margin: 0 auto 14px; border-radius: 24px;
  background: linear-gradient(135deg, #6d8dff, #a56dff);
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; color: #fff; box-shadow: 0 10px 30px rgba(109,141,255,.35);
}
.login-wrap h1 { margin: 0 0 4px; font-size: 24px; }
.login-wrap p { margin: 0 0 22px; }
input, textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--text); font-size: 16px; outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; line-height: 1.6; }

/* 布局 */
#app { max-width: 520px; margin: 0 auto; padding-bottom: 80px; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; padding: 14px 18px; padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(11,16,32,.86); backdrop-filter: blur(10px);
}
.topbar-title { font-size: 19px; font-weight: 700; }
.top-add {
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #6d8dff, #a56dff); color: #fff; font-size: 26px; line-height: 1;
  box-shadow: 0 6px 18px rgba(109,141,255,.4);
}
.view { padding: 12px 16px 24px; }

/* 搜索 / 筛选 */
.searchbar { margin-bottom: 10px; }
.searchbar input { padding: 11px 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* 列表 / 卡片 */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 15px; cursor: pointer; transition: transform .06s;
}
.card:active { transform: scale(.985); }
.card-title { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.card-summary { color: var(--muted); font-size: 14px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag {
  font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--primary-2);
}
.tag.emo { background: rgba(245,184,77,.15); color: var(--warn); }
.card-time { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.voice-ico { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* 按钮 */
.btn {
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-size: 15px; cursor: pointer;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-danger { background: rgba(255,107,122,.12); border-color: rgba(255,107,122,.4); color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.gen-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.gen-buttons .btn { flex: 1 1 30%; padding: 11px 4px; font-size: 14px; }

/* 画像 / 统计 */
.stats-cards { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-card { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat-card .n { font-size: 26px; font-weight: 700; }
.stat-card .l { font-size: 12px; color: var(--muted); }
.dist-row { display: flex; gap: 10px; margin-bottom: 14px; }
.dist-box { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.dist-box h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; font-size: 13px; }
.bar-row .bl { width: 52px; color: var(--muted); text-align: right; }
.bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg-soft); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg,#6d8dff,#a56dff); }
.bar-row .bn { width: 26px; color: var(--muted); font-size: 12px; }

/* 底栏 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(19,26,46,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; background: none; border: none; color: var(--muted);
  padding: 10px 0 8px; font-size: 12px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-ico { font-size: 20px; }
.tab.active { color: var(--primary-2); }

/* 弹层 */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--bg-soft); border-radius: 22px 22px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: slideUp .22s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-head span { font-weight: 700; font-size: 17px; }
.sheet-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.mode-switch { display: flex; gap: 10px; margin-bottom: 16px; }
.mode-btn {
  flex: 1; padding: 10px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 15px; cursor: pointer;
}
.mode-btn.active { border-color: var(--primary); color: #fff; background: rgba(109,141,255,.12); }

.record-btn {
  width: 100%; height: 150px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.record-dot {
  width: 56px; height: 56px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 0 0 rgba(255,107,122,.5);
}
.record-btn.recording .record-dot { animation: pulse 1.2s infinite; background: #ff3b52; }
.record-btn.recording { border-color: var(--danger); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,107,122,.5); }
  70% { box-shadow: 0 0 0 18px rgba(255,107,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,107,122,0); }
}
.record-meta { margin-top: 12px; text-align: center; color: var(--muted); font-size: 13px; }
#send-row { display: flex; gap: 10px; margin-top: 16px; }
#send-row .btn { flex: 1; }
.sheet-status { margin-top: 12px; text-align: center; color: var(--warn); font-size: 14px; }

/* 详情 */
.detail { position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; padding: 18px; padding-top: calc(18px + env(safe-area-inset-top)); }
.detail-head { display: flex; justify-content: space-between; margin-bottom: 14px; }
.back-btn, .del-btn { background: none; border: none; cursor: pointer; font-size: 15px; color: var(--primary-2); }
.del-btn { color: var(--danger); }
.detail-body { max-width: 520px; margin: 0 auto; }
.detail h2 { margin: 4px 0 10px; }
.detail .meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.detail .body-text { font-size: 16px; line-height: 1.8; white-space: pre-wrap; }
.detail audio { width: 100%; margin: 12px 0; }
.kw { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.failbox { background: rgba(255,107,122,.1); border: 1px solid rgba(255,107,122,.3); border-radius: 10px; padding: 10px 12px; color: var(--danger); font-size: 13px; margin-top: 12px; }

/* 总结渲染 */
.md { line-height: 1.75; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 8px; line-height: 1.3; }
.md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 20px; }
.md li { margin: 4px 0; }
.md strong { color: var(--primary-2); }
.md blockquote { border-left: 3px solid var(--primary); margin: 8px 0; padding: 4px 12px; color: var(--muted); }

/* 其他 */
.kv { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-of-type { border-bottom: none; }
.kv b { font-weight: 600; color: var(--primary-2); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.card + .kv { border-top: none; }
#btn-portrait { margin-bottom: 16px; }
#btn-logout { margin-top: 18px; }
.error { color: var(--danger); font-size: 14px; margin-top: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: rgba(20,26,45,.96); color: var(--text); padding: 10px 18px;
  border-radius: 999px; font-size: 14px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.4);
  max-width: 86%; text-align: center;
}
.spinner {
  display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }