:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #2f6bff; --accent-soft: #e8efff; --focus: #ff8a00; --ok: #1a9e5c;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef0f4; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; }
textarea { width: 100%; resize: vertical; }

.btn { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 12px; color: var(--text); display: inline-block; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .5; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 8px 16px;
  background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-size: 18px; color: var(--text); font-weight: 500; }
.brand b { color: var(--accent); }
#tabs { display: flex; gap: 2px; flex-wrap: wrap; }
#tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 6px; color: var(--muted); }
#tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; vertical-align: middle; }
.seg button { border: 0; background: #fff; padding: 4px 10px; color: var(--muted); }
.seg button.active { background: var(--accent); color: #fff; }
.seg.small button { padding: 1px 8px; font-size: 12px; }

.layout { display: flex; gap: 16px; padding: 16px; max-width: 1280px; margin: 0 auto; }
aside { width: 230px; flex-shrink: 0; position: sticky; top: 64px; align-self: flex-start;
  display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 80px); overflow-y: auto; }
aside label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); }
aside select { flex: 1; max-width: 150px; }
label.check { justify-content: flex-start; color: var(--text); }
.group-title { font-weight: 600; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 2px 9px; font-size: 12px; }
.chips button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
main { flex: 1; min-width: 0; }

.list-head { display: flex; align-items: center; gap: 10px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.banner { background: #fff7e6; border: 1px solid #ffd591; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); background: var(--card); border-radius: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.card.liked { border-left: 3px solid var(--focus); }
.undo-bar { background: #f7f7fa; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 16px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.score { background: var(--text); color: #fff; border-radius: 4px; padding: 0 6px; font-weight: 600; cursor: help; }
.track { background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 0 6px; }
.track.sub { background: #f0f1f4; color: var(--muted); }
.layer { background: #fff0e0; color: #c45f00; border-radius: 4px; padding: 0 6px; font-weight: 600; }
.mini { border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 4px; font-size: 11px; padding: 0 6px; }
.lang-btn { margin-left: auto; border: 1px solid var(--line); background: #fff; border-radius: 4px; font-size: 11px; padding: 0 6px; color: var(--muted); }
.title { font-size: 16px; margin: 6px 0 4px; cursor: pointer; line-height: 1.4; }
.title:hover { color: var(--accent); }
.orig { color: var(--muted); font-size: .88em; font-weight: normal; margin-top: 2px; }
.authors { color: var(--muted); font-size: 12px; }
.affils { font-size: 12px; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.badges:empty { display: none; }
.badge { font-size: 11px; border-radius: 4px; padding: 1px 6px; background: #f0f1f4; }
.badge.org { background: #e6f4ff; color: #0958d9; }
.badge.author { background: #f9f0ff; color: #722ed1; }
.badge.venue { background: #e8f8ef; color: var(--ok); }
.badge.hot { background: #fff1f0; color: #cf1322; }
.badge.mine { background: var(--focus); color: #fff; }
.badge.cited { background: #fffbe6; color: #ad6800; }
.more { display: block; text-align: center; padding: 6px; font-size: 12px; }
.week-nav b { color: var(--text); }
.tldr { margin: 6px 0; line-height: 1.6; }
.tweet { margin: 6px 0; line-height: 1.6; white-space: pre-line; color: #3a4252; max-height: 9.6em; overflow: hidden; }
.abs summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.abs p { line-height: 1.7; margin: 6px 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.actions button { border: 1px solid transparent; background: none; border-radius: 6px; padding: 2px 8px; color: var(--muted); }
.actions button:hover { border-color: var(--line); }
.actions button.on { color: var(--focus); }
.links { margin-left: auto; display: inline-flex; gap: 10px; font-size: 12px; }
.src-link { border: 1px solid var(--accent); border-radius: 4px; padding: 1px 8px; font-weight: 600; }
.tweet a { overflow-wrap: anywhere; }

.group { margin-bottom: 24px; }
.group h2 { font-size: 16px; display: flex; gap: 8px; align-items: baseline; margin: 0 0 2px; }
.group h2 a { font-size: 12px; font-weight: normal; margin-left: auto; }
.org-index { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.org-index a { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; color: var(--text); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.panel h2 { font-size: 16px; margin-top: 0; }
.panel textarea { margin: 8px 0; }
#cfg { font-family: Consolas, "JetBrains Mono", monospace; font-size: 12px; }
.tbl { border-collapse: collapse; width: 100%; }
.tbl td, .tbl th { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; }
.log { background: #1d2330; color: #cfd6e4; padding: 10px; border-radius: 6px; max-height: 320px; overflow: auto; font-size: 12px; white-space: pre-wrap; }

.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .25); }
.drawer-inner { position: absolute; right: 0; top: 0; bottom: 0; width: min(760px, 100%); background: #fff; overflow-y: auto;
  padding: 20px 24px 40px; box-shadow: -4px 0 20px rgba(0, 0, 0, .1); }
.drawer-inner h2 { margin: 6px 0 2px; font-size: 19px; line-height: 1.4; }
.drawer-inner h3 { font-size: 14px; margin: 18px 0 6px; display: flex; gap: 8px; align-items: center; }
.drawer-inner .links { margin: 8px 0; display: flex; }
.close { position: sticky; top: 0; float: right; border: 0; background: #fff; font-size: 18px; color: var(--muted); }
.rel { background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.edit-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.related li { margin: 4px 0; }
.article-wrap summary { cursor: pointer; font-weight: 600; margin-top: 16px; }
.article { line-height: 1.8; overflow-wrap: anywhere; }
.article img { max-width: 100%; height: auto !important; }
.article * { max-width: 100%; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 3px 10px; font-size: 12px; }
.quick button:hover { border-color: var(--accent); color: var(--accent); }
.msg { padding: 10px 12px; border-radius: 8px; margin: 8px 0; line-height: 1.7; }
.msg.user { background: var(--accent-soft); margin-left: 15%; }
.msg.assistant { background: var(--bg); }
.msg.pending { color: var(--muted); }
.msg.err { background: #fff1f0; color: #cf1322; }
.msg pre { background: #1d2330; color: #e6e6e6; padding: 8px; border-radius: 6px; overflow-x: auto; }
.msg li { margin-left: 1em; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }

.login { max-width: 320px; margin: 15vh auto; display: flex; flex-direction: column; gap: 10px; background: #fff;
  padding: 24px; border-radius: 10px; border: 1px solid var(--line); }
.login button { background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px; }

body.public { background: #fff; min-height: 100vh; }
.home { max-width: 760px; margin: 0 auto; padding: 48px 20px; }
.home h1 { margin-bottom: 0; }
.home-links { display: flex; gap: 16px; }
.pubs { padding-left: 18px; }
.pubs li { margin-bottom: 14px; line-height: 1.6; }
.home footer { margin-top: 48px; }

/* 导航分组 */
.nav-sep { width: 1px; background: var(--line); margin: 4px 6px; align-self: stretch; }

/* 摘要卡片 */
.points { margin: 4px 0 6px; padding-left: 20px; line-height: 1.65; }
.points li { margin: 1px 0; }
.rel-line { margin: 4px 0; font-size: 12px; color: #6a4a00; background: #fffbe6; border-radius: 4px; padding: 3px 8px; display: inline-block; }
.utag { background: #eef6ee; color: #2e7d32; border-radius: 4px; padding: 0 6px; }
.note-snip { font-size: 12px; color: #555; background: #f7f7fa; border-left: 3px solid var(--accent); padding: 4px 8px; margin: 6px 0; }
.picker { margin-top: 8px; padding: 8px; background: var(--bg); border-radius: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.picker.done { color: var(--ok); }
.btn.small { padding: 2px 8px; font-size: 12px; }
.member-row { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 4px; font-size: 13px; }
.chip-link { background: var(--accent-soft); border-radius: 10px; padding: 1px 8px; margin-right: 4px; }
.tag-input { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--muted); }
.tag-input input { flex: 1; }
.note-preview:empty { display: none; }
.note-preview { background: var(--bg); border-radius: 6px; padding: 4px 12px; margin-top: 6px; font-size: 13px; }

/* Markdown 正文 */
.md-body { line-height: 1.75; overflow-wrap: anywhere; }
.md-body h4 { margin: 14px 0 4px; font-size: 15px; }
.md-body ul, .md-body ol { padding-left: 22px; }
.md-table { border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.md-table td, .md-table th { border: 1px solid var(--line); padding: 4px 8px; vertical-align: top; }
.md-table th { background: var(--bg); }
.msg h4 { margin: 8px 0 2px; }
.msg p { margin: 4px 0; }

/* 专题、笔记、Idea */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.full { width: 100%; margin: 6px 0; }
.title-input { width: 100%; font-size: 17px; font-weight: 600; border: 1px solid transparent; padding: 4px 6px; }
.title-input:hover, .title-input:focus { border-color: var(--line); }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.topic-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.topic-card:hover { border-color: var(--accent); }
.topic-card h3 { margin: 0 0 4px; font-size: 15px; }
.warn { color: var(--focus); }
.brief-row { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; display: flex; flex-direction: column; gap: 3px; }
.note-card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; margin-bottom: 10px; }
.note-card h3 { margin: 4px 0; font-size: 15px; }
.idea-row { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 6px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.idea-row:hover { border-color: var(--accent); }
.idea-status { background: #f0f5ff; color: var(--accent); }
.idea-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 14px; align-items: start; }
.msg.card-version { background: #f6ffed; }
.refs summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* 趋势 */
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
.spark { color: var(--accent); vertical-align: middle; }
.bars { display: flex; align-items: flex-end; gap: 6px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; }
.bar span { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .8; }
.bar em { font-style: normal; font-size: 11px; color: var(--muted); position: absolute; top: -16px; }
.bar-labels { display: flex; gap: 6px; font-size: 11px; color: var(--muted); }
.bar-labels span { flex: 1; text-align: center; }
td.up { color: #cf1322; font-weight: 600; }
td.down { color: var(--muted); }
.org-bar { display: grid; grid-template-columns: 160px 1fr 30px; gap: 8px; align-items: center; font-size: 13px; margin: 3px 0; }
.org-bar i { background: var(--accent-soft); border-left: 3px solid var(--accent); height: 14px; display: block; }
.report { border-top: 1px solid var(--line); padding: 8px 0; }
.report summary { cursor: pointer; }

/* 加载中：顶部细进度条，旧内容保留但变淡 */
body.loading::before { content: ''; position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 50;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 50% 100%;
  animation: slide 1s linear infinite; }
body.loading #main { opacity: .6; transition: opacity .15s .15s; }
@keyframes slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* 我的统计 */
.heat-wrap { overflow-x: auto; padding: 4px 0; }
.heat-months { display: flex; gap: 3px; font-size: 11px; color: var(--muted); margin-left: 0; height: 14px; }
.heat-months span { width: 12px; flex-shrink: 0; overflow: visible; white-space: nowrap; }
.heat { display: flex; gap: 3px; }
.heat-col { display: flex; flex-direction: column; gap: 3px; }
.heat i, .heat-legend i { width: 12px; height: 12px; border-radius: 2px; display: block; background: #ebedf0; }
.heat i.pad { background: transparent; }
.heat .l1, .heat-legend .l1 { background: #9be9a8; }
.heat .l2, .heat-legend .l2 { background: #40c463; }
.heat .l3, .heat-legend .l3 { background: #30a14e; }
.heat .l4, .heat-legend .l4 { background: #216e39; }
.heat-legend { display: flex; gap: 3px; align-items: center; font-size: 11px; color: var(--muted); margin-top: 6px; justify-content: flex-end; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.tile b { font-size: 20px; }
.tile span { color: var(--muted); font-size: 12px; }
.tile em { font-style: normal; font-size: 11px; color: var(--ok); }
.bars.hours { height: 70px; gap: 2px; }
.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.ach { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; color: var(--muted); }
.ach.done { border-style: solid; border-color: #ffd591; background: #fffbe6; color: var(--text); }
.ach span { font-size: 12px; }

@media (max-width: 800px) {
  .idea-layout { grid-template-columns: 1fr; }
  .trend-grid { grid-template-columns: 1fr; }
  .layout { flex-direction: column; padding: 10px; }
  aside { width: 100%; position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
  aside > input { width: 100%; }
  .top-right { margin-left: 0; }
  .links { margin-left: 0; }
  .actions { flex-wrap: wrap; }
}
