:root {
  color-scheme: light;
  /* 对齐 Android 小蹄子品牌色 */
  --primary: #7b52d3;
  --primary-dark: #5e3db3;
  --primary-light: #c084fc;
  --primary-container: #f0ebff;
  --primary-soft: rgb(123 82 211 / 10%);
  --primary-glow: rgb(123 82 211 / 18%);

  --bg: #fbfbfd;
  --surface: #ffffff;
  --surface-2: #f8f7ff;
  --surface-3: #f3f1fa;
  --chat-bg: #f5f4fa;

  --ink: #1c1c1e;
  --muted: #6c6c70;
  --muted-2: #aeaeb2;
  --line: rgb(0 0 0 / 7%);
  --line-strong: #e5e5ea;

  --ok: #34c759;
  --warn: #ff9500;
  --danger: #ff3b30;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 4%), 0 4px 12px rgb(123 82 211 / 5%);
  --shadow-md: 0 8px 32px rgb(123 82 211 / 10%), 0 2px 8px rgb(0 0 0 / 4%);
  --shadow-lg: 0 24px 64px rgb(60 40 100 / 14%);

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --rail-width: 76px;
  --sidebar-width: 272px;
  --content-max: 820px;

  /* DeepSeek Harness 对话区 */
  --harness-label: #666666;
  --harness-muted: #888888;
  --harness-icon: #8e8e8e;
  --harness-ink: #212121;
  --harness-error: #d32f2f;
  --harness-pill-bg: #f5f5f5;
  --harness-pill-border: #e0e0e0;
  --harness-user-bg: #f0f4f8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.hidden { display: none !important; }

button {
  font: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  background: none;
  color: inherit;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease, box-shadow .16s ease;
}
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .42; cursor: not-allowed; }

.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-weight: 600;
  border: none;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgb(123 82 211 / 28%);
  filter: brightness(1.03);
}
.primary.small { padding: 7px 14px; font-size: 13px; }

.ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: rgb(123 82 211 / 22%);
  color: var(--primary-dark);
}
.ghost.small { padding: 6px 12px; font-size: 13px; }

.danger {
  background: var(--surface);
  border-color: rgb(255 59 48 / 28%);
  color: var(--danger);
}
.danger:hover:not(:disabled) { background: rgb(255 59 48 / 6%); }

.block { width: 100%; display: block; }
.spacer { flex: 1; }

.input, .select, textarea.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 13px;
  font: inherit;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ---------- Setup ---------- */

.setup {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgb(192 132 252 / 22%), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgb(123 82 211 / 10%), transparent 50%),
    var(--bg);
}

.setup-card {
  width: min(440px, 100%);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(16px);
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px 32px;
  text-align: center;
}

.setup-logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 8px 24px var(--primary-glow);
}

.setup-card h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.4px;
}

.setup-desc {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.field { display: block; text-align: left; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.setup-card .primary { margin-top: 8px; }
.setup-card .ghost { margin-top: 8px; color: var(--muted); border-color: transparent; }
.setup-card .ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }

.hint { color: var(--muted-2); font-size: 12px; margin: 16px 0 0; line-height: 1.55; }
.error { color: var(--danger); font-size: 13px; margin: 12px 0 0; }

/* ---------- App shell ---------- */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.icon-rail {
  width: var(--rail-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 2;
}

.rail-logo {
  width: 42px;
  height: 42px;
  margin: 16px 0 10px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 0 10px;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 64px;
  padding: 6px 4px;
  border-radius: 12px;
  color: var(--muted);
  position: relative;
}
.rail-item:hover { background: var(--surface-2); color: var(--ink); }
.rail-item.active {
  color: var(--primary);
  background: var(--primary-container);
  box-shadow: inset 0 0 0 1px rgb(123 82 211 / 12%);
}

.rail-icon { width: 22px; height: 22px; }
.rail-label { font-size: 11px; font-weight: 600; line-height: 1.1; }

.rail-footer {
  margin-top: auto;
  padding: 10px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.rail-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
}
.rail-icon-btn svg { width: 18px; height: 18px; }
.rail-icon-btn:hover {
  background: var(--surface-2);
  color: var(--primary);
}

/* Context sidebar */
.context-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  z-index: 1;
}
.context-sidebar.hidden { display: none; }

.sidebar-head {
  padding: 18px 18px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.sidebar-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.sidebar-divider { height: 1px; background: var(--line); }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.sidebar-pane { display: block; }
.sidebar-pane.hidden { display: none; }

.sidebar-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px dashed rgb(123 82 211 / 28%);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}
.sidebar-new-chat:hover {
  background: var(--primary-container);
  border-style: solid;
  border-color: rgb(123 82 211 / 35%);
}

.sidebar-section-label {
  margin: 0 4px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.sidebar-hint {
  margin: 8px 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.sidebar-list { display: flex; flex-direction: column; gap: 4px; }

.sidebar-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 10px 10px 12px;
  border-radius: 12px;
  text-align: left;
  min-height: 54px;
  border: 1px solid transparent;
  cursor: pointer;
}
.sidebar-row:hover,
.sidebar-row.menu-open { background: #ececee; }
.sidebar-row.active {
  background: #ececee;
  border-color: transparent;
  box-shadow: none;
}

.session-more-btn {
  width: 28px;
  height: 28px;
  margin-top: 2px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  opacity: 0;
  pointer-events: none;
}
.session-more-btn svg { width: 16px; height: 16px; display: block; }
.sidebar-row:hover .session-more-btn,
.sidebar-row.menu-open .session-more-btn,
.sidebar-row.active .session-more-btn {
  opacity: 1;
  pointer-events: auto;
}
@media (hover: none) {
  .session-more-btn {
    opacity: 1;
    pointer-events: auto;
  }
}
.session-more-btn:hover,
.session-more-btn[aria-expanded="true"] { background: rgb(0 0 0 / 7%); color: var(--ink); }

.session-menu {
  position: fixed;
  z-index: 40;
  min-width: 168px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgb(15 15 20 / 12%), 0 1px 3px rgb(0 0 0 / 6%);
}
.session-menu.hidden { display: none; }
.session-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}
.session-menu button:hover { background: #f3f3f5; }
.session-menu button:active { transform: none; }
.session-menu svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex-shrink: 0;
}

.sidebar-row-icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--muted-2);
  flex-shrink: 0;
}
.sidebar-row.active .sidebar-row-icon { color: var(--primary); }

