:root{
  --red:#ff2442; --red-d:#e21b38;
  --bg:#f6f7f9; --card:#fff; --ink:#1d2129; --muted:#8a9099;
  --line:#eceef0; --soft:#fff0f2; --ok:#1aab57; --err:#e23b3b;
  --radius:14px; --shadow:0 2px 14px rgba(20,20,40,.06);
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);line-height:1.6;
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Microsoft YaHei",Segoe UI,Roboto,sans-serif}
.hero{padding:34px 20px 16px;text-align:center;position:relative}
.lang-btn{position:absolute;top:14px;right:16px;padding:6px 12px;font-size:13px;min-width:46px}
.hero h1{margin:0;font-size:26px}
.hero .sub{margin:6px 0 0;color:var(--muted);font-size:14px}
/* 1280 是为「一排 4 张卡」让路的（4×~290px + 间距）；880 时 4 张只剩 ~200px 塞不下。
   录入/设置类窄内容用 .card--narrow 收回 880，避免输入框被拉成一整条。 */
.wrap{max-width:1280px;margin:0 auto;padding:8px 16px 40px}
.card--narrow{max-width:880px;margin-left:auto;margin-right:auto}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);
  box-shadow:var(--shadow);padding:18px;margin-bottom:18px}

.tabs{display:flex;gap:8px;margin-bottom:14px}
.tab{border:none;background:var(--bg);color:var(--muted);padding:8px 14px;
  border-radius:999px;cursor:pointer;font-size:14px}
.tab--on{background:var(--soft);color:var(--red);font-weight:600}

