:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --line: #e7e2d9;
  --line-strong: #d5cfc2;
  --ink: #1c221f;
  --ink-2: #5f6b66;
  --ink-3: #969b93;
  --accent: #2f6f5e;
  --accent-hover: #255a4c;
  --accent-soft: #eaf2ee;
  --c-tech: #185fa5;
  --c-paper: #534ab7;
  --c-biz: #ba7517;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.tiny { font-size: 11.5px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 60px;
  padding: 0 24px;
  background: rgba(250, 248, 245, 0.88);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
}
.brand-text { font-size: 15px; font-weight: 500; letter-spacing: 0.02em; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 460px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-3);
  transition: border-color .15s;
}
.search:focus-within { border-color: var(--accent); }
.search input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
}
.search input::placeholder { color: var(--ink-3); }
.search kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.sync-state { font-size: 11.5px; color: var(--ink-3); margin-right: 4px; white-space: nowrap; }

.btn {
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.small { height: 27px; padding: 0 10px; font-size: 12.5px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 226px minmax(0, 1fr);
  gap: 0;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
}

.sidebar {
  position: sticky;
  top: 60px;
  align-self: start;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  padding: 26px 20px 40px 0;
  border-right: 1px solid transparent;
}

.nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 26px; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: 13.5px;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.nav b { font-size: 11.5px; font-weight: 400; color: var(--ink-3); }
.nav a.active b { color: var(--accent); }
.nav b.pill {
  min-width: 19px;
  text-align: center;
  padding: 0 5px;
  height: 17px;
  line-height: 17px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
}
.nav b.pill.zero { background: var(--surface-2); color: var(--ink-3); }

.side-block { margin-bottom: 24px; }
.side-block h3 {
  margin: 0 0 9px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-cloud a {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--ink-2);
  transition: background .12s, color .12s;
}
.tag-cloud a:hover { background: var(--accent-soft); color: var(--accent); }
.tag-cloud a.active { background: var(--accent); color: #fff; }
.tag-cloud a span { opacity: .55; font-size: 10.5px; margin-left: 3px; }

.sources { display: flex; flex-direction: column; gap: 5px; }
.export-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  padding-bottom: 1px;
}
.export-link:hover { color: var(--accent); border-color: var(--accent); }
.sources span { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot.tech { background: var(--c-tech); }
.dot.paper { background: var(--c-paper); }
.dot.biz { background: var(--c-biz); }

/* ---------- content ---------- */
.content { padding: 26px 0 70px 32px; min-width: 0; }
.content-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.content-head h1 { margin: 0; font-size: 21px; font-weight: 500; letter-spacing: -0.01em; }
.view-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); }
.filter-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
}
.filter-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }

/* ---------- note cards ---------- */
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 18px 18px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.card:hover {
  border-color: var(--line-strong);
  box-shadow: 0 6px 20px rgba(28, 34, 31, 0.055);
  transform: translateY(-2px);
}
.card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.card-src { color: var(--ink-2); }
.card-star { color: #c99a2e; }
.card-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.42;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-summary {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.62;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 4px; }
.chip {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 11.5px;
  color: var(--ink-2);
}

.empty {
  grid-column: 1 / -1;
  padding: 76px 20px;
  text-align: center;
  color: var(--ink-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }

/* ---------- inbox ---------- */
.inbox-list { display: flex; flex-direction: column; gap: 10px; }
.item {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 15px 16px 15px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s;
}
.item:hover { border-color: var(--line-strong); }
.item::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 2px;
  background: var(--line-strong);
}
.item[data-cat="技术"]::before { background: var(--c-tech); }
.item[data-cat="学术"]::before { background: var(--c-paper); }
.item[data-cat="行业"]::before { background: var(--c-biz); }

.item-main { flex: 1; min-width: 0; }
.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.item-cat { padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.item[data-cat="技术"] .item-cat { background: #e6f1fb; color: var(--c-tech); }
.item[data-cat="学术"] .item-cat { background: #eeedfe; color: var(--c-paper); }
.item[data-cat="行业"] .item-cat { background: #faeeda; color: var(--c-biz); }
.item-title { margin: 0 0 5px; font-size: 15px; font-weight: 500; line-height: 1.4; }
.item-title a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.item-summary {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.62;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.ai-badge {
  font-size: 10.5px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- editor overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.editor { display: flex; flex-direction: column; height: 100%; }
.editor-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 248, 245, .9);
}
.ed-title {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}
.editor-bar-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.ed-tags {
  width: 170px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font: inherit;
  font-size: 12.5px;
  outline: 0;
}
.ed-tags:focus { border-color: var(--accent); }
.icon-btn {
  height: 30px;
  min-width: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: 14px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on { color: #c99a2e; border-color: #e8d9a8; background: #fdf8ec; }
.icon-btn.danger:hover { color: #a32d2d; border-color: #f0c9c9; background: #fdf1f1; }

.editor-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 0;
}
.ed-content {
  width: 100%;
  height: 100%;
  padding: 24px 26px 60px;
  border: 0;
  border-right: 1px solid var(--line);
  outline: 0;
  resize: none;
  background: transparent;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink);
}
.ed-preview {
  padding: 26px 40px 80px;
  overflow-y: auto;
  background: var(--surface);
}
.ed-preview > * { max-width: 720px; }
.ed-content { padding: 26px 34px 80px; }
.ed-title { font-size: 19px; }

/* ---------- markdown ---------- */
.markdown { font-size: 14px; line-height: 1.72; color: var(--ink); }
.markdown h1, .markdown h2, .markdown h3 { font-weight: 500; line-height: 1.35; margin: 1.5em 0 .5em; }
.markdown h1 { font-size: 20px; }
.markdown h2 { font-size: 17px; }
.markdown h3 { font-size: 15px; }
.markdown p { margin: 0 0 .9em; }
.markdown ul, .markdown ol { margin: 0 0 .9em; padding-left: 1.35em; }
.markdown li { margin: .22em 0; }
.markdown code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--surface-2);
  padding: 1.5px 5px;
  border-radius: 4px;
}
.markdown pre {
  background: #f4f1ec;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 13px 15px;
  overflow-x: auto;
  margin: 0 0 1em;
}
.markdown pre code { background: none; padding: 0; font-size: 12.8px; line-height: 1.6; }
.markdown blockquote {
  margin: 0 0 1em;
  padding: 8px 14px;
  border-left: 3px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--surface-2);
  border-radius: 0 7px 7px 0;
}
.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.markdown hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.markdown table { border-collapse: collapse; margin: 0 0 1em; font-size: 13px; }
.markdown th, .markdown td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--surface-2); font-weight: 500; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 90;
  padding: 9px 16px;
  border-radius: 9px;
  background: #1c221f;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #a32d2d; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 0 16px; }
  .sidebar { display: none; }
  .content { padding: 20px 0 60px; }
  .topbar { padding: 0 14px; gap: 10px; }
  .brand-text, .sync-state, .search kbd { display: none; }
  .editor-body { grid-template-columns: 1fr; }
  .ed-preview { display: none; }
  .ed-content { border-right: 0; }
  .ed-tags { width: 110px; }
}
body { min-height: 100vh; display: flex; flex-direction: column; }
body > .layout { flex: 1 0 auto; width: 100%; box-sizing: border-box; }
.site-foot { flex: none; max-width: 1320px; width: 100%; box-sizing: border-box; margin: 0 auto; padding: 24px 24px 30px; text-align: center; font-size: 12px; line-height: 1.6; }
.site-foot a { color: var(--ink-3); text-decoration: none; border-bottom: 1px solid transparent; }
.site-foot a:hover { color: var(--accent); border-bottom-color: var(--accent); }