.sidebar-row-main { flex: 1; min-width: 0; }
.sidebar-row.streaming .sidebar-row-title::after {
  content: ' · 进行中';
  color: var(--primary);
  font-weight: 600;
  font-size: 11px;
}
.sidebar-row-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-row-sub {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-rename-input {
  display: block;
  width: 100%;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.sidebar-row.renaming { cursor: default; }

.sidebar-foot {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: rgb(255 255 255 / 50%);
}
.sync-status {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
  display: block;
}
.sync-status.error { color: var(--danger); }
.sync-status.pending { color: var(--warn); }

/* Main panel */
.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.tab-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tab-pane.hidden { display: none; }

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: rgb(255 255 255 / 72%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.content-header h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.35px;
}
.content-header p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.content-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 28px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .search {
  flex: 1;
  min-width: 180px;
  border-radius: 999px;
  padding-left: 16px;
  background: var(--surface);
}

.sub-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 14px;
  margin-bottom: 6px;
  scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }

.sub-tab {
  flex: none;
  border-radius: 999px;
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.sub-tab:hover {
  border-color: rgb(123 82 211 / 25%);
  color: var(--primary);
}
.sub-tab.active {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.card-list { display: flex; flex-direction: column; gap: 10px; }
.empty {
  color: var(--muted);
  text-align: center;
  padding: 56px 20px;
  font-size: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.card:hover {
  border-color: rgb(123 82 211 / 18%);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-main { flex: 1; min-width: 0; }
.card-main h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-main h3.done { color: var(--muted); text-decoration: line-through; }

.snippet {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.badge {
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
}
.badge-inbox { background: rgb(52 199 89 / 12%); color: var(--ok); }
.badge-archived { background: var(--surface-3); color: var(--muted); }
.badge-priority { background: var(--primary-container); color: var(--primary-dark); }
.badge-done { background: rgb(52 199 89 / 12%); color: var(--ok); }
.badge-due-soon { background: rgb(255 59 48 / 10%); color: var(--danger); }

.tag {
  background: var(--surface-3);
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
}

.card-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn {
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 5px 7px;
}
.icon-btn:hover { color: var(--primary); background: var(--primary-soft); }
.icon-btn.on { color: var(--warn); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgb(28 28 30 / 38%);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-head .icon-btn { font-size: 24px; }

.modal-body {
  padding: 8px 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-body label { display: block; }
.modal-body label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

textarea.area {
  min-height: 220px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.55;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { accent-color: var(--primary); }

.editor-md-field { display: flex; flex-direction: column; gap: 8px; }
.editor-md-field .field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.editor-source.hidden { display: none; }
.editor-source textarea.area { margin-top: 0; }

.preview-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px 18px;
  min-height: 160px;
  max-height: min(52vh, 480px);
  overflow: auto;
  font-size: 14.5px;
  line-height: 1.6;
}
.preview-box.hidden { display: none; }
.preview-box.chat-md h1 { font-size: 1.35em; margin: 0 0 10px; }
.preview-box.chat-md h2 { font-size: 1.15em; margin: 14px 0 8px; }
.preview-box.chat-md h3 { font-size: 1.05em; margin: 12px 0 6px; }
.preview-box.chat-md hr {
  border: none;
  border-top: 1px solid var(--line-strong);
  margin: 14px 0;
}
.preview-box.chat-md blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--primary);
  background: var(--primary-soft);
  color: var(--ink);
}
.preview-box.chat-md pre {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  font-size: 13px;
}
.preview-box h1, .preview-box h2, .preview-box h3 { margin: 8px 0 4px; }
.preview-box p { margin: 6px 0; }
.preview-box ul, .preview-box ol { margin: 6px 0; padding-left: 22px; }
.preview-box code {
  background: rgb(123 82 211 / 8%);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
}
.preview-box a { color: var(--primary); }
.preview-box-empty {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.modal-foot {
  display: flex;
  gap: 8px;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--line);
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 30;
  max-width: min(560px, calc(100vw - 40px));
}
.toast.error { background: var(--danger); }

/* ---------- Chat ---------- */

.chat-pane {
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgb(123 82 211 / 6%), transparent 55%),
    var(--chat-bg);
  min-height: 0;
}

.board-pane {
  min-height: 0;
  background: var(--bg);
}

.board-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.board-heartbeat {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.board-heartbeat-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.board-heartbeat-main strong {
  font-size: 13px;
  font-weight: 700;
}

.board-heartbeat-main span {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-heartbeat .ghost.small {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
}

.board-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 0;
  background: #fff;
}

.board-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 32px 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.board-composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 20px 16px;
  background: linear-gradient(180deg, transparent, var(--bg) 18%);
}

.board-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 11px 16px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  box-shadow: var(--shadow-sm);
}

.board-input:focus {
  outline: none;
  border-color: rgb(123 82 211 / 35%);
}

.board-version-row {
  display: flex;
  align-items: center;
  gap: 2px;
}

.board-version-row .sidebar-row { flex: 1; }
.board-version-del {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: var(--muted-2);
}
.board-version-del:hover { color: var(--danger); }

.board-shell > .chat-status {
  padding: 0 20px 12px;
  margin: 0;
}

.chat-shell {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.chat-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  width: 100%;
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto;
  padding: 18px 24px 14px;
}

.chat-topbar-rule {
  flex-shrink: 0;
  width: 100%;
  height: 1px;
  background: var(--line-strong);
  box-shadow: 0 1px 0 rgb(255 255 255 / 60%);
}

.chat-topbar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}

.chat-topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-topbar-actions { flex-shrink: 0; }

.chat-topbar-more {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-topbar-more:hover {
  background: rgb(0 0 0 / 5%);
  color: var(--ink);
}

.chat-shell.topbar-collapsed .chat-topbar {
  display: none;
}

.chat-topbar-collapsed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  width: 100%;
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto;
  padding: 8px 24px;
}

.chat-topbar-collapsed.hidden {
  display: none;
}

.chat-shell.topbar-collapsed .chat-topbar-collapsed {
  display: flex;
}

.chat-topbar-collapsed-title {
  min-width: 0;
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overflow-anchor: none;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto;
  padding: 16px 24px 20px;
}

.chat-empty {
  color: var(--muted);
  text-align: center;
  padding: 64px 24px;
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
}

.chat-turn.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 88%;
  margin-left: auto;
}

.chat-turn.user .chat-bubble {
  background: var(--harness-user-bg);
  color: var(--harness-ink);
  border: 1px solid rgb(0 0 0 / 5%);
  border-radius: 18px 18px 4px 18px;
  padding: 11px 15px;
  font-size: 15px;
  line-height: 1.6;
  box-shadow: none;
}

.chat-turn.user .chat-time {
  font-size: 11px;
  color: var(--muted-2);
  padding-right: 4px;
}

.chat-turn.assistant {
  max-width: 100%;
}

.chat-turn.assistant.has-harness {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.chat-turn.assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.chat-turn.assistant.has-harness .chat-answer {
  margin-top: 0;
  padding: 10px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--harness-ink);
}

/* Think/Tool 时间线与正文之间留足间距 */
.chat-turn.assistant.has-harness .dsh-flow + .chat-answer {
  margin-top: 28px;
  padding-top: 4px;
}

.chat-turn.assistant.streaming.has-harness .chat-answer::after {
  content: '▍';
  animation: chat-blink 1s step-end infinite;
  color: var(--harness-icon);
  margin-left: 2px;
}

.chat-turn.assistant.streaming:not(.has-harness) .chat-bubble::after {
  content: '▍';
  animation: chat-blink 1s step-end infinite;
  color: var(--primary);
  margin-left: 2px;
}

/* 助手正文统一走 .chat-answer + .chat-md，与全局 markdown 样式一致 */
.chat-turn.assistant.has-harness .chat-answer.chat-md code {
  background: var(--primary-container);
  color: var(--primary-dark);
}

.chat-turn.assistant.has-harness .chat-answer.chat-md pre {
  background: var(--surface-3);
}

.chat-turn.assistant.has-harness .chat-answer.chat-md th {
  background: var(--surface-2);
}

.chat-turn.assistant.has-harness .chat-answer.chat-md tbody tr:nth-child(even) {
  background: rgb(123 82 211 / 3%);
}

.chat-thinking-placeholder {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* DeepSeek Harness disclosure 行（移植自 deepseek-harness） */
:root {
  --dsw-alias-bg-base: var(--surface, #fff);
  --dsw-alias-label-primary: #212121;
  --dsw-alias-label-secondary: #666666;
  --dsw-alias-label-tertiary: #888888;
  --dsw-alias-label-caption: #bdbdbd;
  --dsw-alias-label-quaternary: #cccccc;
  --dsw-alias-border-l1: #e8e8e8;
  --dsw-alias-border-l2: #eeeeee;
  --dsw-alias-state-error-primary: #d32f2f;
  --dsw-alias-markdown-code-block: #f7f7f8;
  --dsw-font-markdown-code-block-small: 12px/18px ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dsh-flow {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.dsh-disclosure {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
}

.dsh-disclosure-row {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  height: 26px;
  min-width: 0;
}

.dsh-disclosure-row[data-harness-toggle] {
  cursor: pointer;
}

.dsh-leading {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
  color: var(--dsw-alias-label-tertiary);
}

.dsh-svg {
  display: block;
  width: 14px;
  height: 14px;
}

.dsh-chevron {
  color: var(--dsw-alias-label-secondary);
}

.dsh-icon-idle {
  display: inline-flex;
  opacity: 1;
  transition: opacity 100ms ease;
}

.dsh-chevron-hover {
  position: absolute;
  inset: 0;
  margin: auto;
  opacity: 0;
  transition: opacity 100ms ease;
}

.dsh-disclosure-row:hover .dsh-icon-idle {
  opacity: 0;
}

.dsh-disclosure-row:hover .dsh-chevron-hover {
  opacity: 1;
}

.dsh-disclosure[data-open="true"] .dsh-icon-idle,
.dsh-disclosure[data-open="true"] .dsh-chevron-hover {
  opacity: 0;
}

.dsh-title {
  flex: none;
  font-size: 15px;
  line-height: 26px;
  font-weight: 400;
  color: var(--dsw-alias-label-secondary);
}

.dsh-sep {
  flex: none;
  width: 2px;
  height: 2px;
  margin: 0 8px;
  border-radius: 1px;
  background: var(--dsw-alias-label-caption);
}

.dsh-summary {
  min-width: 0;
  overflow: hidden;
  flex: 1 1 auto;
  color: var(--dsw-alias-label-tertiary);
  font-size: 15px;
  line-height: 26px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dsh-summary-follow {
  text-overflow: clip;
}

.dsh-summary-error {
  color: var(--dsw-alias-state-error-primary);
}

.dsh-hash {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dsh-state-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: block;
}

.dsh-state-dot-error {
  background: var(--dsw-alias-state-error-primary);
}

.dsh-file-link {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  font-size: 15px;
  line-height: 26px;
  color: var(--dsw-alias-label-secondary);
  text-decoration: underline;
  text-decoration-color: var(--dsw-alias-label-quaternary);
  text-underline-offset: 3px;
  cursor: pointer;
}

.dsh-file-link:hover {
  color: var(--dsw-alias-label-primary);
  text-decoration-color: currentColor;
}

.dsh-reasoning[data-state="running"] .dsh-disclosure-row::after,
.dsh-tool[data-state="running"] .dsh-disclosure-row::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 0;
  width: 300px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--dsw-alias-bg-base) 60%, transparent) 55%,
    transparent 100%
  );
  animation: dsh-row-sweep 2.6s ease-out infinite;
  pointer-events: none;
}

@keyframes dsh-row-sweep {
  0% { left: -300px; }
  90%, 100% { left: 100%; }
}

.dsh-reasoning-body {
  padding: 4px 0 4px 22px;
  color: var(--dsw-alias-label-tertiary);
  font-size: 15px;
  line-height: 26px;
  white-space: pre-wrap;
  word-break: break-word;
}

.dsh-tool-body-wrap {
  display: flex;
  flex-direction: column;
}

.dsh-io-card {
  display: flex;
  flex-direction: column;
  margin: 4px 0 4px 4px;
  border: 1px solid var(--dsw-alias-border-l1);
  border-radius: 12px;
  background: var(--dsw-alias-markdown-code-block);
  font: var(--dsw-font-markdown-code-block-small);
}

.dsh-io-section {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  align-items: baseline;
  padding: 12px 16px;
  max-height: 150px;
  overflow-y: auto;
}

.dsh-io-label {
  position: sticky;
  top: 0;
  align-self: start;
  color: var(--dsw-alias-label-caption);
}

.dsh-io-divider {
  flex: none;
  height: 1px;
  background: var(--dsw-alias-border-l2);
}

.dsh-io-text {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--dsw-alias-label-secondary);
}

.dsh-io-text-error {
  color: var(--dsw-alias-state-error-primary);
}

@media (prefers-reduced-motion: reduce) {
  .dsh-reasoning[data-state="running"] .dsh-disclosure-row::after,
  .dsh-tool[data-state="running"] .dsh-disclosure-row::after {
    animation: none;
  }
}

.chat-turn.assistant.has-harness .chat-answer.chat-md h1,
.chat-turn.assistant.has-harness .chat-answer.chat-md h2,
.chat-turn.assistant.has-harness .chat-answer.chat-md h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--harness-ink);
  margin: 16px 0 8px;
}

