/* ============================================================
   个人笔记 PWA · 样式表
   设计基准 = Ardot v3.28 定稿（金黄强调色系）
   栅格：屏 390 宽 / 内容区左右 20 / 内容宽 350 / 顶距 50
   ============================================================ */

:root{
  /* ---- v3 色板（对应 Palette 变量集 v3 模式） ---- */
  --ink-strong:#1F1B16;
  --ink-body:#4A443C;
  --ink-label:#7A7264;
  --ink-muted:#A79E90;
  --ink-faint:#C4BCAE;
  --bg-base:#FAFAFA;
  --bg-card:#FFFFFF;
  --bg-subtle:#F4F5F7;
  --line-subtle:#EDEFF2;
  --accent-tint:#FEF7E0;
  --accent-soft:#FBE28C;
  --accent-base:#F9C11E;
  --accent-strong:#8A6600;
  --on-accent:#FFFFFF;
  --danger:#E06C6C;
  --danger-tint:#FDF2F2;
  /* 附件删除按钮 · v3.28 定稿字面色 */
  --att-del:#ABABAB;

  /* ---- 尺寸 ---- */
  --gut:20px;          /* 内容区左右边距 */
  --top:50px;          /* 内容区顶距 */
  --r-card:16px;
  --r-ctl:12px;
  --r-chip:18px;
  --r-sheet:20px;
  --gap-sec:18px;

  --safe-t:env(safe-area-inset-top,0px);
  --safe-b:env(safe-area-inset-bottom,0px);
}

