:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1f; --muted: #6e6e73; --line: #e5e3de;
  --accent: #e8711a; --accent-ink: #ffffff; --accent-soft: #fdf0e6;
  --ok: #1f8a4c; --ok-soft: #e6f4ec; --warn: #b25e00; --warn-soft: #fff4e0;
  --bad: #c62828; --bad-soft: #fdecec; --info: #2e5597; --info-soft: #eaf0fa;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --card: #1e1e1f; --text: #f2f2f2; --muted: #a1a1a6; --line: #333335;
    --accent: #f08a3c; --accent-ink: #1a1a1a; --accent-soft: #3a2616;
    --ok: #5cc98a; --ok-soft: #173325; --warn: #f0b056; --warn-soft: #3a2c12;
    --bad: #ff7b7b; --bad-soft: #3d1c1c; --info: #8fb0ea; --info-soft: #1b2638;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--info); }

.shell { max-width: 760px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }
header.top { position: sticky; top: 0; z-index: 5; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 0 10px; }
header.top h1 { font-size: 20px; margin: 0; flex: 1; letter-spacing: .5px; }
header.top .sub { color: var(--muted); font-size: 13px; font-weight: 400; margin-left: 6px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 600; cursor: pointer; }

nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
nav.tabs a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 11px; padding: 4px 0; position: relative; }
nav.tabs a svg { display: block; margin: 0 auto 2px; width: 24px; height: 24px; }
nav.tabs a.on { color: var(--accent); }
nav.tabs a.mic { margin-top: -22px; }
nav.tabs a.mic span.b { display: flex; width: 54px; height: 54px; margin: 0 auto 2px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; box-shadow: 0 4px 14px rgba(232,113,26,.35); }
nav.tabs a.mic svg { width: 28px; height: 28px; margin: 0; }
.badge { position: absolute; top: 0; left: 50%; margin-left: 6px; background: var(--bad); color: #fff; border-radius: 9px; font-size: 10px; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin: 10px 0; border: 1px solid var(--line); }
.card.tight { padding: 10px 12px; }
.sec { margin: 18px 0 6px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.sec b { color: var(--text); font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--info-soft); color: var(--info); margin-right: 4px; white-space: nowrap; }
.tag.stage { background: var(--accent-soft); color: var(--accent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }

.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.task:last-child { border-bottom: 0; }
.task .chk { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 1px; background: transparent; cursor: pointer; padding: 0; }
.task .chk.done { background: var(--ok); border-color: var(--ok); }
.task .t { font-size: 15px; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.overdue { color: var(--bad) !important; }

.proj { cursor: pointer; }
.proj h3 { margin: 0 0 4px; font-size: 16px; }
.proj .ns { font-size: 13px; margin-top: 6px; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
input.i, select.i, textarea.i { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 12px; outline: none; }
input.i:focus, select.i:focus, textarea.i:focus { border-color: var(--accent); }
textarea.i { resize: vertical; min-height: 120px; }

.talk-box { position: relative; }
.talk-box textarea { min-height: 170px; font-size: 16px; padding-bottom: 56px; }
.micbtn { position: absolute; right: 10px; bottom: 10px; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.micbtn.rec { background: var(--bad); animation: pulse 1.2s infinite; color: #fff; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(198,40,40,.15); } }

.item { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.item .k { font-size: 12px; font-weight: 600; letter-spacing: .5px; }
.item.off { opacity: .45; }
.diff { font-size: 13px; margin: 3px 0; }
.diff del { color: var(--muted); }
.diff ins { text-decoration: none; color: var(--ok); font-weight: 600; }
.conflict { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 6px 8px; font-size: 12px; margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.msg { margin: 12px 0; }
.msg.user { text-align: right; }
.msg.user .bubble { display: inline-block; background: var(--accent); color: var(--accent-ink); border-radius: 14px 14px 4px 14px; padding: 8px 12px; max-width: 85%; text-align: left; white-space: pre-wrap; }
.msg.ai .bubble { background: var(--card); border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; padding: 10px 14px; overflow-x: auto; }
.chatbar { position: fixed; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 16px; }
.chatbar .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.chatbar textarea { min-height: 44px; max-height: 140px; }

.md h1 { font-size: 19px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md h1, .md h2, .md h3 { margin: 14px 0 6px; }
.md p { margin: 6px 0; }
.md ul, .md ol { padding-left: 20px; margin: 6px 0; }
.md table { border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--info-soft); }
.md code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
.sheet h2 { margin: 0 0 8px; font-size: 18px; }

#toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 20px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 30; max-width: 88vw; text-align: center; }
#toast.show { opacity: 1; }

.login { max-width: 380px; margin: 0 auto; padding: 18vh 16px 0; }
.login .logo { width: 64px; height: 64px; border-radius: 18px; margin-bottom: 12px; }
.login h1 { margin: 0 0 4px; }
.timeline { border-left: 2px solid var(--line); margin-left: 6px; padding-left: 12px; }
.timeline div { margin: 0 0 8px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 6px 0; }
.pipeline div { background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: 6px 2px; font-size: 12px; color: var(--muted); cursor: pointer; }
.pipeline div b { display: block; font-size: 18px; color: var(--text); }
.pipeline div.on { border-color: var(--accent); color: var(--accent); }
.chatbar .btn { flex: none; white-space: nowrap; }

.attach-row { display: none; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--card); display: inline-flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; line-height: 20px; padding: 0; cursor: pointer; }
.micbtn.clip { right: 64px; background: var(--card); color: var(--text); border: 1px solid var(--line); }
.chatbar .inner-col { max-width: 760px; margin: 0 auto; }
.chatbar .inner-col .inner { max-width: none; }
.chatbar .chips { margin-bottom: 6px; }
.msg.user .thumbs { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 4px; }
.msg.user .thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