.chat-turn.assistant.has-harness .chat-answer.chat-md h1:first-child,
.chat-turn.assistant.has-harness .chat-answer.chat-md h2:first-child,
.chat-turn.assistant.has-harness .chat-answer.chat-md h3:first-child {
  margin-top: 0;
}

.chat-turn.assistant.has-harness .chat-answer.chat-md ul,
.chat-turn.assistant.has-harness .chat-answer.chat-md ol {
  margin: 0 0 10px;
  padding-left: 1.35em;
}

.chat-turn.assistant.has-harness .chat-answer.chat-md li {
  margin: 4px 0;
}

.chat-turn.assistant.has-harness .chat-answer.chat-md p {
  margin: 0 0 10px;
}


@keyframes chat-blink {
  50% { opacity: 0; }
}

.chat-md :first-child { margin-top: 0; }
.chat-md :last-child { margin-bottom: 0; }
.chat-md p { margin: 0 0 8px; }
.chat-md h1, .chat-md h2, .chat-md h3 { margin: 12px 0 6px; font-size: 1.05em; font-weight: 700; }
.chat-md h3.md-cn-section { font-size: 1.08em; margin-top: 16px; color: var(--ink); }
.chat-md hr {
  border: none;
  border-top: 1px solid var(--line-strong);
  margin: 14px 0;
}
.chat-md ul, .chat-md ol { margin: 0 0 8px; padding-left: 1.25em; }
.chat-md code {
  background: var(--primary-container);
  color: var(--primary-dark);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 14px;
}
.chat-md pre {
  background: var(--surface-3);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}
