/* ============================================================
   拾记 — 全站样式（桌面侧栏 + 移动端底部标签，响应式）
   ============================================================ */
:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --text2: #86868b;
  --text3: #b3b3b7;
  --line: #e8e6e1;
  --accent: #c7952c;          /* 模块主题色，JS 按 tab 切换 */
  --accent-soft: #f7eeda;
  --blue: #4772fa;
  --red: #e5484d;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 60px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.5;
  overscroll-behavior: none;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; color: inherit; font-size: 15px; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text); border: none; outline: none; background: transparent; }
.hidden { display: none !important; }

/* ---------- 通用组件 ---------- */
.btn-primary, .btn-accent, .btn-danger {
  padding: 8px 18px; border-radius: 10px; font-weight: 600; font-size: 14px;
  transition: opacity .15s, transform .1s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-danger { background: #fdecec; color: var(--red); }
.btn-primary:active, .btn-accent:active { opacity: .8; transform: scale(.97); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 17px; color: var(--text2);
}
.icon-btn:hover { background: rgba(0,0,0,.06); }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }
.link-btn { color: var(--text2); font-size: 12px; text-decoration: underline; }
.link-btn:hover { color: var(--text); }
.mini-btn { padding: 2px 10px; border-radius: 8px; background: rgba(0,0,0,.06); font-size: 12px; color: var(--text2); }

/* ---------- 登录/注册 ---------- */
.auth-view { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.auth-bg {
  position: absolute; inset: 0;
  background: linear-gradient(135deg, #f9f3e6 0%, #fdeee4 45%, #e8f0fb 100%);
}
.auth-card {
  position: relative; width: 100%; max-width: 380px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow);
  padding: 32px 28px 28px;
}
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo-icon { font-size: 44px; }
.auth-logo-name { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: 2px; }
.auth-logo-sub { font-size: 12px; color: var(--text2); margin-top: 2px; }
.auth-tabs { display: flex; background: #f2f0ec; border-radius: 10px; padding: 3px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; padding: 8px 0; border-radius: 8px; color: var(--text2); font-weight: 600; }
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--text2); margin-bottom: 4px; }
.field input {
  width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fafaf8; transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); background: #fff; }
.auth-card .btn-primary { width: 100%; padding: 12px; margin-top: 4px; font-size: 16px; }
.auth-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 10px;
  background: #fdecec; color: var(--red); font-size: 13px; text-align: center;
}

/* ---------- 主框架 ---------- */
.app-view { display: flex; height: 100%; }
.sidebar {
  width: 176px; flex-shrink: 0; background: #efede8;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 16px 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #e8b04b, #d97a3d);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { font-weight: 600; font-size: 14px; }
.module-nav { display: flex; flex-direction: column; gap: 2px; }
.module-btn {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--text2); font-weight: 500; text-align: left;
}
.module-btn .mi { font-size: 17px; }
.module-btn.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.sidebar-context { flex: 1; overflow-y: auto; margin-top: 12px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { display: none; flex: 1; min-height: 0; flex-direction: column; overflow: hidden; }
.page.active { display: flex; }
.pane-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px 10px; flex-shrink: 0;
}
.pane-header h1 { font-size: 22px; font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-actions { display: flex; align-items: center; gap: 8px; }

/* 移动端底部标签 */
.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.92); backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
}
.tab-btn { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--text3); font-size: 10px; }
.tab-btn .ti { font-size: 21px; }
.tab-btn.active { color: var(--accent); }
.tabbar { display: flex; }

