/* ============================================================
   LifeOS 设计系统 — 暖白 / 白卡片 / 极浅粉边框 / 少量柔粉强调
   桌面优先多栏，手机单栏重排；触控目标 ≥ 44px
   ============================================================ */
:root {
  /* 颜色 */
  --bg: #FDFBFA;
  --bg-sunken: #FAF5F6;
  --surface: #FFFFFF;
  --surface-2: #FDF8F9;
  --border: #F3E4E9;
  --border-strong: #E9CED7;
  --text: #2A2A2E;
  --text-soft: #5B5560;
  --muted: #8D858D;
  --accent: #D9788F;
  --accent-soft: #FBEFF3;
  --accent-deep: #B85C74;
  --ok: #4E9B7A;
  --warn: #C08A3E;
  --danger: #C2544F;
  --info: #6E7CB0;
  --star: #E0A93B;

  /* 间距 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 44px;

  /* 圆角 */
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 22px; --r-pill: 999px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --fs-xs: 12px; --fs-s: 13px; --fs-m: 14px; --fs-l: 16px; --fs-xl: 20px; --fs-2xl: 26px; --fs-3xl: 34px;

  /* 层级 */
  --shadow-1: 0 1px 2px rgba(60, 30, 40, .04);
  --shadow-2: 0 4px 16px rgba(60, 30, 40, .06);
  --shadow-3: 0 12px 40px rgba(60, 30, 40, .12);
  --z-modal: 100; --z-toast: 200;

  --sidebar-w: 232px;
  --tabbar-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-m);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-l); }
p { margin: 0 0 var(--s3); }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd { font-family: var(--font-mono); font-size: .92em; }
kbd {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px; color: var(--muted); font-size: 11px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--surface);
  padding: var(--s2) var(--s4); z-index: 999; border-radius: 0 0 var(--r-s) 0;
}
.skip-link:focus { left: 0; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: var(--s6) var(--s7) var(--s8); max-width: 1360px; width: 100%; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(253, 251, 250, .88);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s5); min-height: 56px;
}
.topbar__title { font-weight: 600; font-size: var(--fs-l); flex: 1; }
.topbar__right { display: flex; align-items: center; gap: var(--s2); }

.sidebar__brand { display: flex; gap: var(--s3); align-items: center; padding: var(--s5) var(--s5) var(--s4); }
.brand-star { font-size: 22px; }
.brand-name { font-weight: 700; letter-spacing: -.02em; }
.brand-sub { font-size: var(--fs-xs); color: var(--muted); }
.navi { flex: 1; overflow-y: auto; padding: var(--s2) var(--s3) var(--s5); }
.navi__group-title {
  font-size: 11px; letter-spacing: .08em; color: var(--muted);
  padding: var(--s4) var(--s3) var(--s1); text-transform: uppercase;
}
.navi__item {
  display: flex; align-items: center; gap: var(--s3); width: 100%;
  padding: 9px var(--s3); border-radius: var(--r-m); color: var(--text-soft);
  background: none; border: 0; font: inherit; cursor: pointer; text-align: left; min-height: 40px;
}
.navi__item:hover { background: var(--surface-2); color: var(--text); }
.navi__item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }
.navi__icon { width: 18px; text-align: center; }
.sidebar__foot { padding: var(--s3) var(--s4) var(--s5); border-top: 1px solid var(--border); display: grid; gap: var(--s2); }
.stars-chip {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-m);
  padding: var(--s2) var(--s3); font-size: var(--fs-s);
}
.stars-chip b { color: var(--accent-deep); font-size: var(--fs-l); }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--tabbar-h);
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); display: flex; z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  flex: 1; background: none; border: 0; font: inherit; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; min-height: 44px;
}
.tabbar__item[aria-current="page"] { color: var(--accent-deep); font-weight: 600; }
.tabbar__icon { font-size: 18px; }