.chat-md pre code { background: none; padding: 0; color: inherit; }
.chat-md table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 14px;
}
.chat-md th, .chat-md td {
  border: 1px solid var(--line-strong);
  padding: 8px 10px;
  text-align: left;
}
.chat-md th {
  background: var(--surface-2);
  font-weight: 600;
}
.chat-md tbody tr:nth-child(even) { background: rgb(123 82 211 / 3%); }
.chat-md a { color: var(--primary); font-weight: 500; }
.chat-md strong { font-weight: 700; }
.chat-md blockquote {
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--primary-light);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.chat-composer {
  flex-shrink: 0;
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto;
  width: 100%;
  padding: 0 34px 18px;
}

.chat-quick-prompts {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 12px;
  margin: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.chat-quick-prompts::-webkit-scrollbar { display: none; }

.chat-quick-chip {
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .12s ease;
  box-shadow: var(--shadow-sm);
}

.chat-quick-chip:hover:not(:disabled) {
  border-color: rgb(123 82 211 / 32%);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.chat-quick-chip:active:not(:disabled) { transform: scale(.98); }

.chat-quick-chip:disabled {
  opacity: .42;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-composer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid rgb(123 82 211 / 12%);
  border-radius: 24px;
  padding: 8px 8px 8px 10px;
  box-shadow: 0 2px 16px rgb(123 82 211 / 8%), 0 1px 3px rgb(15 15 20 / 4%);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.chat-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(var(--content-max) + 48px);
  margin: 0 auto 8px;
  padding: 0 24px;
}

.chat-attachment-chip {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.chat-attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.chat-attachment-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.chat-plus-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .12s ease;
}

.chat-plus-btn:hover:not(:disabled) {
  color: var(--primary);
  border-color: rgb(123 82 211 / 45%);
  background: var(--primary-soft);
}

.chat-plus-btn:active:not(:disabled) { transform: scale(.96); }

.chat-plus-btn:disabled { opacity: .35; cursor: not-allowed; }

.chat-plus-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.chat-plus-btn .icon-camera { display: none; }

.chat-voice-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .12s ease;
}

.chat-voice-btn:hover:not(:disabled) {
  color: var(--primary);
  border-color: rgb(123 82 211 / 45%);
  background: var(--primary-soft);
}

.chat-voice-btn.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.chat-voice-btn:disabled { opacity: .35; cursor: not-allowed; }

.chat-voice-btn svg {
  width: 17px;
  height: 17px;
  display: block;
}

.chat-shell.voice-call-active .chat-scroll {
  padding-bottom: 8px;
}

.voice-call-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 20px;
  border: 1px solid rgb(123 82 211 / 18%);
  background: linear-gradient(135deg, rgb(123 82 211 / 8%), rgb(255 255 255 / 96%));
  box-shadow: 0 4px 20px rgb(123 82 211 / 10%);
}

