/* ============================================================
   拾光 · 设计令牌
   ============================================================ */
:root {
  --bg: #FAF7F2;
  --bg-sub: #F3EEE7;
  --card: #FFFDFA;
  --border: #E5DED3;
  --border-strong: #D5CCBE;
  --text: #22201D;
  --text-2: #5A554E;
  --text-3: #7A7368;
  --accent: #B4643C;
  --accent-hover: #95502E;
  --accent-soft: #F2E4D9;
  --on-accent: #FFFDFA;
  --success: #4F7A5C;
  --warn: #B07C24;
  --danger: #B4453C;
  --danger-soft: #F7E3E0;
  --hover: #F5F0E8;

  --shadow-1: 0 1px 2px rgba(30, 24, 18, .05);
  --shadow-2: 0 4px 12px rgba(30, 24, 18, .06);
  --shadow-3: 0 12px 32px rgba(30, 24, 18, .08);

  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "STSong", "SimSun", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;

  --reading: 17px;
  --radius-s: 8px;
  --radius-m: 10px;
  --radius-l: 14px;
  --sidebar: 248px;
  --tab-h: 56px;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-move: cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --bg: #171512;
  --bg-sub: #1F1C18;
  --card: #24211C;
  --border: #33302A;
  --border-strong: #443F36;
  --text: #EDE8DF;
  --text-2: #B0A99C;
  --text-3: #948D80;
  --accent: #D98E63;
  --accent-hover: #E8A47C;
  --accent-soft: #3A2A20;
  --on-accent: #1A1512;
  --success: #7FA98A;
  --warn: #D3A45C;
  --danger: #D98B82;
  --danger-soft: #3A2523;
  --hover: #2B2721;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .24);
  --shadow-2: 0 4px 12px rgba(0, 0, 0, .32);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .42);
}