/* ---------- 记事本 ---------- */
body[data-module="notes"] { --accent: #c7952c; --accent-soft: #f7eeda; }
.notes-split { display: flex; flex: 1; min-height: 0; }
.notes-list-pane { width: 340px; flex-shrink: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.search-wrap { padding: 0 16px 10px; }
.search-wrap input {
  width: 100%; padding: 8px 12px; border-radius: 10px; background: #eceae5; font-size: 14px;
}
.notes-list { flex: 1; overflow-y: auto; padding: 0 10px 20px; }
.notes-group-title { font-size: 12px; color: var(--text2); font-weight: 600; padding: 12px 10px 6px; }
.note-item {
  padding: 11px 12px; border-radius: 12px; cursor: pointer; margin-bottom: 2px;
  border-bottom: 1px solid var(--line); border-radius: 0; margin: 0 4px;
}
.note-item:hover { background: rgba(0,0,0,.03); }
.note-item.selected { background: var(--accent-soft); border-bottom-color: transparent; border-radius: 10px; }
.note-item + .note-item.selected { border-radius: 10px; }
.note-item-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-preview { font-size: 13px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-meta { font-size: 11.5px; color: var(--text3); margin-top: 3px; }

.note-editor-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--note-bg, var(--card)); }
.editor-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text3); gap: 8px; }
.editor-empty-icon { font-size: 48px; opacity: .5; }
.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-topbar {
  display: flex; align-items: center; gap: 4px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.editor-tools { display: flex; gap: 2px; }
.back-btn { display: none; font-size: 26px; line-height: 1; padding-bottom: 4px; }
.save-state { font-size: 11.5px; color: var(--text3); margin-left: auto; }
.color-picker {
  display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.color-picker button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.color-picker button[data-color="default"] { background: #fff; }
.color-picker button[data-color="yellow"] { background: #fdf3c9; }
.color-picker button[data-color="green"] { background: #ddf3d8; }
.color-picker button[data-color="blue"] { background: #d8e9fb; }
.color-picker button[data-color="pink"] { background: #fbdfe8; }
.color-picker button.active { border-color: var(--accent); }
#note-content {
  flex: 1; resize: none; padding: 20px 24px; font-size: 15.5px; line-height: 1.7;
  width: 100%; max-width: 820px; margin: 0 auto;
}

/* 笔记颜色 */
.note-c-default { --note-bg: #ffffff; }
.note-c-yellow { --note-bg: #fdf3c9; }
.note-c-green  { --note-bg: #ddf3d8; }
.note-c-blue   { --note-bg: #d8e9fb; }
.note-c-pink   { --note-bg: #fbdfe8; }
.notes-list-pane { background: transparent; }

/* 中间列表收起/展开（仅桌面端） */
.notes-collapse-btn, .notes-expand-btn { display: none; }
#notes-expand-empty { display: none; }
@media (min-width: 820px) {
  .notes-collapse-btn { display: inline-flex; }
  .note-editor-pane { position: relative; }
  body.notes-list-collapsed .notes-list-pane { display: none; }
  body.notes-list-collapsed .notes-expand-btn { display: inline-flex; }
  body.notes-list-collapsed #notes-expand-empty { display: inline; }
  body.notes-list-collapsed .note-editor-pane .back-btn { display: none; }
}

/* ---------- 待办清单 ---------- */
body[data-module="todos"] { --accent: #4772fa; --accent-soft: #e8edfd; }
.list-switcher { display: none; }
.todo-progress-wrap { display: flex; align-items: center; gap: 10px; padding: 0 20px 8px; }
.todo-progress { flex: 1; height: 4px; background: #e9e7e2; border-radius: 2px; overflow: hidden; }
.todo-progress > div { height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .3s; }
#todo-progress-text { font-size: 11.5px; color: var(--text2); }
.todo-list { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.todo-group-title { font-size: 12px; color: var(--text2); font-weight: 600; padding: 12px 10px 6px; display: flex; align-items: center; gap: 6px; }
.todo-row {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 10px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.todo-row:hover { background: rgba(0,0,0,.02); }
.check-circle {
  width: 21px; height: 21px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 1.7px solid #c9c7c2; background: transparent; transition: all .15s; position: relative;
}
.check-circle:hover { border-color: var(--accent); }
.check-circle.done { background: var(--accent); border-color: var(--accent); }
.check-circle.done::after {
  content: ""; position: absolute; left: 6px; top: 2.5px;
  width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.todo-main { flex: 1; min-width: 0; }
.todo-title { font-size: 15px; word-break: break-word; }
.todo-row.completed .todo-title { color: var(--text3); text-decoration: line-through; }
.todo-sub { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.todo-chip { font-size: 11.5px; color: var(--text2); display: inline-flex; align-items: center; gap: 3px; }
.todo-chip.overdue { color: var(--red); }
.todo-chip.today { color: var(--blue); }
.todo-list-name { font-size: 11.5px; padding: 1px 8px; border-radius: 6px; }
.todo-note-preview { font-size: 12.5px; color: var(--text2); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prio-flag { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; margin-top: 7px; }
.prio-1 { background: #6aa1ff; } .prio-2 { background: #ff9f43; } .prio-3 { background: #e5484d; }
.todo-add {
  display: flex; align-items: center; gap: 6px; margin: 0 12px; padding: 6px 10px 6px 4px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 13px; margin-bottom: 10px;
  box-shadow: var(--shadow); flex-shrink: 0;
}
body[data-module="todos"] .page { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
body[data-module="todos"] .todo-add { margin-bottom: calc(var(--tabbar-h) + var(--safe-b) + 10px); }
.todo-add input { flex: 1; padding: 8px 6px; }
#todo-add-btn { padding: 7px 14px; }
#todo-add-date.active, #todo-add-priority.active { color: var(--accent); background: var(--accent-soft); }

/* ---------- 日记本 ---------- */
body[data-module="diary"] { --accent: #f07a4b; --accent-soft: #fdeee6; }
.diary-timeline { flex: 1; overflow-y: auto; padding: 4px 16px calc(var(--tabbar-h) + var(--safe-b) + 20px); }
.diary-month { font-size: 14px; font-weight: 700; color: var(--text2); padding: 16px 8px 8px; }
.diary-card {
  display: flex; gap: 14px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px; margin: 0 2px 12px; cursor: pointer;
  transition: transform .12s;
}
.diary-card:hover { transform: translateY(-1px); }
.diary-date-col {
  width: 46px; flex-shrink: 0; text-align: center; color: var(--accent);
  border-right: 1px solid var(--line); padding-right: 12px;
}
.diary-day { font-size: 24px; font-weight: 800; line-height: 1.1; }
.diary-weekday { font-size: 11px; color: var(--text2); }
.diary-body { flex: 1; min-width: 0; }
.diary-meta { display: flex; gap: 6px; font-size: 13px; margin-bottom: 3px; }
.diary-excerpt {
  font-size: 14px; color: var(--text); white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.diary-photos-mini { display: flex; gap: 6px; margin-top: 8px; overflow: hidden; }
.diary-photos-mini img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.diary-empty { text-align: center; color: var(--text3); padding: 60px 0; }

/* 日记本锁屏 */
.diary-lock {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 20px 24px calc(var(--tabbar-h) + var(--safe-b) + 40px); text-align: center;
}
.diary-lock-icon {
  width: 68px; height: 68px; border-radius: 22px; font-size: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.diary-lock-title { font-size: 18px; font-weight: 700; }
.diary-lock-hint { font-size: 13px; color: var(--text2); min-height: 19px; }
.diary-lock-form { display: flex; gap: 8px; width: 100%; max-width: 320px; margin-top: 6px; }
.diary-lock-form input {
  flex: 1; min-width: 0; padding: 11px 13px; border: 1.5px solid var(--line);
  border-radius: 11px; background: #fafaf8; text-align: center; letter-spacing: 1px;
}
.diary-lock-form input:focus { border-color: var(--accent); background: #fff; }
.diary-lock-form .btn-primary { padding: 11px 20px; border-radius: 11px; flex-shrink: 0; }
.diary-lock-forgot { margin-top: 8px; font-size: 12px; }
#diary-lock-btn.active { color: var(--accent); background: var(--accent-soft); }

/* 密码锁设置弹层 */
.sheet-tip { font-size: 12.5px; color: var(--text2); line-height: 1.6; margin-bottom: 16px; }
.sheet-note { font-size: 12px; color: var(--text3); line-height: 1.6; margin-top: 12px; }
.btn-primary.block { width: 100%; padding: 12px; margin-top: 6px; }
.inline-link { font-size: 12px; vertical-align: baseline; }
.lock-status {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 13px; border-radius: 11px; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 16px;
}
.lock-status-hint { font-weight: 400; color: var(--text2); font-size: 12.5px; }
.lock-actions { display: flex; gap: 10px; }
.lock-actions button { flex: 1; padding: 11px; border-radius: 12px; }

/* ---------- 弹层（底部抽屉 / 居中弹窗） ---------- */
.sheet { position: fixed; inset: 0; z-index: 200; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet-body {
  position: absolute; background: var(--card); padding: 20px;
}
/* 移动端：底部抽屉 */
.sheet-body {
  left: 0; right: 0; bottom: 0;
  border-radius: 18px 18px 0 0; max-height: 88%;
  overflow-y: auto; animation: slideUp .22s ease-out;
  padding-bottom: calc(20px + var(--safe-b));
}
@keyframes slideUp { from { transform: translateY(40%); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-body h3 { text-align: center; margin-bottom: 14px; }
.sheet-cancel { width: 100%; margin-top: 14px; padding: 11px; border-radius: 12px; background: #f2f0ec; color: var(--text2); }
.list-drawer-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px; border-radius: 10px; text-align: left;
}
.list-drawer-item:hover { background: #f6f5f2; }
.list-dot { width: 10px; height: 10px; border-radius: 50%; }
.list-drawer-item .count { margin-left: auto; color: var(--text3); font-size: 13px; }

/* 任务详情 */
.task-detail-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#task-detail-title { flex: 1; font-size: 17px; font-weight: 600; }
#task-detail-note {
  width: 100%; min-height: 90px; padding: 10px; background: #f8f7f4;
  border-radius: 10px; resize: vertical; margin-bottom: 14px; line-height: 1.6;
}
.task-detail-opts { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.opt-group { display: flex; align-items: center; gap: 8px; }
.opt-label { font-size: 13px; color: var(--text2); width: 38px; flex-shrink: 0; }
.opt-group select, .opt-group input[type="date"] {
  padding: 7px 10px; border-radius: 9px; background: #f2f0ec; border: none;
}
.task-detail-actions { display: flex; justify-content: space-between; gap: 10px; }

/* 日记编辑 */
.diary-editor-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.diary-editor-head input[type="date"] { padding: 7px 10px; border-radius: 9px; background: #f2f0ec; font-size: 15px; }
.diary-editor-head span { color: var(--text2); font-size: 13px; }
.picker-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.picker-label { font-size: 13px; color: var(--text2); width: 38px; flex-shrink: 0; }
.emoji-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.emoji-picker button {
  width: 36px; height: 36px; border-radius: 10px; font-size: 19px;
  display: inline-flex; align-items: center; justify-content: center;
}
.emoji-picker button.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
#diary-content {
  width: 100%; min-height: 160px; padding: 12px; background: #f8f7f4;
  border-radius: 12px; resize: vertical; line-height: 1.7; margin-bottom: 12px;
}
.diary-photos { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.diary-photos .photo-item { position: relative; }
.diary-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; cursor: pointer; }
.diary-photos .photo-del {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.diary-editor-actions { display: flex; align-items: center; gap: 10px; }
.diary-editor-actions .spacer { flex: 1; }
.diary-uploading { font-size: 12px; color: var(--text2); }

/* 图片预览 */
.img-viewer { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.img-viewer img { max-width: 94%; max-height: 94%; border-radius: 6px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  transform: translateX(-50%); background: rgba(30,30,30,.88); color: #fff;
  padding: 9px 18px; border-radius: 20px; font-size: 13.5px; z-index: 400;
  animation: toastIn .2s ease-out; max-width: 80vw; text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } }

/* ============================================================
   响应式：桌面 ≥ 820px
   ============================================================ */
@media (min-width: 820px) {
  .tabbar { display: none; }
  .back-btn { display: none; }
  .list-switcher { display: inline-flex; }
  .sheet-body {
    left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%);
    width: 460px; max-width: 92vw; max-height: 86vh; border-radius: 16px;
    animation: popIn .18s ease-out; padding-bottom: 20px;
  }
  @keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%); } to { opacity: 1; transform: translate(-50%, -50%); } }
  .toast { bottom: 40px; }
  .diary-timeline { padding-bottom: 30px; }
}
@media (max-width: 819px) {
  .sidebar { display: none; }
  .page { padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
  .pane-header { padding: 12px 16px 8px; }
  .pane-header h1 { font-size: 20px; }
  .notes-list-pane { width: 100%; border-right: none; }
  /* 移动端笔记编辑器全屏 */
  .note-editor-pane {
    position: fixed; inset: 0; z-index: 120;
    transform: translateX(100%); transition: transform .22s ease-out;
  }
  .note-editor-pane.open { transform: none; }
  .back-btn { display: inline-flex; }
  .diary-card { margin: 0 0 10px; }
}
/* 平板中间宽度：笔记双栏稍微收窄 */
@media (min-width: 820px) and (max-width: 1099px) {
  .notes-list-pane { width: 300px; }
}