*,*::before,*::after{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{height:100%}
body{
  margin:0;background:var(--bg-base);color:var(--ink-body);
  font:400 15px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
  overscroll-behavior-y:none;
}
button,input,textarea{font:inherit;color:inherit}
button{background:none;border:0;padding:0;cursor:pointer}
svg.ic-18{width:18px;height:18px;flex:none}
svg.ic-20{width:20px;height:20px;flex:none}
svg.ic-24{width:24px;height:24px;flex:none}

/* ---------- 屏幕容器 ---------- */
.screen{
  position:fixed;inset:0;display:none;flex-direction:column;
  background:var(--bg-base);
  padding-top:var(--safe-t);
}
.screen.is-active{display:flex}
.content{
  flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;
  padding:0 var(--gut) calc(96px + var(--safe-b));
}
.content.pad-top{padding-top:var(--top)}

/* ---------- 头部 ---------- */
.page-head{padding:0 0 20px}
.big-title{margin:0;font-size:34px;line-height:1.2;font-weight:700;color:var(--ink-strong);letter-spacing:.5px}
.page-sub{margin:8px 0 0;font-size:13px;color:var(--ink-muted)}

.nav-head{
  display:flex;align-items:center;gap:12px;height:42px;margin-bottom:16px;
}
.nav-title{
  flex:1;margin:0;text-align:center;font-size:17px;font-weight:600;color:var(--ink-strong);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.icon-btn{
  width:32px;height:32px;flex:none;display:grid;place-items:center;
  color:var(--ink-strong);border-radius:10px;
}
.icon-btn:active{background:var(--bg-subtle)}
.cta{
  flex:none;height:36px;padding:0 18px;border-radius:var(--r-chip);
  background:var(--accent-base);color:var(--on-accent);
  font-size:14px;font-weight:600;
}
.cta:active{background:var(--accent-soft)}
.cta[disabled]{background:var(--bg-subtle);color:var(--ink-faint)}

/* ---------- 首页类别宫格 ---------- */
.cat-grid{
  display:grid;grid-template-columns:repeat(3,1fr);gap:16px;
}
.cat-cell{
  position:relative;height:74px;border-radius:var(--r-ctl);
  background:var(--bg-card);border:1px solid var(--line-subtle);
  display:flex;align-items:center;justify-content:center;gap:8px;
  padding:0 10px;color:var(--ink-strong);
}
.cat-cell:active{background:var(--bg-subtle)}
.cat-cell .cat-ic{
  width:28px;height:28px;flex:none;display:grid;place-items:center;font-size:20px;line-height:1;
}
.cat-cell .cat-ic.round{
  width:28px;height:28px;border-radius:50%;overflow:hidden;background:var(--accent-tint);
  color:var(--ink-strong);font-size:14px;font-weight:700;
}
.cat-cell .cat-ic img{width:100%;height:100%;object-fit:cover}
.cat-cell .cat-nm{
  font-size:14px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.cat-cell.new .cat-ic{color:var(--ink-muted)}
.cat-cell .del-badge{
  position:absolute;top:-6px;right:-6px;width:22px;height:22px;border-radius:50%;
  background:var(--danger);color:#fff;display:grid;place-items:center;
  box-shadow:0 0 0 2px var(--bg-base);
}
.cat-cell .del-badge svg{width:12px;height:12px}
/* 编辑态抖动 */
.cat-grid.editing .cat-cell{animation:jiggle .36s ease-in-out infinite alternate}
.cat-grid.editing .cat-cell:nth-child(2n){animation-delay:.12s}
.cat-grid.editing .cat-cell:nth-child(3n){animation-delay:.22s}
@keyframes jiggle{from{transform:rotate(-1.4deg)}to{transform:rotate(1.4deg)}}
.cat-cell.dragging{opacity:.45}
.cat-cell.drop-target{outline:2px dashed var(--accent-base);outline-offset:2px}

.chips{display:flex;flex-wrap:wrap;gap:10px}
.chips-left{justify-content:flex-start}
.chip{
  height:34px;padding:0 16px;border-radius:var(--r-chip);
  background:var(--bg-card);border:1px solid var(--line-subtle);
  color:var(--ink-body);font-size:13px;white-space:nowrap;
}
.chip.is-on{background:var(--accent-tint);border-color:var(--accent-soft);color:var(--accent-strong);font-weight:600}

/* ---------- 底部搜索 + FAB ---------- */
.bottom-bar{
  position:absolute;left:0;right:0;bottom:0;padding:8px var(--gut) calc(10px + var(--safe-b));
  background:linear-gradient(to top,var(--bg-base) 62%,transparent);
}
.searchbar{
  width:100%;height:52px;border-radius:var(--r-card);
  background:var(--bg-card);border:1px solid var(--line-subtle);
  display:flex;align-items:center;gap:10px;padding:0 16px;
  color:var(--ink-muted);font-size:15px;text-align:left;
}
.searchbar .ic-18{color:var(--ink-muted)}
.fab{
  position:absolute;right:var(--gut);bottom:calc(78px + var(--safe-b));
  width:56px;height:56px;border-radius:50%;
  background:var(--accent-base);color:var(--on-accent);
  display:grid;place-items:center;box-shadow:0 6px 18px rgba(249,193,30,.38);
}
.fab:active{transform:scale(.95)}

/* ---------- 笔记流 ---------- */
.note-list{display:flex;flex-direction:column;gap:var(--gap-sec)}
.note-card{
  background:var(--bg-card);border:1px solid var(--line-subtle);
  border-radius:var(--r-card);padding:14px;
}
.note-card .nc-head{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.note-card .nc-cat{
  font-size:12px;color:var(--ink-label);background:var(--bg-subtle);
  padding:2px 8px;border-radius:8px;
}
.note-card .nc-time{margin-left:auto;font-size:12px;color:var(--ink-muted)}
.note-card .nc-text{
  font-size:15px;color:var(--ink-body);white-space:pre-wrap;word-break:break-word;
  display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden;
}
.note-card .nc-atts{display:flex;gap:8px;margin-top:10px;overflow-x:auto;padding-bottom:2px}
.note-card .nc-atts::-webkit-scrollbar{display:none}
.nc-thumb{
  width:64px;height:64px;flex:none;border-radius:10px;overflow:hidden;background:var(--bg-subtle);
  display:grid;place-items:center;color:var(--ink-muted);position:relative;
}
.nc-thumb img,.nc-thumb video{width:100%;height:100%;object-fit:cover;display:block}
.nc-file{
  display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 12px;flex:none;
  border-radius:10px;background:var(--bg-subtle);font-size:12px;color:var(--ink-label);
  max-width:180px;
}
.nc-file b{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.empty{
  padding:56px 0;text-align:center;color:var(--ink-muted);font-size:14px;
}
.empty b{display:block;font-size:15px;color:var(--ink-label);margin-bottom:6px;font-weight:600}

/* ---------- 编辑器 ---------- */
.editor{
  width:100%;min-height:161px;padding:14px;margin:14px 0 12px;resize:none;
  border-radius:var(--r-ctl);border:1px solid var(--line-subtle);background:var(--bg-card);
  font-size:15px;line-height:1.6;color:var(--ink-body);
}
.editor::placeholder{color:var(--ink-faint)}
.editor:focus{outline:none;border-color:var(--accent-soft)}

.attach-bar{
  display:flex;gap:10px;padding:12px 10px;border-radius:10px;background:var(--bg-card);
  border:1px solid var(--line-subtle);
}
.attach-bar button{
  flex:1;display:flex;align-items:center;justify-content:center;gap:6px;
  height:40px;border-radius:10px;color:var(--ink-strong);font-size:13px;
}
.attach-bar button:active{background:var(--bg-subtle)}

.attach-sec{margin-top:16px}
.attach-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.att-thumb{
  position:relative;aspect-ratio:1/1;border-radius:var(--r-ctl);overflow:hidden;
  background:linear-gradient(135deg,#EAC97A,#F6E9C8);
}
.att-thumb.is-video{background:linear-gradient(135deg,#5C4E38,#B3A489)}
/* 缩略图 holder：异步加载只覆盖这一层，不影响删除按钮 */
.att-holder{position:absolute;inset:0;display:grid;place-items:center}
.att-holder img,.att-holder video,
.att-thumb img,.att-thumb video{width:100%;height:100%;object-fit:cover;display:block}
.att-thumb .play{
  position:absolute;inset:0;display:grid;place-items:center;color:#fff;
}
.att-thumb .play svg{width:28px;height:28px;opacity:.92}
.att-thumb .dur{
  position:absolute;right:6px;bottom:6px;font-size:11px;color:#fff;
  background:rgba(31,27,22,.55);border-radius:6px;padding:1px 5px;
}
/* 附件删除按钮 —— v3.28 定稿：20×20 ellipse / INSIDE 1.5px / #ABABAB */
.att-del{
  position:absolute;top:6px;right:6px;width:20px;height:20px;border-radius:50%;
  background:var(--bg-base);border:1.5px solid var(--att-del);
  display:grid;place-items:center;z-index:2;
}
.att-del svg{width:9px;height:9px;color:var(--att-del)}
.att-add{
  aspect-ratio:1/1;border-radius:var(--r-ctl);
  background:var(--bg-card);border:1px solid var(--line-subtle);
  display:grid;place-items:center;color:var(--ink-muted);
}
.doc-row{display:flex;flex-direction:column;gap:10px;margin-top:16px}
.doc-item{
  position:relative;display:flex;align-items:center;gap:10px;
  width:100%;height:52px;padding:12px 10px;border-radius:var(--r-ctl);
  background:var(--bg-card);border:1px solid var(--line-subtle);
}
.doc-item .di-ic{
  width:28px;height:28px;flex:none;border-radius:8px;background:var(--bg-subtle);
  display:grid;place-items:center;color:var(--ink-label);
}
.doc-item .di-meta{flex:1;min-width:0}
.doc-item .di-nm{font-size:13px;color:var(--ink-strong);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.doc-item .di-sz{font-size:11px;color:var(--ink-muted);margin-top:2px}
.doc-item .att-del{position:static;flex:none;margin-left:2px}
.hint{margin:14px 0 0;font-size:12px;color:var(--ink-muted);text-align:center}

/* ---------- 搜索 ---------- */
.search-active{display:flex;align-items:center;gap:8px;margin-bottom:20px}
.search-input{
  flex:1;height:48px;padding:0 14px;border-radius:var(--r-ctl);
  background:var(--bg-card);border:1px solid var(--line-subtle);font-size:15px;
}
.search-input:focus{outline:none;border-color:var(--accent-soft)}
.sec-label{margin:24px 0 12px;font-size:13px;font-weight:600;color:var(--ink-label)}
.sec-label:first-child{margin-top:0}
.sug{display:flex;flex-wrap:wrap;gap:10px}
.sug button{
  height:32px;padding:0 14px;border-radius:16px;background:var(--bg-card);
  border:1px solid var(--line-subtle);font-size:13px;color:var(--ink-body);
}
.sug button.warm{background:var(--accent-tint);border-color:var(--accent-soft);color:var(--accent-strong)}

/* ---------- 底部上推面板 ---------- */
.sheet-mask,.dialog-mask{position:fixed;inset:0;background:rgba(31,27,22,.36);z-index:40}
.sheet-mask[hidden],.dialog-mask[hidden]{display:none}
.sheet{
  position:fixed;left:0;right:0;bottom:0;z-index:41;
  background:var(--bg-card);border-radius:var(--r-sheet) var(--r-sheet) 0 0;
  padding:10px var(--gut) calc(24px + var(--safe-b));
  max-height:76vh;overflow-y:auto;
  animation:slideup .26s cubic-bezier(.22,.8,.28,1);
}
.sheet[hidden]{display:none}
@keyframes slideup{from{transform:translateY(100%)}to{transform:translateY(0)}}
.sheet-grab{width:36px;height:4px;border-radius:2px;background:var(--line-subtle);margin:0 auto 16px}
.sheet-title{margin:0 0 16px;font-size:17px;font-weight:600;color:var(--ink-strong)}
.sheet-sub{margin:22px 0 10px;font-size:13px;font-weight:600;color:var(--ink-label)}
.kv{display:flex;align-items:center;justify-content:space-between;padding:12px 0;border-bottom:1px solid var(--line-subtle)}
.kv span{font-size:13px;color:var(--ink-muted)}
.kv b{font-size:14px;font-weight:500;color:var(--ink-strong)}
.history{display:flex;flex-direction:column}
.hitem{display:flex;gap:12px;padding:10px 0;font-size:13px;color:var(--ink-body)}
.hitem .ht{color:var(--ink-muted);flex:none;width:112px}

/* ---------- 类别菜单 ---------- */
.menu-pop{
  position:absolute;right:16px;top:calc(var(--safe-t) + 54px);z-index:30;
  width:196px;background:var(--bg-card);border:1px solid var(--line-subtle);
  border-radius:14px;padding:6px;box-shadow:0 12px 32px rgba(31,27,22,.14);
}
.menu-pop[hidden]{display:none}
.menu-pop button{
  width:100%;display:flex;align-items:center;gap:10px;padding:11px 12px;
  border-radius:10px;font-size:14px;color:var(--ink-body);text-align:left;
}
.menu-pop button:active{background:var(--bg-subtle)}
.menu-pop button.danger{color:var(--danger)}
.menu-pop button svg{color:var(--ink-label)}
.menu-pop button.danger svg{color:var(--danger)}

/* ---------- 预览卡 / 头像 ---------- */
.preview-card{
  display:flex;align-items:center;gap:14px;padding:18px;margin-bottom:16px;
  border-radius:var(--r-chip);background:var(--bg-card);border:1px solid var(--line-subtle);
}
.pv-avatar{
  width:80px;height:80px;flex:none;border-radius:50%;background:var(--accent-tint);
  display:grid;place-items:center;font-size:32px;font-weight:700;color:var(--ink-strong);
  overflow:hidden;
}
.pv-avatar img{width:100%;height:100%;object-fit:cover}
.pv-avatar.big{width:72px;height:72px;font-size:28px}
.pv-name{font-size:18px;font-weight:600;color:var(--ink-strong)}
.text-input{
  width:100%;height:48px;padding:0 14px;border-radius:var(--r-ctl);
  background:var(--bg-card);border:1px solid var(--line-subtle);font-size:15px;
}
.text-input:focus{outline:none;border-color:var(--accent-soft)}

.icon-picker{
  display:grid;grid-template-columns:repeat(6,1fr);gap:16px;
  max-height:232px;overflow-y:auto;padding-bottom:8px;
}
.icon-slot{
  aspect-ratio:1/1;border-radius:12px;background:var(--bg-card);
  border:1px solid var(--line-subtle);display:grid;place-items:center;font-size:22px;
}
.icon-slot.is-on{border-color:var(--accent-base);border-width:2px;background:var(--accent-tint)}
.icon-slot .char{font-size:14px;font-weight:700;color:var(--ink-strong)}

.avatar-block{
  display:flex;align-items:center;gap:14px;padding:16px;margin-bottom:4px;
  border-radius:var(--r-card);background:var(--bg-card);border:1px solid var(--line-subtle);
}
.avatar-meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:3px}
.avatar-meta b{font-size:16px;color:var(--ink-strong);font-weight:600}
.avatar-meta span{font-size:12px;color:var(--ink-muted)}
.ghost-btn{
  height:34px;padding:0 14px;border-radius:var(--r-chip);flex:none;
  border:1px solid var(--line-subtle);background:var(--bg-base);
  font-size:13px;color:var(--ink-body);
}

/* ---------- 弹窗 ---------- */
.dialog{
  position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);z-index:42;
  width:318px;max-width:calc(100vw - 48px);padding:24px 22px 18px;
  border-radius:var(--r-sheet);background:var(--bg-card);text-align:center;
  animation:pop .2s ease-out;
}
@keyframes pop{from{transform:translate(-50%,-50%) scale(.94);opacity:0}to{transform:translate(-50%,-50%) scale(1);opacity:1}}
.dlg-icon{
  width:56px;height:56px;border-radius:50%;background:var(--danger-tint);
  display:grid;place-items:center;margin:0 auto 14px;color:var(--danger);
}
.dlg-icon svg{width:26px;height:26px}
.dlg-title{margin:0 0 8px;font-size:17px;font-weight:600;color:var(--ink-strong)}
.dlg-text{margin:0 0 20px;font-size:13px;line-height:1.6;color:var(--ink-label)}
.dlg-actions{display:flex;gap:10px}
.dlg-actions button{flex:1;height:44px;border-radius:var(--r-ctl);font-size:15px;font-weight:600}
.dlg-ghost{background:var(--bg-subtle);color:var(--ink-body)}
.dlg-danger{background:var(--danger);color:#fff}

/* ---------- 轻提示 ---------- */
.toast{
  position:fixed;left:50%;bottom:calc(96px + var(--safe-b));transform:translateX(-50%);z-index:60;
  background:rgba(31,27,22,.9);color:#fff;font-size:13px;
  padding:10px 18px;border-radius:20px;max-width:80vw;text-align:center;
  animation:pop2 .18s ease-out;
}
.toast[hidden]{display:none}
@keyframes pop2{from{opacity:0;transform:translate(-50%,6px)}to{opacity:1;transform:translate(-50%,0)}}

/* ---------- 录音浮层 ---------- */
.rec-bar{
  position:fixed;left:var(--gut);right:var(--gut);bottom:calc(20px + var(--safe-b));z-index:50;
  display:flex;align-items:center;gap:12px;padding:14px 16px;border-radius:var(--r-card);
  background:var(--ink-strong);color:#fff;box-shadow:0 10px 30px rgba(31,27,22,.3);
}
.rec-dot{width:10px;height:10px;border-radius:50%;background:var(--danger);animation:blink 1s infinite}
@keyframes blink{50%{opacity:.25}}
.rec-bar .rt{flex:1;font-size:14px;font-variant-numeric:tabular-nums}
.rec-bar button{color:#fff;font-size:14px;font-weight:600}

/* 小屏微调 */
@media (max-width:359px){
  .cat-grid{gap:12px}
  .attach-grid{gap:12px}
}