/* ============================================================
   基础
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, p { margin: 0; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

.icon { width: 20px; height: 20px; flex: none; }

/* 桌面端隐藏移动专属元素 */
.tabbar, .fab { display: none; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 200;
  padding: 8px 14px; background: var(--card); color: var(--text);
  border: 1px solid var(--accent); border-radius: var(--radius-s);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* ============================================================
   应用骨架
   ============================================================ */
.app { min-height: 100dvh; }
.workspace {
  margin-left: var(--sidebar);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: margin-right .32s var(--ease-move);
}
body.detail-open .workspace { margin-right: 400px; }

/* ---------- 侧栏 ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar);
  z-index: 40;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 16px;
  background: var(--bg-sub);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.brand-mark {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--serif);
  font-size: 18px;
  display: grid; place-items: center;
}
.brand-name { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.2; letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .06em; margin-top: 2px; }

.new-entry {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 44px; padding: 0 12px;
  background: var(--accent); color: var(--on-accent);
  border-radius: var(--radius-s);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: background .2s var(--ease), transform .12s var(--ease);
}
.new-entry:hover { background: var(--accent-hover); }
.new-entry:active { transform: scale(.985); }
.new-entry kbd {
  margin-left: auto;
  font-family: var(--sans); font-size: 11px;
  background: rgba(255, 255, 255, .18); color: inherit;
  padding: 1px 6px; border-radius: 4px; line-height: 1.6;
}

.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 24px; }
.side-nav button {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 12px;
  border-radius: var(--radius-s);
  color: var(--text-2); font-size: 14px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.side-nav button::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 3px; height: 0; border-radius: 2px;
  background: var(--accent); transform: translateY(-50%);
  transition: height .2s var(--ease);
}
.side-nav button:hover { background: var(--card); color: var(--text); }
.side-nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 500; }
.side-nav button[aria-current="page"]::before { height: 18px; }

.side-tags { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-top: 28px; }
.side-label { font-size: 11px; letter-spacing: .1em; color: var(--text-3); padding: 0 12px 8px; }
.side-tag-list { overflow: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px; }
.side-tag {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 34px; padding: 0 12px; border-radius: var(--radius-s);
  font-size: 13px; color: var(--text-2); text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.side-tag span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-tag em { font-style: normal; font-size: 11px; color: var(--text-3); }
.side-tag:hover { background: var(--card); color: var(--text); }
.side-tag.is-active { background: var(--accent-soft); color: var(--accent-hover); }
.side-empty { font-size: 12px; color: var(--text-3); padding: 2px 12px; line-height: 1.7; }

.side-foot { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.side-foot button {
  display: flex; align-items: center; gap: 12px;
  height: 38px; padding: 0 12px; border-radius: var(--radius-s);
  color: var(--text-2); font-size: 13px; text-align: left;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.side-foot button:hover { background: var(--card); color: var(--text); }
.side-foot button em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--text-3); }
.storage-mini { display: flex; justify-content: space-between; padding: 10px 12px 0; font-size: 11px; color: var(--text-3); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 20px 40px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
}
.topbar-title h1 {
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  line-height: 1.3; letter-spacing: -.01em;
}
.topbar-title p { font-size: 12px; color: var(--text-3); margin-top: 2px; letter-spacing: .02em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.search-wrap {
  position: relative;
  display: flex; align-items: center;
  width: 268px; height: 38px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 0 10px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), width .2s var(--ease);
}
.search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; background: transparent; outline: none;
  font-size: 13px; padding: 0 6px;
}
.search-wrap input::placeholder { color: var(--text-3); }
.search-wrap input::-webkit-search-cancel-button { display: none; }
.search-icon { width: 16px; height: 16px; color: var(--text-3); }
.search-clear { display: grid; place-items: center; width: 22px; height: 22px; color: var(--text-3); border-radius: 50%; }
.search-clear:hover { background: var(--bg-sub); color: var(--text); }
.search-clear .icon { width: 13px; height: 13px; }
.search-kbd { font-family: var(--sans); font-size: 10px; color: var(--text-3); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; line-height: 16px; }
.search-toggle { display: none !important; }

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-s);
  color: var(--text-2);
  transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--bg-sub); color: var(--text); }
.icon-btn:disabled { opacity: .28; cursor: default; pointer-events: none; }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }

/* ---------- 主区 ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 40px 96px;
  outline: none;
}
.view { max-width: 1120px; margin: 0 auto; animation: view-in .32s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ============================================================
   通用组件
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-s);
  font-size: 14px; font-weight: 500;
  transition: background .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), transform .1s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: var(--card); border: 1px solid var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-sub); color: var(--text); border-color: var(--border-strong); }
.btn-text { color: var(--text-2); padding: 0 10px; }
.btn-text:hover { color: var(--accent); }
.btn-danger { color: var(--danger); background: transparent; border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border-radius: 999px;
  background: var(--bg-sub); color: var(--text-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.chip:hover { background: var(--hover); color: var(--text); }
.chip.is-active { background: var(--accent-soft); color: var(--accent-hover); border: 1px solid var(--accent); }
.chip em { font-style: normal; color: var(--text-3); font-size: 11px; }
.chip.is-active em { color: var(--accent-hover); }

.chip-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-divider { width: 1px; height: 16px; background: var(--border); margin: 0 4px; }

.tag-chip {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 9px;
  border-radius: 999px;
  background: var(--bg-sub); color: var(--text-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-chip::before { content: "#"; opacity: .45; margin-right: 2px; }

.section-label {
  font-size: 11px; letter-spacing: .12em; color: var(--text-3);
  text-transform: uppercase;
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 24px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.panel-head h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.panel-head span { font-size: 12px; color: var(--text-3); }

/* ---------- 空状态 ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 64px 24px; }
.empty-art { width: 168px; height: auto; color: var(--text-3); margin-bottom: 24px; opacity: .8; }
.empty h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 14px; color: var(--text-3); max-width: 320px; margin-bottom: 22px; line-height: 1.7; }
.empty .btn { margin-top: 2px; }
.view-timeline > .empty { min-height: calc(100dvh - 260px); justify-content: center; }

/* ---------- 提示条 ---------- */
.seed-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: var(--radius-m);
  font-size: 13px; color: var(--accent-hover);
}
.seed-banner button { flex: none; font-size: 12px; font-weight: 500; color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.seed-banner button:hover { color: var(--accent); }

/* ============================================================
   时间线
   ============================================================ */
.timeline-toolbar { display: block; margin: 4px 0 24px; }
.timeline-toolbar .chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.result-info { margin-top: 8px; text-align: right; font-size: 12px; color: var(--text-3); }
.result-info strong { color: var(--text-2); font-weight: 500; }

.day-group { margin-bottom: 36px; }
.day-head { display: flex; align-items: baseline; gap: 12px; padding: 0 2px 12px; }
.day-head h2 { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .01em; }
.day-head .day-date { font-size: 12px; color: var(--text-3); }
.day-head .day-count { margin-left: auto; font-size: 11px; color: var(--text-3); }

.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry-list.is-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.entry-card {
  position: relative;
  display: block; width: 100%; text-align: left;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  transition: background .16s var(--ease), border-color .16s var(--ease);
  animation: card-in .32s var(--ease) both;
}
.entry-card::before {
  content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--accent);
  opacity: 0; transform: scaleY(.3);
  transition: opacity .16s var(--ease), transform .2s var(--ease);
}
.entry-card:hover { background: var(--hover); border-color: var(--border-strong); }
.entry-card:hover::before { opacity: 1; transform: none; }
.entry-card.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.entry-card.is-selected::before { opacity: 1; transform: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-time { font-size: 11px; color: var(--text-3); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.card-flags { display: flex; align-items: center; gap: 4px; margin-left: auto; color: var(--accent); }
.card-flags .icon { width: 13px; height: 13px; }
.card-mood { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.card-mood i { display: block; width: 4px; border-radius: 2px; background: var(--accent); opacity: .3; }
.card-mood i.on { opacity: 1; }
.card-mood i:nth-child(1) { height: 4px; }
.card-mood i:nth-child(2) { height: 6px; }
.card-mood i:nth-child(3) { height: 8px; }
.card-mood i:nth-child(4) { height: 10px; }
.card-mood i:nth-child(5) { height: 12px; }

.entry-card h3 {
  font-family: var(--serif); font-size: 17px; font-weight: 600;
  line-height: 1.45; margin-bottom: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-excerpt {
  font-size: 14px; line-height: 1.7; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 1.7em;
}
.card-foot { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; overflow: hidden; max-height: 24px; }
.card-words { margin-left: auto; flex: none; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.card-weather { font-size: 11px; color: var(--text-3); }

.entry-list.is-grid .entry-card { display: flex; flex-direction: column; min-height: 172px; padding: 20px; }
.entry-list.is-grid .card-excerpt { -webkit-line-clamp: 3; }
.entry-list.is-grid .card-foot { margin-top: auto; padding-top: 12px; }
.entry-list.is-grid .entry-card h3 { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.entry-list.is-grid .entry-card:nth-child(2) { animation-delay: .04s; }
.entry-list.is-grid .entry-card:nth-child(3) { animation-delay: .08s; }
.entry-list.is-grid .entry-card:nth-child(4) { animation-delay: .12s; }

mark { background: var(--accent-soft); color: var(--text); border-radius: 2px; padding: 0 1px; }
.load-more-wrap { display: flex; justify-content: center; margin-top: 8px; }

/* ============================================================
   日历
   ============================================================ */
.cal-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 4px 0 22px; flex-wrap: wrap; }
.cal-head h2 { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.cal-head p { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.cal-left { min-width: 0; }
.cal-head { margin-bottom: 18px; }

.cal-panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 18px 20px 20px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 6px; }
.cal-weekdays span { text-align: center; font-size: 11px; color: var(--text-3); letter-spacing: .06em; padding-bottom: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 64px;
  border-radius: var(--radius-s);
  font-size: 14px; font-variant-numeric: tabular-nums;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.cal-cell:hover { background: var(--bg-sub); color: var(--text); }
.cal-cell.is-other { color: var(--text-3); opacity: .38; }
.cal-cell.is-today { border-color: var(--accent); color: var(--accent-hover); font-weight: 600; }
.cal-cell.is-selected { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.cal-cell.is-selected .cal-dot { background: var(--on-accent); }
.cal-dot {
  position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}
.cal-cell.is-today .cal-dot { bottom: auto; top: 5px; right: 5px; left: auto; transform: none; }
.cal-cell.is-selected { box-shadow: 0 0 0 3px var(--accent-soft); }

.cal-day { margin-top: 78px; }
.cal-day-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.cal-day-head h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.cal-day-head span { font-size: 12px; color: var(--text-3); }
.cal-empty { padding: 36px 24px; text-align: center; background: var(--card); border: 1px dashed var(--border-strong); border-radius: var(--radius-m); }
.cal-empty p { font-size: 14px; color: var(--text-3); margin-bottom: 16px; }

/* ============================================================
   统计
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-m); padding: 18px 20px; }
.stat-card .stat-label { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value { font-family: var(--serif); font-size: 30px; font-weight: 600; line-height: 1.25; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-card .stat-value small { font-size: 13px; font-family: var(--sans); font-weight: 400; color: var(--text-3); margin-left: 3px; }
.stat-card .stat-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.stat-card.accent .stat-value { color: var(--accent); }

.stats-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.stats-panels > .panel:last-child { grid-column: 1 / -1; }
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; display: flex; justify-content: center; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 14px); gap: 4px; }
.heat-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--bg-sub); border: 1px solid transparent; }
[data-theme="dark"] .heat-cell { background: #26231E; }
.heat-cell.l1 { background: color-mix(in srgb, var(--accent) 32%, var(--bg-sub)); }
.heat-cell.l2 { background: color-mix(in srgb, var(--accent) 52%, var(--bg-sub)); }
.heat-cell.l3 { background: color-mix(in srgb, var(--accent) 74%, var(--bg-sub)); }
.heat-cell.l4 { background: var(--accent); }
.heat-cell.is-today { border-color: var(--text-2); }
.heat-legend { display: flex; align-items: center; gap: 5px; margin-top: 12px; font-size: 11px; color: var(--text-3); }
.heat-legend .heat-cell { width: 10px; height: 10px; }
.heat-note { margin-top: 10px; font-size: 11px; color: var(--text-3); }

.cal-day .entry-list.is-grid { grid-template-columns: 1fr; }

.mood-rows { display: flex; flex-direction: column; gap: 10px; }
.mood-row { display: grid; grid-template-columns: 52px 1fr 44px; align-items: center; gap: 12px; font-size: 12px; color: var(--text-2); }
.mood-track { height: 8px; border-radius: 4px; background: var(--bg-sub); overflow: hidden; }
.mood-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .5s var(--ease); }
.mood-row:nth-child(1) .mood-fill { opacity: .34; }
.mood-row:nth-child(2) .mood-fill { opacity: .5; }
.mood-row:nth-child(3) .mood-fill { opacity: .68; }
.mood-row:nth-child(4) .mood-fill { opacity: .85; }
.mood-row:nth-child(5) .mood-fill { opacity: 1; }
.mood-val { text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11px; }

.trend { width: 100%; height: auto; display: block; }
.trend text { font-family: var(--sans); font-size: 10px; fill: var(--text-3); }
.trend .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.trend .bar { fill: var(--accent); opacity: .88; }
.trend .bar:hover { opacity: 1; }

.stats-empty { text-align: center; padding: 40px 20px; color: var(--text-3); font-size: 14px; }

/* ============================================================
   设置
   ============================================================ */
.settings { display: flex; flex-direction: column; gap: 20px; max-width: 880px; }
.settings-group { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-m); overflow: hidden; }
.settings-group > h2 {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  padding: 16px 22px 12px; border-bottom: 1px solid var(--border);
}
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row h3 { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.setting-row p { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.setting-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.segmented { display: inline-flex; background: var(--bg-sub); border: 1px solid var(--border); border-radius: var(--radius-s); padding: 2px; gap: 2px; flex: none; }
.segmented button { height: 30px; padding: 0 12px; border-radius: 6px; font-size: 12px; color: var(--text-2); transition: background .16s var(--ease), color .16s var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow-1); font-weight: 500; }

.storage-bar { height: 6px; background: var(--bg-sub); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.storage-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s var(--ease); }
.storage-info { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.danger-zone .setting-row h3 { color: var(--danger); }
.shortcut-list { padding: 8px 22px 16px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; font-size: 13px; color: var(--text-2); border-bottom: 1px dashed var(--border); }
.shortcut-row:last-child { border-bottom: 0; }
kbd.key {
  display: inline-block; font-family: var(--sans); font-size: 11px;
  background: var(--bg-sub); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
  color: var(--text-2); min-width: 22px; text-align: center;
}
.about-text { padding: 4px 22px 20px; font-size: 12px; color: var(--text-3); line-height: 1.9; }
.about-text strong { color: var(--text-2); font-weight: 500; }

/* ============================================================
   详情面板
   ============================================================ */
.detail-scrim { position: fixed; inset: 0; background: rgba(30, 24, 18, .34); z-index: 55; display: none; }
.detail {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 400px; z-index: 60;
  display: flex; flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-3);
  transform: translateX(102%);
  transition: transform .32s var(--ease-move);
  visibility: hidden;
}
.detail.is-open { transform: none; visibility: visible; }
.detail-head {
  display: flex; align-items: center; gap: 6px;
  height: 58px; padding: 0 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.detail-head .detail-date { flex: 1; min-width: 0; font-size: 12px; color: var(--text-3); padding-left: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-head .icon-btn { width: 34px; height: 34px; }
.detail-nav { flex: none; }
.detail-scroll { flex: 1; overflow: auto; padding: 26px 28px 40px; }
.detail-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--text-3); margin-bottom: 12px; }
.detail-meta .dot { width: 2px; height: 2px; background: var(--text-3); border-radius: 50%; opacity: .6; }
.detail h1 {
  font-family: var(--serif); font-size: 27px; font-weight: 600;
  line-height: 1.4; letter-spacing: -.01em; margin-bottom: 20px;
  overflow-wrap: anywhere;
}
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.detail-images { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 24px; }
.detail-images img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--border); cursor: zoom-in; }
.detail-images img:only-child { grid-column: 1 / -1; height: auto; max-height: 320px; }
.detail-foot { flex: none; display: flex; align-items: center; gap: 4px; padding: 10px 12px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--card); }
.detail-foot .btn-edit { margin-right: auto; height: 38px; }
.detail-foot .icon-btn { width: 38px; height: 38px; }
.detail-foot .icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }
.detail-nav { display: flex; gap: 2px; }

/* ---------- 富文本 ---------- */
.prose { font-size: var(--reading); line-height: 1.85; color: var(--text); overflow-wrap: anywhere; }
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.4; margin: 1.7em 0 .6em; }
.prose h1 { font-size: 1.5em; }
.prose h2 { font-size: 1.28em; }
.prose h3 { font-size: 1.12em; }
.prose h4 { font-size: 1em; }
.prose blockquote {
  margin: 1.2em 0; padding: 2px 0 2px 16px;
  border-left: 2px solid var(--accent);
  color: var(--text-2); font-size: .97em;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose ul, .prose ol { margin: 0 0 1.05em; padding-left: 1.4em; }
.prose li { margin-bottom: .3em; }
.prose li::marker { color: var(--accent); }
.prose code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .86em; background: var(--bg-sub); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}
.prose pre {
  background: var(--bg-sub); border: 1px solid var(--border);
  border-radius: var(--radius-s); padding: 14px 16px;
  overflow: auto; margin: 1.2em 0; line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: .82em; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose img { max-width: 100%; border-radius: var(--radius-s); }
.prose .md-img-placeholder { display: block; font-size: 12px; color: var(--text-3); border: 1px dashed var(--border); border-radius: 6px; padding: 10px; text-align: center; }

/* ============================================================
   编辑器
   ============================================================ */
.editor-layer { position: fixed; inset: 0; z-index: 80; }
.editor-backdrop { position: absolute; inset: 0; background: rgba(28, 22, 16, .46); }
.editor {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -48%);
  width: 760px; max-width: calc(100vw - 48px);
  height: min(88dvh, 880px);
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  opacity: 0;
  transition: opacity .24s var(--ease), transform .28s var(--ease-move);
}
.editor.is-open { opacity: 1; transform: translate(-50%, -50%); }
.editor-head { display: flex; align-items: center; gap: 14px; height: 62px; padding: 0 18px 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.editor-head h2 { font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1.3; }
.editor-head .save-state { font-size: 11px; color: var(--text-3); }
.editor-head-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.editor-head-actions .btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-hover); border-color: transparent; }
.editor-close { width: 34px; height: 34px; flex: none; }

.editor-fields { flex: none; padding: 16px 28px 0; }
.editor-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.meta-field { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); }
.meta-field input[type="date"], .meta-field select {
  height: 30px; border: 1px solid var(--border); background: var(--card);
  border-radius: 6px; padding: 0 7px; font-size: 12px; color: var(--text-2);
  outline: none;
}
.meta-field input[type="date"]:focus, .meta-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.mood-picker { display: flex; align-items: center; gap: 2px; }
.mood-picker button {
  display: grid; place-items: center;
  width: 28px; height: 30px; border-radius: 6px;
  transition: background .16s var(--ease);
}
.mood-picker button:hover { background: var(--bg-sub); }
.mood-picker i {
  display: block; border-radius: 50%;
  border: 1.5px solid var(--text-3);
  transition: background .16s var(--ease), border-color .16s var(--ease), box-shadow .16s var(--ease), transform .16s var(--ease);
}
.mood-picker button:nth-child(1) i { width: 8px; height: 8px; }
.mood-picker button:nth-child(2) i { width: 11px; height: 11px; }
.mood-picker button:nth-child(3) i { width: 14px; height: 14px; }
.mood-picker button:nth-child(4) i { width: 17px; height: 17px; }
.mood-picker button:nth-child(5) i { width: 20px; height: 20px; }
.mood-picker button[aria-pressed="true"] i {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); transform: scale(1.08);
}