.demo-banner {
  display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap;
  background: #FFF6E6; border-bottom: 1px solid #F0DCB8; color: #7A5A18;
  padding: var(--s1) var(--s5); font-size: var(--fs-s);
}
.demo-banner > span:first-child {
  background: #E0A93B; color: #fff; border-radius: var(--r-pill); padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.demo-banner__hint { color: #8A6A28; }

/* ---------------- 组件 ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  padding: var(--s5); box-shadow: var(--shadow-1);
}
.card--flush { padding: 0; overflow: hidden; }
.card__head {
  display: flex; align-items: center; gap: var(--s3); justify-content: space-between;
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card__head h3 { margin: 0; }
.card__body { padding: var(--s5); }
.card__body--tight { padding: var(--s3) var(--s4); }

.grid { display: grid; gap: var(--s5); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.grid--sidebar-right { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: grid; gap: var(--s4); }
.stack--s { gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 var(--s4); border-radius: var(--r-m);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-s); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { border-color: #EBC9C7; color: var(--danger); }
.btn--danger:hover { background: #FCF1F0; }
.btn--sm { min-height: 30px; padding: 0 var(--s3); font-size: var(--fs-xs); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 36px; min-height: 36px; font-size: var(--fs-l); }
.btn--pill { border-radius: var(--r-pill); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: var(--r-pill);
  padding: 2px 10px; font-size: var(--fs-xs); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-soft);
}
.chip--accent { background: var(--accent-soft); border-color: #F1D6E0; color: var(--accent-deep); }
.chip--ok { background: #EDF6F1; border-color: #D3E8DD; color: var(--ok); }
.chip--warn { background: #FCF4E8; border-color: #EFDCC0; color: var(--warn); }
.chip--danger { background: #FBEFEE; border-color: #EDCFCD; color: var(--danger); }
.chip--info { background: #EFF1F9; border-color: #DBDFF0; color: var(--info); }
.chip--muted { opacity: .72; }
.chip--click { cursor: pointer; }

.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

label.field { display: grid; gap: 6px; font-size: var(--fs-s); color: var(--text-soft); }
label.field > span { font-weight: 500; }
input, select, textarea {
  font: inherit; font-size: var(--fs-m); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-m); padding: 9px var(--s3); width: 100%; min-height: 38px;
  /* 表单控件的固有宽度来自 cols / 最长 option，窄屏下会把父级顶破 */
  max-width: 100%;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(217,120,143,.12); }
.field-error { color: var(--danger); font-size: var(--fs-xs); }
.form-row { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.inline-check { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-s); min-height: 30px; }

ul.plain, ol.plain { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-weight: 500; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.list-item__title.is-done { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.list-item__sub { font-size: var(--fs-xs); color: var(--muted); display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.list-item__actions { display: flex; gap: var(--s1); opacity: .55; transition: opacity .12s; flex-wrap: wrap; }
.list-item:hover .list-item__actions, .list-item:focus-within .list-item__actions { opacity: 1; }

.check {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong);
  background: var(--surface); cursor: pointer; flex: 0 0 22px; margin-top: 2px; display: grid; place-items: center;
  font-size: 12px; color: transparent;
}
.check:hover { border-color: var(--accent); }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }

.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab {
  border: 0; background: none; font: inherit; font-size: var(--fs-m); color: var(--muted);
  padding: var(--s2) var(--s3) 10px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; min-height: 40px;
}
.tab[aria-selected="true"] { color: var(--accent-deep); border-bottom-color: var(--accent); font-weight: 600; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-m); padding: 2px; }
.seg button {
  border: 0; background: none; font: inherit; font-size: var(--fs-s); color: var(--text-soft);
  padding: 6px var(--s3); border-radius: 9px; cursor: pointer; min-height: 32px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--accent-deep); font-weight: 600; box-shadow: var(--shadow-1); }

.metric { display: grid; gap: 2px; }
.metric__label { font-size: var(--fs-xs); color: var(--muted); }
.metric__value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.02em; }
.metric__value small { font-size: var(--fs-s); font-weight: 400; color: var(--muted); }

.state { padding: var(--s6); text-align: center; color: var(--muted); }
.state__icon { font-size: 28px; }
.state h3 { color: var(--text-soft); margin-bottom: var(--s1); }
.state .btn { margin-top: var(--s3); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), #F6EDF0, var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; border-radius: var(--r-s); height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

