:root {
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-solid: #111a2e;
  --line: rgba(148, 163, 184, 0.22);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --gold: #e6b84c;
  --working: #3b82f6;
  --thinking: #a855f7;
  --needs_me: #ef4444;
  --done: #22c55e;
  --idle: #94a3b8;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; -webkit-tap-highlight-color: transparent; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene.rotate-zone { cursor: ew-resize; }
#scene.dragging { cursor: grabbing; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar { position: fixed; top: calc(12px + var(--safe-t)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.brand, .counts { pointer-events: auto; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #f6d27a, #c8902b); box-shadow: inset 0 0 0 3px rgba(255,255,255,.25); position: relative; flex: none; }
.logo::after { content: "M"; position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; color: #3b2a07; font-size: 18px; }
h1 { margin: 0; font-size: 17px; letter-spacing: .5px; }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--done); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2s infinite; }
.dot.off { background: var(--needs_me); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.55); } 70% { box-shadow: 0 0 0 7px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
#conn { color: #fca5a5; }

.counts { display: flex; gap: 4px; padding: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; font-size: 13px; white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
.st { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.st.working { background: var(--working); } .st.thinking { background: var(--thinking); } .st.needs_me { background: var(--needs_me); }
.st.done { background: var(--done); } .st.idle { background: var(--idle); }
.chip.needs_me.has { background: rgba(239, 68, 68, .18); }

.toolbar { position: fixed; left: 12px; bottom: calc(12px + var(--safe-b)); display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.tb { border: 0; background: transparent; border-radius: 10px; padding: 7px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tb:hover { background: rgba(148,163,184,.15); }
.tb.on { background: rgba(230,184,76,.22); color: #fde68a; }
.tb .ic { font-size: 15px; line-height: 1; }

.banner { position: fixed; top: calc(76px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: rgba(230,184,76,.92); color: #2b1d02; padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; }

.panel { position: fixed; right: 12px; top: calc(80px + var(--safe-t)); bottom: calc(12px + var(--safe-b)); width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; transition: transform .25s ease, opacity .25s; }
.panel.closed { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.panel-head .x { margin-left: auto; }
.x { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.x:hover { color: var(--text); background: rgba(148,163,184,.15); }
.member-list { overflow-y: auto; padding: 0 8px 10px; overscroll-behavior: contain; }
.dept { margin: 10px 6px 4px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dept i { width: 10px; height: 10px; border-radius: 3px; }
.mrow { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 8px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.mrow:hover, .mrow.sel { background: rgba(148,163,184,.14); }
.mrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .lb { font-size: 12px; color: var(--muted); white-space: nowrap; }
.mrow .lb.needs_me { color: #fca5a5; font-weight: 600; }
.mrow .lb.done { color: #86efac; }

.card { position: fixed; left: 12px; bottom: calc(72px + var(--safe-b)); width: 300px; max-height: calc(100vh - 170px); overflow-y: auto; overscroll-behavior: contain; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.card .x { position: absolute; right: 8px; top: 8px; }
.card-name { font-size: 18px; font-weight: 700; }
.card-dept { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-state { margin-top: 10px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(148,163,184,.15); font-size: 13px; }
.card-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: 13px; }
.card-meta dt { color: var(--muted); }
.card-meta dd { margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(2,6,23,.62); display: grid; place-items: center; padding: 16px; z-index: 10; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-box { width: min(460px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 18px; padding: 24px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.wl-hero { font-size: 44px; }
.modal-box h2 { margin: 6px 0 10px; font-size: 21px; }
.modal-box p { line-height: 1.6; margin: 8px 0; font-size: 14px; }
.legend { list-style: none; padding: 0; margin: 14px 0; text-align: left; display: grid; gap: 7px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.primary { border: 0; background: linear-gradient(135deg, #f6d27a, #c8902b); color: #2b1d02; font-weight: 700; padding: 11px 22px; border-radius: 12px; cursor: pointer; font-size: 15px; }
.ghost { border: 1px solid var(--line); background: transparent; padding: 11px 18px; border-radius: 12px; cursor: pointer; font-size: 15px; color: var(--muted); }
.primary:focus-visible, .ghost:focus-visible, .tb:focus-visible, .mrow:focus-visible, .x:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.foot { position: fixed; right: 12px; bottom: calc(10px + var(--safe-b)); pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
body.panel-open .foot { display: none; }

/* work board (left) */
.board { position: fixed; left: 12px; top: calc(80px + var(--safe-t)); bottom: calc(68px + var(--safe-b)); width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; transition: transform .25s ease, opacity .25s; }
.board.closed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.board-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px; padding: 0 8px 10px; }
.bsec { display: flex; flex-direction: column; min-height: 0; }
.sec-projects { flex: 0 1 auto; max-height: 31%; }
.sec-tasks { flex: 1 1 0; min-height: 120px; }
.sec-approvals { flex: 0 1 auto; max-height: 30%; }
.bsec h3 { margin: 8px 6px 4px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; gap: 6px; letter-spacing: .5px; }
.cnt { font-variant-numeric: tabular-nums; background: rgba(148,163,184,.18); color: var(--text); border-radius: 999px; padding: 0 7px; font-size: 11px; line-height: 17px; }
.cnt.alert { background: var(--needs_me); color: #fff; }
.blist { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; }
.brow { display: block; width: 100%; border: 0; background: transparent; text-align: left; padding: 7px 8px; border-radius: 9px; font-size: 13px; line-height: 1.35; color: var(--text); }
button.brow { cursor: pointer; }
button.brow:hover { background: rgba(148,163,184,.14); }
.brow:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.brow .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.brow .m { display: flex; align-items: center; gap: 6px; margin-top: 3px; font-size: 11.5px; color: var(--muted); min-width: 0; }
.brow .m .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brow .m .r { margin-left: auto; white-space: nowrap; }
.proj { display: flex; align-items: center; gap: 8px; }
.proj .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj .lead { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.proj .nums { display: flex; gap: 4px; flex: none; }
.num { font-size: 11px; border-radius: 6px; padding: 1px 6px; background: rgba(59,130,246,.18); color: #bfdbfe; font-variant-numeric: tabular-nums; }
.num.blk { background: rgba(239,68,68,.2); color: #fecaca; }
.num.zero { background: rgba(148,163,184,.12); color: var(--muted); }
.tag { flex: none; font-size: 11px; border-radius: 6px; padding: 1px 6px; font-weight: 600; }
.tag.blocked { background: rgba(239,68,68,.2); color: #fca5a5; }
.tag.in_progress { background: rgba(59,130,246,.2); color: #93c5fd; }
.tag.in_review { background: rgba(168,85,247,.2); color: #d8b4fe; }
.tag.todo { background: rgba(148,163,184,.18); color: #cbd5e1; }
.prio { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 3px; vertical-align: 1px; }
.prio.critical { background: #ef4444; } .prio.high { background: #f97316; } .prio.medium { background: #eab308; } .prio.low { background: #64748b; }
.appr { border-left: 3px solid var(--needs_me); border-radius: 4px 9px 9px 4px; background: rgba(239,68,68,.07); }
.empty { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.more { padding: 4px 10px 2px; font-size: 11.5px; color: var(--muted); }
body.board-open .card { left: 344px; }
.card-work { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.cw-h { font-size: 12px; color: var(--muted); margin: 6px 0 4px; display: flex; align-items: center; gap: 6px; }
.cw-list { display: flex; flex-direction: column; gap: 2px; }
.cw-item { display: flex; align-items: flex-start; gap: 6px; padding: 5px 6px; border-radius: 8px; font-size: 13px; line-height: 1.35; color: var(--text); text-decoration: none; }
a.cw-item:hover { background: rgba(148,163,184,.14); }
.cw-item.now { background: rgba(59,130,246,.12); }
.cw-item .tag { margin-top: 1px; }
.cw-t { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.live { flex: none; font-size: 11px; font-weight: 600; color: #fff; background: var(--working); border-radius: 6px; padding: 1px 6px; margin-top: 1px; }
.cw-empty { font-size: 12.5px; color: var(--muted); padding: 3px 6px; }
.card-chat { display: block; margin-top: 10px; text-align: center; padding: 9px 12px; border-radius: 10px; background: linear-gradient(135deg, #f6d27a, #c8902b); color: #2b1d02; font-weight: 700; font-size: 14px; text-decoration: none; }
.card-chat:hover { filter: brightness(1.06); }
a.brow { text-decoration: none; cursor: pointer; }
a.brow:hover { background: rgba(239,68,68,.14); }
.card-chat:focus-visible, .cw-item:focus-visible, a.brow:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (max-width: 760px) {
  .topbar { left: 8px; right: 8px; top: calc(8px + var(--safe-t)); flex-direction: column; gap: 6px; }
  .brand { padding: 8px 12px; }
  h1 { font-size: 15px; }
  .counts { justify-content: flex-start; padding: 4px; }
  .chip { padding: 4px 7px; font-size: 12px; gap: 4px; }
  .toolbar { left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); justify-content: space-between; }
  .tb { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; }
  .banner { top: auto; bottom: calc(76px + var(--safe-b)); font-size: 12px; white-space: nowrap; }
  .panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(70px + var(--safe-b)); height: 52vh; }
  .panel.closed { transform: translateY(calc(100% + 90px)); }
  .card, body.board-open .card { left: 8px; right: 8px; width: auto; bottom: calc(70px + var(--safe-b)); max-height: 58vh; }
  .board { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(70px + var(--safe-b)); height: 60vh; }
  .board.closed { transform: translateY(calc(100% + 90px)); }
  .board-body { overflow-y: auto; overscroll-behavior: contain; }
  .bsec { max-height: none !important; flex: none !important; min-height: 0 !important; }
  .blist { overflow: visible; }
  .sec-approvals { order: -1; }
  .foot { display: none; }
}
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } .panel, .board { transition: none; } }
