/* ============================================================
   人生支线工作台 —— 样式
   温暖浅色（默认）+ 深色（data-theme="dark"）
   ============================================================ */

:root {
  --bg: #faf5ee;
  --bg-2: #f2eadd;
  --surface: #fffdf8;
  --surface-2: #f7f0e4;
  --text: #3b332a;
  --text-dim: #8d8171;
  --accent: #d98e4a;
  --accent-strong: #b96a35;
  --accent-soft: rgba(217, 142, 74, 0.16);
  --border: #e9ddca;
  --shadow: 0 6px 24px rgba(84, 58, 26, 0.10);
  --shadow-sm: 0 2px 8px rgba(84, 58, 26, 0.08);
  --danger: #c65b4e;
  --radius: 14px;
  --radius-sm: 9px;
  --font-serif: Georgia, "Times New Roman", "Songti SC", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

html[data-theme="dark"] {
  --bg: #1e1a15;
  --bg-2: #262019;
  --surface: #2a231a;
  --surface-2: #322a1f;
  --text: #ece4d6;
  --text-dim: #9c8f7b;
  --accent: #e0a05a;
  --accent-strong: #eeb576;
  --accent-soft: rgba(224, 160, 90, 0.18);
  --border: #3a3123;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --danger: #d97368;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background .3s ease, color .3s ease;
}
button { font-family: inherit; }
textarea, input { font-family: inherit; }
.hidden { display: none !important; }

/* ===== 顶栏 ===== */
#topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo { font-size: 26px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-serif); font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: var(--text-dim); }
.top-actions { display: flex; align-items: center; gap: 8px; }
#search {
  width: 200px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .2s, width .2s;
}
#search:focus { border-color: var(--accent); width: 240px; }

/* ===== 按钮 ===== */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  transition: transform .06s ease, background .2s, border-color .2s, color .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { border-color: var(--border); background: var(--surface); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
#userChip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; background: var(--surface-2);
}
#userChip img { width: 22px; height: 22px; border-radius: 50%; }

/* ===== 布局 ===== */
#layout { display: flex; height: calc(100vh - 60px); }
#sidebar {
  width: 320px; flex: 0 0 320px;
  overflow-y: auto;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
#main { flex: 1; position: relative; overflow: hidden; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px;
  box-shadow: var(--shadow-sm);
}
.panel h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--text-dim); letter-spacing: .4px; }
.list { display: flex; flex-direction: column; gap: 7px; }

/* ===== 列表项（日程/任务/文档/套件） ===== */
.item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.item:hover { background: var(--accent-soft); }
.item .time { color: var(--accent-strong); font-size: 12px; min-width: 46px; }
.item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--text-dim); font-size: 11.5px; }
.item.done .title { text-decoration: line-through; color: var(--text-dim); }
.item .x { color: var(--text-dim); cursor: pointer; padding: 0 2px; }
.inline-form { display: flex; gap: 6px; margin-top: 9px; }
.inline-form input {
  flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); outline: none;
}
.inline-form input:focus { border-color: var(--accent); }

/* ===== 灵感墙 ===== */
#wall { position: absolute; inset: 0; overflow: hidden; }
.note {
  position: absolute;
  width: 260px; min-height: 120px;
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
  cursor: grab;
  display: flex; flex-direction: column;
  transition: box-shadow .15s;
}
.note:hover { box-shadow: 0 10px 34px rgba(84, 58, 26, 0.18); }
.note.dragging { cursor: grabbing; box-shadow: 0 14px 40px rgba(84, 58, 26, 0.24); }
.note-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; font-family: var(--font-serif); word-break: break-word; }
.note-content { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; flex: 1; }
.note-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.note-tag { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: rgba(0,0,0,.07); }
.note-img { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.note .drag-hint { color: var(--text-dim); opacity: 0; transition: opacity .15s; font-size: 11px; align-self: flex-end; margin-top: 4px; }
.note:hover .drag-hint { opacity: .7; }

/* 便签颜色（按标签自动映射 + 手动） */
.note[data-color="amber"]  { background: #f9e8c8; color: #5d421c; }
.note[data-color="blue"]   { background: #dbe9f5; color: #27435c; }
.note[data-color="green"]  { background: #ddecdc; color: #2c5233; }
.note[data-color="purple"] { background: #e7dcf2; color: #4a3864; }
.note[data-color="rose"]   { background: #f7dedc; color: #64393a; }
.note[data-color="cream"]  { background: #fbf4e4; color: #5d5544; }
html[data-theme="dark"] .note[data-color="amber"]  { background: #4a3a1f; color: #f0d9a8; }
html[data-theme="dark"] .note[data-color="blue"]   { background: #2a3d50; color: #c8dff0; }
html[data-theme="dark"] .note[data-color="green"]  { background: #2b4030; color: #c4e2c8; }
html[data-theme="dark"] .note[data-color="purple"] { background: #3b3050; color: #dccdf0; }
html[data-theme="dark"] .note[data-color="rose"]   { background: #4a3334; color: #f0cfcd; }
html[data-theme="dark"] .note[data-color="cream"]  { background: #42392a; color: #ece0c4; }
.note .note-tag { background: rgba(0,0,0,.12); }

.empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-dim); }
.empty-emoji { font-size: 44px; margin: 0; }

/* ===== FAB ===== */
#fab {
  position: fixed; right: 26px; bottom: 26px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 28px; cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 30;
  transition: transform .1s ease;
}
#fab:hover { transform: scale(1.06); }
#fab:active { transform: scale(.94); }

/* ===== 模态 ===== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 22, 12, 0.45);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
html[data-theme="dark"] .modal { background: rgba(0,0,0,.6); }
.modal-card {
  width: min(520px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-card.quick { width: min(420px, 92vw); }
.modal-card input[type="text"], .modal-card input:not([type]), .modal-card textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text); outline: none; font-size: 14px; resize: vertical;
}
.modal-card input:focus, .modal-card textarea:focus { border-color: var(--accent); }
.modal-card textarea { min-height: 90px; }
#noteContent { min-height: 130px; }
.modal-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tag-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-dim);
  border-radius: 14px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.color-dots { display: flex; gap: 6px; }
.dot { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.dot.active { border-color: var(--text); }
.modal-actions { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.file-pick {
  display: block; padding: 16px; text-align: center;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer; color: var(--text-dim);
}
#lensPreview img { max-width: 100%; max-height: 220px; border-radius: 8px; margin: 0 auto; display: block; }

/* ===== 专注 ===== */
#focusOverlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.focus-box { text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.focus-clock { font-size: 92px; font-weight: 200; font-family: var(--font-serif); letter-spacing: 2px; }
.focus-label { font-size: 15px; color: var(--text-dim); }

/* ===== Toast ===== */
#toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 20px; font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

@media (max-width: 860px) {
  #sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
  #layout { flex-direction: column; }
  #search { width: 120px; }
}