.save-state { font-size: var(--fs-xs); color: var(--muted); }
.save-state[data-state="saving"] { color: var(--warn); }
.save-state[data-state="saved"] { color: var(--ok); }
.save-state[data-state="failed"] { color: var(--danger); }
.save-state[data-state="pending"] { color: var(--info); }

.toast-root { position: fixed; right: var(--s5); bottom: var(--s5); z-index: var(--z-toast); display: grid; gap: var(--s2); max-width: min(420px, 92vw); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-m); box-shadow: var(--shadow-3); padding: var(--s3) var(--s4);
  font-size: var(--fs-s); animation: slide .18s ease-out;
}
.toast--ok { border-left-color: var(--ok); }
.toast--err { border-left-color: var(--danger); }
.toast--warn { border-left-color: var(--warn); }
.toast__title { font-weight: 600; margin-bottom: 2px; }
.toast__actions { display: flex; gap: var(--s2); margin-top: var(--s2); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(42,32,36,.32); z-index: var(--z-modal); display: grid; place-items: center; padding: var(--s4); animation: fade .14s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  width: min(680px, 100%); max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal--wide { width: min(1000px, 100%); }
.modal__head { padding: var(--s5) var(--s6) var(--s3); border-bottom: 1px solid var(--border); }
.modal__head h3 { margin-bottom: 2px; }
.modal__sub { font-size: var(--fs-xs); color: var(--muted); }
.modal__body { padding: var(--s5) var(--s6); overflow-y: auto; }
.modal__foot { padding: var(--s3) var(--s6) var(--s5); display: flex; gap: var(--s2); justify-content: flex-end; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------------- 日历 ---------------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); gap: 6px; }
.cal-dow { font-size: var(--fs-xs); color: var(--muted); text-align: center; padding: var(--s1) 0; }
.cal-cell {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m);
  min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left; font: inherit;
}
.cal-cell:hover { border-color: var(--border-strong); }
.cal-cell--today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.cal-cell--empty { background: transparent; border-style: dashed; cursor: default; }
.cal-cell__num { font-size: var(--fs-s); font-weight: 600; color: var(--text-soft); display: flex; justify-content: space-between; align-items: center; }
.cal-cell__num .density { font-size: 10px; color: var(--muted); font-weight: 400; }
.cal-task { font-size: 11px; background: var(--accent-soft); color: var(--accent-deep); border-radius: 5px; padding: 1px 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-task--done { background: #EDF6F1; color: var(--ok); text-decoration: line-through; }
.cal-task--due { background: #FCF4E8; color: var(--warn); }
.cal-dots { display: flex; gap: 3px; }
.heat-legend { display: flex; gap: var(--s3); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.heat-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; margin-right: 4px; vertical-align: -2px; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; overflow-x: auto; padding-bottom: var(--s2); }
.heat__cell { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); }
.heat__cell[data-l="1"] { background: #FBE3EA; border-color: #F6D6E0; }
.heat__cell[data-l="2"] { background: #F2B8C6; border-color: #EBA7B8; }
.heat__cell[data-l="3"] { background: #D9788F; border-color: #D16B84; }

.week-3col { display: grid; grid-template-columns: 260px minmax(0,1fr) 300px; gap: var(--s5); align-items: start; }
.week-day { border-bottom: 1px solid var(--border); padding: var(--s3) 0; }
.week-day:last-child { border-bottom: 0; }
.week-day__head { font-size: var(--fs-s); font-weight: 600; color: var(--text-soft); margin-bottom: var(--s2); }

/* ---------------- 其他 ---------------- */
.page-head { display: flex; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { flex: 1; min-width: 200px; }
.page-head p { margin: 0; color: var(--muted); font-size: var(--fs-s); width: 100%; }
.section-title { display: flex; align-items: center; gap: var(--s3); margin: var(--s6) 0 var(--s3); }
.section-title h2 { flex: 1; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: var(--s3); }
.tool-card {
  display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l);
  color: var(--text); text-decoration: none; min-height: 56px;
}
.tool-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-1); text-decoration: none; }
.tool-card__icon { width: 32px; height: 32px; border-radius: var(--r-s); background: var(--surface-2); display: grid; place-items: center; font-size: 16px; flex: 0 0 32px; }
.tool-card__name { font-weight: 500; font-size: var(--fs-s); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card__url { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.area-card { border-top: 3px solid var(--accent); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: var(--s2) var(--s4); font-size: var(--fs-s); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chat-stream { display: grid; gap: var(--s3); max-height: 420px; overflow-y: auto; padding: var(--s2); }
.bubble { border-radius: var(--r-l); padding: var(--s3) var(--s4); max-width: 92%; white-space: pre-wrap; word-break: break-word; font-size: var(--fs-s); }
.bubble--user { background: var(--accent-soft); border: 1px solid #F2DCE4; justify-self: end; }
.bubble--assistant { background: var(--surface-2); border: 1px solid var(--border); }
.bubble--failed { background: #FBEFEE; border-color: #EDCFCD; color: var(--danger); }
.bubble__meta { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; gap: var(--s2); flex-wrap: wrap; }
.diff-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
.diff-table th, .diff-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.diff-table th { color: var(--muted); font-weight: 500; }
.diff-old { color: var(--danger); text-decoration: line-through; }
.diff-new { color: var(--ok); }
.stars-list { display: grid; gap: 2px; }
.star-row { display: grid; grid-template-columns: 92px 64px 1fr auto; gap: var(--s3); align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); }
.star-row:last-child { border-bottom: 0; }
.star-plus { color: var(--ok); font-weight: 600; }
.star-minus { color: var(--danger); font-weight: 600; }
.mono { font-family: var(--font-mono); font-size: 11px; color: var(--muted); word-break: break-all; }
.notice {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--r-m); padding: var(--s3) var(--s4); font-size: var(--fs-s); color: var(--text-soft);
}
.notice--warn { border-left-color: var(--warn); background: #FFFBF4; }
.notice--danger { border-left-color: var(--danger); background: #FDF4F3; }
.scroll-x { overflow-x: auto; }
.canvas-bars { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.canvas-bars > i { flex: 1; background: linear-gradient(180deg, #F2B8C6, #E5A0B4); border-radius: 3px 3px 0 0; min-height: 2px; }
.filter-bar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* 搜索：类型筛选片与命中高亮 */
button.chip { cursor: pointer; font: inherit; font-size: var(--fs-xs); }
button.chip:hover { border-color: var(--border-strong); }
button.chip[aria-pressed="true"] { font-weight: 600; }
mark.mark { background: #FCE9EF; color: var(--accent-deep); border-radius: 3px; padding: 0 2px; }

.only-mobile { display: none; }
@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .week-3col { grid-template-columns: minmax(0, 1fr); }
  .grid--sidebar-right { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .only-mobile { display: initial; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform .18s ease; box-shadow: var(--shadow-3); height: 100vh;
  }
  .sidebar.is-open { transform: translateX(0); }
  .main { padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--s6)); }
  /* 同样要写 minmax(0, 1fr)：1fr 的下限是 min-content，窄屏单列会被内容撑破 */
  .grid--2, .grid--3, .grid--main { grid-template-columns: minmax(0, 1fr); }
  .topbar__right .btn--sm { display: none; }
  .topbar { padding: var(--s2) var(--s3); }
  .tool-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cal-cell { min-height: 74px; }
  .cal-task { display: none; }
  h1 { font-size: var(--fs-xl); }
  .modal__body, .modal__head, .modal__foot { padding-left: var(--s4); padding-right: var(--s4); }
  .kv { grid-template-columns: 80px 1fr; }
  .star-row { grid-template-columns: 74px 56px 1fr; }
  .star-row > *:last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .form-row { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   全局壳：可折叠导航 + 全局日期
   ============================================================ */
.sidebar__brand { position: relative; }
.sidebar__collapse { position: absolute; right: var(--s2); top: var(--s3); width: 28px; min-height: 28px; font-size: 12px; color: var(--muted); }
.sidebar__collapse:hover { color: var(--text); }

/* 折叠态：只剩图标，宽度收窄。桌面端才生效 —— 手机端是抽屉，折叠没有意义 */
@media (min-width: 901px) {
  .app.is-navcollapsed .sidebar { width: 64px; flex-basis: 64px; }
  .app.is-navcollapsed .brand-text,
  .app.is-navcollapsed .navi__label,
  .app.is-navcollapsed .navi__group-title,
  .app.is-navcollapsed .stars-chip,
  .app.is-navcollapsed #openSearch { display: none; }
  .app.is-navcollapsed .sidebar__brand { padding: var(--s5) 0 var(--s4); justify-content: center; }
  .app.is-navcollapsed .sidebar__collapse { position: static; }
  .app.is-navcollapsed .navi { padding: var(--s2) var(--s1) var(--s5); }
  .app.is-navcollapsed .navi__item { justify-content: center; padding: 9px 0; }
  .app.is-navcollapsed .navi__group-title { display: block; height: 10px; padding: 0; overflow: hidden; }
  .app.is-navcollapsed .sidebar__foot { padding: var(--s2) var(--s1); }
}

.datebar { display: flex; align-items: center; gap: 4px; }
.datebar__label {
  display: inline-flex; align-items: baseline; gap: 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-m);
  padding: 5px var(--s3); font: inherit; font-size: var(--fs-s); color: var(--text); min-height: 34px;
  font-variant-numeric: tabular-nums;
}
.datebar__label:hover { border-color: var(--border-strong); }
.datebar__text { font-weight: 600; }
.datebar__unit { font-size: 10px; color: var(--muted); }
.datebar__today { min-height: 30px; }
.datebar__picker { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* 窄屏顶栏：日期条整体换到第二行。
   单行放下「菜单 + 日期‹› + 标题 + 回到今天 + 搜索/撤销/重做/设置」在 390px 下必然溢出，
   所以让顶栏可换行，把日期条独占一行。 */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar__title {
    flex: 1 1 auto; min-width: 0; font-size: var(--fs-m);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .topbar__right { margin-left: auto; }
  .save-state { max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .datebar { order: 10; flex: 1 1 100%; min-width: 0; }
  .datebar__label { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  .datebar__today { flex: 0 0 auto; }
}

/* ============================================================
   今日工作台：顶部状态 → 左 Todo / 右 AI → 底部当日记录
   ============================================================ */

/* 顶部状态不做成卡片，也不放一排同样重的线框胶囊 ——
   一排等价的小胶囊等于没有重点。这里只放大一件事：离星愿还差多少星。
   其余信息用「大数字 + 小标签」的淡排版跟在后面。 */
.wb-status { display: grid; gap: var(--s4); padding-bottom: var(--s5); border-bottom: 1px solid var(--border); }
.wb-status__top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }
.wb-status__id { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.wb-status__date { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.wb-status__meta { font-size: var(--fs-s); color: var(--muted); }
.wb-status__total { display: flex; align-items: baseline; gap: 5px; font-size: var(--fs-s); color: var(--muted); }
.wb-status__total b { font-size: var(--fs-xl); font-weight: 600; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.wb-star { font-size: .9em; }

/* 星愿进度：这一块是全页唯一被放大的东西 */
.wish { display: grid; gap: 6px; }
.wish__line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; font-size: var(--fs-m); }
.wish__text { color: var(--muted); }
.wish__name { font-weight: 600; }
.wish__num { font-size: var(--fs-2xl); font-weight: 700; color: var(--accent-deep); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.wish__bar { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.wish__bar > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #F2B8C6, #D9788F); }
.wish__foot { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-xs); color: var(--muted); }
.wish__cheer { color: var(--accent-deep); font-weight: 600; }
.wish__empty { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; font-size: var(--fs-s); color: var(--muted); }

/* 当日计数：无边框、无底色，只让数字比标签大一点 */
.wb-status__stats { display: flex; gap: var(--s5); flex-wrap: wrap; }
.wb-stat { display: inline-flex; align-items: baseline; gap: 4px; font-size: var(--fs-xs); color: var(--muted); }
.wb-stat b { font-size: var(--fs-l); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.wb-stat__unit { font-size: 11px; }
.wb-stat--quiet { opacity: .62; }
.wb-stat--quiet b { color: var(--text-soft); }

.wb-status__links { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.linkbtn {
  border: 0; background: none; font: inherit; font-size: var(--fs-xs); color: var(--muted);
  cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}
.linkbtn:hover { color: var(--accent-deep); text-decoration-color: var(--accent); }
.wb-status__note { font-size: var(--fs-xs); color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }

.wb-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--s5); align-items: start; }
/* 窄屏单列时必须写 minmax(0, 1fr)，不能写 1fr。
   1fr 等价于 minmax(auto, 1fr)，而 auto 的下限是内容的 min-content ——
   于是「手机上一列」实际上被左侧 todo 卡片的最小宽度撑着，整页横向溢出。 */
@media (max-width: 1080px) { .wb-main { grid-template-columns: minmax(0, 1fr); } }
.wb-left, .wb-right { display: grid; gap: var(--s4); }

/* 网格 / 弹性子项默认 min-width:auto，一个不可断行的长串就能把整列撑破视口。
   这里统一允许收缩，真正的长串由各元素自己的 overflow-wrap / 换行处理。 */
.stack > *, .wb-left > *, .wb-right > *, .grid > * { min-width: 0; }

/* 今日 todo：一个列表。逾期 / 遗留只是行内小标，不是分组 */
.todo-scope { font-size: var(--fs-xs); color: var(--muted); }
.todo-divider {
  display: flex; align-items: baseline; gap: var(--s2); justify-content: space-between; flex-wrap: wrap;
  padding: var(--s4) var(--s1) var(--s2); font-size: var(--fs-xs); color: var(--muted);
}
.todo-divider__hint { font-size: 11px; opacity: .8; }
.todo-all-done { padding: var(--s4); font-size: var(--fs-s); color: var(--muted); text-align: center; }

/* 已完成的行：降对比 + 划线，但仍在同一个列表里，不另外开区域 */
.list-item.is-done-row { opacity: .5; }
.list-item.is-done-row:hover { opacity: .85; }
.list-item.is-cancelled-row { opacity: .4; }
.list-item.is-cancelled-row .list-item__title { text-decoration: line-through; }

/* 行内元信息：不用线框胶囊，只有需要警示的才给颜色 */
.meta-tag { font-size: 11px; color: var(--text-soft); }
.meta-tag--danger { color: var(--danger); font-weight: 600; }
.meta-tag--warn { color: var(--warn); font-weight: 600; }
.meta-tag--quiet { color: var(--muted); }
.meta-star { color: var(--accent-deep); font-weight: 600; }
.meta-quiet { color: var(--muted); }
.meta-danger { color: var(--danger); }
.meta-ok { color: var(--ok); }

/* ============================================================
   录入面板：不先选类型，识别结果可改
   ============================================================ */
.intake-status { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.intake-detect { display: grid; gap: var(--s2); }
.intake-detect__row { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.intake-detect__label { font-size: var(--fs-xs); color: var(--muted); }
.intake-detect__value {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: var(--fs-s);
  color: var(--accent-deep); background: var(--accent-soft); border-radius: var(--r-s); padding: 2px 9px;
}
.intake-detect__why { font-size: 11px; color: var(--muted); }
.intake-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.intake-kind {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit; font-size: var(--fs-xs);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill);
  padding: 4px 11px; min-height: 30px; color: var(--text-soft);
}
.intake-kind:hover { border-color: var(--border-strong); color: var(--text); }
.intake-kind[aria-pressed="true"] { background: var(--accent-soft); border-color: #F1D6E0; color: var(--accent-deep); font-weight: 600; }
.intake-hint { font-size: var(--fs-xs); color: var(--muted); }
.intake-steps { display: grid; gap: var(--s3); }
.intake-step { border: 1px solid var(--border); border-radius: var(--r-m); overflow: hidden; }
.intake-step__head {
  display: flex; align-items: center; gap: var(--s2); padding: 7px var(--s3);
  background: var(--surface-2); font-size: var(--fs-xs); font-weight: 600; color: var(--text-soft);
}
.intake-step__no {
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-deep);
  display: grid; place-items: center; font-size: 10px; flex: 0 0 18px;
}
.intake-step__body { padding: var(--s3); font-size: var(--fs-s); display: grid; gap: 6px; }
.intake-note { display: flex; gap: var(--s2); font-size: var(--fs-s); }
.intake-note__label { color: var(--muted); flex: 0 0 92px; }
.intake-why { font-size: 11px; color: var(--muted); }
.intake-action {
  display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s2) var(--s3);
  border: 1px solid var(--border); border-radius: var(--r-m); background: var(--surface);
}
.intake-action input { width: auto; min-height: 0; margin-top: 3px; }
.intake-action--blocked { background: #FFFBF4; border-color: #EFDCC0; }
.intake-source { font-size: 11px; }
.intake-source--local { color: var(--warn); }
.intake-source--ai { color: var(--info); }

/* ============================================================
   今日提问：提示清单（不是问卷，所以没有输入框）
   ============================================================ */
.q-panel { border: 1px solid var(--border); border-radius: var(--r-l); overflow: hidden; background: var(--surface); }
.q-panel__head {
  display: flex; align-items: center; gap: var(--s2); width: 100%; padding: var(--s3) var(--s4);
  background: none; border: 0; font: inherit; cursor: pointer; text-align: left; min-height: 44px;
}
.q-panel__head:hover { background: var(--surface-2); }
.q-panel__title { font-weight: 600; font-size: var(--fs-s); }
.q-panel__badge {
  font-size: 11px; color: var(--accent-deep); background: var(--accent-soft);
  border-radius: var(--r-pill); padding: 1px 8px;
}
.q-panel__hint { flex: 1; font-size: 11px; color: var(--muted); }
.q-panel__chev { font-size: 11px; color: var(--muted); }
.q-panel__body { padding: 0 var(--s4) var(--s4); display: grid; gap: 4px; }
.q-panel__foot { padding: var(--s2) var(--s4) var(--s4); font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); margin-top: var(--s2); }
.q-list__group {
  font-size: 10px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase;
  padding: var(--s3) 0 2px;
}
.q-list__group:first-child { padding-top: 0; }
.q-line { display: flex; gap: 6px; font-size: var(--fs-s); color: var(--text-soft); line-height: 1.7; }
.q-line__dot { color: var(--border-strong); }
.q-hl { background: #FCE9EF; color: var(--accent-deep); border-radius: 3px; padding: 0 3px; font-weight: 500; }

/* 日记栏目（label + textarea） */
.q-item { display: grid; gap: 4px; }
.q-item > span { font-size: var(--fs-xs); color: var(--text-soft); }
.q-item textarea { min-height: 52px; font-size: var(--fs-s); }

/* ============================================================
   热力图墙：每行一个实体 × 全年格子（主线维度 / 项目维度）
   ============================================================ */
.heatwall { display: grid; gap: 2px; }
.heatwall__row {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: var(--s3);
  align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border);
}
.heatwall__row:last-child { border-bottom: 0; }
.heatwall__name { display: flex; align-items: center; gap: 6px; font-size: var(--fs-s); min-width: 0; }
.heatwall__name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heatwall__plot { min-width: 0; overflow-x: auto; overflow-y: hidden; padding-bottom: 2px; }
.heatwall__plotinner { width: max-content; min-width: 100%; display: grid; gap: 2px; }
.heatwall__cells { display: grid; grid-auto-rows: 13px; gap: 2px; width: 100%; }
.heatwall__cells.is-cols { grid-auto-flow: column; grid-template-rows: repeat(7, 13px); }
.heatwall__cell {
  border: 0; padding: 0; border-radius: 3px; background: var(--surface-2); cursor: pointer;
  border: 1px solid rgba(0,0,0,.03); width: 100%; min-height: 0; height: 13px;
}
.heatwall__cell:hover { outline: 1px solid var(--accent); }
.heatwall__cell[data-l="1"] { background: #FBE3EA; border-color: #F6D6E0; }
.heatwall__cell[data-l="2"] { background: #F2B8C6; border-color: #EBA7B8; }
.heatwall__cell[data-l="3"] { background: #D9788F; border-color: #D16B84; }
.heatwall__cell[data-outside] { opacity: .25; cursor: default; }
.heatwall__meta { font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.heatwall__months { display: grid; gap: 2px; font-size: 9px; color: var(--muted); width: 100%; }
.heatwall__months > span { text-align: center; }

/* 窄屏：名字列收窄、指标换行，格子区自己滚，不把页面撑宽 */
@media (max-width: 720px) {
  .heatwall__row { grid-template-columns: 84px minmax(0, 1fr); grid-template-areas: "name plot" "meta plot"; row-gap: 2px; }
  .heatwall__name { grid-area: name; }
  .heatwall__plot { grid-area: plot; }
  .heatwall__meta { grid-area: meta; text-align: left; white-space: normal; }
}

/* 时间进度：时间已过 x% 与完成 y% 并排，绝不合成一个数 */
.progress-pair { display: flex; gap: var(--s3); flex-wrap: wrap; }
.progress-pair__item { display: grid; gap: 2px; min-width: 96px; }
.progress-pair__label { font-size: 11px; color: var(--muted); }
.progress-pair__value { font-size: var(--fs-l); font-weight: 600; }
.progress-pair__bar { height: 5px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.progress-pair__bar > i { display: block; height: 100%; background: var(--accent); }
.progress-pair__bar--time > i { background: #B9C7DE; }

/* ============================================================
   月视图：每周一格「目标」与一格「复盘」
   ============================================================ */
.cal-weekrow { display: grid; grid-template-columns: 96px repeat(7, minmax(0,1fr)) 96px; gap: 6px; align-items: stretch; }
.cal-weekrow + .cal-weekrow { margin-top: 6px; }
.cal-sidecol {
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-m);
  padding: 6px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; text-align: left;
  font: inherit; font-size: 11px; color: var(--text-soft); min-height: 96px;
}
.cal-sidecol:hover { border-color: var(--accent); }
.cal-sidecol__title { font-weight: 600; font-size: 10px; color: var(--muted); }
.cal-sidecol__body { flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; white-space: pre-wrap; }
.cal-sidecol__body.is-empty { color: var(--muted); font-style: italic; }
.cal-sidecol__foot { font-size: 10px; color: var(--muted); }
.cal-sidecol--review { background: #FBF7F2; }
.cal-monthsides { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: var(--s5); align-items: start; }
@media (max-width: 1080px) {
  .cal-weekrow { grid-template-columns: minmax(0, 1fr); }
  .cal-sidecol { min-height: 0; }
  .cal-monthsides { grid-template-columns: minmax(0, 1fr); }
}

/* ============================================================
   想法库：关键词 tab 与相似关联
   ============================================================ */
.kw-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kw-pill {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit; font-size: var(--fs-xs);
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-pill);
  padding: 3px 10px; min-height: 28px; color: var(--text-soft);
}
.kw-pill[aria-pressed="true"] { background: var(--accent-soft); border-color: #F1D6E0; color: var(--accent-deep); font-weight: 600; }
.kw-pill--suggested { border-style: dashed; color: var(--warn); }
.kw-count { font-size: 10px; color: var(--muted); }
.kw-related { display: grid; gap: 4px; }
.kw-related__item {
  display: flex; gap: var(--s2); align-items: baseline; padding: 5px var(--s2); border-radius: var(--r-s);
  background: var(--surface-2); font-size: var(--fs-xs); border: 0; font-family: inherit; text-align: left; cursor: pointer; width: 100%;
}
.kw-related__item:hover { background: var(--accent-soft); }
.kw-why { color: var(--muted); font-size: 11px; }

/* ============================================================
   标签管理
   ============================================================ */
.tag-row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); }
.tag-row:last-child { border-bottom: 0; }
.tag-swatch { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.tag-name { font-weight: 500; }
.tag-row__main { flex: 1; min-width: 0; }

/* 拖动排序手柄：默认很淡，悬停才明显；手机端也能看到位置提示 */
.drag-handle { color: var(--border-strong); font-size: 13px; cursor: grab; align-self: center; user-select: none; }
.list-item:hover .drag-handle { color: var(--muted); }
