:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --mark: #fde68a;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  --radius: 10px;
  --topbar-h: 56px;
  --sidebar-w: 200px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #242a32;
    --border: #2d343d;
    --text: #e6e8eb;
    --muted: #8b95a3;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --mark: #7c5e00;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); margin: 0; font-size: 13px; }
kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 2px 5px; border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface); color: var(--muted);
}
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary kbd { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); color: #fff; }
.btn.danger-text { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-text:hover { background: rgba(220,38,38,.08); }
.btn.block { width: 100%; justify-content: center; height: 38px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
input[type=text], input[type=password], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { resize: vertical; min-height: 60px; line-height: 1.55; }

/* ---------- 品牌 ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: .2px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--primary);
  position: relative; flex: none;
}
.brand-mark::before {
  content: ""; position: absolute; inset: 5px 4px; border: 1.5px solid #fff; border-radius: 2px;
}
.brand-mark::after {
  content: ""; position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #fff;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
}

/* ---------- 登录 ---------- */
.login-view { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.login-card .brand { font-size: 20px; }
.login-card .muted { margin: -8px 0 4px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

/* ---------- 布局 ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 14px;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.search { position: relative; flex: 1; max-width: 640px; }
.search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; padding-right: 32px; height: 36px; background: var(--surface-2); border-color: transparent; }
.search input:focus { background: var(--surface); border-color: var(--primary); }
.search input::-webkit-search-cancel-button { display: none; }
.search #search-clear { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; }
.count { white-space: nowrap; min-width: 60px; }
/* 最近搜索下拉 */
.search-recent {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.search-recent .sr-head { display: flex; align-items: center; padding: 4px 8px 6px; font-size: 11.5px; color: var(--muted); }
.search-recent .sr-head .link-btn { margin-left: auto; font-size: 11.5px; }
.search-recent .sr-item {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 8px 7px 10px; border: 0; border-radius: 7px;
  background: none; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; text-align: left;
}
.search-recent .sr-item svg { width: 14px; height: 14px; flex: none; color: var(--muted); }
.search-recent .sr-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-recent .sr-item:hover, .search-recent .sr-item.active { background: var(--surface-2); }
.search-recent .sr-item .sr-del {
  flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted);
  font-size: 16px; line-height: 1; cursor: pointer; opacity: 0;
}
.search-recent .sr-item:hover .sr-del, .search-recent .sr-item.active .sr-del { opacity: 1; }
.search-recent .sr-item .sr-del:hover { background: var(--border); color: var(--text); }
@media (hover: none) { .search-recent .sr-item .sr-del { opacity: 1; } }
.user-menu { margin-left: auto; position: relative; }
.user-btn { padding: 0 10px 0 6px; gap: 8px; }
.user-btn .avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; text-transform: uppercase; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 180px; padding: 6px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 60; }
.user-dropdown .ud-head { padding: 6px 10px 8px; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 6px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; }
.user-dropdown button:hover { background: var(--surface-2); }
.user-dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.viewas-bar { display: flex; align-items: center; gap: 10px; padding: 7px 20px; background: #fde68a; color: #1f2328; font-size: 13px; border-bottom: 1px solid #f59e0b; }
.viewas-bar .btn { margin-left: auto; }
body.view-as #upload-btn, body.view-as #url-btn, body.view-as #draft-btn, body.view-as #select-btn, body.view-as #stash-add, body.view-as .stash-drop, body.view-as #cat-add, body.view-as #manage-cats, body.view-as #ext-btn,
body.view-as #detail-save, body.view-as #detail-save-close, body.view-as #detail-delete, body.view-as #detail-restore, body.view-as #detail-purge, body.view-as #btn-reocr, body.view-as #btn-analyze, body.view-as #btn-table, body.view-as #btn-translate, body.view-as #btn-edit, body.view-as #btn-share, body.view-as #btn-source, body.view-as #image-strip .st-tools, body.view-as #image-strip .st.add, body.view-as #trash-empty, body.view-as .stash-item .ops button, body.view-as #shares-prune, body.view-as #shares-revoke-all, body.view-as #fields-edit-btn { display: none !important; }
.dialog.users-dialog { width: min(1100px, 100%); max-width: none; max-height: min(860px, 100%); }
.users-dialog .dialog-body { flex: 1; min-height: 0; }
.users-dialog .tbl { overflow: auto; }
.user-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.user-add input[type=text] { width: auto; flex: 1 1 160px; padding: 6px 10px; }
.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th, .users-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.users-table td:first-child { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.users-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.users-table .ops { display: inline-flex; gap: 8px; }
.usage-cell { display: flex; flex-direction: column; gap: 3px; min-width: 150px; }
.usage-cell .bar, .ud-usage .bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.usage-cell .bar i, .ud-usage .bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.usage-cell .bar i.hot, .ud-usage .bar i.hot { background: var(--danger); }
.usage-cell .def, .users-table .def { color: var(--muted); font-size: 11px; }
.ud-usage { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.ud-usage.nolimit .bar { display: none; }
.users-table .st-disabled { color: var(--danger); }
.users-table .me { color: var(--muted); font-size: 11px; margin-left: 4px; }
@media (max-width: 860px) { .user-btn .btn-text { display: none; } .viewas-bar { padding: 7px 12px; flex-wrap: wrap; } }

.body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: var(--sidebar-w); flex: none; padding: 16px 12px; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.cat-list { display: flex; flex-direction: column; gap: 2px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 0; background: none;
  font: inherit; color: var(--text); text-align: left; width: 100%;
}
.cat-item:hover { background: var(--surface-2); }
.cat-item.active { background: rgba(37,99,235,.10); color: var(--primary); font-weight: 600; }
.cat-item .n { font-size: 12px; color: var(--muted); font-weight: normal; }
.cat-item.active .n { color: var(--primary); }
.paste-hint { margin-top: auto; font-size: 12px; color: var(--muted); line-height: 2; padding: 0 6px; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ---------- 上传队列 ---------- */
.upload-queue { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.up-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px;
}
.up-item img { width: 40px; height: 30px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.up-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-item .status { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.up-item.error .status { color: var(--danger); }
.up-item.done .status { color: #16a34a; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border);
  border-top-color: var(--primary); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 卡片网格 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; display: flex; flex-direction: column; min-width: 0;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: transparent; }
.card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.card .thumb { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }
.cat {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.cat::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; }
.cat[data-cat="报表数据"]::before { background: #2563eb; }
.cat[data-cat="聊天记录"]::before { background: #16a34a; }
.cat[data-cat="配置代码"]::before { background: #7c3aed; }
.cat[data-cat="文档说明"]::before { background: #d97706; }
.card .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.card .snippet {
  font-size: 12.5px; line-height: 1.5; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  word-break: break-all; min-height: 1.5em;
}
.card .snippet.empty { color: var(--muted); font-style: italic; }
.card .foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.card .foot .time { margin-left: auto; white-space: nowrap; }

.empty { text-align: center; padding: 80px 20px; color: var(--muted); }
.empty h3 { margin: 0 0 8px; font-weight: 600; color: var(--text); font-size: 16px; }
.empty p { margin: 0; }
.more-wrap { display: flex; justify-content: center; padding: 24px 0 8px; }

/* ---------- 拖拽遮罩 ---------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(37,99,235,.10); backdrop-filter: blur(2px); pointer-events: none;
}
.drop-overlay div {
  padding: 24px 40px; border: 2px dashed var(--primary); border-radius: 16px;
  background: var(--surface); color: var(--primary); font-size: 18px; font-weight: 600;
}

/* ---------- 详情弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  width: 100%; height: 100%; max-width: 1700px;
  background: var(--surface); border-radius: 14px; overflow: hidden; display: flex;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
/* 全屏：铺满整个窗口 */
.modal.full { padding: 0; }
.modal.full .modal-box { max-width: none; border-radius: 0; }
.modal.full #modal-full { color: var(--primary); }
.modal-image {
  flex: 1; min-width: 0; background: #0f1216; display: flex; flex-direction: column;
  align-items: center; justify-content: center; position: relative;
}
.modal-image a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 16px; }
.modal-image img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.modal-image #detail-meta { position: absolute; left: 12px; bottom: 10px; color: rgba(255,255,255,.55); }
.modal-panel { width: clamp(360px, 30%, 480px); flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border); }
.panel-title { font-weight: 600; flex: 1; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.panel-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field > span em { font-style: normal; font-weight: normal; margin-left: 4px; }
.field.grow { flex: 1; }
.field.grow textarea { flex: 1; min-height: 160px; font-family: inherit; font-size: 13px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.seg button:hover { background: var(--surface-2); }
.seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.tag-box {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  cursor: text; min-height: 40px;
}
.tag-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.tag-box .chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px;
  background: rgba(37,99,235,.10); color: var(--primary); font-size: 12.5px;
}
.tag-box .chip button {
  border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1;
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
}
.tag-box .chip button:hover { background: rgba(37,99,235,.18); }
.tag-box input { flex: 1; min-width: 100px; border: 0; padding: 4px 4px; background: transparent; box-shadow: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 200;
  padding: 10px 16px; border-radius: 10px; background: #1f2328; color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 80vw;
}
.toast.error { background: var(--danger); }
.toast.action { background: var(--primary); cursor: pointer; pointer-events: auto; }
/* 相似截图 */
.similar-list { display: flex; flex-wrap: wrap; gap: 8px; }
.similar-list .sim {
  display: flex; flex-direction: column; gap: 3px; width: 96px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: var(--surface); cursor: pointer; font: inherit; color: var(--text); text-align: left;
}
.similar-list .sim:hover { border-color: var(--primary); }
.similar-list .sim img { width: 100%; height: 64px; object-fit: cover; border-radius: 5px; background: var(--surface-2); }
.similar-list .sim span { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-dialog { width: min(640px, 100%); }
/* 暂存区 */
.dialog.stash-dialog { width: min(1000px, 100%); max-width: none; height: min(860px, 100%); max-height: none; }
.stash-dialog .dialog-body { flex: 1; min-height: 0; }
.stash-dialog .panel-head { gap: 12px; }
.stash-dialog .panel-title { flex: none; white-space: nowrap; }
.stash-dialog #stash-total { white-space: nowrap; }
.stash-search { flex: 1; min-width: 120px; max-width: 320px; margin-left: auto; padding: 5px 10px; font-size: 13px; }
.stash-foot { padding: 8px 18px; gap: 10px; }
.stash-foot .btn:disabled { opacity: .4; }
.stash-drop { padding: 14px; border: 2px dashed var(--border); border-radius: 10px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.6; transition: border-color .12s, background .12s; }
.stash-drop.over, .stash-dialog.over .stash-drop { border-color: var(--primary); background: rgba(37,99,235,.06); color: var(--primary); }
.stash-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; align-content: start; }
.stash-item { display: grid; grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: auto auto; gap: 2px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.stash-item .ic { grid-row: 1 / 3; }
.stash-item > div { min-width: 0; }
.stash-item .ic { width: 44px; height: 36px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: var(--muted); overflow: hidden; letter-spacing: .3px; }
.stash-item .ic img { width: 100%; height: 100%; object-fit: cover; }
.stash-item .t { display: block; font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); text-decoration: none; }
.stash-item .t:hover { color: var(--primary); }
.stash-item .m { font-size: 12px; color: var(--muted); }
.stash-item .ops { grid-column: 2; display: flex; flex-wrap: wrap; gap: 2px 10px; }
.stash-item .ops a, .stash-item .ops button { white-space: nowrap; }
.stash-item .m { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stash-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 12px; }
@media (max-width: 860px) { .stash-list { grid-template-columns: 1fr; } .stash-search { width: 100%; flex-basis: 100%; order: 9; max-width: none; margin-left: 0; } .stash-dialog .panel-head { flex-wrap: wrap; } }
.dup-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dup-compare figure { margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.dup-compare figcaption { font-size: 12px; color: var(--muted); padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dup-compare img { display: block; width: 100%; height: 200px; object-fit: contain; }
.toast.action:hover { background: var(--primary-hover); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .body { flex-direction: column; }
  .sidebar {
    width: auto; flex-direction: row; gap: 4px; padding: 8px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .cat-list { flex-direction: row; gap: 4px; }
  .cat-item { white-space: nowrap; padding: 6px 10px; gap: 5px; }
  .paste-hint { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .brand { font-size: 0; }
  .count { display: none; }
  .modal { padding: 0; }
  .modal-box { border-radius: 0; flex-direction: column; height: 100%; }
  .modal-image { flex: 0 0 40%; }
  .modal-panel { width: 100%; flex: 1; border-left: 0; border-top: 1px solid var(--border); }
  .content { padding: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}

/* ---------- 第二阶段：状态、标题、动作、表格 ---------- */
.card .title { font-weight: 600; font-size: 13.5px; line-height: 1.4; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .title + .snippet { font-size: 12px; color: var(--muted); -webkit-line-clamp: 2; }
.status-chip {
  position: absolute; right: 8px; top: 8px; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(31,35,40,.72); color: #fff; backdrop-filter: blur(4px);
}
.status-chip.failed { background: rgba(220,38,38,.85); }
.status-chip .spinner { width: 10px; height: 10px; border-width: 2px; border-color: rgba(255,255,255,.35); border-top-color: #fff; }
.card .foot .icon-table { display: inline-flex; color: var(--muted); }
.card .foot .icon-table svg { width: 14px; height: 14px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.small.busy { opacity: .6; pointer-events: none; }
#detail-status { margin-left: auto; }
#detail-status.err { color: var(--danger); }
#detail-ocr.pending { color: var(--muted); font-style: italic; }
#detail-ocr.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12.5px; white-space: pre; overflow-x: auto; tab-size: 2; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-tools { margin-left: auto; display: inline-flex; gap: 10px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: 12px; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.table-view { display: flex; flex-direction: column; gap: 12px; }
.table-view .tbl-title { font-size: 12.5px; font-weight: 600; margin: 0 0 4px; }
.table-view .tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-view table { border-collapse: collapse; font-size: 12.5px; width: max-content; min-width: 100%; }
.table-view th, .table-view td { padding: 5px 10px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table-view th:last-child, .table-view td:last-child { border-right: 0; }
.table-view tr:last-child td { border-bottom: 0; }
.table-view th { background: var(--surface-2); font-weight: 600; position: sticky; top: 0; }
.table-view .tbl-empty { color: var(--muted); font-size: 12.5px; }

/* ---------- 第三阶段：多选、分类管理、最近标签、分组、看图 ---------- */
.select-bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 20px;
  background: rgba(37,99,235,.08); border-bottom: 1px solid var(--border); font-size: 13px;
}
.select-bar #select-count { font-weight: 600; margin-right: 6px; }
.app.selecting .card { cursor: default; }
.app.selecting .card .check { display: flex; }
.card .check {
  display: none; position: absolute; left: 8px; top: 8px; width: 22px; height: 22px; border-radius: 6px;
  background: rgba(255,255,255,.92); border: 1.5px solid #9ca3af; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 700; z-index: 2;
}
.card.selected { outline: 2px solid var(--primary); outline-offset: 1px; }
.card.selected .check { background: var(--primary); border-color: var(--primary); }
.card.selected .check::after { content: "✓"; }
.card.selected .check[data-n]::after { content: attr(data-n); font-size: 12px; }
.count-badge {
  position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(31,35,40,.72); color: #fff; backdrop-filter: blur(4px);
}
.count-badge svg { width: 12px; height: 12px; }

.manage-cats { text-align: left; padding: 6px 10px; font-size: 12.5px; color: var(--muted); }
.manage-cats:hover { color: var(--primary); }
.dialog {
  width: min(520px, 100%); max-height: min(720px, 100%); background: var(--surface); border-radius: 14px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.dialog-body { padding: 14px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.cat-rows { display: flex; flex-direction: column; gap: 4px; }
.cat-row { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.cat-row input { flex: 1; padding: 6px 10px; }
.cat-row input:disabled { background: var(--surface-2); color: var(--muted); }
.cat-row .n { width: 44px; text-align: right; font-size: 12px; color: var(--muted); }
.cat-row .icon-btn { width: 28px; height: 28px; font-size: 14px; }
.cat-row .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.cat-row .link-btn { font-size: 12px; margin-left: 4px; }
.cat-add { display: flex; gap: 8px; margin-top: 4px; }
.cat-add input { flex: 1; }

.recent-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.recent-tags .label { font-size: 11.5px; color: var(--muted); margin-right: 2px; }
.recent-tags .rt {
  font: inherit; font-size: 12px; padding: 2px 9px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.recent-tags .rt:hover { border-color: var(--primary); color: var(--primary); }
.recent-tags .rt.on { background: rgba(37,99,235,.10); border-color: transparent; color: var(--primary); }

.modal-image { padding-bottom: 0; }
.image-btn {
  flex: 1; min-height: 0; width: 100%; border: 0; background: none; padding: 16px; cursor: zoom-in;
  display: flex; align-items: center; justify-content: center;
}
.image-btn img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; border-radius: 4px; }
.image-foot {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px 8px; color: rgba(255,255,255,.55);
}
.image-foot a { color: rgba(255,255,255,.7); }
.image-foot a:hover { color: #fff; }
.modal-image #detail-meta { position: static; }
.image-strip {
  width: 100%; display: flex; gap: 8px; padding: 8px 14px 12px; overflow-x: auto; flex: none;
  background: rgba(255,255,255,.04); border-top: 1px solid rgba(255,255,255,.08);
}
.image-strip .st {
  position: relative; flex: none; width: 76px; height: 56px; border-radius: 6px; overflow: hidden;
  border: 2px solid transparent; background: #1f2530; cursor: pointer;
}
.image-strip .st img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-strip .st.active { border-color: var(--primary); }
.image-strip .st .st-tools {
  position: absolute; inset: auto 0 0 0; display: none; justify-content: space-between;
  background: rgba(0,0,0,.65); padding: 2px 4px;
}
.image-strip .st:hover .st-tools { display: flex; }
.image-strip .st .st-tools button {
  border: 0; background: none; color: #fff; font-size: 11px; cursor: pointer; padding: 1px 3px;
}
.image-strip .st .st-tools button:hover { text-decoration: underline; }
.image-strip .st.add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: rgba(255,255,255,.6); font-size: 11px; border: 1.5px dashed rgba(255,255,255,.3); background: transparent;
}
.image-strip .st.add:hover { color: #fff; border-color: rgba(255,255,255,.7); }
.image-strip .st.add span:first-child { font-size: 18px; line-height: 1; }

/* 看图 */
.lightbox { position: fixed; inset: 0; z-index: 300; background: #000; outline: none; user-select: none; }
.lightbox-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; }
.lightbox-stage.dragging { cursor: grabbing; }
.lightbox-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 80px; border: 0; border-radius: 10px;
  background: rgba(255,255,255,.12); color: #fff; font-size: 40px; line-height: 1; cursor: pointer;
}
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-bar {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px; background: rgba(20,22,26,.85); color: #ddd; font-size: 12.5px;
}
.lb-bar #lb-counter { padding: 0 6px; }
.lb-zoom { min-width: 42px; text-align: center; color: #9ca3af; }
.lb-btn { border: 0; border-radius: 999px; background: transparent; color: #eee; font: inherit; font-size: 12.5px; padding: 4px 10px; cursor: pointer; }
.lb-btn:hover { background: rgba(255,255,255,.15); }

@media (max-width: 860px) {
  .select-bar { padding: 8px 12px; flex-wrap: wrap; }
  .image-strip .st { width: 60px; height: 44px; }
  .lb-nav { width: 36px; height: 60px; font-size: 30px; }
}

/* ---------- 显示模式 ---------- */
.seg-icons { display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-2); }
.seg-icons button {
  width: 30px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.seg-icons button svg { width: 16px; height: 16px; fill: currentColor; }
.seg-icons button:hover { color: var(--text); }
.seg-icons button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.card .hover-title { display: none; }

/* 大网格 */
.grid.mode-grid-l { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.grid.mode-grid-l .card .title { font-size: 15px; }
.grid.mode-grid-l .card .snippet { font-size: 13px; -webkit-line-clamp: 3; }

/* 小网格 */
.grid.mode-grid-s { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.grid.mode-grid-s .card .info { padding: 7px 9px 8px; gap: 3px; }
.grid.mode-grid-s .card .title { font-size: 12.5px; -webkit-line-clamp: 1; }
.grid.mode-grid-s .card .snippet { font-size: 11.5px; -webkit-line-clamp: 1; min-height: 0; }
.grid.mode-grid-s .card .title + .snippet { display: none; }
.grid.mode-grid-s .card .tag, .grid.mode-grid-s .card .icon-table { display: none; }
.grid.mode-grid-s .card .foot { font-size: 11px; }
.grid.mode-grid-s .status-chip, .grid.mode-grid-s .count-badge { font-size: 10px; padding: 1px 6px; }

/* 列表 */
.grid.mode-list { display: flex; flex-direction: column; gap: 8px; }
.grid.mode-list .card { flex-direction: row; align-items: stretch; }
.grid.mode-list .card:hover { transform: none; }
.grid.mode-list .card .thumb { width: 120px; height: 84px; aspect-ratio: auto; flex: none; }
.grid.mode-list .card .info { flex: 1; min-width: 0; padding: 8px 14px; justify-content: center; gap: 4px; }
.grid.mode-list .card .title { -webkit-line-clamp: 1; }
.grid.mode-list .card .snippet { -webkit-line-clamp: 2; min-height: 0; }
.grid.mode-list .card .foot .time { margin-left: auto; }

/* 瀑布流：行跨度由 JS 计算 */
.grid.mode-masonry { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); grid-auto-rows: 4px; gap: 0 16px; align-items: start; }
.grid.mode-masonry .card { margin-bottom: 16px; }
.grid.mode-masonry .card .thumb { aspect-ratio: var(--ar, 4 / 3); max-height: 520px; }
.grid.mode-masonry .card .thumb img { object-fit: contain; object-position: center; }

/* 图墙 */
.grid.mode-wall { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.grid.mode-wall .card { border-radius: 6px; }
.grid.mode-wall .card .thumb { aspect-ratio: 1 / 1; }
.grid.mode-wall .card .info { display: none; }
.grid.mode-wall .card .hover-title {
  display: block; position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 8px 7px;
  font-size: 12px; line-height: 1.3; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,0)); opacity: 0; transition: opacity .15s; pointer-events: none;
}
.grid.mode-wall .card:hover .hover-title { opacity: 1; }
.grid.mode-wall .card.selected .hover-title { opacity: 1; }

@media (max-width: 860px) {
  .seg-icons button[data-mode="grid-l"], .seg-icons button[data-mode="grid-s"], .seg-icons button[data-mode="masonry"] { display: none; }
  .grid.mode-grid-l { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .grid.mode-list .card .thumb { width: 88px; height: 62px; }
  .grid.mode-list .card .info { padding: 6px 10px; }
  .grid.mode-wall { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 4px; }
}

/* 手机顶栏：给搜索框让位 */
@media (max-width: 860px) {
  .topbar .brand { display: none; }
  .topbar { gap: 6px; }
  .search { min-width: 120px; }
  .search input { padding-right: 28px; }
  #upload-btn { padding: 0 10px; }
  #upload-btn .btn-text { display: none; }
  #select-btn { padding: 0 10px; }
  .seg-icons { padding: 2px; }
  .seg-icons button { width: 28px; height: 26px; }
}

/* ---------- 第四阶段：筛选栏、收藏、回收站、右键菜单、字段、译文、分享、问答 ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 14px; padding: 6px 20px; font-size: 12.5px; color: var(--muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.filter-bar label { display: inline-flex; align-items: center; gap: 6px; }
.filter-bar select, .filter-bar input[type=date] {
  width: auto; padding: 3px 8px; font-size: 12.5px; border-radius: 6px; background: var(--surface-2); border-color: transparent; color: var(--text);
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); box-shadow: none; }
.date-range { display: inline-flex; align-items: center; gap: 6px; }
.view-label { color: var(--primary); font-weight: 600; }

.special-list { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.app.trash-view .card { opacity: .78; }
.app.trash-view .card:hover { opacity: 1; }

.card .star-btn {
  position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; border: 0; border-radius: 50%;
  background: rgba(31,35,40,.55); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; opacity: 0;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); z-index: 2;
}
.card:hover .star-btn { opacity: 1; }
.card .star-btn.on { opacity: 1; color: #fbbf24; background: rgba(31,35,40,.7); }
.card .star-btn:hover { transform: scale(1.1); }
.card .status-chip { right: 40px; }
.app.selecting .card .star-btn { display: none; }
.star-toggle {
  border: 0; background: none; font-size: 20px; line-height: 1; color: #cbd5e1; cursor: pointer; padding: 2px 4px; margin-right: 2px;
}
.star-toggle.on { color: #f59e0b; }
.star-toggle:hover { color: #f59e0b; }
.trash-notice { padding: 8px 18px; background: rgba(220,38,38,.08); color: var(--danger); font-size: 12.5px; border-bottom: 1px solid var(--border); }

.ctx-menu {
  position: fixed; z-index: 250; min-width: 150px; padding: 4px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.ctx-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; border-radius: 6px;
  font: inherit; font-size: 13px; color: var(--text); cursor: pointer;
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button.danger { color: var(--danger); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.fields-view { display: flex; flex-wrap: wrap; gap: 6px; }
.fields-view .fld {
  font: inherit; font-size: 12px; padding: 3px 9px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); text-align: left;
}
.fields-view .fld b { font-weight: 600; color: var(--muted); margin-right: 4px; }
.fields-view .fld:hover { border-color: var(--primary); color: var(--primary); }
.fields-view .fld-empty { font-size: 12px; color: var(--muted); }

.share-panel { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-size: 12.5px; }
.share-row { display: flex; align-items: center; gap: 8px; }
.share-row select { width: auto; padding: 4px 8px; font-size: 12.5px; }
.share-row input { flex: 1; font-size: 12.5px; padding: 5px 8px; }
.share-row > span:first-child { white-space: nowrap; }

.ask-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 90;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.ask-drawer .panel-head { padding: 12px 12px 12px 18px; }
.ask-messages { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.ask-hint { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.ask-msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.ask-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.ask-msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.ask-msg.error { background: rgba(220,38,38,.1); color: var(--danger); }
.ask-msg .cite { color: var(--primary); font-size: 11px; vertical-align: super; cursor: pointer; margin: 0 1px; }
.ask-sources { align-self: flex-start; display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.ask-src {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px 3px 3px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 12px; color: var(--text); cursor: pointer; max-width: 100%;
}
.ask-src img { width: 32px; height: 24px; object-fit: cover; border-radius: 4px; background: var(--surface-2); }
.ask-src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.ask-src:hover { border-color: var(--primary); }
.ask-src .no { color: var(--primary); font-weight: 600; }
.ask-form { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.ask-form textarea { flex: 1; min-height: 44px; resize: none; }
.ask-form .btn { align-self: flex-end; }
.ask-thinking { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }

@media (max-width: 860px) {
  .filter-bar { padding: 6px 12px; gap: 10px; flex-wrap: wrap; }
  .card .star-btn { opacity: 1; }
}

/* ---------- 第五阶段：标签侧栏、时间线、统计、编辑器 ---------- */
.tag-side { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.tag-side .side-title { font-size: 11.5px; color: var(--muted); padding: 0 10px 4px; display: flex; align-items: center; }
.tag-side .side-title .link-btn { margin-left: auto; font-size: 11.5px; }
.tag-side .tag-items { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px; }
.tag-side .tg {
  font: inherit; font-size: 12px; padding: 2px 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); max-width: 100%;
  display: inline-flex; align-items: center; gap: 4px;
}
.tag-side .tg .n { color: var(--muted); font-size: 11px; }
.tag-side .tg:hover { border-color: var(--primary); color: var(--primary); }
.tag-side .tg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tag-side .tg.active .n { color: rgba(255,255,255,.75); }
.card .tag { cursor: pointer; }
.card .tag:hover { border-color: var(--primary); color: var(--primary); }
#tag-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#tag-chips .chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px;
  background: rgba(37,99,235,.10); color: var(--primary); font-size: 12.5px;
}
#tag-chips .chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; width: 18px; height: 18px; border-radius: 50%; padding: 0; }
#tag-chips .chip button:hover { background: rgba(37,99,235,.18); }
.tags-dialog .tag-items { display: flex; flex-wrap: wrap; gap: 6px; }
.tags-dialog .tg { font: inherit; font-size: 13px; padding: 4px 11px; border-radius: 999px; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.tags-dialog .tg .n { color: var(--muted); font-size: 11.5px; margin-left: 4px; }
.tags-dialog .tg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.tags-dialog .tg.active .n { color: rgba(255,255,255,.75); }

/* 时间线 */
.grid.mode-timeline { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.grid.mode-timeline .date-head {
  grid-column: 1 / -1; margin: 10px 0 -4px; font-size: 14px; font-weight: 600; display: flex; align-items: baseline; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.grid.mode-timeline .date-head:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.grid.mode-timeline .date-head .n { font-size: 12px; font-weight: normal; color: var(--muted); }
.grid.mode-timeline .date-head .wd { font-size: 12px; font-weight: normal; color: var(--muted); }
.timeline-rail {
  position: fixed; right: 14px; top: calc(var(--topbar-h) + 60px); bottom: 20px; width: 92px; overflow-y: auto; z-index: 4;
  padding: 6px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 12px;
}
.timeline-rail .rm { color: var(--muted); font-size: 11px; padding: 6px 6px 2px; font-weight: 600; }
.timeline-rail .rd { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 3px 6px; border-radius: 6px; font: inherit; font-size: 12px; color: var(--text); cursor: pointer; }
.timeline-rail .rd:hover { background: var(--surface-2); }
.timeline-rail .rd.active { background: rgba(37,99,235,.10); color: var(--primary); font-weight: 600; }
.timeline-rail .rd .n { float: right; color: var(--muted); font-size: 11px; }
.app.has-rail .content { padding-right: 124px; }

/* 统计 */
.stats-dialog { width: min(760px, 100%); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stat-tile { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.stat-tile .v { font-size: 20px; font-weight: 600; line-height: 1.2; }
.stat-tile .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat-sec { display: flex; flex-direction: column; gap: 8px; }
.stat-sec h4 { margin: 4px 0 0; font-size: 13px; font-weight: 600; }
.stat-sec .sub { font-size: 11.5px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 0 2px; border-bottom: 1px solid var(--border); }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bars .bar { width: 100%; max-width: 34px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; transition: opacity .1s; }
.bars .col:hover .bar { opacity: 1; }
.bars .col .tip {
  position: absolute; bottom: 100%; margin-bottom: 4px; font-size: 11px; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 6px; white-space: nowrap; opacity: 0; pointer-events: none;
}
.bars .col:hover .tip { opacity: 1; }
.bars-x { display: flex; gap: 6px; padding: 4px 2px 0; }
.bars-x span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); }
.hbars { display: flex; flex-direction: column; gap: 5px; }
.hbar { display: grid; grid-template-columns: 80px 1fr 40px; align-items: center; gap: 8px; font-size: 12.5px; }
.hbar .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .trk { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fil { height: 100%; background: var(--primary); border-radius: 4px; opacity: .85; }
.hbar .val { text-align: right; color: var(--muted); }
.usage-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.usage-table th, .usage-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: right; }
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table th { color: var(--muted); font-weight: 600; }

/* 编辑器 */
.editor { position: fixed; inset: 0; z-index: 400; background: #0f1216; display: flex; flex-direction: column; outline: none; color: #e6e8eb; }
.ed-toolbar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: #1a1e24; border-bottom: 1px solid #2d343d; flex-wrap: wrap; }
.ed-group { display: inline-flex; gap: 3px; padding: 3px; border-radius: 8px; background: #242a32; }
.ed-group button { border: 0; border-radius: 6px; background: transparent; color: #cbd5e1; font: inherit; font-size: 12.5px; padding: 5px 9px; cursor: pointer; min-width: 30px; }
.ed-group button:hover { background: #2d343d; color: #fff; }
.ed-group button.active { background: var(--primary); color: #fff; }
.ed-group button:disabled { opacity: .35; cursor: default; }
.ed-colors button { width: 26px; height: 26px; border-radius: 50%; padding: 0; position: relative; }
.ed-colors button::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.ed-colors button.active { background: #2d343d; box-shadow: 0 0 0 2px var(--primary); }
.ed-hint { font-size: 12px; color: #8b95a3; }
.ed-toolbar .btn { background: #242a32; border-color: #2d343d; color: #e6e8eb; }
.ed-toolbar .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.ed-toolbar kbd { background: #2d343d; border-color: #3b4350; color: #cbd5e1; }
.ed-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ed-canvas { box-shadow: 0 10px 40px rgba(0,0,0,.5); background: #fff; touch-action: none; }
.ed-apply-crop { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); }
.ed-text-input { position: absolute; width: 240px; padding: 6px 8px; font-size: 14px; border: 2px solid var(--primary); border-radius: 6px; background: #fff; color: #111; z-index: 2; }
.ed-save { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: #1a1e24; border-top: 1px solid #2d343d; font-size: 13px; flex-wrap: wrap; }
.ed-save label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.ed-save .btn { background: #242a32; border-color: #2d343d; color: #e6e8eb; }
.ed-save .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 860px) {
  .timeline-rail { display: none; }
  .app.has-rail .content { padding-right: 12px; }
  .ed-toolbar { gap: 6px; padding: 6px 8px; }
  .ed-hint { display: none; }
}

/* ---------- 文档导入 ---------- */
.doc-badge {
  position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  background: rgba(31,35,40,.72); color: #fff; backdrop-filter: blur(4px); text-transform: uppercase;
}
.doc-badge[data-kind="pdf"] { background: rgba(220,38,38,.85); }
.doc-badge[data-kind="docx"] { background: rgba(37,99,235,.85); }
.doc-badge[data-kind="xlsx"], .doc-badge[data-kind="csv"] { background: rgba(22,163,74,.85); }
.doc-badge[data-kind="markdown"], .doc-badge[data-kind="text"], .doc-badge[data-kind="code"], .doc-badge[data-kind="html"] { background: rgba(124,58,237,.85); }
.app.selecting .card .doc-badge { display: none; }
.image-links { display: inline-flex; gap: 12px; }
.image-links a { color: rgba(255,255,255,.7); }
.image-links a:hover { color: #fff; }
.paste-hint .muted { font-size: 11px; line-height: 1.5; display: inline-block; margin-top: 2px; }
.up-item .up-doc { width: 40px; height: 30px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* 粘贴文本保存为文档 */
.paste-dialog { width: min(680px, 100%); }
.dialog.paste-dialog.full { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
.paste-dialog.full .dialog-body { flex: 1; min-height: 0; }
.paste-dialog.full .code-editor .code-hl, .paste-dialog.full .code-editor textarea { font-size: 14px; }
.paste-dialog.full .panel-head #paste-full { color: var(--primary); }
.paste-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.paste-row label { display: inline-flex; align-items: center; gap: 6px; flex: 1; font-size: 13px; color: var(--muted); }
.paste-row label input { flex: 1; }
/* 代码编辑器：透明 textarea 叠在高亮层上，textarea 管输入与光标，pre 只负责颜色 */
.code-editor { position: relative; height: 340px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); overflow: hidden; }
.code-editor:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.code-editor .code-hl, .code-editor textarea {
  position: absolute; inset: 0; margin: 0; padding: 8px 10px; border: 0; border-radius: 0; box-shadow: none;
  font: 13px/1.55 ui-monospace, Consolas, "Courier New", monospace; tab-size: 2; letter-spacing: 0; word-spacing: 0;
  white-space: pre; word-wrap: normal; overflow: auto; background: transparent; box-sizing: border-box;
}
.code-editor .code-hl { pointer-events: none; color: var(--text); }
.code-editor .code-hl code { font: inherit; white-space: inherit; background: none; padding: 0; }
.code-editor textarea { color: transparent; caret-color: var(--text); resize: none; outline: none; -webkit-text-fill-color: transparent; }
.code-editor textarea::selection { background: rgba(37,99,235,.25); }
.code-editor.plain textarea { color: var(--text); -webkit-text-fill-color: currentColor; }
.code-editor.plain .code-hl { visibility: hidden; }
.code-editor.wrap .code-hl, .code-editor.wrap textarea { white-space: pre-wrap; word-wrap: break-word; }
.paste-dialog.full .code-editor { flex: 1; min-height: 0; height: auto; }
/* 高亮层里的元素一律清掉站内样式（Prism 的 .tag / .content / .title 等类名会撞上页面自己的样式，带来内边距导致与光标错位） */
.code-hl code * { all: unset; }
/* token 颜色 */
.code-hl .token.comment, .code-hl .token.prolog, .code-hl .token.doctype, .code-hl .token.cdata { color: #6b7280; font-style: italic; }
.code-hl .token.punctuation { color: #6b7280; }
.code-hl .token.tag, .code-hl .token.keyword, .code-hl .token.selector, .code-hl .token.important, .code-hl .token.atrule { color: #1d4ed8; }
.code-hl .token.attr-name, .code-hl .token.property, .code-hl .token.variable, .code-hl .token.builtin { color: #7c3aed; }
.code-hl .token.attr-value, .code-hl .token.string, .code-hl .token.char, .code-hl .token.url, .code-hl .token.regex { color: #15803d; }
.code-hl .token.number, .code-hl .token.boolean, .code-hl .token.constant, .code-hl .token.symbol { color: #b45309; }
.code-hl .token.function, .code-hl .token.class-name { color: #0e7490; }
.code-hl .token.operator, .code-hl .token.entity { color: #374151; }
.code-hl .token.title, .code-hl .token.bold { font-weight: 600; }
.code-hl .token.italic { font-style: italic; }
.code-hl .token.title { color: #1d4ed8; }
.code-hl .token.list, .code-hl .token.hr, .code-hl .token.blockquote { color: #7c3aed; }
.code-hl .token.code, .code-hl .token.code-block { color: #b45309; }
.code-hl .token.url .token.content { color: #1d4ed8; }
.code-hl .language-json .token.property { color: #1d4ed8; }
.code-hl .language-json .token.null { color: #7c3aed; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .code-hl .token.comment, .code-hl .token.prolog, .code-hl .token.doctype, .code-hl .token.cdata, .code-hl .token.punctuation { color: #8b95a3; }
  .code-hl .token.tag, .code-hl .token.keyword, .code-hl .token.selector, .code-hl .token.important, .code-hl .token.atrule, .code-hl .token.title, .code-hl .language-json .token.property, .code-hl .token.url .token.content { color: #7cb3ff; }
  .code-hl .token.attr-name, .code-hl .token.property, .code-hl .token.variable, .code-hl .token.builtin, .code-hl .token.list, .code-hl .token.hr, .code-hl .token.blockquote, .code-hl .language-json .token.null { color: #c4a3ff; }
  .code-hl .token.attr-value, .code-hl .token.string, .code-hl .token.char, .code-hl .token.url, .code-hl .token.regex { color: #7ee2a0; }
  .code-hl .token.number, .code-hl .token.boolean, .code-hl .token.constant, .code-hl .token.symbol, .code-hl .token.code, .code-hl .token.code-block { color: #ffbe6f; }
  .code-hl .token.function, .code-hl .token.class-name { color: #67d8e8; }
  .code-hl .token.operator, .code-hl .token.entity { color: #d1d5db; }
}
.paste-actions { display: flex; align-items: center; gap: 8px; }

/* 详情图片区右上角的关闭按钮：悬停时出现 */
.image-close {
  position: absolute; top: 12px; right: 12px; z-index: 3; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.18); color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
  backdrop-filter: blur(4px); opacity: 0; transition: opacity .15s, background .15s;
}
.modal-image:hover .image-close, .image-close:focus-visible { opacity: 1; }
.image-close:hover { background: rgba(255,255,255,.35); }

/* ---------- 详情：图片 / 原文 / 并排 ---------- */
.modal-image { flex-direction: row; align-items: stretch; }
.modal-image .image-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.modal-image.mode-image .source-pane { display: none; }
.modal-image.mode-source .image-col { display: none; }
.modal-image.mode-split .image-col { flex: 1 1 50%; }
.modal-image.mode-split .source-pane { flex: 1 1 50%; border-left: 1px solid rgba(255,255,255,.08); }
.modal-image.mode-source .source-pane { flex: 1; }
.view-switch { position: absolute; left: 12px; top: 12px; z-index: 3; display: inline-flex; gap: 2px; padding: 3px; border-radius: 9px; background: rgba(20,22,26,.8); backdrop-filter: blur(4px); }
.view-switch button { border: 0; border-radius: 6px; background: transparent; color: #cbd5e1; font: inherit; font-size: 12.5px; padding: 4px 10px; cursor: pointer; }
.view-switch button:hover { color: #fff; }
.view-switch button.active { background: var(--primary); color: #fff; }
.view-switch button:disabled { opacity: .35; cursor: default; }
.source-pane { min-width: 0; display: flex; flex-direction: column; background: #161a20; color: #e6e8eb; }
.sp-bar { display: flex; align-items: center; gap: 12px; padding: 12px 56px 10px 14px; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 12.5px; flex-wrap: wrap; }
.modal-image.mode-source .sp-bar, .modal-image.mode-split .sp-bar { padding-left: 14px; }
.modal-image.mode-source .sp-bar { padding-left: 220px; }
.sp-lang { font-weight: 700; color: #7cb3ff; letter-spacing: .3px; }
.sp-note { color: #8b95a3; }
.sp-note a { color: #7cb3ff; display: inline; width: auto; height: auto; padding: 0; }
.sp-opt { display: inline-flex; align-items: center; gap: 4px; color: #cbd5e1; cursor: pointer; user-select: none; }
.sp-btn { border: 1px solid #3b4350; border-radius: 6px; background: #242a32; color: #e6e8eb; font: inherit; font-size: 12.5px; padding: 4px 10px; cursor: pointer; }
.sp-btn:hover { background: #2d343d; }
.sp-body { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 20px; font: 13px/1.6 ui-monospace, Consolas, "Courier New", monospace; tab-size: 4; }
.sp-body pre { margin: 0; font: inherit; white-space: pre; background: none; border: 0; padding: 0; color: inherit; }
.source-pane.wrap .sp-body pre { white-space: pre-wrap; word-break: break-word; }
.sp-body .sp-text + .code-block, .sp-body .code-block + .sp-text { margin-top: 10px; }
.code-block { position: relative; margin: 10px 0; border: 1px solid #2d343d; border-radius: 8px; background: #0f1216; overflow: hidden; }
.code-block .cb-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; background: #1d2229; border-bottom: 1px solid #2d343d; font-size: 11.5px; color: #8b95a3; user-select: none; }
.code-block .cb-copy { border: 0; border-radius: 5px; background: transparent; color: #cbd5e1; font: inherit; font-size: 12px; padding: 3px 8px; cursor: pointer; }
.code-block .cb-copy:hover { background: #2d343d; color: #fff; }
.code-block pre { padding: 10px 12px; overflow-x: auto; }
.sp-sel-copy { position: fixed; z-index: 150; border: 0; border-radius: 7px; background: var(--primary); color: #fff; font: 12.5px/1 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; padding: 7px 12px; cursor: pointer; box-shadow: 0 6px 18px rgba(0,0,0,.35); user-select: none; }
.sp-sel-copy:hover { background: var(--primary-hover); }
.sp-sel-copy.done { background: #16a34a; }
.sp-empty { color: #8b95a3; font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 13px; padding: 20px 4px; }
/* 原文面板固定深色配色 */
.sp-body code * { all: unset; }
.sp-body .token.comment, .sp-body .token.prolog, .sp-body .token.doctype, .sp-body .token.cdata, .sp-body .token.punctuation { color: #8b95a3; }
.sp-body .token.comment { font-style: italic; }
.sp-body .token.tag, .sp-body .token.keyword, .sp-body .token.selector, .sp-body .token.important, .sp-body .token.atrule, .sp-body .token.title, .sp-body .language-json .token.property, .sp-body .token.url .token.content { color: #7cb3ff; }
.sp-body .token.attr-name, .sp-body .token.property, .sp-body .token.variable, .sp-body .token.builtin, .sp-body .token.list, .sp-body .token.hr, .sp-body .token.blockquote, .sp-body .language-json .token.null { color: #c4a3ff; }
.sp-body .token.attr-value, .sp-body .token.string, .sp-body .token.char, .sp-body .token.url, .sp-body .token.regex { color: #7ee2a0; }
.sp-body .token.number, .sp-body .token.boolean, .sp-body .token.constant, .sp-body .token.symbol, .sp-body .token.code-snippet, .sp-body .token.code { color: #ffbe6f; }
.sp-body .token.function, .sp-body .token.class-name { color: #67d8e8; }
.sp-body .token.operator, .sp-body .token.entity { color: #d1d5db; }
.sp-body .token.title, .sp-body .token.bold { font-weight: 700; }
.sp-body .token.italic { font-style: italic; }
@media (max-width: 860px) {
  .view-switch button[data-view="split"] { display: none; }
  .view-switch { top: 8px; left: 8px; }
  .modal-image.mode-source .sp-bar { padding-left: 150px; }
  .sp-bar { padding-right: 48px; gap: 8px; }
}
@media (hover: none) { .image-close { opacity: 1; } }

/* 分享链接管理 */
.shares-dialog { width: min(760px, 100%); }
.share-list { display: flex; flex-direction: column; gap: 6px; }
.share-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.share-item img { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; background: var(--surface-2); }
.share-item .no-thumb { width: 56px; height: 40px; border-radius: 6px; background: var(--surface-2); }
.share-item .t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.share-item .t:hover { color: var(--primary); }
.share-item .u { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-item .m { font-size: 12px; color: var(--muted); }
.share-item .m .bad { color: var(--danger); }
.share-item .ops { display: inline-flex; gap: 8px; }
.share-item.dead { opacity: .6; }

/* ---------- 笔记草稿 ---------- */
.draft-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); z-index: 95;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0,0,0,.12);
  display: flex; flex-direction: column;
}
.draft-panel .panel-head { padding: 10px 12px 10px 18px; gap: 8px; }
.draft-tabs { display: flex; gap: 4px; padding: 6px 12px 0; overflow-x: auto; border-bottom: 1px solid var(--border); flex: none; scrollbar-width: thin; }
.draft-tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 6px 10px; border-radius: 8px 8px 0 0;
  border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.draft-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border); font-weight: 600; }
.draft-tab .dot { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; flex: none; visibility: hidden; }
.draft-tab.dirty .dot { visibility: visible; }
.draft-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 18px 12px; gap: 10px; }
.draft-row { display: flex; align-items: center; gap: 10px; }
.draft-row input { flex: 1; }
#draft-text { flex: 1; min-height: 0; resize: none; font-size: 15px; line-height: 1.7; font-family: inherit; }
#draft-kind[data-kind="txt"] ~ #draft-text, .draft-editor.mono #draft-text { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 13.5px; }
.draft-foot { display: flex; align-items: center; gap: 8px; }
.draft-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13.5px; padding: 24px; text-align: center; }
.draft-empty.hidden { display: none; }
#draft-status.err { color: var(--danger); }
@media (max-width: 860px) {
  .draft-panel { width: 100%; }
  .draft-editor { padding: 10px 12px; }
  .draft-foot kbd { display: none; }
}

/* ---------- 手机版统一适配（放在最后，覆盖前面的规则） ---------- */
@media (max-width: 860px) {
  @supports (height: 100dvh) { .app { height: 100dvh; } }
  html, body { overflow-x: hidden; }

  /* 顶栏：搜索 + 上传 + 退出 一行，显示模式 + 笔记/问答/选择 第二行 */
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; }
  .topbar .search { order: 1; flex: 1 1 120px; min-width: 0; max-width: none; }
  .topbar #upload-btn { order: 2; }
  .topbar #logout-btn { order: 3; margin-left: 0; }
  .topbar::after { content: ""; order: 4; flex-basis: 100%; height: 0; }
  .topbar #view-modes { order: 5; }
  .topbar #draft-btn { order: 6; }
  .topbar #ask-btn { order: 7; }
  .topbar #select-btn { order: 8; }
  .topbar #url-btn { order: 9; }
  .topbar #view-modes { margin-right: auto; }
  .topbar .btn { height: 32px; padding: 0 10px; font-size: 13px; }
  .seg-icons button { width: 30px; height: 26px; }

  /* 筛选栏 / 多选栏 */
  .filter-bar { padding: 6px 12px; gap: 8px 12px; font-size: 12.5px; }
  .filter-bar select { max-width: 42vw; }
  .date-range { flex-basis: 100%; }
  .date-range input[type=date] { flex: 1; min-width: 0; }
  .select-bar { gap: 6px; }
  .select-bar kbd { display: none; }
  .btn.small { height: 32px; }

  /* 侧栏：变成可横向滑动的一条 */
  .sidebar {
    width: auto; height: auto; flex: none; flex-direction: row; align-items: center; gap: 6px;
    padding: 8px 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
    border-right: 0; border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar > * { flex: none; }
  .cat-list { flex-direction: row; align-items: center; gap: 4px; }
  .cat-item { width: auto; white-space: nowrap; padding: 6px 10px; gap: 5px; height: 32px; }
  .special-list { margin: 0 0 0 4px; padding: 0 0 0 8px; border-top: 0; border-left: 1px solid var(--border); }
  .tag-side { display: flex; align-items: center; gap: 6px; margin: 0 0 0 4px; padding: 0 0 0 8px; border-top: 0; border-left: 1px solid var(--border); }
  .tag-side .side-title { padding: 0; white-space: nowrap; gap: 4px; }
  .tag-side .side-title .link-btn { margin-left: 0; }
  .tag-side .tag-items { flex-wrap: nowrap; padding: 0; }
  .tag-side .tg { white-space: nowrap; }
  .manage-cats { padding: 6px 8px; white-space: nowrap; }
  .paste-hint { display: none; }

  .content { padding: 12px; }
  .app.has-rail .content { padding-right: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .grid.mode-timeline { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .card .star-btn { opacity: 1; }

  /* 详情：上图下信息，信息区可滚动 */
  .modal { padding: 0; }
  .modal-box { border-radius: 0; flex-direction: column; height: 100%; max-width: none; }
  .modal-image { flex: 0 0 42%; min-height: 200px; }
  .image-btn { padding: 8px; }
  .image-foot { padding: 0 10px 6px; font-size: 11.5px; }
  .image-close { opacity: 1; width: 32px; height: 32px; top: 8px; right: 8px; }
  .modal-panel { width: 100%; flex: 1; min-height: 0; border-left: 0; border-top: 1px solid var(--border); }
  .panel-head { padding: 8px 8px 8px 14px; }
  .panel-body { padding: 12px 14px; gap: 14px; }
  .panel-foot { padding: 10px 14px; }
  .panel-foot kbd, .draft-foot kbd { display: none; }
  #modal-full { display: none; }
  .field.grow textarea { min-height: 120px; }
  .share-row { flex-wrap: wrap; }
  .share-row input { flex: 1 1 100%; }
  .image-strip .st { width: 76px; height: 56px; }
  .image-strip .st.active .st-tools { display: flex; }
  .image-strip .st .st-tools button { white-space: nowrap; padding: 1px 2px; }

  /* 各种对话框：手机上铺满 */
  .dialog { width: 100%; height: 100%; max-height: none; border-radius: 0; }
  .dialog-body { padding: 12px 14px 16px; }
  .share-item { grid-template-columns: 48px 1fr; }
  .share-item img, .share-item .no-thumb { width: 48px; height: 36px; }
  .share-item .ops { grid-column: 2; }
  .hbar { grid-template-columns: 64px 1fr 40px; }
  .usage-table { display: block; overflow-x: auto; white-space: nowrap; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
  .paste-row label { flex: 1 1 100%; }

  /* 抽屉 / 笔记 / 看图 / 编辑器 */
  .ask-drawer, .draft-panel { width: 100%; border-left: 0; }
  .ask-msg { max-width: 96%; }
  .ask-form { padding: 10px 12px; }
  .draft-editor { padding: 10px 12px; }
  .draft-row { flex-wrap: wrap; }
  .draft-row input { flex: 1 1 100%; }
  .lb-nav { width: 36px; height: 60px; font-size: 30px; }
  .lb-bar { max-width: calc(100% - 16px); flex-wrap: wrap; justify-content: center; bottom: 10px; }
  .ed-toolbar { gap: 6px; padding: 6px 8px; }
  .ed-hint { display: none; }
  .ed-group button { padding: 5px 7px; min-width: 28px; }
  .ed-save { gap: 8px 12px; padding: 8px 10px; }

  .toast { max-width: calc(100% - 24px); bottom: 16px; }
  .ctx-menu { max-width: calc(100vw - 16px); }
}

/* 触屏设备：悬停才出现的东西改为常显 */
@media (hover: none) {
  .card .star-btn { opacity: 1; }
  .image-strip .st.active .st-tools { display: flex; }
  .grid.mode-wall .card .hover-title { opacity: 1; }
}

/* 文档瘦身 */
.slim-dialog { width: min(560px, calc(100vw - 32px)); }
.slim-stats { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); color: var(--text); }
.slim-progress { margin-top: 12px; display: grid; gap: 6px; }
.slim-progress .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.slim-progress .bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .3s; }
.slim-errors { margin: 10px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; color: var(--danger); }

/* 文档栏：最小化的详情 */
.dock {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 150;
  display: flex; gap: 6px; padding: 6px; max-width: calc(100vw - 32px); overflow-x: auto; scrollbar-width: thin;
  background: rgba(22,26,32,.92); backdrop-filter: blur(8px); border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.dock-item {
  position: relative; flex: none; display: flex; align-items: center; gap: 7px; height: 36px; padding: 0 26px 0 5px; max-width: 220px;
  border-radius: 8px; background: rgba(255,255,255,.07); color: #e6e8eb; cursor: pointer; font-size: 12.5px; user-select: none;
  border: 1px solid transparent;
}
.dock-item:hover { background: rgba(255,255,255,.14); }
.dock-item.active { background: rgba(37,99,235,.35); border-color: var(--primary); }
.dock-item img, .dock-item .dock-noimg { width: 36px; height: 27px; object-fit: cover; object-position: left top; border-radius: 4px; flex: none; background: #2a3038; }
.dock-item em { font-style: normal; font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 3px; background: rgba(255,255,255,.16); color: #cbd5e1; flex: none; }
.dock-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dock-x {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: rgba(255,255,255,.55); font-size: 15px; line-height: 1; cursor: pointer;
}
.dock-x:hover { background: rgba(255,255,255,.18); color: #fff; }
body.has-dock .modal { padding-bottom: 62px; }
body.has-dock .modal.full { padding-bottom: 52px; }
body.has-dock .toast { bottom: 64px; }
@media (max-width: 640px) {
  .dock { left: 0; right: 0; bottom: 0; transform: none; max-width: none; border-radius: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .dock-item { max-width: 150px; }
  .dock-item em { display: none; }
  body.has-dock .modal, body.has-dock .modal.full { padding-bottom: calc(50px + env(safe-area-inset-bottom)); }
}

/* 用户管理：在线小绿点 */
.online-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #16a34a; margin-right: 5px; vertical-align: middle; }

/* ---------- 速查（右侧抽屉） ---------- */
#snip-btn .n { margin-left: 6px; font-size: 11px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
#snip-btn.on { border-color: var(--primary); color: var(--primary); }
.snip-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 160;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -10px 0 30px rgba(0,0,0,.18);
  display: flex; flex-direction: column;
}
.snip-panel .panel-head { padding: 10px 12px 10px 18px; gap: 8px; }
#snip-list-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.snip-bar { padding: 10px 12px 6px; }
.snip-bar input { width: 100%; }
.snip-groups { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 8px; }
.snip-groups:empty { display: none; }
.snip-groups button {
  font: inherit; font-size: 12.5px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.snip-groups button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.snip-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.snip-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; position: relative;
}
.snip-item:hover { background: var(--surface-2); }
.snip-item.copied { border-color: #16a34a; background: rgba(22,163,74,.10); }
.snip-item.dragging { opacity: .5; }
.snip-item.drop-before { box-shadow: 0 -2px 0 var(--primary); }
.snip-item.drop-after { box-shadow: 0 2px 0 var(--primary); }
.snip-grip { flex: none; width: 16px; color: var(--muted); cursor: grab; text-align: center; line-height: 1; touch-action: none; user-select: none; }
.snip-main { flex: 1; min-width: 0; display: block; overflow: hidden; }
.snip-name { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip-name .g { font-weight: normal; font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-right: 6px; }
.snip-preview { display: block; font: 12px/1.5 ui-monospace, Consolas, "Courier New", monospace; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip-edit { flex: none; opacity: 0; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 12.5px; padding: 2px 4px; }
.snip-item:hover .snip-edit, .snip-item:focus-within .snip-edit { opacity: 1; }
.snip-edit:hover { color: var(--primary); }
.snip-empty { padding: 24px 18px; color: var(--muted); font-size: 13px; text-align: center; }
.snip-form { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; overflow-y: auto; }
.snip-form textarea { min-height: 200px; flex: 1; resize: vertical; font: 13px/1.6 ui-monospace, Consolas, "Courier New", monospace; }
.snip-form-foot { display: flex; align-items: center; gap: 8px; }
body.snip-open .dock { transform: none; left: auto; right: calc(min(400px, 100%) + 12px); }
@media (max-width: 860px) {
  .snip-panel { width: 100%; }
  body.snip-open .dock { right: 0; left: 0; }
}