.voice-call-bar.hidden { display: none; }

.voice-call-ring {
  --voice-level: 0;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgb(123 82 211 / calc(.18 + var(--voice-level) * .35)) 0%, rgb(123 82 211 / 8%) 70%);
  box-shadow: 0 0 0 calc(4px + var(--voice-level) * 10px) rgb(123 82 211 / calc(.08 + var(--voice-level) * .12));
  transition: box-shadow .08s linear, background .08s linear;
}

.voice-call-bar[data-phase="thinking"] .voice-call-ring,
.voice-call-bar[data-phase="connecting"] .voice-call-ring {
  animation: voice-pulse 1.2s ease-in-out infinite;
}

.voice-call-bar[data-phase="speaking"] .voice-call-ring {
  animation: voice-pulse .85s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: .88; }
}

.voice-call-meta {
  flex: 1;
  min-width: 0;
}

.voice-call-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.voice-call-status {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.voice-hangup-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgb(229 57 53 / 28%);
  transition: transform .12s ease, background .15s ease;
}

.voice-hangup-btn:hover { background: #d32f2f; }
.voice-hangup-btn:active { transform: scale(.96); }

.voice-hangup-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.chat-turn.user .chat-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-turn.user .chat-msg-image {
  max-width: min(220px, 100%);
  max-height: 180px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgb(255 255 255 / 25%);
}
.chat-composer-inner:focus-within {
  border-color: rgb(123 82 211 / 28%);
  box-shadow: 0 0 0 4px var(--primary-soft), 0 4px 20px rgb(123 82 211 / 10%);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  min-height: 24px;
  max-height: 140px;
  padding: 6px 4px;
  outline: none;
  align-self: center;
}

.chat-composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.chat-send-btn,
.chat-stop-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
}

.chat-send-btn {
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 14px rgb(123 82 211 / 28%);
}
.chat-send-btn:hover:not(:disabled) { filter: brightness(1.05); }
.chat-send-btn svg { width: 18px; height: 18px; }
.chat-send-btn:disabled { opacity: .4; box-shadow: none; }

.chat-stop-btn {
  background: var(--ink);
  color: #fff;
}
.chat-stop-btn svg { width: 12px; height: 12px; }

.chat-status {
  margin: 8px 8px 0;
  font-size: 12px;
  color: var(--muted-2);
  text-align: center;
  line-height: 1.4;
}
.chat-status.error { color: var(--danger); }

/* Todo sections */
.todo-sections { display: flex; flex-direction: column; gap: 14px; }

.todo-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.todo-section-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.todo-section-head:hover { background: var(--surface-2); }

