:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e3e8ef;
  --line-soft: #eef2f7;
  --panel: #ffffff;
  --bg: #f5f7fa;
  --viewer-bg: #eaedf2;
  --accent: #3b5bdb;
  --accent-2: #3350c7;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #0f9f6e;
  --warn: #c2760a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .06);
  --radius: 10px;
  --radius-sm: 7px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; }

/* Keyboard users get a visible ring; mouse users do not. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus:not(:focus-visible), input:focus:not(:focus-visible), select:focus:not(:focus-visible) { outline: none; }

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 16px; height: 16px; flex: none; display: block; }

.app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }

/* ------------------------------- topbar ------------------------------- */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 10px; width: 252px; flex: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(145deg, #4c6ef5, #2f4bbf);
  color: #fff; font-weight: 700; font-size: 17px;
  display: grid; place-items: center;
  box-shadow: 0 3px 8px rgba(59, 91, 219, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14px; letter-spacing: .2px; }
.brand-text span { font-size: 10.5px; color: var(--faint); }

.doc-head { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.doc-name {
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw;
}
.doc-meta { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.team-doc-switch {
  width: auto; max-width: 178px; height: 27px; padding: 2px 24px 2px 8px;
  font-size: 11.5px; color: var(--ink-2); align-self: center;
}

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }

.search {
  position: relative; display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 8px 0 9px; border: 1px solid var(--line); border-radius: 8px;
  background: #fbfcfe; color: var(--faint); width: 210px; transition: border-color .15s, background .15s;
}
.search:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(59,91,219,.08); }
.search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 12px; color: var(--ink); }
.search input::placeholder { color: var(--faint); }
.search-clear { width: 18px; height: 18px; border-radius: 50%; color: var(--muted); font-size: 14px; line-height: 1; display: grid; place-items: center; }
.search-clear:hover { background: var(--line-soft); color: var(--ink); }
.search-results {
  position: absolute; top: 38px; right: 0; width: 380px; max-height: 420px; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 6px; z-index: 60;
}
.search-results .sr-head { font-size: 10.5px; color: var(--faint); padding: 4px 8px 6px; }
.search-hit-row { display: flex; gap: 8px; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.search-hit-row:hover { background: #f5f8ff; }
.search-hit-page { flex: none; font-size: 10px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 1px 5px; height: 17px; }
.search-hit-text { font-size: 11.5px; color: var(--ink-2); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-hit-text mark { background: #fff2a8; color: #7a4b00; padding: 0 1px; border-radius: 2px; }
.search-empty { padding: 14px 10px; font-size: 11.5px; color: var(--faint); text-align: center; }

.presence { display: flex; align-items: center; margin-right: 4px; }
.presence .p-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  color: #fff; font-size: 11px; font-weight: 600;
  display: grid; place-items: center;
  border: 2px solid #fff; margin-left: -7px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.presence .p-avatar:first-child { margin-left: 0; }
.presence .p-avatar.following { box-shadow: 0 0 0 2px var(--accent), var(--shadow-sm); }
.follow-btn {
  margin-left: 8px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 11px; white-space: nowrap;
}
.follow-btn:hover { border-color: var(--accent); color: var(--accent); }
.follow-btn.active { background: var(--accent-soft); border-color: #c9d5ff; color: var(--accent); }
.follow-bar { display: none; }
.presence .p-avatar::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
  border: 1.5px solid #fff;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  background: var(--panel); border: 1px solid var(--line);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #d3dbe6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(59, 91, 219, .25); }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary:disabled, .btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: transparent; }
.btn.tiny { height: 26px; padding: 0 9px; font-size: 11.5px; }
.btn.danger { color: var(--danger); border-color: #f3d1d1; background: var(--danger-soft); }

.avatar-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 12px; border: 1px solid #dde4ff;
}
.avatar-btn:hover { background: #e3e9ff; }

/* ------------------------------ workspace ----------------------------- */
.workspace { flex: 1; min-height: 0; display: flex; }

.rail {
  width: 252px; flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px; }
.rail-title { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .3px; }
.rail-title .count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--line-soft); border-radius: 9px; font-size: 10.5px; color: var(--muted);
  text-align: center; line-height: 17px;
}
.icon-btn {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  color: var(--muted); border: 1px solid transparent;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }

.upload-hint {
  margin: 0 12px 10px; padding: 9px 10px;
  border: 1px dashed #cfd8e6; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 11.5px; cursor: pointer;
  background: #fbfcfe; transition: border-color .15s, background .15s;
}
.upload-hint:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.doc-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; }
.doc-item {
  display: flex; gap: 9px; padding: 8px; border-radius: 8px;
  cursor: pointer; position: relative; border: 1px solid transparent;
}
.doc-item:hover { background: #f8fafc; }
.doc-item.active { background: var(--accent-soft); border-color: #dbe2ff; }
.doc-thumb {
  width: 34px; height: 44px; flex: none; border-radius: 4px; overflow: hidden;
  background: #fff; border: 1px solid var(--line); display: grid; place-items: center;
  color: #c4cfe0;
}
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.doc-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; justify-content: center; }
.doc-title {
  font-size: 12px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-sub { font-size: 10.5px; color: var(--faint); display: flex; gap: 6px; align-items: center; }
.doc-badge { padding: 0 4px; border-radius: 3px; background: var(--line-soft); font-size: 9.5px; color: var(--muted); }
.doc-item .row-actions { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: none; }
.doc-item:hover .row-actions { display: flex; }
.doc-empty { padding: 22px 12px; text-align: center; color: var(--faint); font-size: 11.5px; line-height: 1.8; }

.rail-foot { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.rail-link {
  display: flex; align-items: center; gap: 7px; width: 100%; padding: 7px 8px;
  border-radius: 7px; color: var(--ink-2); font-size: 12px; text-align: left;
}
.rail-link:hover { background: var(--line-soft); }
.rail-badge { margin-left: auto; font-size: 9.5px; color: var(--accent); background: var(--accent-soft); border-radius: 9px; padding: 0 6px; line-height: 16px; }
.rail-badge:empty { display: none; }

.rail-version { font-size: 10px; color: #b6c0cf; padding-left: 8px; }
.rail-icp { padding-left: 8px; font-size: 10px; color: var(--faint); text-decoration: none; }
.rail-icp:hover { color: var(--accent); text-decoration: underline; }

/* -------------------------------- stage ------------------------------- */
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--viewer-bg); }

.toolbar {
  height: 46px; flex: none; display: flex; align-items: center; gap: 8px;
  padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line);
  overflow: hidden;
}
/* Tools may scroll horizontally; the zoom cluster must never be pushed off. */
.toolbar-main {
  display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.toolbar-main::-webkit-scrollbar { display: none; }
/* Fade the right edge only when there is more to scroll, so a half-cut button
   reads as "scrollable" instead of "broken". */
.toolbar-main.scrollable { mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent); }
.toolbar-right { display: flex; align-items: center; gap: 6px; flex: none; }
.tool-group { display: flex; align-items: center; gap: 2px; }
.toolbar-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }
.color-tools { display: flex; align-items: center; }
.color-pick { display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 11.5px; color: var(--muted); }
.color-pick span { white-space: nowrap; }
.color-pick input[type="color"] {
  width: 28px; height: 28px; padding: 2px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; cursor: pointer;
}
.color-pick input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-pick input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.pen-size { display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 11.5px; color: var(--muted); }
.pen-size input[type="range"] { width: 64px; accent-color: var(--accent); }
.pen-size #penSizeLabel { min-width: 12px; text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.toolbar-spacer { flex: 1 1 6px; min-width: 0; }
.page-indicator, .zoom, .conn { flex: none; }

.tool {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px;
  border-radius: 7px; color: var(--muted); font-size: 12px; white-space: nowrap;
  border: 1px solid transparent;
}
.tool:hover { background: #f5f7fa; color: var(--ink-2); }
.tool.active { background: var(--accent-soft); color: var(--accent); border-color: #dbe2ff; font-weight: 500; }
.tool span { font-size: 11.5px; }

.page-indicator { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; padding: 0 8px; }

.conn {
  font-size: 10.5px; padding: 3px 8px; border-radius: 20px; margin-right: 6px;
  background: var(--line-soft); color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 5px;
}
.conn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #cbd5e1; }
.conn.online { background: #f0fbf6; color: #0b7a56; }
.conn.online::before { background: #12a67c; box-shadow: 0 0 0 3px rgba(18, 166, 124, .12); }
.conn.connecting::before { background: #f59e0b; }
.conn.offline, .conn.error { background: #fff7ed; color: #b45309; }
.conn.offline::before, .conn.error::before { background: #f59e0b; }
.zoom { display: flex; align-items: center; gap: 4px; position: relative; }
.zoom span { font-size: 11.5px; color: var(--ink-2); min-width: 38px; text-align: center; font-variant-numeric: tabular-nums; }
.zoom-value {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  height: 28px; min-width: 58px; padding: 0 6px; border: 1px solid transparent;
  border-radius: 7px; background: transparent; color: var(--ink-2);
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.zoom-value:hover { background: #f5f7fa; }
.zoom-value[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent); border-color: #dbe2ff; }
.zoom #zoomLabel { min-width: 34px; text-align: center; }
.zoom .zoom-caret { width: 12px; height: 12px; color: var(--faint); flex: none; }
.zoom-menu {
  /* Fixed so the toolbar's overflow:hidden cannot clip the popover; app.js
     positions it under the percentage button on open. */
  position: fixed; top: 0; left: 0; z-index: 60; width: 136px;
  display: flex; flex-direction: column; padding: 4px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.zoom-menu.hidden { display: none; }
.zoom-menu-item {
  display: flex; align-items: center; justify-content: space-between;
  height: 30px; padding: 0 10px; border-radius: 6px; font-size: 12px;
  color: var(--ink-2); text-align: left;
}
.zoom-menu-item:hover { background: #f5f7fa; }
.zoom-menu-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.zoom-menu-item.active::after { content: "✓"; font-size: 11px; }
.zoom-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

.viewer { flex: 1; min-height: 0; overflow: auto; position: relative; }
.pages { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: 22px 16px 80px; }

.page {
  position: relative; background: #fff; box-shadow: var(--shadow-md);
  border-radius: 2px; flex: none;
  /* Auto margins center a page that fits but leave an oversized (zoomed-in)
     page anchored at the left edge, so the viewer can scroll to its right side. */
  margin: 0 auto;
  transition: box-shadow .15s;
  /* Off-screen page shells skip style/layout/paint work; the intrinsic size
     below preserves the scroll range for long documents. */
  content-visibility: auto;
}
.page.current { box-shadow: 0 0 0 2px rgba(59, 91, 219, .55), var(--shadow-md); }
.page canvas { display: block; width: 100%; height: 100%; border-radius: 2px; }
.page-num {
  position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%);
  font-size: 10.5px; color: #93a0b5; font-variant-numeric: tabular-nums;
}
.page-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; font-size: 11px; pointer-events: none; }
.page-placeholder[hidden] { display: none; }

.overlay { position: absolute; inset: 0; pointer-events: none; }
.overlay.interactive { pointer-events: auto; }
/* Drawing must win over panning on touch screens. Select mode is untouched so
   vertical page scrolling still works. */
.pages[data-mode="highlight"] .overlay,
.pages[data-mode="ink"] .overlay,
.pages[data-mode="line"] .overlay,
.pages[data-mode="eraser"] .overlay,
.pages[data-mode="signature"] .overlay { touch-action: none; }
.pages[data-mode="eraser"] .overlay { cursor: cell; }
/* Invisible, wider hit stroke so a thin ink line is easy to erase by touch. */
.annot-hit { pointer-events: stroke; }
.overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.annot-rect { fill-opacity: .35; stroke: none; }
.search-rect { fill: #ffe066; fill-opacity: .38; stroke: #f2b705; stroke-width: .8; }
.search-rect.active { fill-opacity: .6; stroke-width: 1.4; }
.annot-ink { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.annot-node { position: absolute; pointer-events: auto; }
.annot-note {
  position: absolute; width: 22px; height: 22px; border-radius: 50% 50% 50% 4px;
  background: #f59e0b; color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  transform: translate(-50%, -100%); cursor: pointer;
}
.annot-textbox {
  position: absolute; background: rgba(255, 255, 255, .92); outline: 1px dashed #c7d2e3;
  color: var(--ink); line-height: 1.25; overflow: hidden;
}
.annot-textbox.edit { outline: 1.5px solid var(--accent); background: #fff; }
.annot-float-tip {
  position: absolute; padding: 5px 9px; background: #1e293b; color: #fff;
  border-radius: 6px; font-size: 11px; max-width: 240px; z-index: 5;
  box-shadow: var(--shadow-md);
}
.annot-selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.draft-layer, .cursor-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.cursor-layer { z-index: 7; }
.remote-cursor { position: absolute; display: flex; align-items: flex-start; transform: translate(-2px, -2px); transition: left .08s linear, top .08s linear; }
.remote-cursor span {
  font-size: 9.5px; color: #fff; padding: 1px 5px; border-radius: 0 4px 4px 4px;
  white-space: nowrap; margin: 9px 0 0 -1px; box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.draft-box {
  position: absolute; border: 1.5px dashed; border-radius: 3px; background: rgba(255,255,255,.92);
  padding: 0 2px; white-space: pre; color: #111827; line-height: 1.2;
}
.draft-caret { display: inline-block; width: 1.5px; height: 1em; vertical-align: -2px; animation: caretBlink 1s steps(2) infinite; }
@keyframes caretBlink { 50% { opacity: 0; } }
.draft-tag {
  position: absolute; left: 0; top: -16px; font-size: 9px; font-weight: 500; color: #fff;
  padding: 1px 5px; border-radius: 4px; white-space: nowrap;
}

.text-hit {
  position: absolute; border-radius: 2px; cursor: text;
  background: rgba(59, 91, 219, .001);
}
.text-hit:hover { background: rgba(59, 91, 219, .12); box-shadow: inset 0 0 0 1px rgba(59, 91, 219, .5); }

.textedit-input {
  position: absolute; z-index: 8; border: 1.5px solid var(--accent);
  border-radius: 3px; padding: 2px 4px; background: #fff;
  box-shadow: var(--shadow-md); outline: none; resize: none;
  font-family: inherit; line-height: 1.2; color: var(--ink);
}

.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 24px;
}
.empty-state.hidden { display: none; }
.empty-art { opacity: .9; margin-bottom: 4px; }
.empty-state h2 { font-size: 17px; color: var(--ink-2); }
.empty-state p { font-size: 12.5px; color: var(--muted); max-width: 420px; line-height: 1.7; }
.empty-actions { display: flex; gap: 8px; margin-top: 8px; }
.cap-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 18px; max-width: 520px; }
.cap-chip {
  font-size: 10.5px; padding: 4px 8px; border-radius: 20px;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
}
.cap-chip.ok { color: #0b7a56; border-color: #cdeee1; background: #f2fbf7; }
.cap-chip.warn { color: #a16207; border-color: #fde9c3; background: #fffbf0; }

/* ------------------------------ inspector ----------------------------- */
.inspector {
  width: 320px; flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
}
.inspector-tabs { display: flex; gap: 2px; padding: 8px 10px 0; border-bottom: 1px solid var(--line); }
.itab {
  padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.itab:hover { color: var(--ink-2); }
.itab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.inspector-body { flex: 1; min-height: 0; overflow-y: auto; }
.tabpane { display: none; padding: 12px; }
.tabpane.active { display: block; }
.pane-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pane-head span:first-child { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.pane-head .hint { font-size: 10.5px; color: var(--faint); }
.doc-notes-head-actions { display: flex; align-items: center; gap: 4px; }
.doc-notes-head-actions .icon-btn { width: 22px; height: 22px; border-radius: 5px; }
.doc-notes-head-actions .icon-btn .ico { width: 13px; height: 13px; }

.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.thumb {
  position: relative; border: 1.5px solid transparent; border-radius: 6px;
  cursor: grab; background: #f8fafc; padding: 4px;
  transition: border-color .15s, transform .12s;
}
.thumb:hover { border-color: #cdd8e8; }
.thumb.current { border-color: var(--accent); }
.thumb.dragging { opacity: .4; }
.thumb.drop-target { border-color: var(--accent); border-style: dashed; }
.thumb-frame {
  position: relative; width: 100%; aspect-ratio: 1 / 1.414; overflow: hidden;
  display: grid; place-items: center; background: #fff; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}
.thumb-frame img, .thumb-frame canvas { width: 100%; height: 100%; object-fit: contain; display: block; transition: transform .18s ease; }
.thumb-frame.rot90 img, .thumb-frame.rot90 canvas, .thumb-frame.rot270 img, .thumb-frame.rot270 canvas { transform: rotate(90deg) scale(.707); }
.thumb-frame.rot180 img, .thumb-frame.rot180 canvas { transform: rotate(180deg); }
.thumb-frame .thumb-skeleton { position: absolute; inset: 0; aspect-ratio: auto; border-radius: 0; }
.thumb .t-num {
  position: absolute; left: 6px; bottom: 6px; background: rgba(15, 23, 42, .72);
  color: #fff; font-size: 9.5px; padding: 1px 5px; border-radius: 8px;
}
.thumb .t-rot {
  position: absolute; right: 6px; top: 6px; background: rgba(59, 91, 219, .9);
  color: #fff; font-size: 9px; padding: 1px 4px; border-radius: 4px;
}
.thumb .t-tools {
  position: absolute; inset: auto 4px 4px auto; display: flex; gap: 2px; opacity: 0;
  transition: opacity .15s;
}
.thumb:hover .t-tools { opacity: 1; }
.thumb .t-del, .thumb .t-move {
  width: 20px; height: 20px; border-radius: 4px; background: rgba(255, 255, 255, .95);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.thumb .t-del { color: var(--danger); }
.thumb .t-move { color: var(--ink-2); }
.thumb .t-move:disabled { opacity: .35; cursor: default; }
.thumb-skeleton { aspect-ratio: 1 / 1.414; background: linear-gradient(100deg, #f1f5f9 30%, #e8eef6 50%, #f1f5f9 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.annot-list { display: flex; flex-direction: column; gap: 8px; }
.annot-orphan {
  margin-top: 10px; padding: 9px 10px; border-radius: 8px; border: 1px dashed #e6c9a8;
  background: #fffbf3; color: #9a6b1f; font-size: 10.5px; line-height: 1.6;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.annot-orphan .btn { color: #9a6b1f; border-color: #eddcc2; }

.annot-empty { color: var(--faint); font-size: 11.5px; text-align: center; padding: 18px 8px; line-height: 1.8; }
.annot-card {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  display: flex; gap: 8px; align-items: flex-start; background: #fff;
}
.annot-card:hover { border-color: #cfd9e8; }
.annot-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.annot-main { flex: 1; min-width: 0; }
.annot-title { font-size: 11.5px; font-weight: 500; color: var(--ink-2); display: flex; gap: 6px; align-items: center; }
.annot-sub { font-size: 10.5px; color: var(--faint); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.annot-card .del { color: var(--faint); padding: 2px; border-radius: 4px; }
.annot-card .del:hover { color: var(--danger); background: var(--danger-soft); }

.tool-section { margin-bottom: 18px; }
.tool-section h3 { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .4px; margin-bottom: 7px; padding-left: 2px; }
.tool-card {
  width: 100%; display: flex; gap: 10px; align-items: center;
  padding: 10px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; text-align: left; margin-bottom: 6px;
  transition: border-color .15s, background .15s, transform .1s;
}
.tool-card:hover { border-color: #c9d5e8; background: #fbfcfe; }
.tool-card:active { transform: scale(.995); }
.tool-card .ico { color: var(--accent); width: 18px; height: 18px; }
.tool-card div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tool-card strong { font-size: 12px; font-weight: 500; color: var(--ink); }
.tool-card span { font-size: 10.5px; color: var(--faint); }
.tool-card.danger .ico { color: var(--danger); }
.tool-card.danger:hover { border-color: #f3c6c6; background: var(--danger-soft); }

/* -------------------------------- modal ------------------------------- */
.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(2px); display: grid; place-items: center; pointer-events: auto;
  animation: fade .16s ease;
  padding: 24px;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(520px, calc(100vw - 32px)); max-width: 100%; max-height: 86vh;
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.1); overflow: hidden;
}
.modal.wide { width: min(680px, calc(100vw - 32px)); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; }
.modal-head h2 { font-size: 15px; }
.modal-head p { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.modal-body { padding: 4px 18px 16px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px;
  border-top: 1px solid var(--line); background: #fcfdff;
}
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 91, 219, .1); }
.textarea { min-height: 150px; resize: vertical; line-height: 1.6; font-family: inherit; }
.help { font-size: 10.5px; color: var(--faint); margin-top: 4px; line-height: 1.5; }
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-chip {
  padding: 7px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 11.5px; color: var(--ink-2); background: #fff; display: flex; gap: 6px; align-items: center;
}
.radio-chip.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.radio-chip input { display: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { padding: 8px 10px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.tab-body { display: none; }
.tab-body.active { display: block; }

.progress { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s ease; border-radius: 3px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 3px; background: #fcfdff;
}
.stat-label { font-size: 10.5px; color: var(--faint); }
.stat-value { font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 10px; color: var(--muted); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.admin-table th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 10.5px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); background: #fbfcfe;
}
.admin-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.admin-table tr:last-child td { border-bottom: none; }

.form-group-title {
  font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: .3px;
  margin: 14px 0 6px; padding-bottom: 5px; border-bottom: 1px solid var(--line-soft);
}
.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.form-row-inline { flex-direction: row; align-items: center; gap: 8px; }
.form-row-inline .form-label { flex-direction: row; align-items: center; gap: 7px; margin: 0; }
.form-label { display: flex; align-items: baseline; gap: 6px; font-size: 11.5px; color: var(--muted); }
.form-label > span:first-child { color: var(--ink-2); font-size: 12px; }
.form-required { font-size: 9px; color: var(--danger); background: var(--danger-soft); border-radius: 3px; padding: 0 4px; font-weight: 500; }

.version-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line-soft); }
.version-row:last-child { border-bottom: none; }
.version-main { flex: 1; min-width: 0; }
.version-title { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.version-title strong { font-size: 12.5px; }
.version-actions { display: flex; gap: 6px; align-items: center; flex: none; }

.job-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 11.5px; }
.job-row:last-child { border-bottom: none; }
.job-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.job-status { font-size: 10.5px; color: var(--faint); }
.job-status.done { color: var(--ok); }
.job-status.failed { color: var(--danger); }

.sig-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.sig-canvas { display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair; }

.user-card { display: flex; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; }
.user-card .avatar-btn { width: 38px; height: 38px; font-size: 14px; }
.user-card strong { font-size: 13px; display: block; }
.user-card span { font-size: 11px; color: var(--faint); }

.team-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.team-row:last-child { border-bottom: none; }
.team-name { font-size: 12.5px; }
.team-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.team-code { font-size: 11px; color: var(--muted); background: var(--line-soft); padding: 2px 6px; border-radius: 4px; letter-spacing: 1px; }
.team-space-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.team-space-head .help { line-height: 1.6; }
.team-card { border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px 10px; margin-bottom: 12px; background: #fff; }
.team-card .team-row { border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
.team-head-main { min-width: 0; }
.team-head-main .team-name { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.team-code-line { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.team-code-line .btn { padding: 1px 6px; font-size: 10px; }
.team-section { margin-top: 10px; }
.team-section-title { display: flex; align-items: center; justify-content: space-between; color: var(--faint); font-size: 10.5px; letter-spacing: .04em; margin-bottom: 4px; }
.team-member { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line-soft); min-width: 0; }
.team-member:last-of-type { border-bottom: none; }
.member-avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; color: #fff; font-size: 10.5px; font-weight: 600; }
.member-main { min-width: 0; flex: 1; }
.member-name { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink); }
.member-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-size: 10.5px; }
.member-role { width: auto; min-width: 66px; padding: 3px 22px 3px 8px; font-size: 11px; }
.team-member .icon-btn { width: 26px; height: 26px; flex: none; color: var(--danger); }
.team-invite { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.team-invite .input { flex: 1; min-width: 0; }
.team-invite .select { width: auto; }
.team-invite .btn { flex: none; }
.team-file { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 8px; margin-bottom: 5px; border: 1px solid var(--line-soft); border-radius: 7px; background: #fff; text-align: left; }
.team-file:hover { border-color: var(--accent); background: var(--accent-soft); }
.team-file-main { min-width: 0; }
.team-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12px; }
.team-file-sub { color: var(--faint); font-size: 10.5px; }
.team-empty { color: var(--faint); font-size: 11.5px; padding: 6px 0; }
.team-add-docs { margin-top: 9px; border-top: 1px dashed var(--line-soft); padding-top: 8px; }
.team-add-docs summary { cursor: pointer; color: var(--accent); font-size: 11.5px; list-style: none; }
.team-add-docs summary::-webkit-details-marker { display: none; }
.team-add-docs summary::before { content: '+ '; }
.team-pick-list { max-height: 190px; overflow: auto; margin-top: 6px; }
.team-pick { display: flex; align-items: flex-start; gap: 8px; padding: 5px 2px; font-size: 11.5px; }
.team-pick input { flex: none; margin-top: 2px; }
.team-pick.disabled { opacity: .55; }
.team-pick-main { min-width: 0; }
.team-pick-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-pick-sub { color: var(--faint); font-size: 10px; line-height: 1.5; }
.team-pick-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.team-add-docs .help { margin-top: 5px; line-height: 1.6; }
.team-create { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 12px; }
.team-create .field { margin-bottom: 8px; }
.team-create .help { line-height: 1.7; }
.doc-badge.muted { color: var(--faint); }

/* -------------------------------- toast ------------------------------- */
.toast-root { position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1e293b; color: #fff; font-size: 12px; padding: 9px 14px; border-radius: 8px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn .2s ease; max-width: 460px;
}
.toast.ok { background: #0b7a56; }
.toast.err { background: #b91c1c; }
.toast .ico { width: 14px; height: 14px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------- dropzone ----------------------------- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 150; background: rgba(59, 91, 219, .1);
  display: none; place-items: center; pointer-events: none;
  backdrop-filter: blur(1px);
}
.drop-overlay.show { display: grid; }
.drop-card {
  background: #fff; border: 2px dashed var(--accent); border-radius: 16px;
  padding: 28px 40px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); color: var(--accent);
}
.drop-card .ico { width: 30px; height: 30px; }
.drop-card strong { font-size: 15px; }
.drop-card span { font-size: 11.5px; color: var(--muted); }

/* ------------------------------ utilities ----------------------------- */
.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); display: inline-block; }

@media (max-width: 1500px) {
  /* Undo/redo + search made the toolbar tight on 1366/1440 laptops: drop the
     text labels first, icons keep working and titles explain them on hover. */
  .tool span { display: none; }
  .tool { padding: 0 8px; }
  .search { width: 172px; }
  .brand { width: 208px; }
}

@media (max-width: 1180px) {
  .rail { width: 210px; }
  .inspector { width: 264px; }
  .brand { width: 190px; }
  .search { width: 148px; }
  #btnFit { display: none; }
}
/* ------------------------------ mobile ------------------------------- */
.mobile-only { display: none; }
.drawer-backdrop {
  position: fixed; left: 0; right: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: 0;
  background: rgba(15, 23, 42, .38); z-index: 24; opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

@media (max-width: 980px) {
  .mobile-only { display: inline-flex; }
  .brand { width: auto; }
  .brand-text span { display: none; }
  .doc-head { display: none; }
  .search { width: 132px; }

  .rail {
    position: fixed; left: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: 0;
    width: min(268px, 82vw);
    z-index: 26; transform: translateX(-103%); transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .rail.open { transform: none; }
  .rail-foot { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }

  .inspector {
    position: fixed; right: 0; top: calc(var(--topbar-h) + env(safe-area-inset-top)); bottom: 0;
    width: min(300px, 88vw);
    z-index: 26; display: flex; transform: translateX(103%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .inspector.open { transform: none; }
}

@media (max-width: 760px) {
  .tool span { display: none; }
  .tool { padding: 0 7px; }
  .search { width: 108px; }
  .search input { font-size: 11.5px; }
  .page-indicator { display: none; }
  /* Keep a compact zoom control on phones (the collaboration text is the part
     that must yield width there); the fit-width text button lives in the
     percentage menu instead of the toolbar. */
  .conn { display: none; }
  .zoom { display: flex; gap: 1px; }
  .zoom #btnFit { display: none; }
  .zoom-value { min-width: 48px; padding: 0 4px; }
  .topbar { gap: 6px; padding: env(safe-area-inset-top) 8px 0; }
  .pages { padding: 14px 8px 72px; gap: 14px; }
  .toast { max-width: calc(100vw - 32px); }

  /* The search dropdown is anchored to a narrow input; pin it to the viewport
     so long hit text never overflows a phone screen. */
  .search-results {
    position: fixed; left: 10px; right: 10px;
    /* Below the toolbar, so search results never block the editing tools. */
    top: calc(var(--topbar-h) + env(safe-area-inset-top) + 50px);
    width: auto; max-height: 60dvh;
  }

  .follow-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 0 10px; }
  .follow-bar .btn { width: auto; }
  .modal-backdrop { padding: 12px; }
  .modal, .modal.wide { width: calc(100vw - 24px); max-height: 90dvh; }
  .modal-head, .modal-body { padding-left: 14px; padding-right: 14px; }
  .modal-foot { padding: 10px 14px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .team-space-head { flex-direction: column; align-items: stretch; }
  .team-space-head .btn { align-self: flex-start; }
  .team-card .team-row { flex-wrap: wrap; }
  .team-head-main { width: 100%; }
  .team-actions { width: 100%; justify-content: flex-start; }
  .team-invite { flex-wrap: wrap; }
  .team-invite .input { flex: 1 1 100%; }
  .team-invite .select, .team-invite .btn { flex: 1 1 auto; }
  .team-member { flex-wrap: wrap; }
  .member-main { flex: 1 1 calc(100% - 38px); }
  .member-role { margin-left: 32px; }
  .team-file { padding: 8px; }

  /* The primary actions must survive on phones: icon-only, no labels.
     Share lives in the document rail (团队空间) so the export button keeps its
     place; presence collapses into the rail as well. */
  #btnExport { padding: 0 8px; gap: 0; font-size: 0; }
  #btnExport .ico { width: 17px; height: 17px; }
  #btnShare { display: none; }
  .presence { display: none; }
  .brand-text { display: none; }
  .search { width: 96px; }
}

/* Touch devices: bigger targets, always-visible thumbnail actions, and 16px
   inputs so iOS Safari does not zoom when a field receives focus. */
@media (hover: none) and (pointer: coarse) {
  .input, .textarea, .select, .search input { font-size: 16px; }
  .icon-btn { width: 32px; height: 32px; }
  .tool { height: 34px; min-width: 36px; justify-content: center; }
  .color-pick input[type="color"] { width: 34px; height: 34px; }
  .thumb .t-tools { opacity: 1; }
  .thumb .t-del, .thumb .t-move { width: 24px; height: 24px; }
  /* Backdrop blur and large shadows are costly on low-end mobile GPUs. */
  .modal-backdrop { backdrop-filter: none; }
  .page { box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
}
/* --------------------------------- todos --------------------------------- */
/* Rail entry badge reuses .rail-badge; the panel and document tab share the
   same item markup so both stay visually consistent. */
.todo-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.todo-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.todo-filter {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 12px; white-space: nowrap;
}
.todo-filter:hover { border-color: #c7d2e3; }
.todo-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.todo-day-label { font-size: 11.5px; color: var(--muted); margin-left: 4px; }

.todo-panel-grid { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 14px; align-items: start; }
.todo-side, .todo-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.todo-calendar { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.todo-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.todo-cal-title { font-size: 12.5px; font-weight: 600; color: var(--ink); text-align: center; }
.todo-cal-week { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: 4px; }
.todo-cal-week span { text-align: center; font-size: 10px; color: var(--faint); padding: 2px 0; }
.todo-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.todo-cal-day {
  position: relative; min-height: 34px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; border-radius: 7px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font-size: 11.5px;
}
.todo-cal-day:hover { background: var(--accent-soft); }
.todo-cal-day.out { color: #c3cbd9; }
.todo-cal-day.today { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.todo-cal-day.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.todo-cal-count {
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); font-size: 9.5px;
  line-height: 15px; font-weight: 600; text-align: center;
}
.todo-cal-day.selected .todo-cal-count { background: rgba(255, 255, 255, .25); color: #fff; }
.todo-hint { line-height: 1.6; padding-top: 8px; }

.todo-quick {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px; background: #fff;
}
.todo-quick-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 8px; }
.todo-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.todo-field-label { font-size: 11px; color: var(--muted); }
.todo-field-block { width: 100%; }
.todo-notes { border-top: 1px dashed var(--line); padding-top: 7px; }
.todo-notes summary { cursor: pointer; font-size: 11.5px; color: var(--muted); user-select: none; }
.todo-notes .textarea { margin-top: 7px; }
.todo-quick-actions { display: flex; justify-content: flex-end; }

.todo-list { display: flex; flex-direction: column; gap: 7px; max-height: 360px; overflow: auto; padding-right: 2px; }
.todo-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.todo-item:hover { border-color: #cfd9e8; }
.todo-item.done { background: #fafbfc; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--faint); }
.todo-item.overdue { border-left: 3px solid var(--danger); }
.todo-check { flex: none; width: 15px; height: 15px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; }
.todo-priority { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; }
.todo-priority.p0 { background: #94a3b8; }
.todo-priority.p1 { background: var(--accent); }
.todo-priority.p2 { background: var(--danger); }
.todo-main { flex: 1; min-width: 0; }
.todo-title-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.todo-title { font-size: 12.5px; color: var(--ink); line-height: 1.45; overflow-wrap: anywhere; }
.todo-doc {
  display: inline-flex; align-items: center; gap: 4px; max-width: 190px; padding: 1px 7px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--accent-soft);
  color: var(--accent); font-size: 10px;
}
.todo-doc .ico { width: 11px; height: 11px; }
.todo-doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; font-size: 10.5px; color: var(--muted); }
.todo-due.overdue { color: var(--danger); font-weight: 600; }
.todo-status { padding: 0 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 10px; }
.todo-note-preview { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.todo-actions { display: flex; gap: 2px; flex: none; }
.todo-actions .icon-btn { width: 26px; height: 26px; color: var(--faint); }
.todo-actions .todo-delete:hover { color: var(--danger); background: var(--danger-soft); }
.todo-empty { color: var(--faint); font-size: 11.5px; text-align: center; padding: 22px 8px; line-height: 1.8; }

.todo-edit { display: flex; flex-direction: column; gap: 10px; }
.todo-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 130px 130px; gap: 8px; }
.todo-field-error { min-height: 16px; font-size: 11.5px; color: var(--danger); }

/* Document todos inspector tab */
.doc-todo-form { display: flex; gap: 6px; margin-bottom: 8px; }
.doc-todo-form .input { flex: 1; min-width: 0; }
.todo-doc-hint { line-height: 1.6; margin-bottom: 8px; }
.todo-doc-list { display: flex; flex-direction: column; gap: 6px; }
.todo-doc-list .todo-item { padding: 7px 8px; }

@media (max-width: 1180px) {
  .todo-panel-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .todo-panel-grid { grid-template-columns: minmax(0, 1fr); }
  .todo-cal-grid { gap: 2px; }
  .todo-cal-day { min-height: 30px; font-size: 10.5px; }
  .todo-cal-count { min-width: 13px; height: 13px; line-height: 13px; font-size: 9px; }
  .todo-quick-row { grid-template-columns: minmax(0, 1fr); }
  .todo-edit-grid { grid-template-columns: minmax(0, 1fr); }
  .todo-item { flex-wrap: wrap; }
  .todo-list { max-height: none; }
  .todo-actions { margin-left: auto; }
  .todo-doc { max-width: 140px; }
  .todo-filter { height: 30px; padding: 0 10px; }
}

/* --------------------------------- notes --------------------------------- */
/* Sticky-note board: one colour class per card, transparent inputs so the note
   colour shows through, and a responsive auto-fill grid. */
.notes-panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.notes-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notes-toolbar .input { flex: 1 1 220px; min-width: 0; }
.notes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px; align-items: start; max-height: 58vh; overflow: auto; padding: 2px;
}
.note-card {
  display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 10px;
  border: 1px solid var(--note-border); border-radius: 10px;
  background: var(--note-bg); box-shadow: var(--shadow-sm);
}
.note-card:focus-within { box-shadow: 0 0 0 2px rgba(59, 91, 219, .22), var(--shadow-md); }
.note-card.pinned { box-shadow: 0 0 0 2px rgba(59, 91, 219, .22), var(--shadow-md); }
.note-color-yellow { --note-bg: #fff9dd; --note-border: #efe3a8; }
.note-color-pink { --note-bg: #ffeef3; --note-border: #f3cdd8; }
.note-color-blue { --note-bg: #eaf2ff; --note-border: #c9ddf5; }
.note-color-green { --note-bg: #eaf9f0; --note-border: #c6e8d3; }
.note-color-purple { --note-bg: #f3edff; --note-border: #dccff5; }

.note-card-head { display: flex; align-items: center; gap: 4px; }
.note-title {
  flex: 1; min-width: 0; border: none; background: transparent; padding: 2px;
  border-radius: 5px; font-size: 13px; font-weight: 600; color: var(--ink);
}
.note-title:focus, .note-content:focus { background: rgba(255, 255, 255, .7); outline: none; }
.note-content {
  width: 100%; min-height: 72px; max-height: 240px; resize: none; border: none;
  background: transparent; padding: 0 2px; border-radius: 5px;
  font-size: 11.5px; line-height: 1.65; color: var(--ink-2);
}
.note-pin, .note-delete {
  width: 24px; height: 24px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 6px; color: var(--faint);
}
.note-pin .ico, .note-delete .ico { width: 14px; height: 14px; }
.note-pin:hover, .note-delete:hover { background: rgba(255, 255, 255, .65); color: var(--ink-2); }
.note-pin[aria-pressed="true"] { color: var(--accent); background: rgba(59, 91, 219, .1); }
.note-delete:hover { color: var(--danger); }
.note-card-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; }
.note-colors { display: flex; align-items: center; gap: 5px; }
.note-color {
  width: 14px; height: 14px; flex: none; padding: 0; border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, .12);
}
.note-color[data-color="yellow"] { background: #f2cf4a; }
.note-color[data-color="pink"] { background: #f29bb4; }
.note-color[data-color="blue"] { background: #7fb3f2; }
.note-color[data-color="green"] { background: #7cc79a; }
.note-color[data-color="purple"] { background: #b399ef; }
.note-color.active { box-shadow: 0 0 0 2px var(--note-bg), 0 0 0 3.5px var(--ink-2); }
.note-saved { margin-left: auto; min-height: 14px; font-size: 10px; color: var(--muted); white-space: nowrap; }
.note-saved.busy { color: var(--warn); }
.note-saved.done { color: var(--ok); }
.note-empty { padding: 28px 10px; text-align: center; font-size: 11.5px; line-height: 1.8; color: var(--faint); }

@media (max-width: 1180px) {
  .notes-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

@media (max-width: 760px) {
  .notes-grid { grid-template-columns: minmax(0, 1fr); max-height: none; }
  .notes-toolbar .input { flex: 1 1 100%; }
  .notes-toolbar .btn { flex: 1 1 auto; }
  .note-content { max-height: 180px; }
  .note-card { padding: 9px; }
}

/* ------------------------------ notes v2 --------------------------------- */
.notes-scope { flex: 0 0 128px; height: 32px; }
.note-card.readonly { box-shadow: none; }
.note-card.readonly .note-title { cursor: default; }
.note-card.dragging { opacity: .55; }
.note-card.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.note-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.note-doc {
  display: inline-flex; align-items: center; gap: 4px; max-width: 190px; padding: 1px 7px;
  border-radius: 999px; border: 1px solid rgba(15, 23, 42, .1); background: rgba(255, 255, 255, .6);
  color: var(--accent); font-size: 10px;
}
.note-doc .ico { width: 11px; height: 11px; }
.note-doc span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-team, .note-owner {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
  font-size: 10px; background: rgba(255, 255, 255, .6); border: 1px solid rgba(15, 23, 42, .1);
  color: var(--muted);
}
.note-owner { color: var(--warn); }
.note-drag, .note-share {
  width: 24px; height: 24px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 6px; color: var(--faint);
}
.note-drag { cursor: grab; }
.note-drag:active { cursor: grabbing; }
.note-drag .ico, .note-share .ico { width: 14px; height: 14px; }
.note-drag:hover, .note-share:hover { background: rgba(255, 255, 255, .65); color: var(--ink-2); }

.note-md {
  font-size: 11.5px; line-height: 1.65; color: var(--ink-2);
  overflow-wrap: anywhere; cursor: text; min-height: 18px;
}
.note-card.readonly .note-md { cursor: default; }
.note-md.empty { color: var(--faint); font-style: italic; cursor: default; }
.note-md h1, .note-md h2, .note-md h3 { color: var(--ink); line-height: 1.35; margin: 6px 0 4px; }
.note-md h1 { font-size: 14px; }
.note-md h2 { font-size: 13px; }
.note-md h3 { font-size: 12px; }
.note-md p { margin: 0 0 4px; }
.note-md p:last-child { margin-bottom: 0; }
.note-md ul, .note-md ol { margin: 0 0 4px; padding-left: 17px; }
.note-md li { margin: 1px 0; }
.note-md code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10.5px;
  background: rgba(15, 23, 42, .07); border-radius: 3px; padding: 0 3px;
}
.note-md pre.md-code {
  margin: 4px 0; padding: 6px 8px; border-radius: 6px; overflow: auto;
  background: rgba(15, 23, 42, .06); font-size: 10.5px; line-height: 1.5;
}
.note-md pre.md-code code { background: none; padding: 0; }
.note-md blockquote {
  margin: 4px 0; padding-left: 8px; border-left: 2px solid rgba(15, 23, 42, .18);
  color: var(--muted);
}
.note-md hr { border: none; border-top: 1px dashed rgba(15, 23, 42, .18); margin: 6px 0; }
.note-md a { color: var(--accent); text-decoration: underline; }

.note-attach { display: flex; flex-direction: column; gap: 6px; }
.note-attach-list { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.note-att-img {
  width: 56px; height: 56px; object-fit: cover; border-radius: 6px;
  border: 1px solid rgba(15, 23, 42, .12); background: #fff; cursor: zoom-in;
}
.note-attachment {
  display: inline-flex; align-items: center; gap: 4px; max-width: 190px; padding: 3px 7px;
  border-radius: 6px; border: 1px solid rgba(15, 23, 42, .1); background: rgba(255, 255, 255, .65);
  color: var(--ink-2); font-size: 10.5px; text-decoration: none;
}
.note-attachment .ico { width: 11px; height: 11px; flex: none; }
.note-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-att-size { flex: none; color: var(--faint); font-size: 9.5px; }
.note-att-del {
  width: 20px; height: 20px; flex: none; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 50%; color: var(--faint);
}
.note-att-del .ico { width: 11px; height: 11px; }
.note-att-del:hover { color: var(--danger); background: rgba(255, 255, 255, .7); }
.note-attach-btn {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border: 1px dashed rgba(15, 23, 42, .22); border-radius: 6px;
  font-size: 10.5px; color: var(--muted);
}
.note-attach-btn .ico { width: 11px; height: 11px; }
.note-attach-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.note-attach-btn:disabled { opacity: .5; cursor: not-allowed; }
.note-attach-input { display: none; }

.note-share-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.note-share-form .help { line-height: 1.7; }
.note-share-teams { display: flex; flex-direction: column; gap: 4px; }
.note-share-option {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 12px; color: var(--ink-2);
  cursor: pointer;
}
.note-share-option:hover { border-color: #cfd9e8; background: #f8fafc; }
.note-share-empty { font-size: 11px; }

.doc-note-form { display: flex; gap: 6px; margin-bottom: 8px; }
.doc-note-form .input { flex: 1; min-width: 0; }
#btnDocNotesOpen { margin-bottom: 8px; }
.doc-note-list { display: flex; flex-direction: column; gap: 6px; }
.doc-note-item { padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.doc-note-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.doc-note-title {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: var(--ink);
}
.doc-note-badge {
  flex: none; padding: 0 6px; border-radius: 999px; font-size: 9.5px;
  color: var(--accent); background: var(--accent-soft);
}
.doc-note-content {
  margin-top: 2px; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-note-meta { margin-top: 3px; font-size: 10px; color: var(--faint); }

@media (max-width: 1180px) {
  .notes-scope { flex: 0 0 112px; }
  .note-att-img { width: 48px; height: 48px; }
}

@media (max-width: 760px) {
  .note-drag { display: none; }
  .notes-scope { flex: 1 1 100%; }
  .note-att-img { width: 44px; height: 44px; }
  .doc-note-form { flex-wrap: wrap; }
  .doc-note-form .btn { flex: 1 1 auto; }
  .note-card .note-share, .note-card .note-delete, .note-card .note-pin { width: 26px; height: 26px; }
  .note-md pre.md-code { font-size: 10px; }
}

/* ========================= v1.7 design tokens ========================= */
:root {
  --control-h: 32px;
  --control-h-sm: 26px;
  --icon: 16px;
  --icon-sm: 14px;
  --radius: 10px;
  --radius-sm: 8px;
  --modal-w-sm: 440px;
  --modal-w-md: 600px;
  --modal-w-lg: 820px;
  --modal-w-xl: 1040px;
  --modal-max-h: 88vh;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --topbar-h: 56px;
}

/* ------------------------------- buttons ------------------------------ */
.btn { height: var(--control-h); padding: 0 14px; font-size: 13px; border-radius: var(--radius-sm); }
.btn .ico { width: 15px; height: 15px; }
.btn.tiny { height: var(--control-h-sm); padding: 0 10px; font-size: 12px; }
.btn.tiny .ico { width: var(--icon-sm); height: var(--icon-sm); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); box-shadow: 0 2px 6px rgba(220, 38, 38, .22); }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.danger:disabled { box-shadow: none; }
.icon-btn { width: 30px; height: 30px; border-radius: 7px; }
.icon-btn .ico { width: var(--icon); height: var(--icon); }
.btn.is-busy, .icon-btn.is-busy { opacity: .65; cursor: progress; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------- topbar ------------------------------ */
.topbar { gap: var(--space-3); padding-left: 14px; padding-right: 14px; }
.brand { width: 232px; }
.doc-head { gap: var(--space-2); }
.doc-name { max-width: 32vw; }
.doc-meta { color: var(--muted); }
.search { width: clamp(200px, 22vw, 360px); }
.top-actions { gap: 6px; }
.avatar-btn { width: 30px; height: 30px; }
@media (max-width: 1280px) {
  #btnShare span, #btnExport span { display: none; }
  #btnShare, #btnExport { padding: 0 10px; }
  .brand { width: 190px; }
}
@media (max-width: 980px) {
  .doc-name { max-width: 40vw; }
}

/* -------------------------------- rail -------------------------------- */
.doc-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.doc-title, .rail-link span, .team-doc-switch { font-size: 12.5px; }
.rail-link .ico { width: var(--icon); height: var(--icon); }
.rail-version, .rail-icp { font-size: 10.5px; }
.rail-badge { font-variant-numeric: tabular-nums; }

/* ------------------------------ inspector ----------------------------- */
/* Five tabs must fit the panel without scrolling: when the strip scrolls, the
   inactive tabs get clipped on the left ("页面" half hidden) which reads like
   the last tab is covered. Equal-width tabs keep every label fully visible. */
.inspector-tabs { gap: 2px; padding: 0 6px; overflow: hidden; }
.itab {
  display: inline-flex; flex: 1 1 0; min-width: 0; align-items: center; justify-content: center;
  gap: 3px; height: 42px; padding: 0 2px; font-size: 11.5px; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.itab span { overflow: hidden; text-overflow: ellipsis; }
.itab .ico { width: 14px; height: 14px; flex: none; }
.itab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; background: linear-gradient(180deg, transparent, var(--accent-soft)); }
.tabpane { padding: var(--space-3); }
@media (max-width: 1180px) {
  .inspector { width: 300px; }
  .itab { gap: 2px; padding: 0 2px; font-size: 11px; }
  .itab .ico { width: 13px; height: 13px; }
}
@media (max-width: 980px) {
  /* Mobile drawer keeps its own width (must not inherit the desktop 300px rule). */
  .inspector { width: min(300px, 88vw); }
}

/* ------------------------------- toolbar ------------------------------ */
.toolbar { gap: var(--space-2); padding: 0 10px; }
.toolbar-main { gap: 4px; overflow-x: auto; scrollbar-width: none; }
.toolbar-main::-webkit-scrollbar { display: none; }
.toolbar-main.scrollable { mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
.tool-group { gap: 1px; }
.toolbar-sep { height: 18px; margin: 0 4px; }
.tool { height: 32px; padding: 0 9px; }
.tool .ico { width: var(--icon); height: var(--icon); }
.tool[data-mode="undo"], .tool[data-mode="redo"] { width: 28px; height: 28px; justify-content: center; padding: 0; }
.toolbar-right .icon-btn, .toolbar-right .tool { height: 28px; }

/* -------------------------------- modal ------------------------------- */
.modal { width: min(var(--modal-w-md), calc(100vw - 32px)); max-height: var(--modal-max-h); }
.modal--sm { width: min(var(--modal-w-sm), calc(100vw - 32px)); }
.modal--md { width: min(var(--modal-w-md), calc(100vw - 32px)); }
.modal--lg { width: min(var(--modal-w-lg), calc(100vw - 32px)); }
.modal--xl { width: min(var(--modal-w-xl), calc(100vw - 32px)); }
.modal-head { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid var(--line-soft); }
.modal-foot { position: sticky; bottom: 0; z-index: 2; }
.modal-body { overscroll-behavior: contain; }
@media (max-width: 760px) {
  .modal-backdrop { padding: 8px; }
  .modal, .modal--sm, .modal--md, .modal--lg, .modal--xl {
    width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }
  .modal-head, .modal-foot { position: sticky; }
}

/* ============================ team space ============================== */
.modal.team-modal {
  width: min(1120px, 94vw);
  height: min(820px, 88vh);
  max-height: 88vh;
}
.modal.team-modal .modal-body { display: flex; flex: 1; min-height: 0; padding: 0; overflow: hidden; }
.modal.team-modal .modal-foot { justify-content: stretch; }
.team-space { display: grid; grid-template-columns: 264px minmax(0, 1fr); flex: 1; min-height: 0; width: 100%; }
.team-side {
  display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line);
  background: #fbfcfe;
}
.team-side-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.team-side-title { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .2px; }
.team-count { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 3px; }
.team-list-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px;
  border: 1px solid transparent; border-radius: 8px; text-align: left;
}
.team-list-item:hover { background: #f1f5fd; }
.team-list-item.selected { background: var(--accent-soft); border-color: #d7e0ff; box-shadow: inset 3px 0 0 var(--accent); }
.team-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 8px; color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.team-list-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.team-list-name { font-size: 12.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-list-meta { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-side-empty { padding: 18px 10px; text-align: center; color: var(--faint); font-size: 11px; line-height: 1.7; }
.team-side-actions { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.team-side-actions .btn { flex: 1; justify-content: center; }
.team-role-badge {
  flex: none; padding: 1px 6px; border-radius: 999px; font-size: 9.5px; line-height: 16px;
  background: var(--line-soft); color: var(--muted); white-space: nowrap;
}
.team-role-badge.role-owner { background: #fff4d6; color: #9a6b1f; }
.team-role-badge.role-member { background: var(--accent-soft); color: var(--accent); }
.team-role-badge.role-viewer { background: #eef2f7; color: var(--muted); }

.team-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.team-main-head { padding: 12px 16px 0; border-bottom: 1px solid var(--line); background: #fff; flex: none; }
.team-title-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team-title { font-size: 15px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-head-meta { margin-left: auto; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-mobile-select { display: none; margin: 0 0 8px; }
.team-tabs { display: flex; gap: 4px; margin-top: 10px; }
.team-tab {
  display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 11px;
  font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.team-tab .ico { width: 14px; height: 14px; }
.team-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 500; }
.team-pane { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 18px; }
.team-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.team-pane-summary { font-size: 12px; color: var(--muted); }
.team-state-empty, .team-state-error {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px; text-align: center; color: var(--faint);
}
.team-state-empty .ico, .team-state-error .ico { width: 28px; height: 28px; color: #c4cfe0; }
.team-state-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.team-state-help { font-size: 11.5px; color: var(--faint); line-height: 1.7; max-width: 360px; }
.team-state-actions { display: flex; gap: 8px; margin-top: 4px; }
.team-skeleton {
  height: 44px; border-radius: 8px; margin-bottom: 8px;
  background: linear-gradient(90deg, #f1f4f9 25%, #e8edf6 37%, #f1f4f9 63%);
  background-size: 400% 100%; animation: team-shimmer 1.2s ease infinite;
}
@keyframes team-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.team-member-list { display: flex; flex-direction: column; gap: 6px; }
.team-member-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.team-member-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; color: #fff;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 600;
}
.team-member-main { flex: 1; min-width: 0; }
.team-member-name-row { display: flex; align-items: center; gap: 6px; }
.team-member-name { font-size: 12.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-self-tag { font-size: 9.5px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 4px; }
.team-member-email { font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-member-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.team-member-joined { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-member-controls { display: flex; align-items: center; gap: 4px; flex: none; }
.team-role-select { width: 92px; height: 28px; padding: 2px 8px; font-size: 11.5px; }
.team-invite-form {
  display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.team-invite-form .input { flex: 1; min-width: 0; }
.team-invite-form .select { width: 110px; flex: none; }
.team-readonly-hint { margin-top: 12px; font-size: 11.5px; color: var(--faint); }
.team-files-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.team-files-toolbar .input { flex: 1; min-width: 0; }
.team-current-doc {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 10px;
  border: 1px solid #dbe4ff; border-radius: 9px; background: var(--accent-soft); min-width: 0;
}
.team-current-doc-name { flex: 1; min-width: 0; font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-current-doc-state { font-size: 10.5px; color: var(--muted); flex: none; }
.team-current-doc-state.on { color: var(--ok); }
.team-file-list { display: flex; flex-direction: column; gap: 4px; }
.team-file-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.team-file-row:hover { background: #f6f8fc; border-color: var(--line); }
.team-file-icon { width: 28px; height: 28px; flex: none; border-radius: 7px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.team-file-main { flex: 1; min-width: 0; }
.team-file-name { font-size: 12.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-file-sub { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-file-owner { width: 110px; flex: none; font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-file-time { width: 92px; flex: none; font-size: 10.5px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.team-file-actions { display: flex; gap: 2px; flex: none; opacity: 0; }
.team-file-row:hover .team-file-actions, .team-file-row:focus-within .team-file-actions { opacity: 1; }
.team-add-docs {
  display: flex; flex-direction: column; gap: 8px;
}
.team-add-docs .input { width: 100%; }
.team-add-docs-list {
  display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff;
}
.team-add-doc-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; font-size: 12.5px; cursor: pointer; }
.team-add-doc-row:hover { background: #f6f8fc; }
.team-add-doc-row.disabled { opacity: .55; cursor: default; }
.team-add-doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-add-doc-badge { font-size: 9.5px; color: var(--muted); background: var(--line-soft); border-radius: 4px; padding: 0 5px; }
.team-add-docs-actions { display: flex; justify-content: flex-end; gap: 8px; }
.team-selected-count { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-settings-section { margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.team-settings-section h4 { font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.team-inline-form { display: flex; gap: 8px; }
.team-inline-form .input { flex: 1; min-width: 0; }
.team-invite-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.team-invite-code {
  flex: 1; min-width: 140px; padding: 8px 10px; border-radius: 8px;
  background: #f6f8fc; border: 1px dashed var(--line); letter-spacing: 2px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; color: var(--ink-2);
}
.team-settings-section.danger-zone { border-bottom: none; padding-bottom: 0; }
.team-settings-section.danger-zone h4 { color: var(--danger); }
.team-settings-section.danger-zone .btn { margin-top: 8px; }
.btn.armed {
  animation: armed-pulse 1s ease-in-out infinite;
  background: var(--danger); border-color: var(--danger); color: #fff;
}
@keyframes armed-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .35); } 50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, .12); } }
.team-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.team-doc-bar { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 11.5px; color: var(--muted); }
.team-doc-label { flex: none; color: var(--faint); }
.team-doc-name { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.team-doc-state { flex: none; font-size: 10.5px; color: var(--faint); }
.team-doc-state.on { color: var(--ok); }
.team-foot-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.team-form { max-width: 440px; display: flex; flex-direction: column; gap: 10px; }
.team-form h3 { font-size: 14px; color: var(--ink); }

@media (max-width: 900px) {
  .team-space { grid-template-columns: minmax(0, 1fr); }
  .team-side { display: none; }
  .team-mobile-select { display: block; }
  .team-modal .modal-foot { flex-direction: column; align-items: stretch; }
  .team-foot { flex-direction: column; align-items: stretch; }
  .team-foot-actions { justify-content: flex-end; }
}
@media (max-width: 760px) {
  .modal.team-modal { width: calc(100vw - 16px); height: calc(100dvh - 16px); max-height: calc(100dvh - 16px); }
  .team-main-head { padding: 10px 12px 0; }
  .team-pane { padding: 12px; }
  .team-file-owner, .team-file-time { display: none; }
  .team-file-actions { opacity: 1; }
  .team-member-row { flex-wrap: wrap; }
  .team-member-controls { width: 100%; justify-content: flex-end; }
  .team-invite-form { flex-wrap: wrap; }
  .team-invite-form .select { width: 100%; }
  .team-doc-name { max-width: 150px; }
}

/* Keep the old narrow-screen proportions after the v1.7 topbar/tabs base rules. */
@media (max-width: 1180px) {
  .brand { width: 190px; }
  .search { width: 148px; }
}
@media (max-width: 980px) {
  .brand { width: auto; }
  .brand-text span { display: none; }
  .search { width: 132px; }
  .doc-name { max-width: 40vw; }
}
@media (max-width: 760px) {
  .search { width: 96px; }
  .itab { padding: 0 7px; gap: 4px; }
  .itab .ico { width: 14px; height: 14px; }
  .toolbar-main { gap: 2px; }
}

.team-mobile-actions { display: none; gap: 6px; margin: 0 0 8px; }
.team-mobile-actions .btn { flex: 1; justify-content: center; }
@media (max-width: 900px) {
  .team-mobile-actions { display: flex; }
}

/* ======================= document library (v1.8) ===================== */
.rail-head-actions { display: flex; align-items: center; gap: 2px; }
.doc-search {
  display: flex; align-items: center; gap: 6px; height: 30px;
  margin: 0 12px 8px; padding: 0 7px; border: 1px solid var(--line);
  border-radius: 7px; background: #fbfcfe; color: var(--faint);
}
.doc-search:focus-within { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(59, 91, 219, .08); }
.doc-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 12px; color: var(--ink); }
.doc-search input::placeholder { color: var(--faint); }
.doc-search .ico { width: 14px; height: 14px; }
.doc-search .search-clear { width: 17px; height: 17px; font-size: 13px; }
.folder-list {
  flex: none; max-height: 180px; overflow-y: auto; padding: 0 8px 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.folder-item {
  display: flex; align-items: center; gap: 6px; min-height: 30px; padding: 5px 7px;
  border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 12px; border: 1px solid transparent;
}
.folder-item:hover { background: #f6f8fc; }
.folder-item.active { background: var(--accent-soft); border-color: #dbe2ff; color: var(--accent); font-weight: 500; }
.folder-item .ico { width: 14px; height: 14px; flex: none; color: var(--faint); }
.folder-item.active .ico { color: var(--accent); }
.folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count {
  flex: none; min-width: 18px; padding: 0 5px; border-radius: 9px; text-align: center;
  background: var(--line-soft); color: var(--muted); font-size: 9.5px; line-height: 16px;
  font-variant-numeric: tabular-nums;
}
.folder-item.active .folder-count { background: #dfe6ff; color: var(--accent); }
.folder-actions { display: flex; align-items: center; gap: 1px; flex: none; opacity: 0; pointer-events: none; }
.folder-item:hover .folder-actions, .folder-item:focus-within .folder-actions { opacity: 1; pointer-events: auto; }
.folder-actions .icon-btn { width: 21px; height: 21px; border-radius: 5px; }
.folder-actions .icon-btn .ico { width: 12px; height: 12px; }
.rail-head-actions .icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.doc-item { align-items: center; }
.doc-item .doc-check { display: none; align-items: center; flex: none; margin-right: -3px; }
.doc-item .doc-check input { width: 14px; height: 14px; accent-color: var(--accent); cursor: pointer; }
.rail.select-mode .doc-item .doc-check { display: flex; }
.rail.select-mode .doc-item .row-actions { display: none !important; }
.doc-item.selected { background: var(--accent-soft); border-color: #c8d4ff; }
.doc-item.selected .doc-title { color: var(--accent); }
/* Keep page/mine/folder metadata on a single compact line: at 1024 the 210px
   rail used to wrap the folder badge into 3-4 lines and grow every row. */
.doc-item .doc-sub { white-space: nowrap; overflow: hidden; }
.doc-item .doc-sub > span { flex: none; }
.doc-item .doc-sub .doc-folder-badge { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.doc-empty { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.doc-empty .ico { width: 22px; height: 22px; color: #c4cfe0; }
.doc-empty-title { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.doc-empty-hint { font-size: 10.5px; color: var(--faint); line-height: 1.6; }
.doc-batch-bar {
  flex: none; border-top: 1px solid var(--line); background: #f8faff;
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
.doc-batch-info { font-size: 11.5px; color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.doc-batch-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-batch-actions .btn { flex: 1 1 auto; justify-content: center; padding: 0 7px; }
.doc-batch-actions .btn:disabled { opacity: .4; }

/* ------------------------------- move dialog -------------------------- */
.move-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.move-target {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 12.5px; color: var(--ink-2);
}
.move-target:hover { background: #f8fafc; }
.move-target.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.move-target input { accent-color: var(--accent); }
.move-target .ico { width: 15px; height: 15px; flex: none; }
.move-target-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- merge dialog ------------------------- */
.merge-body { display: flex; flex-direction: column; gap: 12px; }
.merge-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.merge-pane { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.merge-pane-title { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.merge-picker-list {
  display: flex; flex-direction: column; gap: 2px; min-height: 160px; max-height: 320px;
  overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.merge-picker-row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12px; border: 1px solid transparent;
}
.merge-picker-row:hover { background: #f6f8fc; }
.merge-picker-row.selected { background: var(--accent-soft); border-color: #dbe2ff; }
.merge-picker-row input { accent-color: var(--accent); flex: none; }
.merge-picker-row .ico { width: 14px; height: 14px; flex: none; color: var(--faint); }
.merge-picker-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.merge-picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.merge-picker-pages { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.merge-order {
  display: flex; flex-direction: column; gap: 3px; min-height: 160px; max-height: 320px;
  overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
}
.merge-order.drag-active { border-color: var(--accent); background: var(--accent-soft); }
.merge-item {
  display: flex; align-items: center; gap: 7px; padding: 6px 7px;
  background: #fff; border: 1px solid var(--line); border-radius: 7px; min-width: 0;
}
.merge-item.dragging { opacity: .45; }
.merge-item.drag-over { border-color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.merge-grip { flex: none; color: var(--faint); cursor: grab; display: grid; place-items: center; width: 16px; }
.merge-grip:active { cursor: grabbing; }
.merge-grip .ico { width: 13px; height: 13px; }
.merge-index {
  flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 10px; font-variant-numeric: tabular-nums;
}
.merge-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.merge-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--ink); }
.merge-item-pages { font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.merge-item-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.merge-item-actions .icon-btn { width: 24px; height: 24px; }
.merge-item-actions .icon-btn .ico { width: 13px; height: 13px; }
.merge-summary { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.merge-empty { padding: 18px 10px; text-align: center; font-size: 11.5px; color: var(--faint); line-height: 1.7; }
.merge-name-field { margin-top: 0; }
@media (max-width: 760px) {
  .doc-batch-actions .btn { flex: 1 1 44%; }
  .merge-layout { grid-template-columns: minmax(0, 1fr); }
  .merge-picker-list { max-height: 180px; }
  .merge-order { max-height: 220px; }
  .folder-list { max-height: 150px; }
  .doc-search { margin-left: 10px; margin-right: 10px; }
}

/* ===================== v1.9 load bar + team content ===================== */
.workspace { position: relative; }
/* Thin top loading bar for document download/parse and uploads. The track
   stays visible at 0-2% so the bar reads as "loading" immediately, and the
   label is centered over the stage instead of covering the inspector tabs. */
.workspace { position: relative; }
.load-bar {
  position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 45;
  pointer-events: none; background: rgba(59, 91, 219, .12);
}
.load-bar.hidden { display: none; }
.load-bar-fill {
  height: 100%; width: 0; min-width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(90deg, var(--accent), #6f8cff);
  box-shadow: 0 0 8px rgba(59, 91, 219, .45);
  transition: width .18s ease;
}
/* The label sits at the bottom-right corner of the stage (right of it is the
   inspector), so it never covers the toolbar or the document's top edge. */
.load-bar-text {
  position: fixed; top: auto; bottom: 18px; right: 336px; transform: none; z-index: 46;
  max-width: min(42vw, 380px);
  padding: 3px 10px; border-radius: 999px; background: rgba(15, 23, 42, .78);
  color: #fff; font-size: 10.5px; line-height: 1.5; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; backdrop-filter: blur(4px);
}
@media (max-width: 1180px) {
  .load-bar-text { right: 316px; }
}
@media (max-width: 980px) {
  .load-bar-text { right: 16px; bottom: 16px; }
}
.load-bar.hidden .load-bar-text { display: none; }

/* team tabs: all five visible on the 1120px workbench, scroll on narrow */
.team-tabs { flex: none; overflow-x: auto; scrollbar-width: none; }
.team-tabs::-webkit-scrollbar { display: none; }
.team-tab { flex: none; }

.team-notes-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px; padding-bottom: 6px;
}
.team-note-card {
  display: flex; flex-direction: column; gap: 7px; min-width: 0; text-align: left;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.team-note-card:hover { border-color: #c9d5ff; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.team-note-head { display: flex; align-items: center; gap: 6px; min-width: 0; }
.team-note-title { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-note-mine { flex: none; font-size: 9px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.team-note-preview { font-size: 11.5px; color: var(--muted); line-height: 1.6; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; word-break: break-word; }
.team-note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-note-author { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.team-note-attach { color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; line-height: 15px; }
.team-note-time { margin-left: auto; }

.team-note-view { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.team-note-view-meta { font-size: 11px; color: var(--faint); }
.team-note-content { max-height: 320px; overflow-y: auto; padding-right: 2px; font-size: 12.5px; }
.team-note-attachment-section { border-top: 1px dashed var(--line); padding-top: 9px; }
.team-note-attachment-section h4 { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.team-note-attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.team-note-image { display: block; width: 86px; height: 62px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); background: #f8fafc; }
.team-note-image img { width: 100%; height: 100%; object-fit: cover; }
.team-note-help { border-top: 1px solid var(--line-soft); padding-top: 8px; }

.team-todo-list { display: flex; flex-direction: column; gap: 6px; }
.team-todo-row {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fff;
}
.team-todo-row.done { background: #fbfcfe; }
.team-todo-status { width: 15px; height: 15px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.team-todo-status:disabled { cursor: not-allowed; opacity: .55; }
.team-todo-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.team-todo-title { font-size: 12.5px; color: var(--ink); word-break: break-word; }
.team-todo-row.done .team-todo-title { text-decoration: line-through; color: var(--faint); }
.team-todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 10px; color: var(--faint); font-variant-numeric: tabular-nums; }
.team-todo-badge { border-radius: 4px; padding: 0 5px; line-height: 15px; background: var(--line-soft); color: var(--muted); }
.team-todo-badge.status-open { background: var(--accent-soft); color: var(--accent); }
.team-todo-badge.status-doing { background: #fff2d8; color: var(--warn); }
.team-todo-badge.status-done { background: #e6f7ef; color: var(--ok); }
.team-todo-note-preview { font-size: 10.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-todo-actions { display: flex; align-items: center; gap: 1px; flex: none; }
.team-todo-actions .icon-btn { width: 25px; height: 25px; }
.team-todo-actions .icon-btn .ico { width: 13px; height: 13px; }
.team-todo-form { display: flex; flex-direction: column; gap: 10px; }
.team-todo-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.team-todo-field { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--muted); }
.team-todo-field .textarea { min-height: 78px; }
.team-todo-error { min-height: 16px; font-size: 11px; color: var(--danger); }

.todo-team {
  flex: none; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); font-size: 9.5px; line-height: 16px;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.todo-quick-row { grid-template-columns: minmax(0, 1fr) 140px 130px; }

@media (max-width: 760px) {
  .load-bar-text { right: 12px; bottom: 14px; max-width: 76vw; }
  /* Five team tabs must stay reachable on a phone: drop the icons so labels
     fit instead of hiding the last tab behind a horizontal scroller. */
  .team-tabs { gap: 2px; }
  .team-tab { padding: 0 7px; gap: 0; font-size: 11.5px; }
  .team-tab .ico { display: none; }
  .team-notes-grid { grid-template-columns: minmax(0, 1fr); }
  .team-note-content { max-height: 240px; }
  .team-note-image { width: 72px; height: 54px; }
  .team-todo-grid { grid-template-columns: minmax(0, 1fr); }
  .todo-quick-row { grid-template-columns: minmax(0, 1fr); }
  .team-todo-actions { flex-direction: column; }
}

/* ===================== annotation interaction v2 ===================== */
.overlay .annot-rect,
.overlay .annot-ink,
.overlay .annot-line,
.overlay .annot-hit,
.annot-textbox,
.annot-note,
.annot-node,
.annot-selection,
.annot-toolbar { pointer-events: auto; }
.annot-note, .annot-textbox, .annot-node { cursor: pointer; }
.annot-rect { cursor: pointer; }
.annot-selection {
  position: absolute; z-index: 6; border: 1.5px dashed var(--accent);
  border-radius: 3px; background: rgba(59, 91, 219, .06);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, .1);
  pointer-events: none;
}
.annot-toolbar {
  position: absolute; z-index: 9; display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 4px 5px; background: #fff; border: 1px solid var(--line);
  border-radius: 9px; box-shadow: var(--shadow-lg); max-width: calc(100% - 8px);
}
.annot-toolbar .icon-btn { width: 24px; height: 24px; }
.annot-toolbar .icon-btn .ico { width: 14px; height: 14px; }
.annot-toolbar .annot-edit { color: var(--accent); }
.annot-toolbar .annot-delete { color: var(--danger); }
.annot-color {
  width: 18px; height: 18px; flex: none; padding: 0; border-radius: 50%;
  border: 1.5px solid rgba(15, 23, 42, .14); cursor: pointer;
}
.annot-color.active { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
body.annot-dragging, body.annot-dragging * { cursor: grabbing !important; user-select: none; }

.annot-filters { display: flex; gap: 4px; margin-bottom: 9px; }
.annot-filter {
  padding: 4px 10px; border-radius: 6px; font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); background: #fff;
}
.annot-filter:hover { background: var(--line-soft); }
.annot-filter.active { color: var(--accent); border-color: #c9d5ff; background: var(--accent-soft); font-weight: 500; }
.annot-card { cursor: pointer; transition: border-color .15s, background .15s; }
.annot-card.active { border-color: var(--accent); background: #f7f9ff; box-shadow: inset 2px 0 0 var(--accent); }
.annot-author { margin-left: auto; max-width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.annot-sub { display: flex; align-items: center; gap: 6px; }
.annot-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.annot-time { margin-left: auto; flex: none; color: var(--faint); font-variant-numeric: tabular-nums; }
.annot-card-actions { display: flex; align-items: center; gap: 1px; flex: none; opacity: 0; }
.annot-card:hover .annot-card-actions, .annot-card:focus-within .annot-card-actions { opacity: 1; }
.annot-card-actions .icon-btn { width: 23px; height: 23px; }
.annot-card-actions .icon-btn .ico { width: 13px; height: 13px; }
.annot-card-actions .annot-card-delete { color: var(--faint); }
.annot-card-actions .annot-card-delete:hover { color: var(--danger); background: var(--danger-soft); }

@media (max-width: 760px) {
  .annot-toolbar { gap: 2px; padding: 3px 4px; }
  .annot-toolbar .icon-btn { width: 22px; height: 22px; }
  .annot-color { width: 16px; height: 16px; }
  .annot-card-actions { opacity: 1; }
}
