:root {
  --bg: #fbfbfb;
  --sidebar: #f7f8fa;
  --surface: #ffffff;
  --ink: #282a30;
  --body: #3a3d44;
  --muted: #6b6f76;
  --faint: #8b8f96;
  --line: #e8e9ed;
  --line-strong: #d8dae0;
  --hover: #f1f2f5;
  --active: #ebedf5;
  --accent: #5e6ad2;
  --accent-soft: #eef0fb;
  --green: #26a269;
  --amber: #d9a441;
  --red: #c4453c;
  --radius: 6px;
  font-family: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --shadow-sm: 0 1px 2px rgba(23, 25, 31, .06);
  --shadow-md: 0 4px 16px rgba(23, 25, 31, .1);
  --shadow-lg: 0 12px 32px rgba(23, 25, 31, .14);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--body); font-size: 14px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.hidden { display: none !important; }
::selection { background: #dfe2fb; color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); padding: 6px 11px; min-height: 32px; font-size: 13px; cursor: pointer; transition: background .12s ease, border-color .12s ease; }
button:hover:not(:disabled) { background: var(--hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #4f5ac2; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
input, textarea, select { width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 8px 10px; font-size: 14px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94, 106, 210, .14); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
h1, h2, h3 { color: var(--ink); }
a { color: var(--accent); text-underline-offset: 3px; }
.error { color: var(--red); font-size: 13px; min-height: 16px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.7; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 1px 7px; border-radius: 4px; background: var(--hover); color: var(--muted); font-weight: 500; }
.pill.bad { background: #fbeceb; color: var(--red); }
.pill.warn { background: #fdf5e3; color: #9a6a12; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; box-shadow: var(--shadow-sm); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark, .workspace-mark, .avatar { display: inline-grid; place-items: center; background: var(--accent); color: #fff; border-radius: 6px; font-weight: 600; }
.brand-mark { width: 34px; height: 34px; font-size: 16px; }
.login-brand strong { display: block; font-size: 16px; color: var(--ink); }
.login-brand small { color: var(--muted); font-size: 12px; }
.login form button { width: 100%; margin-top: 18px; }
#login-error { margin: 10px 0 0; }

/* ---------- 应用骨架 ---------- */
.app { min-height: 100vh; display: flex; }
.sidebar { width: 236px; flex: 0 0 236px; background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px 10px; position: sticky; top: 0; height: 100vh; }
.workspace { display: flex; align-items: center; gap: 9px; padding: 6px 8px 14px; }
.workspace-mark { width: 26px; height: 26px; font-size: 13px; }
.workspace strong { display: block; font-size: 13px; color: var(--ink); font-weight: 600; }
.workspace small { color: var(--faint); font-size: 11px; }
.side-nav { display: grid; gap: 1px; }
.side-nav button { border: 0; background: transparent; min-height: 32px; padding: 6px 8px; text-align: left; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; border-radius: var(--radius); }
.side-nav button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.side-nav button:hover { background: var(--hover); color: var(--ink); }
.side-nav button.active { background: var(--active); color: var(--ink); font-weight: 550; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.side-user { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); padding: 0 4px; }
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.topbar { height: 44px; flex: 0 0 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.crumb { font-size: 12px; color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 26px 40px; }
.page-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

/* ---------- 聊天（ChatGPT 阅读体验） ---------- */
.messages { flex: 1; overflow-y: auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 28px 24px 8px; display: flex; flex-direction: column; gap: 26px; scrollbar-width: thin; scrollbar-color: #d5d7dd transparent; }
.messages::-webkit-scrollbar { width: 10px; }
.messages::-webkit-scrollbar-thumb { background: #d5d7dd; border: 3px solid transparent; background-clip: content-box; border-radius: 10px; }
.msg { width: 100%; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user > * { max-width: 82%; }
.msg.user { white-space: pre-wrap; }
.msg.user { background: none; }
.msg.user { color: var(--ink); font-size: 15px; line-height: 1.7; }
.msg.user { padding: 0; }
.msg.user { border-radius: 0; }
.msg.user { align-self: stretch; }
.msg.user { display: block; }
.msg.user .bubble { background: #f1f2f4; border-radius: 16px 16px 4px 16px; padding: 9px 14px; max-width: 78%; margin-left: auto; white-space: pre-wrap; }
.msg.assistant { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; }
.avatar { width: 26px; height: 26px; font-size: 12px; border-radius: 50%; background: var(--ink); color: #fff; }
.msg-main { min-width: 0; }
.msg-name { font-size: 12px; font-weight: 600; color: var(--ink); margin: 2px 0 4px; }
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .12s; }
.msg.assistant:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions button { border: 0; background: transparent; color: var(--faint); min-height: 26px; padding: 2px 6px; font-size: 12px; }
.msg-actions button:hover { background: var(--hover); color: var(--ink); }
.msg.process { align-self: flex-start; font-size: 12px; color: var(--muted); background: var(--hover); border-radius: 4px; padding: 3px 8px; width: fit-content; margin-left: 38px; }
.cursor::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* markdown */
.md { color: var(--body); font-size: 15px; line-height: 1.85; word-break: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3 { margin: 22px 0 9px; line-height: 1.35; letter-spacing: -.015em; font-weight: 600; }
.md h1 { font-size: 21px; }
.md h2 { font-size: 17px; }
.md h3 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--faint); }
.md strong { font-weight: 600; color: var(--ink); }
.md code { background: var(--hover); border-radius: 4px; padding: 1px 5px; font-size: 13px; font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; }
.md pre { background: #1f2126; color: #e9eaee; border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 12px 0; font-size: 13px; line-height: 1.6; }
.md pre code { background: none; padding: 0; color: inherit; }
.md blockquote { border-left: 2px solid var(--line-strong); margin: 10px 0; padding: 1px 0 1px 12px; color: var(--muted); }
.md table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.md th { background: var(--sidebar); color: var(--muted); font-weight: 600; text-align: left; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 10px; vertical-align: top; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.chat-welcome { max-width: 520px; margin: auto; text-align: center; padding: 8vh 0 0; }
.chat-welcome h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 6px; }
.chat-welcome p { color: var(--muted); margin: 0; }
.chat-welcome .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chat-welcome .actions button { background: var(--surface); border-color: var(--line-strong); font-size: 13px; border-radius: 20px; padding: 6px 13px; }

.composer-wrap { flex: 0 0 auto; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 24px 14px; }
.composer { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 8px 8px 8px 14px; box-shadow: var(--shadow-sm); }
.composer textarea { border: 0; padding: 4px 0; resize: none; max-height: 160px; background: transparent; font-size: 15px; line-height: 1.6; }
.composer textarea:focus { box-shadow: none; }
.composer .send { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 10px; display: grid; place-items: center; }
.composer .send svg { width: 15px; height: 15px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-hint { text-align: center; color: var(--faint); font-size: 11px; margin: 7px 0 0; }

/* ---------- 通用页面块（Linear 密度） ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 14px; }
.page-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 12px; margin-left: auto; }
.section { margin: 20px 0 6px; }
.section h2, .group-head { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 0 0 6px; display: flex; align-items: center; gap: 7px; }
.group-count { color: var(--faint); font-weight: 500; }
.list { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; }
.row { display: block; width: 100%; text-align: left; padding: 10px 13px; border: 0; border-top: 1px solid var(--line); background: var(--surface); cursor: default; border-radius: 0; min-height: 0; }
.row:first-child { border-top: 0; }
button.row { cursor: pointer; }
button.row:hover { background: var(--hover); }
.row strong { display: block; font-size: 14px; font-weight: 550; color: var(--ink); line-height: 1.45; }
.row small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; line-height: 1.55; }
.row .actions { margin-top: 8px; display: flex; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.tile { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer; }
.tile:hover { border-color: var(--line-strong); }
.tile strong { display: block; font-size: 14px; }
.tile small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.form { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px; margin: 10px 0; }
.form .actions { margin-top: 12px; display: flex; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 13px 14px; margin-top: 8px; box-shadow: var(--shadow-sm); }
.card small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-bottom: 4px; }
.card strong { display: block; color: var(--ink); font-size: 14px; }
.card p { margin: 4px 0 9px; color: var(--body); font-size: 13px; line-height: 1.6; }
.card .actions { display: flex; gap: 6px; }
.chat-log { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px; font-size: 14px; line-height: 1.8; white-space: pre-wrap; max-height: 420px; overflow-y: auto; }
.doc-hit { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin: 6px 0; }
.doc-hit:hover { background: var(--hover); }
.doc-hit strong { display: block; font-size: 13px; color: var(--ink); }
.doc-hit small { color: var(--muted); font-size: 12px; }
.toast { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; border-radius: 6px; padding: 7px 13px; font-size: 13px; z-index: 80; box-shadow: var(--shadow-md); }

/* 今日 */
.today-date { color: var(--muted); font-size: 12px; }
.today-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 10px 13px; cursor: pointer; min-height: 44px; }
.today-row:first-child { border-top: 0; }
.today-row:hover { background: var(--hover); }
.today-row .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; background: var(--faint); }
.today-row .dot.green { background: var(--green); }
.today-row .dot.amber { background: var(--amber); }
.today-row .dot.red { background: var(--red); }
.today-row .dot.accent { background: var(--accent); }
.today-row .row-main { min-width: 0; flex: 1; }
.today-row .row-main strong { display: block; font-size: 14px; color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-row .row-main small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-row .chev { color: var(--faint); font-size: 14px; flex: 0 0 auto; }
.task-with-calendar { display: flex; align-items: center; border-top: 1px solid var(--line); }
.task-with-calendar:first-child { border-top: 0; }
.task-with-calendar .today-row { min-width: 0; flex: 1; }
.calendar-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; white-space: nowrap; flex: 0 0 auto; }
.reminder-row { background: var(--accent-soft); cursor: default; }
.today-actions { display: flex; gap: 6px; margin-top: 6px; }
.today-actions button { min-height: 28px; padding: 3px 9px; font-size: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 8px; font-size: 13px; }

/* 表格化项目/任务 */
.table-head { display: flex; align-items: center; gap: 10px; padding: 6px 13px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--sidebar); font-size: 11px; letter-spacing: .03em; text-transform: uppercase; color: var(--faint); }
.table-head + .list { border-radius: 0 0 8px 8px; }
.col-name { flex: 1; min-width: 0; }
.col-status { width: 76px; flex: 0 0 76px; }
.col-owner { width: 78px; flex: 0 0 78px; }
.col-due { width: 82px; flex: 0 0 82px; text-align: right; }
.project-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: var(--surface); padding: 10px 13px; min-height: 44px; cursor: pointer; }
.project-row:first-child { border-top: 0; }
.project-row:hover { background: var(--hover); }
.project-row .col-name { font-size: 14px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-row .col-meta { font-size: 12px; color: var(--muted); }
.status-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.status-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.status-dot.active i { background: var(--green); }
.status-dot.week i { background: var(--amber); }
.status-dot.iterating i { background: var(--accent); }
.status-dot.done i { background: var(--faint); }

/* 底部移动导航 */
.nav { display: none; }
.nav button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--faint); min-height: 54px; padding: 6px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; position: relative; }
.nav button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nav button.active { color: var(--accent); font-weight: 600; }
.nav-dot { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 9px; line-height: 15px; text-align: center; font-weight: 600; }

.entry-banner { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); width: min(420px, calc(100% - 24px)); z-index: 70; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; padding: 11px 13px; box-shadow: var(--shadow-lg); }
.entry-banner strong { display: block; font-size: 13px; color: var(--ink); }
.entry-banner small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.entry-banner .actions { margin-top: 8px; display: flex; gap: 6px; }
.entry-banner button { min-height: 28px; padding: 3px 10px; font-size: 12px; }

button.row .chev, .today-row .chev { color: var(--faint); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar { height: 48px; flex-basis: 48px; padding: 0 14px; }
  .nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 40; padding-bottom: env(safe-area-inset-bottom); }
  .shell { height: 100vh; }
  .main { padding-bottom: 0; }
  .page { padding: 14px 14px 78px; }
  .page-chat { padding-bottom: 66px; }
  .messages { padding: 18px 14px 6px; gap: 22px; }
  .composer-wrap { padding: 6px 12px calc(10px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 14px; }
  .msg.assistant { grid-template-columns: 22px minmax(0, 1fr); gap: 9px; }
  .avatar { width: 22px; height: 22px; font-size: 11px; }
  .md { font-size: 15px; line-height: 1.8; }
  .chat-welcome { padding-top: 5vh; }
  .table-head { display: none; }
  .project-row { padding: 11px 12px; flex-wrap: wrap; gap: 4px 10px; }
  .project-row .col-status, .project-row .col-owner, .project-row .col-due { width: auto; flex: 0 0 auto; }
  .project-row .col-name { flex: 1 1 100%; }
  .today-row { padding: 11px 12px; }
}

/* 兼容旧视图类名 */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 0 14px; }
.panel-head h1 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 0; }
.panel-head .sub { color: var(--muted); font-size: 12px; }
.grid + .muted { margin-top: 8px; }


/* ===== 手机原生基线 + Apple 手感 ===== */
:root { --ease-out: cubic-bezier(.22, 1, .36, 1); --ease-spring: cubic-bezier(.34, 1.4, .64, 1); }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { min-height: 100dvh; }
button, a, [role="button"], .tile, .row, .today-row, .project-row, .nav button, .side-nav button {
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
button:active, .tile:active, .today-row:active, .project-row:active { transform: scale(.985); }
button, .tile, .today-row, .project-row { transition: transform 120ms var(--ease-out), background 120ms var(--ease-out), border-color 120ms var(--ease-out); }
input, textarea, select { font-size: 16px; }
.messages, .page { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

.composer .tool { flex: 0 0 34px; width: 34px; height: 34px; min-height: 34px; padding: 0; border: 0; background: transparent; color: var(--faint); display: grid; place-items: center; border-radius: 10px; }
.composer .tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.composer .tool:active { background: var(--hover); }
.composer .tool.recording { color: var(--red); background: #fbeceb; animation: micPulse 1.1s ease-in-out infinite; }
@keyframes micPulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 24px 6px; max-width: 760px; margin: 0 auto; width: 100%; }
.attach-chip { font-size: 11px; color: var(--muted); background: var(--hover); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.page:not(.hidden) { animation: pageIn 180ms var(--ease-out) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.entry-banner { animation: sheetIn 260ms var(--ease-spring) both; }
@keyframes sheetIn { from { opacity: 0; transform: translate(-50%, -8px) scale(.98); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
.toast { animation: toastIn 200ms var(--ease-out) both; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (max-width: 900px) {
  .app, .shell { height: 100dvh; }
  .topbar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(50px + env(safe-area-inset-top, 0px));
    flex-basis: calc(50px + env(safe-area-inset-top, 0px));
    height: 50px; flex-basis: 50px;
    background: rgba(251, 251, 251, .82);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: .5px solid rgba(0, 0, 0, .08);
  }
  .crumb { font-size: 13px; font-weight: 600; color: var(--ink); }
  .nav {
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-top: .5px solid rgba(0, 0, 0, .08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .nav button { min-height: 52px; }
  .nav button:active { transform: scale(.94); }
  .nav button.active { color: var(--ink); }
  .nav button.active span { background: transparent; color: var(--ink); padding: 0; font-weight: 600; }
  .nav button.active svg { color: var(--accent); }
  .composer-wrap { padding: 6px 12px calc(10px + env(safe-area-inset-bottom, 0px)); }
  .composer {
    border-radius: 22px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: .5px solid rgba(0, 0, 0, .1);
    box-shadow: 0 8px 24px rgba(20, 22, 28, .12);
    padding: 6px 6px 6px 10px;
  }
  .composer textarea { min-height: 34px; max-height: 120px; }
  .page-chat { padding-bottom: 0; }
  .messages { padding: 16px 14px 8px; }
  .msg.assistant { grid-template-columns: 24px minmax(0, 1fr); gap: 10px; }
  .avatar { width: 24px; height: 24px; font-size: 11px; }
  .msg.user .bubble { font-size: 15px; }
  .today-row { min-height: 52px; padding: 11px 12px; }
  .today-row .row-main strong { font-size: 15px; }
  .today-actions button { min-height: 32px; font-size: 13px; }
}

@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled) { background: var(--hover); }
  .today-row:hover, .project-row:hover, button.row:hover { background: var(--hover); }
}
@media (hover: none) {
  button:hover:not(:disabled) { background: var(--surface); }
  button.primary:hover:not(:disabled) { background: var(--accent); }
  .today-row:hover, .project-row:hover, button.row:hover { background: var(--surface); }
}
@media (prefers-reduced-motion: reduce) {
  .page:not(.hidden), .entry-banner, .toast { animation: none; }
  button, .tile, .today-row, .project-row { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .nav, .composer { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--surface); }
}

/* ===== 聊天输入框固定：页面不滚，只有消息区滚 ===== */
html, body { height: 100%; overflow: hidden; }
.app { height: 100dvh; overflow: hidden; }
.shell { height: 100%; min-height: 0; overflow: hidden; }
.main { min-height: 0; overflow: hidden; }
.page { min-height: 0; }
.page-chat { height: 100%; min-height: 0; overflow: hidden; }
.messages { min-height: 0; flex: 1; }
.composer-wrap { flex: 0 0 auto; }
.login { height: 100%; overflow-y: auto; min-height: 100dvh; }

@media (max-width: 900px) {
  body { position: fixed; inset: 0; width: 100%; }
  .page-chat { padding-bottom: 0; }
  .messages { padding-bottom: 148px; }
  .composer-wrap {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    z-index: 35;
    max-width: none;
    padding: 8px 12px 8px;
    background: linear-gradient(to top, var(--bg) 55%, rgba(251, 251, 251, 0));
  }
  .attachments {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(116px + env(safe-area-inset-bottom, 0px));
    z-index: 36;
    padding: 0 16px;
    background: transparent;
  }
  .entry-banner { top: calc(56px + env(safe-area-inset-top, 0px)); }
}


/* ===== 移动底栏底座 v2：输入框永远在导航上方 ===== */
:root { --nav-h: 56px; --safe-b: env(safe-area-inset-bottom, 0px); }
html { color-scheme: light; }
body { background: #fbfbfb; color: #282a30; }

@media (max-width: 900px) {
  .page.page-chat:not(.hidden) { animation: none !important; }
  .page-chat { padding-bottom: 0 !important; }
  .nav {
    height: calc(var(--nav-h) + var(--safe-b));
    min-height: 0;
    padding-bottom: var(--safe-b);
    box-sizing: border-box;
    z-index: 70;
    overflow: hidden;
  }
  .nav button {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 5px 0 6px;
    overflow: hidden;
  }
  .nav button svg { width: 18px; height: 18px; }
  .nav button span { font-size: 10px; line-height: 1.2; white-space: nowrap; }
  .nav-dot { left: auto; right: 18%; top: 2px; }

  .composer-wrap {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--nav-h) + var(--safe-b));
    z-index: 60;
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 8px 12px 8px;
    background: linear-gradient(to top, #fbfbfb 60%, rgba(251, 251, 251, 0));
  }
  .messages {
    flex: 1 1 auto;
    min-height: 0;
    padding-bottom: calc(var(--nav-h) + var(--safe-b) + 96px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .attachments {
    position: fixed;
    left: 0; right: 0;
    bottom: calc(var(--nav-h) + var(--safe-b) + 72px);
    z-index: 61;
    padding: 0 16px;
  }
  .entry-banner { top: calc(52px + env(safe-area-inset-top, 0px)); }
  .composer { border-radius: 20px; }
  .composer textarea { font-size: 16px; }
}


/* ===== 大独立语音按钮 ===== */
.composer .tool#mic {
  flex: 0 0 44px;
  width: 44px; height: 44px; min-height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 3px 10px rgba(23, 25, 31, .18);
}
.composer .tool#mic svg { width: 21px; height: 21px; stroke-width: 1.6; }
.composer .tool#mic:active { transform: scale(.94); background: #3a3d44; }
.composer .tool#mic.recording { background: var(--red); color: #fff; }
.composer .send { flex: 0 0 34px; }
@media (max-width: 900px) {
  .composer .tool#mic { flex-basis: 46px; width: 46px; height: 46px; min-height: 46px; }
  .composer textarea { min-height: 42px; }
}

/* ===== 工单 04：AI 助理新会简报 / 今天抬头 / 新会预览 ===== */
.chat-welcome { width: 100%; }
@media (max-width: 900px) {
  .app { height: 100vh; height: 100dvh; min-height: 0; flex-direction: column; overflow: hidden; }
  .shell { flex: 1 1 0; height: auto; min-height: 0; }
  .nav { position: static; flex: 0 0 auto; }
  .page:not(.page-chat) { padding-bottom: 18px; }
  .page.page-chat:not(.hidden) { flex: 1 1 0; height: auto; }
  .messages { padding-bottom: 12px; }
  .composer-wrap { position: static; flex: 0 0 auto; padding: 8px 12px; background: var(--bg); }
  .attachments { position: static; padding: 0; }
}
.chat-brief {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  position: relative; width: 100%; max-width: 460px; margin: 0 auto 22px; padding: 11px 30px 12px 14px;
  text-align: left; background: var(--surface); color: var(--body); cursor: pointer;
  border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.chat-brief:hover { background: #fff; border-color: var(--accent); box-shadow: var(--shadow-md); }
.chat-brief:active { transform: scale(.995); }
.chat-brief .brief-head { display: flex; align-items: center; gap: 8px; width: 100%; }
.chat-brief .brief-kicker { font-size: 10px; font-weight: 600; letter-spacing: .08em; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 6px; }
.chat-brief .brief-when { margin-left: auto; font-size: 11px; color: var(--faint); }
.chat-brief .brief-title { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.chat-brief .brief-meta { font-size: 12px; color: var(--muted); line-height: 1.5; }
.chat-brief .brief-cta { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: 17px; }

.today-head { align-items: flex-start; flex-wrap: wrap; gap: 4px 14px; }
.today-head h1 { margin: 0; }
.today-date { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.delta-line { margin-left: auto; max-width: 100%; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; line-height: 1.5; }
.delta-line::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: 1px; }

.my-todos .today-row { padding: 9px 12px; min-height: 46px; }
.today-row.todo-proposal { background: #fffdf6; }
.today-row .today-actions { margin-top: 0; flex: 0 0 auto; }
.text-link { border: 0; background: transparent; color: var(--accent); font-size: 12px; padding: 2px 4px; min-height: 26px; }
.text-link:hover:not(:disabled) { background: var(--accent-soft); }
.group-head .text-link, .group-head .conn-alert { margin-left: auto; }
.head-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.conn-alert { font-size: 11px; color: var(--red); background: #fbeceb; border-radius: 4px; padding: 1px 7px; }
.conn-row { flex-wrap: wrap; }
.conn-row .today-actions { margin-left: auto; }
.error-empty { border-color: var(--red); color: var(--red); line-height: 1.7; }
.error-actions { display: flex; gap: 8px; margin-top: 10px; }
.meeting-history { border-top: 1px solid var(--line); }

/* 新会预览 */
.preview-head { align-items: flex-start; }
.preview-title { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.preview-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 12px; color: var(--muted); }
.preview-meta code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 11px; background: var(--hover); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.preview-meta-item { white-space: nowrap; }
.preview-conclusion .conclusion { margin: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 15px; line-height: 1.7; }
.preview-status { margin-left: auto; font-size: 11px; color: var(--faint); font-weight: 400; }
.confirm-list .confirm-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 13px; border-top: 1px solid var(--line); }
.confirm-list .confirm-row:first-child { border-top: 0; }
.confirm-main { flex: 1; min-width: 0; }
.confirm-edits { margin-top: 8px; font-size: 13px; color: var(--muted); }
.confirm-edits summary { width: fit-content; cursor: pointer; padding: 4px 0; }
.confirm-edits .form { display: grid; gap: 8px; margin-top: 6px; }
.confirm-main strong { display: block; font-size: 14px; font-weight: 550; color: var(--ink); line-height: 1.45; }
.confirm-basis { display: block; margin-top: 3px; font-size: 12px; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.confirm-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.confirm-button { flex: 0 0 auto; align-self: center; }
.confirm-row.is-confirmed { background: #f7fbf8; }
.confirm-row.is-confirmed .dot { margin-top: 6px; }
.preview-next { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 18px 0 6px; }
.preview-next p { margin: 0; }
.candidate-list { margin: 0; padding: 12px 14px 12px 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-size: 13px; line-height: 1.7; color: var(--body); overflow-wrap: anywhere; }
.candidate-list li { margin: 2px 0; }
.candidate-list li.candidate-used { color: var(--faint); }
.candidate-list .mention { margin-left: 6px; font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
details.raw { margin-top: 14px; padding: 10px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
details.raw summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.raw pre { margin: 10px 0 0; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: 13px; line-height: 1.75; color: var(--body); }

/* 工具日志折叠 */
.tool-log { margin-left: 38px; max-width: 100%; width: fit-content; padding: 4px 9px; font-size: 12px; color: var(--muted); background: var(--hover); border-radius: 6px; }
.tool-log summary { cursor: pointer; list-style: none; color: var(--faint); }
.tool-log summary::-webkit-details-marker { display: none; }
.tool-log summary::before { content: "▸ "; }
.tool-log[open] summary::before { content: "▾ "; }
.tool-log .tool-lines { margin-top: 4px; color: var(--muted); }
.tool-log .tool-line { font-size: 11px; line-height: 1.6; }

/* 对话里的变更卡：依据 / 负责人 / 期限 */
.card .card-fields { display: flex; flex-direction: column; gap: 3px; margin: 2px 0 9px; }
.card-field { display: inline-flex; gap: 5px; align-items: baseline; max-width: 100%; font-size: 12px; color: var(--body); }
.card-field em { flex: 0 0 auto; font-style: normal; color: var(--faint); }
.card-field span { overflow-wrap: anywhere; }
.proposal-card .actions .ghost { border-color: transparent; background: transparent; color: var(--muted); }
.proposal-card .actions .ghost:hover:not(:disabled) { background: var(--hover); color: var(--ink); }

@media (max-width: 900px) {
  .chat-brief { max-width: 100%; margin-bottom: 18px; }
  .today-head { gap: 4px 10px; }
  .delta-line { margin-left: 0; width: 100%; border-radius: 8px; }
  .my-todos .today-row { min-height: 52px; }
  .preview-meta { gap: 6px 10px; }
  .preview-meta-item { white-space: normal; }
  .confirm-list .confirm-row { flex-wrap: wrap; gap: 9px; }
  .confirm-button { width: 100%; min-height: 40px; }
  .conn-row .today-actions { margin-left: 17px; }
  .tool-log { margin-left: 32px; }
  .candidate-list { padding-left: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-brief, .chat-brief:active { transition: none; transform: none; }
}

/* 连接失败：状态、时间与原因必须可读（不省略） */
.conn-row .row-main small { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }

[data-project-task][hidden] { display: none; }

.project-tree { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-wrap: anywhere; }
.project-tree ul { margin: 8px 0 4px 7px; padding-left: 16px; border-left: 1px solid var(--line); list-style: none; }
.project-tree li { margin: 8px 0; }
.project-tree summary { cursor: pointer; }

/* 安装入口 */
#install-dialog { max-width: min(32rem, 90vw); border: 1px solid #ddd; border-radius: 14px; padding: 1.5rem; line-height: 1.6; }
#install-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.install-open { font-size: 0.85rem; }

/* Project structure: independent cards keep long names and small screens readable. */
.project-graph-scroll { overflow-x: auto; overscroll-behavior-x: contain; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 20px; }
.project-graph { min-width: max-content; display: flex; flex-direction: column; align-items: center; }
.project-graph-root, .project-graph-branch summary { width: 190px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow-wrap: anywhere; }
.project-graph-root { text-align: center; }
.project-graph-root small, .project-graph-branch summary small { display: block; margin-top: 4px; color: var(--muted); }
.project-graph-branches { display: flex; align-items: flex-start; position: relative; padding-top: 28px; }
.project-graph-branches::before { content: ''; position: absolute; top: 14px; left: 50%; height: 14px; border-left: 1px solid var(--line); }
.project-graph-branch { position: relative; width: 210px; padding: 14px 10px 0; border-top: 1px solid var(--line); }
.project-graph-branch:first-child { border-top-color: transparent; }
.project-graph-branch:first-child::after { content: ''; position: absolute; top: -1px; left: 50%; right: 0; border-top: 1px solid var(--line); }
.project-graph-branch:last-child { border-top-color: transparent; }
.project-graph-branch:last-child::after { content: ''; position: absolute; top: -1px; left: 0; right: 50%; border-top: 1px solid var(--line); }
.project-graph-branch:only-child::after { display: none; }
.project-graph-branch::before { content: ''; position: absolute; top: 0; left: 50%; height: 14px; border-left: 1px solid var(--line); }
.project-graph-branch summary { cursor: pointer; }
.project-graph-tasks { display: grid; gap: 8px; margin: 12px 0 0 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.project-graph-task { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.project-graph-unconfirmed { margin-top: 16px; }
.project-graph-unconfirmed details { margin: 8px 0; }
.project-graph-unconfirmed summary { cursor: pointer; }
.project-graph-empty { margin: 20px 0 0; }

/* 手机首批视觉调整：只作用于今天和工作列表。 */
@media (max-width: 900px) {
  #page-today, #page-work:has(#project-grid) { background: #f3f4f6; padding: 22px 16px 28px; }
  #page-today .page-head, #page-work:has(#project-grid) .page-head { margin-bottom: 22px; }
  #page-today h1, #page-work:has(#project-grid) h1 { font-size: 26px; letter-spacing: -.03em; }
  #page-today .today-date { margin-top: 5px; font-size: 13px; }
  #page-today .delta-line { margin-top: 12px; padding: 12px 14px; border: 0; border-radius: 14px; background: #e9ebef; color: #515761; }
  #page-today .section { margin-top: 24px; }
  #page-today .group-head { margin-bottom: 10px; }
  #page-today .group-title { color: #1c2027; font-size: 15px; font-weight: 700; letter-spacing: 0; }
  #page-today .list, #page-today .empty { border: 0; border-radius: 16px; background: white; box-shadow: 0 2px 10px rgba(27,35,48,.04); overflow: hidden; }
  #page-today .today-row { min-height: 64px; padding: 13px 14px; gap: 12px; }
  #page-today .row-main strong { font-size: 14px; line-height: 1.45; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
  #page-today .row-main small { margin-top: 4px; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
  #page-today .today-row:has(.today-actions) { flex-wrap: wrap; }
  #page-today .today-actions { flex: 0 0 100%; display: flex; flex-wrap: wrap; gap: 8px; padding-left: 19px; }
  #page-today .task-with-calendar .calendar-link { flex: 0 0 auto; }
  #page-today .empty { padding: 18px 14px; line-height: 1.6; }
  #page-work:has(#project-grid) .head-actions { gap: 8px; }
  #page-work:has(#project-grid) .head-actions .sub { color: #747b86; }
  #page-work:has(#project-grid) #new-project { min-height: 42px; border-radius: 14px; }
  #page-work:has(#project-grid) .table-head { display: none; }
  #page-work #project-grid { display: grid; gap: 12px; border: 0; background: transparent; overflow: visible; }
  #page-work #project-grid .project-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 8px; min-height: 122px; padding: 18px; text-align: left; border: 1px solid #dce7ed; border-radius: 18px; background: #e4f1f6; box-shadow: 0 3px 12px rgba(37,54,72,.05); }
  #page-work #project-grid .project-row:nth-child(3n+2) { background: #eeebf8; border-color: #e4dff1; }
  #page-work #project-grid .project-row:nth-child(3n) { background: #e7f2e9; border-color: #d9e9dd; }
  #page-work #project-grid .col-name { min-width: 0; font-size: 17px; font-weight: 700; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
  #page-work #project-grid .col-status { justify-self: end; }
  #page-work #project-grid .col-meta { display: block; color: #555f6b; font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
  #page-work #project-grid .col-owner::before { content: '负责人 · '; }
  #page-work #project-grid .col-due { text-align: right; }
  #page-work #project-grid .col-due::before { content: '截止 · '; }
  #page-work #project-grid .empty { padding: 24px 16px; background: #fff; border-radius: 16px; line-height: 1.6; }
  #page-today button:focus-visible, #page-work button:focus-visible { outline: 3px solid #5e6ad2; outline-offset: 2px; }
}

.notification-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px; border-bottom:1px solid #e8e8e8; }
.notification-row strong,.notification-row small { display:block; overflow-wrap:anywhere; }
.notification-row small { margin-top:6px; color:#666; }
.notification-actions { display:flex; flex-wrap:wrap; gap:8px; flex-shrink:0; }
@media(max-width:600px) { .notification-row { align-items:stretch; flex-direction:column; } .notification-actions button { min-height:44px; } }

#import-preview:not(:empty) { margin-top:16px; padding:16px; border:1px solid var(--line); border-radius:10px; background:var(--surface); scroll-margin-top:70px; }
#import-preview > button { display:block; margin:14px 0; min-height:44px; }
.import-preview-text { max-height:min(55vh, 36rem); overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; padding:12px; border:1px solid var(--line); border-radius:8px; }