.row{display:flex;gap:10px}
input,textarea{width:100%;border:1px solid var(--line);border-radius:10px;padding:11px 12px;
  font-size:14px;font-family:inherit;background:#fff;color:var(--ink)}
input:focus,textarea:focus{outline:none;border-color:var(--red)}
textarea{display:block;margin-bottom:10px;resize:vertical}

.btn{border:none;border-radius:10px;padding:11px 16px;font-size:14px;cursor:pointer;
  white-space:nowrap;background:#eef0f2;color:var(--ink);transition:.15s}
.btn:hover{filter:brightness(.97)}
.btn--primary{background:var(--red);color:#fff}
.btn--primary:hover{background:var(--red-d)}
.btn--ghost{background:transparent;border:1px solid var(--line)}
.btn--danger{background:transparent;border:1px solid #f3c2c2;color:var(--err)}
.btn:disabled{opacity:.6;cursor:not-allowed}

.hint{color:var(--muted);font-size:12px;margin:10px 2px 0}
.status{margin-top:12px;padding:10px 12px;border-radius:10px;font-size:13px;background:#f1f3f5}
.status--loading{background:#fff7e6;color:#9a6700}
.status--ok{background:#e9f9ef;color:var(--ok)}
.status--err{background:#fdecec;color:var(--err)}
.muted{color:var(--muted);font-weight:400;font-size:13px}

/* 笔记卡片 */
.note__head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:8px}
.badge{background:var(--soft);color:var(--red);border-radius:999px;padding:3px 10px;font-size:12px;font-weight:600}
.badge--soft{background:#f1f3f5;color:var(--muted);font-weight:500}
.src{margin-left:auto;color:var(--muted);font-size:11px}
.note__title{margin:4px 0;font-size:18px;word-break:break-word}
.note__author{color:var(--muted);font-size:13px;margin-bottom:6px}
.tags{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
.tag{background:#f1f3f5;color:#555;border-radius:6px;padding:2px 8px;font-size:12px}
.note__body{white-space:pre-wrap;word-break:break-word;background:#fafbfc;border:1px solid var(--line);
  border-radius:10px;padding:12px;font-size:13.5px;font-family:inherit;max-height:320px;overflow:auto;margin:8px 0}
.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(110px,1fr));gap:8px;margin:10px 0}
.gallery img{width:100%;aspect-ratio:3/4;object-fit:cover;border-radius:10px;background:#f1f3f5;display:block}
.note__link{display:inline-block;color:var(--red);font-size:13px;text-decoration:none;margin:4px 0}
.note__actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}
.result .note,.lib__list .note{border:1px solid var(--line);border-radius:12px;box-shadow:none;padding:16px;background:#fff;margin:0}

/* 收藏库 */
.lib__head{display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;align-items:center;margin-bottom:12px}
.lib__head h2{margin:0;font-size:18px}
.lib__tools{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.lib__tools input{width:auto;min-width:160px}
.chips{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}
.chip{border:1px solid var(--line);background:#fff;color:var(--muted);border-radius:999px;
  padding:5px 12px;font-size:13px;cursor:pointer}
.chip--on{background:var(--red);color:#fff;border-color:var(--red)}
/* 库与合集共用（#libList + #compList 同一个类，一处覆盖两边）：
   一排 4 张 → 窄窗口 2 张 → 手机 1 张。
   minmax(0,1fr) 而非 1fr——否则长标题/长链接会把格子撑破。
   不写 align-items:start——默认 stretch 让同排卡片等高，底边齐平；
   试过 start（各自然高），同排高低参差像没对齐的砖墙，难看。 */
.lib__list{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
/* 折叠态卡片：按钮沉到卡片底部，卡片再高按钮也一条线对齐 */
.lib__list>.note.is-fold,.lib__list>.comp.is-fold{display:flex;flex-direction:column}
.lib__list>.note.is-fold .note__actions,.lib__list>.comp.is-fold .note__actions{margin-top:auto;padding-top:10px}
@media(max-width:1080px){ .lib__list{grid-template-columns:repeat(2,minmax(0,1fr))} }
/* 手机回单列：2 列在 375px 上每格仅 146px，徽标/按钮一行一个、折叠卡反被撑到 592px，
   比单列还费划——密度是负的。单列 ~343px 就是原本合理的样子，字号也不必缩。 */
/* 必须 minmax(0,1fr) 不能写 1fr：1fr＝minmax(auto,1fr)，auto 下限是内容的 min-content 宽，
   有真实卡片时列宽被撑到 668px（375px 视口）→ 整页横向溢出＝手机上「完全没适配」。
   踩过：空库测不出来（没内容就没 min-content），必须灌真实数据再量。 */
@media(max-width:560px){ .lib__list{grid-template-columns:minmax(0,1fr)} }
/* 展开态（笔记/合集）与合集编辑态占满整行——正文·图集·转写挤在 ~290px 里没法读 */
.lib__list>.note:not(.is-fold),.lib__list>.comp:not(.is-fold){grid-column:1/-1}
/* 空状态是裸 <p class="empty">，别让它只占一格 */
.lib__list>.empty{grid-column:1/-1}
.empty{color:var(--muted);text-align:center;padding:24px}
.foot{text-align:center;font-size:12px;padding:18px;color:var(--muted)}

/* 云同步 */
.sync-pill{border:1px solid var(--line);background:#fff;border-radius:999px;padding:5px 12px;
  font-size:12px;cursor:pointer;color:var(--muted);white-space:nowrap}
.sync-pill.is-ok{color:var(--ok);border-color:#bfe9cf;background:#f1fbf5}
.sync-pill.is-syncing{color:#9a6700;border-color:#f0e0b8;background:#fffaf0}
.sync-pill.is-err{color:var(--err);border-color:#f3c2c2;background:#fdf0f0}
.settings{border:1px dashed var(--line);border-radius:12px;padding:14px;margin-bottom:14px;background:#fafbfc;max-width:880px}
.settings code{background:#eef0f2;border-radius:5px;padding:1px 6px;font-size:12px}
.settings .row{margin-top:8px}
#settingsStatus{margin-top:8px}
.settings__hr{border:none;border-top:1px dashed var(--line);margin:14px 0}
.settings a{color:var(--red)}

/* 多选 → AI 整理 */
.selbar{display:flex;flex-wrap:wrap;gap:8px;align-items:center;background:#fff7f8;
  border:1px solid #ffd9df;border-radius:12px;padding:10px 12px;margin-bottom:14px}
.selbar__sel{width:auto;min-width:150px;padding:9px 10px;border:1px solid var(--line);
  border-radius:10px;background:#fff;font-size:13px;color:var(--ink)}
.note__sel{display:flex;align-items:center;gap:6px;margin-bottom:8px;font-size:12px;color:var(--muted);cursor:pointer}
.note__sel input{width:auto}
.note.is-sel{border-color:var(--red);box-shadow:0 0 0 2px var(--soft)}

/* 合集 */
.comp{border:1px solid var(--line);border-radius:12px;padding:16px;background:#fff}
.comp__meta{display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px}
.comp__title{margin:2px 0 4px;font-size:19px;word-break:break-word}
.comp__summary{color:#444;font-size:13.5px;background:#fafbfc;border-left:3px solid var(--red);
  padding:8px 12px;border-radius:0 8px 8px 0;margin:8px 0}
.comp__sec{margin:14px 0}
.comp__sec h4{margin:0 0 6px;font-size:15px}
.comp__sec .body{white-space:pre-wrap;word-break:break-word;font-size:14px}
.comp__src{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.comp__src a{font-size:11px;color:var(--muted);background:#f1f3f5;border-radius:6px;padding:2px 8px;text-decoration:none}

/* —— 手机适配（≤560px，实测 375px）——
   本 app 此前只有下面前三条，标签栏/工具栏/hero 从没管过：375px 实测标签各 56px 全断成两行、
   工具栏 233px 排成 1+1+1+2+1+2+2 七行乱堆、要滚 436px 才见「我的收藏库」。 */
@media(max-width:560px){
  .row{flex-direction:column}
  .lib__head{flex-direction:column;align-items:stretch}
  .lib__tools input{width:100%}

  /* hero 瘦身：小屏上没必要占掉半屏 */
  .hero{padding:18px 16px 8px}
  .hero h1{font-size:20px}
  .hero .sub{font-size:11.5px;line-height:1.45}
  .lang-btn{top:10px;right:10px;padding:4px 9px;font-size:12px;min-width:40px}

  /* 标签栏改横向滚动、绝不换行（与 Business-Lab / Album-Journal 同套路） */
  .tabs{flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;gap:6px}
  .tabs::-webkit-scrollbar{display:none}
  .tab{white-space:nowrap;flex:none}

  /* 工具栏与卡片收一号，把七行乱堆压下去 */
  .wrap{padding:6px 12px 32px}
  .card{padding:14px}
  .lib__tools{gap:6px}
  .lib__tools .btn,.lib__tools .sync-pill{padding:8px 10px;font-size:12.5px}
  .chips{gap:6px;margin-bottom:10px}
  .chip{padding:4px 10px;font-size:12px}
}

/* 图片归档：过期占位 + 合集选择栏的图片开关 */
.img-dead{display:flex;align-items:center;justify-content:center;min-height:90px;padding:8px;border:1px dashed var(--line,rgba(0,0,0,.15));border-radius:8px;color:#999;font-size:12px;background:rgba(0,0,0,.03);}
img[data-repo]:not([src]){min-height:90px;background:rgba(0,0,0,.05);border-radius:8px;}
.selbar__imgs{display:inline-flex;align-items:center;gap:5px;cursor:pointer;user-select:none;}
.selbar__imgs input{accent-color:currentColor;cursor:pointer;}

/* —— 统一库：平台/类型徽标 + 语音转写 + 筛选分隔 —— */
.chips--plat{margin-bottom:8px}
.chips__sep{width:1px;align-self:center;height:16px;background:var(--line);margin:0 4px}
.badge--plat{font-weight:600}
.badge--xhs{background:var(--soft);color:var(--red)}
.badge--bili{background:#eaf7fc;color:#0086b3}
.note__ts{margin:8px 0}
.note__ts>summary{cursor:pointer;color:var(--muted);font-size:13px;list-style:none;user-select:none}
.note__ts>summary::-webkit-details-marker{display:none}
.note__ts>summary::before{content:"▸ "}
.note__ts[open]>summary::before{content:"▾ "}
.note__ts-body{margin-top:6px;max-height:240px;overflow:auto}
.dot{font-size:11px;vertical-align:middle}
.dot--on{color:var(--ok)}
.dot--off{color:var(--muted)}

/* —— 卡片折叠：默认收起，只留角标+标题+一行摘要；点标题/箭头展开 —— */
.note__fold{margin-left:auto;border:none;background:transparent;cursor:pointer;color:var(--muted);
  font-size:13px;line-height:1;padding:2px 6px;transition:transform .15s;flex:none}
.note.is-fold .note__fold,.comp.is-fold .note__fold{transform:rotate(-90deg)}
.note.is-fold .note__more,.comp.is-fold .comp__more{display:none}
.note:not(.is-fold) .note__peek{display:none}
.note__peek{color:var(--muted);font-size:13px;margin:4px 0 2px;cursor:pointer;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.note__title,.comp__title{cursor:pointer}
.note.is-fold,.comp.is-fold{padding-bottom:12px}
.note.is-fold .note__actions,.comp.is-fold .note__actions{margin-top:8px}

/* —— 合集手动编辑态 —— */
.comp.is-editing input,.comp.is-editing textarea{width:100%;margin:6px 0;font-family:inherit}
.comp__ed-title{font-size:17px;font-weight:600}
.comp__ed-c{font:13.5px/1.7 inherit;white-space:pre-wrap;resize:vertical}
.comp__ed-h{font-weight:600}


/* ===== 移动端与无障碍基线（2026-07-31 统一注入；规则源：web-interface-guidelines）===== */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:.01ms!important;animation-iteration-count:1!important;
    transition-duration:.01ms!important;scroll-behavior:auto!important;
  }
}
button,a,summary,label,[role="button"],[onclick]{
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
:focus-visible{outline:2px solid currentColor;outline-offset:2px}