.editor-title {
  display: block; width: 100%;
  margin: 12px 0 6px; padding: 4px 0;
  border: 0; outline: none; background: transparent;
  font-family: var(--serif); font-size: 26px; font-weight: 600;
  line-height: 1.4; color: var(--text);
}
.editor-title::placeholder { color: var(--text-3); font-weight: 400; }

.tag-editor { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 30px; margin: 2px 0 8px; }
.tag-editor .tag-chip { height: 24px; padding-right: 5px; }
.tag-editor .tag-chip button { display: inline-grid; place-items: center; width: 17px; height: 17px; border-radius: 50%; color: var(--text-3); margin-left: 2px; }
.tag-editor .tag-chip button:hover { background: var(--border); color: var(--text); }
.tag-editor .tag-chip button .icon { width: 10px; height: 10px; }
.tag-input {
  width: 110px; height: 24px;
  border: 0; outline: none; background: transparent;
  font-size: 12px; color: var(--text-2);
}
.tag-input::placeholder { color: var(--text-3); }
.tag-suggest { position: relative; display: inline-flex; }
.tag-suggest-list {
  position: absolute; top: 26px; left: -4px; z-index: 5;
  min-width: 130px; padding: 4px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column;
}
.tag-suggest-list button { text-align: left; font-size: 12px; padding: 5px 8px; border-radius: 4px; color: var(--text-2); }
.tag-suggest-list button:hover, .tag-suggest-list button:focus { background: var(--accent-soft); color: var(--accent-hover); }