.todo-section-head h3 {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.todo-section-count { color: var(--muted); font-size: 13px; }
.todo-section-loading { padding: 12px 16px; color: var(--muted); font-size: 14px; }
.todo-section-chevron {
  color: var(--muted);
  font-size: 14px;
  transition: transform .15s ease;
}
.todo-section-chevron.collapsed { transform: rotate(-90deg); }

.todo-section-body .task-row:first-child { border-top: 1px solid var(--line); }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background .12s ease;
}
.task-row:hover { background: var(--surface-2); }
.task-row.done .task-main h3 {
  text-decoration: line-through;
  color: var(--muted);
}

.task-priority-bar {
  width: 3px;
  min-height: 24px;
  align-self: center;
  border-radius: 2px;
  background: transparent;
  flex-shrink: 0;
}
.task-priority-bar.on { background: var(--primary); }

.task-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
  transition: background .12s ease, border-color .12s ease;
}
.task-check.done {
  background: var(--ok);
  border-color: var(--ok);
}

.task-main { flex: 1; min-width: 0; }
.task-title-row { display: flex; align-items: flex-start; gap: 8px; }
.task-main h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  flex: 1;
}

.task-project {
  flex-shrink: 0;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.task-meta { margin-top: 4px; }
.task-due { color: #2196f3; font-size: 12px; font-weight: 500; }
.task-row.done .task-due { color: var(--muted); font-weight: 400; }

.load-more {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px dashed rgb(123 82 211 / 25%);
}
.load-more:hover { background: var(--primary-container); }

/* List loading */
.list-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 16px 20px;
}

.list-loading-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid var(--primary-container);
  border-top-color: var(--primary);
  animation: list-spin .75s linear infinite;
}

@keyframes list-spin {
  to { transform: rotate(360deg); }
}

.list-loading-text {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.todo-skeleton-section {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 4px;
}

.todo-skeleton-head {
  height: 18px;
  width: 38%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.todo-skeleton-row {
  height: 14px;
  margin-top: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.todo-skeleton-row.short { width: 62%; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.toolbar .input:disabled {
  opacity: .55;
  cursor: wait;
}

/* ---------------- 健康 · 体重小本 ---------------- */

.health-root {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 24px 40px;
}

.health-loading,
.health-empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 16px;
  margin: 0;
}

.health-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.health-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
}

.health-sub {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.health-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.health-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
  margin-bottom: 16px;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.health-weight-card {
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.health-weight-card:hover {
  border-color: rgb(123 82 211 / 25%);
  box-shadow: var(--shadow-md);
}

.health-card-label {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.health-weight-value {
  margin: 0;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  color: var(--primary-dark);
}

.health-weight-sub {
  margin: 8px 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.health-spark {
  width: 100%;
  max-width: 120px;
  height: 28px;
  color: var(--primary);
  display: block;
  margin-bottom: 8px;
}

.health-card-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted-2);
}

.health-calorie-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.health-ring {
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}

.health-calorie-main {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
}

.health-calorie-main span {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}

.health-calorie-budget {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.health-progress-row,
.health-steps-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 10px;
}

.health-steps-row {
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 0;
}

.health-steps-row:hover { color: var(--primary-dark); }

.health-bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.health-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .2s ease;
}

.health-bar-fill.intake { background: var(--primary); }
.health-bar-fill.steps { background: rgb(52 199 89 / 85%); }

.health-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.health-section-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.health-records {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-record,
.health-history-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.health-record-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.health-record-main strong {
  font-size: 14px;
  font-weight: 600;
}

.health-record-main span,
.health-record time,
.health-history-item span {
  font-size: 13px;
  color: var(--muted);
}

.health-record-del {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

.health-record-del:hover {
  color: var(--danger);
  background: rgb(255 59 48 / 8%);
}

.health-history-month {
  margin-bottom: 20px;
}

.health-history-month h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.health-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.health-history-item strong {
  font-size: 15px;
  color: var(--ink);
}

.health-history-item em {
  font-style: normal;
  font-size: 12px;
  color: var(--ok);
}

@media (max-width: 720px) {
  .health-grid { grid-template-columns: 1fr; }
  .health-root { padding: 16px 16px 32px; }
}

/* ---------- 手机端（对齐 Android 竖屏：底栏 + 大标题） ---------- */

.mobile-tab-bar,
.mobile-page-header,
.mobile-subpage-bar,
.mobile-back-link,
.sidebar-close-btn,
.sidebar-overlay {
  display: none;
}

#tab-me { display: none; }
#tab-me.tab-pane:not(.hidden) { display: none; }

.mobile-only,
.mobile-fab,
.mobile-icon-btn { display: none; }

.notes-filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.notes-filter-row .sub-tabs {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  padding-bottom: 14px;
}

.me-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px;
  background: var(--surface);
  border: 1px solid #c7c7cc;
  border-radius: 15px;
  text-align: left;
}
.me-identity-text { flex: 1; min-width: 0; }
.me-identity strong {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.me-identity em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--muted-2);
}
.me-row-chevron { color: var(--muted-2); font-size: 20px; line-height: 1; }

.me-stats {
  display: flex;
  margin-top: 12px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid #c7c7cc;
  border-radius: 15px;
}
.me-stat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  border: none;
  background: none;
  border-radius: 0;
}
.me-stat strong {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.me-stat span {
  font-size: 11px;
  color: var(--muted-2);
}

.me-motto {
  margin: auto 20px 6px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-2);
  line-height: 1.5;
}

.me-plugins {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 0;
  margin: 4px 4px 8px;
}
.me-plugin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border: none;
  background: none;
  border-radius: 0;
  font-size: 12px;
  color: var(--ink);
}
.me-plugin-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: #efeff4;
  border: 1px solid #c7c7cc;
  color: var(--primary);
}
.me-plugin-icon svg { width: 28px; height: 28px; }

