/* ===== 知汇 · 个人知识管理网站 设计系统 ===== */
:root {
  --bg: #F6F5F1;
  --surface: #FFFFFF;
  --sidebar: #EFEDE6;
  --panel: #FAF8F4;
  --ink: #1A1A1A;
  --ink-2: #4A4741;
  --ink-3: #6E6A62;
  --ink-4: #8C877D;
  --ink-5: #A39E94;
  --line: #E4E0D6;
  --line-2: #E9E7DF;
  --brand: #3D8A5A;
  --brand-weak: #EAF3EC;
  --brand-ink: #1F4F36;
  --brand-ink-2: #3D6B4F;
  --brand-ink-3: #7FA98C;
  --clay: #B4643A;
  --indigo: #5B54B8;
  --teal: #2F7F8C;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
  --shadow-1: 0 4px 16px -4px rgba(15,15,12,0.10);
  --shadow-2: 0 2px 4px -2px rgba(15,15,12,0.06);
  --serif: "Noto Serif SC", "Source Han Serif CN", serif;
  --sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink-2);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.6;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ===== 顶栏 ===== */
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-2);
  flex-shrink: 0;
}
.logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--ink); }
.search-box {
  width: 420px; max-width: 38vw;
  height: 40px; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: #F1EFE9; border-radius: 10px;
}
.search-box input {
  border: none; background: none; outline: none; flex: 1;
  font-size: 14px; color: var(--ink-2);
}
.search-box input::placeholder { color: var(--ink-4); }
.spacer { flex: 1; }
.sync-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: 100px; background: var(--brand-weak);
  color: var(--brand); font-size: 13px; font-weight: 500;
}
.btn-primary {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; border-radius: 10px; background: var(--brand);
  color: #fff; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.btn-ghost {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 13px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.avatar {
  width: 32px; height: 32px; border-radius: 100px; background: #E4DFD5;
  display: grid; place-items: center; color: var(--ink-3); font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--line-2); }

/* ===== 整体布局 ===== */
.layout { display: flex; height: calc(100vh - 64px); overflow: hidden; }
.sidebar {
  width: 264px; flex-shrink: 0; padding: 24px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 20px; background: var(--bg);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-radius: 10px; color: var(--ink-2); font-size: 14px;
}
.nav-item.active { background: var(--brand-weak); color: var(--brand-ink); font-weight: 500; }
.nav-item:hover:not(.active) { background: var(--line-2); }
.section-label { font-size: 12px; font-weight: 500; color: var(--ink-5); margin-bottom: 2px; }
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between;
  height: 36px; padding: 0 12px; border-radius: 8px; font-size: 14px; color: var(--ink-2);
}
.cat-item:hover { background: var(--line-2); }
.cat-item.active { background: var(--brand-weak); color: var(--brand-ink); font-weight: 500; }
.cat-count { font-size: 13px; color: var(--ink-5); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  padding: 5px 12px; border-radius: 100px; background: var(--surface);
  font-size: 13px; color: var(--ink-3); border: 1px solid var(--line-2);
}
.tag-pill.active { background: var(--brand-weak); color: var(--brand-ink); border-color: transparent; }
.sidebar-spacer { flex: 1; }
.store-card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.store-head { display: flex; align-items: center; gap: 8px; }
.store-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.bar { height: 6px; border-radius: 100px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 100px; background: var(--brand); }
.store-note { font-size: 12px; color: var(--ink-4); line-height: 1.5; }
.store-sub { font-size: 12px; color: var(--ink-5); line-height: 1.5; }

/* ===== 内容区 ===== */
.content { flex: 1; overflow-y: auto; padding: 32px; }
.list-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.page-title { font-family: var(--serif); font-weight: 600; font-size: 28px; color: var(--ink); }
.page-meta { font-size: 13px; color: var(--ink-4); }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-select {
  display: flex; align-items: center; gap: 6px; padding: 9px 12px;
  border-radius: 8px; background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.filter-tag {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  border-radius: 8px; background: var(--brand-weak); color: var(--brand-ink); font-size: 13px; font-weight: 500;
}
.filter-tag .x { cursor: pointer; opacity: .7; }
.filter-tag .x:hover { opacity: 1; }
.view-toggle {
  display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--line); margin-left: auto;
}
.view-toggle button { padding: 6px; border-radius: 6px; color: var(--ink-4); }
.view-toggle button.active { background: var(--brand-weak); color: var(--brand); }