.editor-toolbar {
  flex: none; display: flex; align-items: center; gap: 2px;
  padding: 6px 28px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.editor-toolbar::-webkit-scrollbar { display: none; }
.tool-btn {
  display: grid; place-items: center;
  min-width: 30px; height: 30px; padding: 0 6px;
  border-radius: 6px; color: var(--text-2);
  font-size: 13px; font-weight: 600; flex: none;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.tool-btn:hover { background: var(--bg-sub); color: var(--text); }
.tool-btn .icon { width: 16px; height: 16px; }
.tool-sep { width: 1px; height: 16px; background: var(--border); margin: 0 5px; flex: none; }
.toolbar-spacer { flex: 1; }

.editor-body { flex: 1; min-height: 0; display: flex; position: relative; }
.editor-body textarea {
  flex: 1; width: 100%;
  border: 0; outline: none; resize: none;
  background: transparent;
  padding: 16px 28px 24px;
  font-family: var(--sans);
  font-size: var(--reading);
  line-height: 1.9;
  color: var(--text);
}
.editor-body textarea::placeholder { color: var(--text-3); }
.editor-preview {
  display: none; flex: 1; min-width: 0; overflow: auto;
  padding: 16px 28px 24px;
  border-left: 1px solid var(--border);
  background: var(--bg);
}
.editor.preview-on .editor-body { display: grid; grid-template-columns: 1fr 1fr; }
.editor.preview-on .editor-preview { display: block; }
.editor.preview-on .editor-body textarea { min-width: 0; }

.editor-images { flex: none; display: flex; gap: 8px; flex-wrap: wrap; padding: 0 28px 12px; }
.editor-images:empty { display: none; }
.img-thumb { position: relative; width: 64px; height: 64px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-thumb button { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(30, 24, 18, .62); color: #fff; display: grid; place-items: center; }
.img-thumb button .icon { width: 10px; height: 10px; }

.editor-foot {
  flex: none; display: flex; align-items: center; gap: 12px;
  min-height: 58px; padding: 10px 22px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--card);
}
.editor-count { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.editor-count .save-state { display: block; color: var(--text-3); }
.editor-foot-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ============================================================
   弹层 / Toast
   ============================================================ */
.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(30, 24, 18, .38); }
.modal {
  position: relative;
  width: 420px; max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-3);
  padding: 24px;
  animation: modal-in .24s var(--ease) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.4; margin-bottom: 8px; }
.modal p { font-size: 13px; color: var(--text-2); line-height: 1.75; }
.modal .modal-extra { margin-top: 12px; font-size: 12px; color: var(--text-3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; flex-wrap: wrap; }
.modal-actions .btn { height: 38px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 120;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--text); color: var(--bg);
  border-radius: var(--radius-s);
  font-size: 13px; line-height: 1.5;
  box-shadow: var(--shadow-3);
  transform: translate(-50%, 14px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease), transform .24s var(--ease);
  max-width: calc(100vw - 32px);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
[data-theme="dark"] .toast button { color: var(--accent-hover); }

body.is-locked { overflow: hidden; }

/* ============================================================
   响应式：1024–1199 图标轨
   ============================================================ */
@media (min-width: 1024px) and (max-width: 1199px) {
  :root { --sidebar: 72px; }
  .sidebar { padding: 20px 10px 14px; align-items: center; }
  .brand { padding: 0 0 20px; }
  .brand-text, .new-entry span, .new-entry kbd, .side-nav span,
  .side-tags, .side-foot button span, .side-foot button em, .storage-mini { display: none; }
  .new-entry { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .side-nav { width: 100%; margin-top: 18px; }
  .side-nav button { justify-content: center; padding: 0; height: 42px; }
  .side-nav button::before { left: -10px; }
  .side-foot { width: 100%; align-items: center; }
  .side-foot button { justify-content: center; padding: 0; width: 100%; height: 40px; }
  .side-foot .icon { width: 21px; height: 21px; }
  body.detail-open .workspace { margin-right: 0; }
  .detail {
    top: 50%; left: 50%; right: auto; bottom: auto;
    width: min(720px, calc(100vw - 48px)); height: auto; max-height: 88dvh;
    border: 1px solid var(--border); border-radius: var(--radius-l);
    transform: translate(-50%, -46%); opacity: 0; visibility: hidden;
    transition: opacity .24s var(--ease), transform .28s var(--ease-move), visibility .28s;
  }
  .detail.is-open { transform: translate(-50%, -50%); opacity: 1; visibility: visible; }
  .detail-scrim { display: block; }
}

/* ============================================================
   响应式：< 1024 移动
   ============================================================ */
@media (max-width: 1023px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  body.detail-open .workspace { margin-right: 0; }

  .topbar { padding: 14px 20px 12px; gap: 12px; flex-wrap: wrap; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title p { font-size: 11px; }
  .topbar-actions { gap: 4px; }
  .search-wrap { display: none; }
  .search-toggle { display: grid !important; }
  .topbar.search-open .search-wrap {
    display: flex;
    position: absolute; left: 20px; right: 20px; top: calc(100% - 2px);
    width: auto; z-index: 10;
    box-shadow: var(--shadow-2);
    animation: search-in .2s var(--ease) both;
  }
  @keyframes search-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
  .search-kbd { display: none; }
  .layout-btn { display: none; }

  .main { padding: 0 20px calc(104px + env(safe-area-inset-bottom)); }
  .view { max-width: 100%; }

  .tabbar {
    display: block;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg);
    border-top: 1px solid var(--border);
  }
  .tabbar-inner { display: grid; grid-template-columns: repeat(4, 1fr); height: var(--tab-h); }
  .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; color: var(--text-3);
    transition: color .16s var(--ease);
  }
  .tabbar button .icon { width: 22px; height: 22px; }
  .tabbar button[aria-current="page"] { color: var(--accent); }
  .tabbar button[aria-current="page"] .icon { fill: color-mix(in srgb, var(--accent) 12%, transparent); }

  .fab {
    display: grid; place-items: center;
    position: fixed; right: 16px;
    bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
    width: 56px; height: 56px; z-index: 46;
    background: var(--accent); color: var(--on-accent);
    border-radius: 16px;
    box-shadow: var(--shadow-3);
    transition: transform .14s var(--ease), background .16s var(--ease);
  }
  .fab:hover { background: var(--accent-hover); }
  .fab:active { transform: scale(.94); }
  .fab .icon { width: 24px; height: 24px; }

  .timeline-toolbar { margin: 2px 0 20px; gap: 10px; }
  .timeline-toolbar .chips { gap: 6px; flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 4px; scrollbar-width: none; }
  .timeline-toolbar .chips::-webkit-scrollbar { display: none; }
  .chip { height: 30px; padding: 0 12px; }
  .result-info { display: none; }

  .day-group { margin-bottom: 28px; }
  .day-head { padding-bottom: 10px; }
  .day-head h2 { font-size: 16px; }
  .entry-list.is-grid { grid-template-columns: 1fr; }
  .entry-card { padding: 16px 18px; }
  .entry-list.is-grid .entry-card { min-height: 0; }
  .card-excerpt { -webkit-line-clamp: 2; }

  .cal-head { margin: 2px 0 16px; }
  .cal-head h2 { font-size: 22px; }
  .cal-layout { grid-template-columns: 1fr; gap: 0; }
  .cal-day { margin-top: 24px; }
  .cal-panel { padding: 12px 10px 14px; }
  .cal-grid { gap: 2px; }
  .cal-cell { min-height: 44px; aspect-ratio: auto; height: 44px; font-size: 13px; border-radius: 6px; }
  .cal-dot { bottom: 4px; }
  .cal-cell.is-today .cal-dot { top: 4px; right: 4px; }
  .detail-scrim { display: block; }
  .detail {
    inset: 0; width: 100%; height: 100dvh; max-height: none;
    border: 0; border-radius: 0;
    transform: translateY(14px); opacity: 0; visibility: hidden;
    transition: opacity .22s var(--ease), transform .26s var(--ease-move), visibility .26s;
  }
  .detail.is-open { transform: none; opacity: 1; visibility: visible; }
  .detail-scroll { padding: 22px 20px 30px; }
  .detail h1 { font-size: 23px; }
  .detail-images img { height: 108px; }
  .detail-foot { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .detail-foot .btn-edit { height: 40px; padding: 0 14px; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 25px; }
  .stats-panels { grid-template-columns: 1fr; gap: 14px; }
  .stats-panels > .panel:last-child { grid-column: auto; }
  .panel { padding: 18px 16px; }
  .heatmap { grid-template-rows: repeat(7, 10px); gap: 3px; }
  .heat-cell { width: 10px; height: 10px; }
  .mood-row { grid-template-columns: 44px 1fr 40px; gap: 8px; }

  .settings { max-width: 100%; }
  .settings-group > h2 { padding: 14px 16px 10px; }
  .setting-row { padding: 14px 16px; gap: 14px; flex-wrap: wrap; }
  .setting-row > div:first-child { min-width: 0; }
  .setting-actions { width: 100%; }
  .setting-actions .btn { flex: 1; }
  .segmented button { padding: 0 10px; }
  .shortcut-list { padding: 4px 16px 14px; }
  .about-text { padding: 4px 16px 16px; }
  .storage-bar { width: 100%; }

  .editor-layer { display: block; }
  .editor-backdrop { background: var(--card); }
  .editor {
    inset: 0; width: 100%; max-width: none; height: 100dvh;
    border: 0; border-radius: 0; box-shadow: none;
    transform: none; opacity: 1;
  }
  .editor.is-open { transform: none; }
  .editor-head { height: 56px; padding: 0 12px 0 10px; gap: 8px; }
  .editor-head h2 { font-size: 15px; }
  .editor-head .save-state { display: none; }
  .editor-fields { padding: 12px 18px 0; }
  .editor-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .editor-meta .meta-field:nth-child(1) { grid-column: 1; grid-row: 1; }
  .editor-meta .meta-field:nth-child(3) { grid-column: 2; grid-row: 1; }
  .editor-meta .meta-field:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .editor-meta .meta-field { font-size: 11px; min-width: 0; }
  .editor-meta .meta-field input[type="date"],
  .editor-meta .meta-field select { flex: 1; min-width: 0; height: 28px; }
  .mood-picker button { width: 26px; height: 28px; }
  .editor-title { font-size: 22px; margin: 10px 0 2px; }
  .tag-editor { margin-bottom: 4px; }
  .editor-toolbar { padding: 5px 18px; }
  .editor.preview-on .editor-toolbar { display: none; }
  .editor-body textarea { padding: 12px 18px 20px; font-size: 16px; }
  .editor-preview { padding: 12px 18px 20px; }
  .editor.preview-on .editor-body { display: block; }
  .editor.preview-on .editor-body textarea { display: none; }
  .editor.preview-on .editor-preview { display: block; height: 100%; overflow: auto; border-left: 0; }
  .editor-images { padding: 0 18px 10px; }
  .editor-foot { padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); min-height: 56px; gap: 8px; }
  .editor-foot-actions { gap: 6px; }
  .editor-foot .btn { height: 38px; padding: 0 14px; }
  .editor-foot .btn-text { display: none; }
  .editor-count { font-size: 10px; line-height: 1.5; }
  .editor-count .save-state { display: block; font-size: 10px; }
  .trend text { font-size: 18px; }

  .modal { padding: 20px; }
  .modal-actions .btn { flex: 1; }
  .toast { bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); width: max-content; }

  .seed-banner { font-size: 12px; padding: 10px 12px; gap: 10px; align-items: flex-start; }
  .seed-banner button { margin-top: 1px; }
}

@media (max-width: 400px) {
  .main { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar.search-open .search-wrap { left: 16px; right: 16px; }
  .detail-scroll { padding-left: 18px; padding-right: 18px; }
  .editor-fields { padding-left: 16px; padding-right: 16px; }
  .editor-toolbar { padding-left: 14px; padding-right: 14px; }
  .editor-body textarea { padding-left: 16px; padding-right: 16px; }
  .editor-preview { padding-left: 16px; padding-right: 16px; }
  .cal-cell { font-size: 12px; }
}

/* ============================================================
   动效降级
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .12s !important;
    animation-delay: 0s !important;
    transition-duration: .12s !important;
    scroll-behavior: auto !important;
  }
  .entry-card, .view, .modal { animation: none !important; }
  .entry-card:hover, .btn:active, .fab:active { transform: none !important; }
  .detail, .editor { transition: opacity .12s !important; }
}

/* ============================================================
   打印
   ============================================================ */
@media print {
  @page { margin: 20mm 18mm; }
  body { background: #fff !important; color: #111 !important; }
  .app, .sidebar, .topbar, .tabbar, .fab, .editor-layer, .modal-layer,
  .toast, .detail-scrim, .detail-foot, .skip-link { display: none !important; }
  .workspace { margin: 0 !important; }
  .detail-head { display: flex !important; height: auto !important; padding: 0 0 12px !important; border: 0 !important; }
  .detail-head .icon-btn, .detail-nav { display: none !important; }
  .detail-head .detail-date { font-size: 10pt !important; color: #555 !important; white-space: normal !important; overflow: visible !important; }
  .detail {
    position: static !important; display: block !important;
    width: auto !important; height: auto !important;
    border: 0 !important; box-shadow: none !important;
    transform: none !important; visibility: visible !important;
    background: #fff !important; opacity: 1 !important;
  }
  .detail-scroll { overflow: visible !important; padding: 0 !important; }
  .prose { color: #111 !important; font-size: 12pt !important; }
  .prose blockquote { border-left-color: #999 !important; color: #444 !important; }
  .prose a { color: #111 !important; text-decoration: underline; }
  .detail h1 { color: #111 !important; font-size: 22pt !important; }
  .detail-meta, .detail-tags { color: #555 !important; }
  .detail-images { break-inside: avoid; }
}