@media (min-width: 769px) {
  .note-card-head,
  .note-preview,
  .note-tags { display: none; }
}

.note-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: #aeaeB2;
  font-size: 12px;
}
.note-card-head .note-time { color: #aeaeB2; }
.note-card-head .note-meta-div { opacity: .7; }
.note-card-head .note-meta-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.note-card-head .icon-btn { margin-left: auto; }
.note-preview {
  margin: 0;
  color: #333;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-tags {
  margin-top: 8px;
  color: #aeaeB2;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.empty-hint {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
}

@media (max-width: 768px) {
  html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
  }

  body {
    padding: env(safe-area-inset-top) 0 0;
  }

  .setup {
    min-height: 100dvh;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    align-items: start;
  }

  .setup-card {
    padding: 28px 20px 24px;
    border-radius: 18px;
  }

  .app {
    position: relative;
    height: 100dvh;
    flex-direction: column;
    padding-bottom: 0;
  }

  .icon-rail,
  .desktop-only { display: none !important; }

  .mobile-only { display: inline-flex; }

  .mobile-tab-bar {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    flex-shrink: 0;
    background: var(--bg);
    border-top: none;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 8;
  }

  .mobile-tab {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px 2px;
    border: none;
    border-radius: 0;
    background: none;
    color: #aeaeB2;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.1;
  }
  .mobile-tab:active { transform: none; }
  .mobile-tab.active { color: var(--primary); }

  .mobile-tab-icon {
    width: 22px;
    height: 22px;
  }

  .mobile-tab-ai-blob {
    position: relative;
    width: 22px;
    height: 22px;
    display: block;
    border-radius: 46% 54% 48% 52%;
    background: radial-gradient(circle at 35% 32%, #e879f9 0%, #c026d3 42%, #7c3aed 78%);
    animation: ai-jelly 3.8s linear infinite;
  }
  .mobile-tab-ai-blob i { display: none; }
  @keyframes ai-jelly {
    0%, 100% { border-radius: 46% 54% 48% 52%; }
    33% { border-radius: 54% 46% 58% 42%; }
    66% { border-radius: 42% 58% 46% 54%; }
  }

  .mobile-fab {
    display: grid;
    place-items: center;
    position: absolute;
    left: 50%;
    bottom: calc(20px + 56px + env(safe-area-inset-bottom));
    z-index: 6;
    width: 56px;
    height: 56px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #28c76f;
    color: #fff;
    font-size: 28px;
    font-weight: 400;
    line-height: 1;
    box-shadow: none;
    transform: translateX(-50%);
  }
  .mobile-fab:active { transform: translateX(-50%) scale(.96); }
  .mobile-fab.hidden { display: none; }
  body.keyboard-open .mobile-fab { display: none; }

  .mobile-icon-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    margin: 0 0 10px;
    padding: 8px;
    border: none;
    border-radius: 0;
    background: none;
    color: #6c6c70;
  }
  .mobile-icon-btn svg { width: 22px; height: 22px; }

  .main-panel {
    flex: 1;
    min-height: 0;
  }

  .mobile-page-header,
  .content-header.mobile-large-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 62px;
    padding: 12px 16px 10px;
    background: var(--bg);
    border-bottom: none;
    backdrop-filter: none;
  }

  .mobile-page-header h1,
  .content-header.mobile-large-header h1 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.1;
  }

  .content-header.mobile-large-header p { display: none; }

  .mobile-header-btn {
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--ink);
  }
  .mobile-header-btn svg { width: 22px; height: 22px; display: block; }
  .mobile-header-btn:active { background: var(--surface-2); }

  .mobile-subpage-bar {
    display: flex;
    align-items: center;
    padding: 8px 12px 0;
    background: var(--bg);
  }

  .mobile-back-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin: 0 0 4px;
    padding: 0 2px;
    border: none;
    background: none;
    color: var(--primary);
    font-size: 16px;
    font-weight: 500;
  }

  .content-header { padding: 12px 16px 10px; }

  .content-body {
    padding: 0 0 calc(20px + env(safe-area-inset-bottom));
  }
  #tab-notes .content-body,
  #tab-tasks .content-body,
  #tab-memos .content-body {
    padding: 0 0 96px;
  }
  #tab-memos .toolbar {
    padding: 8px 16px 0;
    margin-bottom: 8px;
  }
  #tab-me .content-body {
    display: flex;
    flex-direction: column;
    padding: 8px 16px 24px;
    min-height: 0;
    overflow: auto;
  }

  .notes-filter-row {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 4px 4px 0 4px;
    border-bottom: 1px solid #e5e5ea;
    background: var(--bg);
  }
  .notes-filter-row .sub-tabs {
    padding: 0 8px 0 4px;
    margin: 0;
  }
  #tab-notes.search-open .notes-filter-row .sub-tabs { display: none; }
  #tab-notes.search-open .notes-search-toolbar { display: block; }

  .notes-search-toolbar { display: none; padding: 8px 16px 10px; }
  .toolbar .search {
    min-height: 36px;
    background: #fff;
    border: 1px solid #c7c7cc;
    border-radius: 15px;
  }

  .sub-tab {
    padding: 6px 12px;
    background: none;
    border: none;
    border-radius: 0;
    color: #6c6c70;
    font-size: 14px;
    font-weight: 400;
    box-shadow: none;
  }
  .sub-tab:hover {
    border: none;
    color: var(--ink);
  }
  .sub-tab.active {
    background: none;
    border: none;
    color: var(--ink);
    font-weight: 600;
    box-shadow: none;
  }

  #tab-notes,
  #tab-tasks,
  #tab-memos {
    background: #f5f5f5;
  }
  #tab-notes .mobile-large-header,
  #tab-tasks .mobile-large-header,
  #tab-memos .mobile-large-header,
  #tab-me .mobile-large-header,
  #tab-chat .mobile-page-header,
  #tab-board .mobile-page-header {
    background: var(--bg);
  }

  .card-list {
    gap: 8px;
    padding: 8px 16px 0;
  }
  .card {
    flex-direction: column;
    gap: 0;
    border: none;
    border-radius: 10px;
    padding: 18px;
    box-shadow: none;
  }
  .card:hover { transform: none; box-shadow: none; }
  .note-card .card-main h3,
  .note-card .meta,
  .note-card .card-actions,
  .note-card .badge { display: none; }
  .empty {
    padding: 48px 32px;
    font-size: 17px;
    font-weight: 700;
    color: var(--ink);
  }

  .todo-sections {
    gap: 10px;
    padding: 8px 16px 0;
  }
  .todo-section {
    border-radius: 10px;
    box-shadow: none;
    overflow: hidden;
  }
  .task-row {
    min-height: 52px;
    padding: 10px 14px;
    gap: 8px;
  }
  .task-check {
    width: 24px;
    height: 24px;
    margin-top: 0;
    align-self: center;
  }
  .task-due { color: #2196f3; }

  .grid2 { grid-template-columns: 1fr; }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgb(28 28 30 / 38%);
    z-index: 16;
  }
  .sidebar-overlay:not(.hidden) { display: block; }

  .context-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    z-index: 17;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top);
  }
  body.sidebar-open .context-sidebar {
    display: flex;
  }
  body.sidebar-open .sidebar-overlay { display: block; }

  .sidebar-close-btn { display: inline-flex; }

  #tab-me.tab-pane:not(.hidden) { display: flex; }

  #tab-chat,
  #tab-board { background: var(--bg); }

  .chat-messages,
  .chat-composer,
  .chat-attachments {
    max-width: none;
    padding-left: 12px;
    padding-right: 12px;
  }

  .chat-messages { padding: 8px 16px 12px; gap: 8px; }
  .chat-composer { padding: 8px 26px 10px; }
  .chat-attachments { padding: 0 12px; }

  .chat-turn.user { max-width: 78%; }
  .chat-turn.user .chat-bubble {
    background: #007aff;
    color: #fff;
    border: none;
    border-radius: 18px;
    padding: 11px 16px;
    font-size: 16px;
  }
  .chat-turn.user .chat-time { display: none; }
  .chat-turn.assistant .chat-bubble {
    background: #fff;
    border: 1px solid #c7c7cc;
    border-radius: 18px;
    box-shadow: none;
    padding: 14px 16px 10px;
  }

  .chat-composer-inner {
    min-height: 48px;
    padding: 0 6px;
    border: 1px solid #c7c7cc;
    border-radius: 999px;
    box-shadow: none;
    background: #fff;
  }
  .chat-composer-inner:focus-within {
    border-color: #c7c7cc;
    box-shadow: none;
  }
  .chat-plus-btn,
  .chat-voice-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: none;
    color: #8e8e93;
    box-shadow: none;
  }
  .chat-plus-btn .icon-plus { display: none; }
  .chat-plus-btn .icon-camera { display: block; width: 22px; height: 22px; }
  .chat-send-btn {
    background: #007aff;
    box-shadow: none;
  }
  .chat-quick-chip {
    background: #fff;
    border: 1px solid #c7c7cc;
    box-shadow: none;
  }

  .chat-input,
  .board-input,
  .toolbar .search,
  .input,
  textarea.input,
  textarea.area {
    font-size: 16px;
  }

  .board-heartbeat {
    padding: 10px 16px;
    flex-wrap: wrap;
  }
  .board-composer { padding: 10px 12px 12px; }

  .health-header h1 { font-size: 28px; }
  .health-root { padding: 8px 16px 28px; }

  .modal {
    padding: 0;
    place-items: stretch;
    background: var(--bg);
    backdrop-filter: none;
  }
  .modal-card {
    width: 100%;
    max-height: 100dvh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .modal-head {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    border-bottom: 1px solid var(--line);
  }
  .modal-body { padding: 12px 16px 16px; }
  textarea.area { min-height: 36vh; }
  .modal-foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }

  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }

  body.keyboard-open .mobile-tab-bar { display: none; }
  body.keyboard-open .toast { bottom: 20px; }
}

@media (max-width: 900px) and (min-width: 769px) {
  .context-sidebar { display: none; }
  body[data-tab="board"] .context-sidebar,
  body[data-tab="chat"] .context-sidebar {
    display: flex;
    width: 220px;
  }
  .content-body { padding: 16px 18px 24px; }
  .board-composer { padding: 10px 12px 14px; }
}