/* 卡片列表 */
.cards { display: flex; flex-direction: column; gap: 14px; }
.cards.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.card {
  display: flex; gap: 18px; padding: 20px; background: var(--surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-1), var(--shadow-2);
  cursor: pointer; transition: transform .12s ease;
}
.card:hover { transform: translateY(-2px); }
.card .thumb {
  width: 112px; height: 84px; border-radius: 10px; flex-shrink: 0;
}
.card .body { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card .c-title { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--ink); line-height: 1.5; }
.card .c-sum { font-size: 14px; color: var(--ink-3); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .c-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--ink-5); }
.badge { padding: 4px 10px; border-radius: 6px; background: var(--brand-weak); color: var(--brand); font-size: 12px; font-weight: 500; }
.mini-tag { padding: 3px 10px; border-radius: 100px; background: #F3F1EA; color: var(--ink-3); font-size: 12px; }
.empty {
  text-align: center; color: var(--ink-4); padding: 80px 20px; font-size: 15px;
}

/* ===== 详情页 ===== */
.reader-wrap { display: flex; height: calc(100vh - 64px); overflow: hidden; }
.toc { width: 240px; flex-shrink: 0; padding: 32px; overflow-y: auto; }
.toc .section-label { margin-bottom: 10px; }
.toc a { display: block; font-size: 13px; color: var(--ink-3); padding: 5px 0; }
.toc a.active { color: var(--brand-ink); font-weight: 500; }
.reader { flex: 1; overflow-y: auto; padding: 40px; display: flex; justify-content: center; }
.article { width: 720px; max-width: 100%; display: flex; flex-direction: column; gap: 18px; }
.article .a-head { display: flex; align-items: center; gap: 10px; }
.article h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.35; color: var(--ink); }
.article .a-meta { font-size: 13px; color: var(--ink-5); }
.article .a-cover { width: 100%; height: 280px; border-radius: 14px; }
.article p { font-family: var(--serif); font-size: 17px; line-height: 1.75; color: #33312C; }
.article h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--ink); margin-top: 6px; }
.article .quote { padding: 18px; border-radius: 10px; background: #F3F1EA; font-family: var(--serif); font-size: 17px; color: var(--ink-2); line-height: 1.75; }
.article .a-img { width: 100%; height: 220px; border-radius: 12px; }
.article .a-cap { font-size: 13px; color: var(--ink-5); text-align: center; }
.side-panel { width: 320px; flex-shrink: 0; padding: 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.panel-card { background: var(--surface); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel-card h3 { font-size: 14px; font-weight: 500; color: var(--ink); }
.prop-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.prop-row .k { color: var(--ink-5); }
.prop-row .v { color: var(--ink-2); font-weight: 500; }
.att-row { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: var(--panel); }
.att-name { flex: 1; font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 12px; color: var(--ink-5); }
.cloud-card { background: var(--brand-weak); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cloud-card h3 { font-size: 14px; font-weight: 500; color: var(--brand-ink); display: flex; align-items: center; gap: 8px; }
.cloud-card p { font-size: 12px; color: var(--brand-ink-2); line-height: 1.6; }
.cloud-card .ts { font-size: 12px; color: var(--brand-ink-3); }

/* ===== 编辑器 ===== */
.editor-top { display: flex; align-items: center; gap: 12px; padding: 0 16px; height: 64px; background: var(--surface); border-bottom: 1px solid var(--line-2); flex-shrink: 0; }
.editing-state { padding: 4px 10px; border-radius: 6px; background: #F3F1EA; color: var(--ink-3); font-size: 12px; font-weight: 500; }
.ed-title { font-size: 15px; font-weight: 500; color: var(--ink); }
.toolbar {
  display: flex; align-items: center; gap: 2px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--line-2); flex-wrap: wrap; flex-shrink: 0;
}
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 6px; }
.tb-btn { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center; color: var(--ink-2); font-size: 13px; font-weight: 600; }
.tb-btn:hover { background: var(--line-2); }
.tb-btn.on { background: var(--brand-weak); color: var(--brand); }
.tb-style { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.tb-style:hover { background: var(--line-2); }
.editor-wrap { display: flex; height: calc(100vh - 64px - 52px); overflow: hidden; }
.paper-scroll { flex: 1; overflow-y: auto; padding: 32px; display: flex; justify-content: center; }
.paper { width: 760px; max-width: 100%; min-height: 100%; background: var(--surface); border-radius: var(--radius-lg); padding: 48px; box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 16px; }
.paper .e-title { font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.4; color: var(--ink); border: none; outline: none; width: 100%; }
.paper .e-title::placeholder { color: var(--ink-5); }
.paper .e-meta { font-size: 13px; color: var(--ink-5); }
.e-body { font-family: var(--serif); font-size: 17px; line-height: 1.75; color: #33312C; outline: none; min-height: 320px; }
.e-body:empty:before { content: attr(data-placeholder); color: var(--ink-5); }
.e-body h1 { font-family: var(--serif); font-weight: 600; font-size: 28px; color: var(--ink); margin: 8px 0; }
.e-body h2 { font-family: var(--serif); font-weight: 600; font-size: 22px; color: var(--ink); margin: 8px 0; }
.e-body img { max-width: 100%; border-radius: 10px; margin: 6px 0; }
.e-body blockquote { padding: 14px 18px; border-left: 3px solid var(--brand); background: #F3F1EA; border-radius: 0 10px 10px 0; color: var(--ink-2); margin: 6px 0; }
.e-body a { color: var(--brand); text-decoration: underline; }
.editor-side { width: 320px; flex-shrink: 0; padding: 32px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.field-label { font-size: 12px; color: var(--ink-5); margin-bottom: 6px; display: block; }
.select-box, .text-input { width: 100%; padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid transparent; color: var(--ink-2); font-size: 13px; display: flex; align-items: center; justify-content: space-between; }
.text-input { color: var(--ink-2); }
.upload-zone { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 8px; background: var(--panel); border: 1px dashed var(--line); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.upload-zone:hover { border-color: var(--brand); color: var(--brand); }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; background: #F3F1EA; font-size: 12px; color: var(--ink-2); margin: 4px 6px 0 0; }
.attachment-chip .x { cursor: pointer; opacity: .6; }
.attachment-chip .x:hover { opacity: 1; }
.att-hint { font-size: 12px; color: var(--ink-5); margin-top: 6px; }

/* ===== 移动端 ===== */
.bottom-tab { display: none; }
.fab { display: none; }
.mob-cats { display: none; }

@media (max-width: 1023px) {
  .sidebar { display: none; }
  .layout { display: block; height: auto; overflow: visible; }
  .content { padding: 16px; }
  .cards.grid { grid-template-columns: repeat(2, 1fr); }
  .reader-wrap { display: block; height: auto; overflow: visible; }
  .toc, .side-panel { display: none; }
  .reader { padding: 20px 16px; }
  .article { width: 100%; }
  .article h1 { font-size: 26px; }
  .editor-wrap { display: block; height: auto; overflow: visible; }
  .paper-scroll { padding: 16px; }
  .paper { padding: 24px; width: 100%; }
  .editor-side { display: block; width: 100%; padding: 16px; }
  .bottom-tab {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 60px;
    background: var(--surface); border-top: 1px solid var(--line-2); z-index: 20;
    align-items: stretch;
  }
  .bottom-tab button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--ink-5); }
  .bottom-tab button.active { color: var(--brand); }
  .bottom-tab button svg { width: 22px; height: 22px; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 20px; bottom: 78px;
    width: 56px; height: 56px; border-radius: 100px; background: var(--brand); color: #fff;
    box-shadow: 0 6px 18px -4px rgba(61,138,90,.5); z-index: 21;
  }
  .content { padding-bottom: 80px; }
  .topbar .search-box { width: auto; flex: 1; max-width: none; }
  .topbar .brand-name, .topbar .sync-chip span { display: none; }
}

@media (max-width: 767px) {
  .cards, .cards.grid { grid-template-columns: 1fr; }
  .card { flex-direction: column; }
  .card .thumb { width: 100%; height: 160px; }
  .page-title { font-size: 22px; }
  .toolbar { gap: 1px; padding: 6px 8px; }
  .tb-sep { margin: 0 3px; }
}

/* ===== 列表卡片标题就地重命名 ===== */
.c-title-row { display: flex; align-items: flex-start; gap: 8px; }
.c-title-row .c-title { flex: 1; min-width: 0; }
.rename-btn {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px;
  color: var(--ink-5); font-size: 13px; display: grid; place-items: center;
}
.rename-btn:hover { background: var(--line-2); color: var(--brand); }
.del-btn {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px;
  color: var(--ink-5); font-size: 13px; display: grid; place-items: center;
  border: none; background: none; cursor: pointer; margin-left: 2px;
}
.del-btn:hover { background: #FBE9E7; color: #C0392B; }
.btn-danger {
  width: 100%; margin-top: 12px; padding: 10px; border-radius: 8px;
  border: 1px solid #E6B0AA; background: #fff; color: #C0392B; font-size: 13px; cursor: pointer;
}
.btn-danger:hover { background: #FBE9E7; }
.title-edit {
  flex: 1; font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--ink);
  border: 1px solid var(--brand); border-radius: 8px; padding: 2px 8px; outline: none; line-height: 1.5;
}

/* ===== 侧栏分类重命名 ===== */
.cat-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-rename {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 6px;
  color: var(--ink-5); font-size: 12px; display: grid; place-items: center;
}
.cat-rename:hover { background: var(--line-2); color: var(--brand); }
.cat-edit { flex: 1; font-size: 14px; color: var(--ink-2); border: 1px solid var(--brand); border-radius: 6px; padding: 2px 8px; outline: none; }
@media (max-width: 767px) { .card .rename-btn { opacity: 1; } }

