/* ============================================================
   1. Design tokens
   ============================================================ */
:root{
  color-scheme: light;
  --font-ui: "Segoe UI","Microsoft YaHei UI","Microsoft YaHei",system-ui,-apple-system,BlinkMacSystemFont,sans-serif;
  --font-mono: "Cascadia Mono","Consolas","SFMono-Regular","Menlo",monospace;
  --fs-11:11px; --fs-12:12px; --fs-13:13px; --fs-14:14px; --fs-15:15px; --fs-18:18px; --fs-20:20px;
  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px; --sp-8:32px;
  --r-sm:5px; --r-md:7px; --r-lg:10px; --r-xl:14px;
  --line:1.5;
  --t-fast:120ms cubic-bezier(.2,.7,.3,1);
  --t-base:180ms cubic-bezier(.2,.7,.3,1);

  --bg:#f3f5f8;
  /* audit: allow-anti-pattern — pure white is intentional for the data-grid surface */
  --surface:#ffffff;
  --surface-2:#f7f9fb;
  --surface-3:#eef2f6;
  --border:#e2e7ed;
  --border-strong:#cbd5df;
  /* 表格细线：比 --border 略深，否则 1px 在纯白底上几乎看不见 */
  --grid-line:#cfd9e4;
  --text:#17202b;
  --text-2:#475669;
  --text-3:#7a8897;

  --accent:#2457d6;
  --accent-strong:#1b46b8;
  --accent-weak:#eaf0ff;
  /* audit: allow-anti-pattern — foreground token for text/icons on accent or solid-dark surfaces */
  --on-accent:#fff;
  --toast-bg:#17202b;
  --toast-fg:#fff;
  --ring:rgba(36,87,214,.16);

  --danger:#c0372f;
  --danger-weak:#fdf0ef;
  --warn:#a85b08;
  --warn-weak:#fff7e8;
  --orange:#b54708;
  --orange-weak:#fff1e6;
  --success:#157347;
  --success-weak:#eafaf1;
  --purple:#6741b8;
  --purple-weak:#f4f0ff;

  --shadow-1:0 1px 2px rgba(20,30,45,.05);
  --shadow-2:0 12px 32px rgba(20,30,45,.13);
  --shadow-3:0 30px 90px rgba(20,30,45,.24);
}
[data-theme="dark"]{
  color-scheme: dark;
  --bg:#0e1319;
  --surface:#151c24;
  --surface-2:#1a222c;
  --surface-3:#212b36;
  --border:#26313d;
  --border-strong:#3a4857;
  --grid-line:#36434f;
  --text:#e7edf3;
  --text-2:#a9b6c4;
  --text-3:#738291;

  --accent:#6b95ff;
  --accent-strong:#86a9ff;
  --accent-weak:#182744;
  --on-accent:#0e1319;
  --toast-bg:#e7edf3;
  --toast-fg:#111820;
  --ring:rgba(107,149,255,.22);

  --danger:#f27870;
  --danger-weak:#331b1b;
  --warn:#e3a45c;
  --warn-weak:#2e2415;
  --orange:#f08c4d;
  --orange-weak:#33210f;
  --success:#57c98a;
  --success-weak:#142b20;
  --purple:#b498f0;
  --purple-weak:#241d36;

  --shadow-1:0 1px 2px rgba(0,0,0,.25);
  --shadow-2:0 14px 38px rgba(0,0,0,.42);
  --shadow-3:0 30px 100px rgba(0,0,0,.58);
}

/* ============================================================
   2. Reset & primitives
   ============================================================ */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font:var(--fs-13)/var(--line) var(--font-ui);
  color:var(--text);
  background:var(--bg);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none;padding:0}
a{color:var(--accent);text-decoration:none}
::selection{background:var(--accent-weak)}
*{scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:var(--border-strong);border:3px solid transparent;background-clip:padding-box;border-radius:999px}
::-webkit-scrollbar-track{background:transparent}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.input:focus-visible,.select:focus-visible,.textarea:focus-visible{outline:none}

.icon{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round;flex:0 0 auto}
.muted{color:var(--text-3)}
.mono{font-family:var(--font-mono);font-size:11.5px;color:var(--text-2)}
.spacer{flex:1}

/* ============================================================
   3. App chrome
   ============================================================ */
.app{height:100vh;display:flex;flex-direction:column;min-height:0}

.topbar{
  height:56px;flex:0 0 56px;
  display:flex;align-items:center;gap:14px;
  padding:0 16px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
  position:relative;z-index:20;
}
.brand{display:flex;align-items:center;gap:10px;min-width:196px}
.brand-mark{
  width:30px;height:30px;border-radius:8px;
  /* audit: allow-anti-pattern — white on the accent brand chip is intentional */
  background:var(--accent);color:var(--on-accent);
  display:grid;place-items:center;
  font-size:12px;font-weight:750;letter-spacing:.04em;
  box-shadow:var(--shadow-1);
}
.brand-text{min-width:0}
.brand-title{font-size:13.5px;font-weight:700;line-height:1.25;white-space:nowrap}
.brand-sub{font-size:10.5px;color:var(--text-3);line-height:1.3;white-space:nowrap}

.search{position:relative;flex:1;max-width:520px;min-width:160px}
.search input{
  width:100%;height:34px;
  padding:0 38px 0 34px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--surface-2);
  outline:none;
  font-size:12.5px;
  transition:border-color var(--t-fast),box-shadow var(--t-fast),background var(--t-fast);
}
.search input::placeholder{color:var(--text-3)}
.search input:focus{border-color:var(--accent);background:var(--surface);box-shadow:0 0 0 3px var(--ring)}
.search .icon{position:absolute;left:10px;top:9px;width:16px;height:16px;color:var(--text-3);pointer-events:none}
.search kbd{
  position:absolute;right:8px;top:8px;
  font:10px/18px var(--font-mono);
  color:var(--text-3);
  border:1px solid var(--border);
  border-bottom-color:var(--border-strong);
  border-radius:4px;padding:0 5px;background:var(--surface);
}

.top-actions{margin-left:auto;display:flex;align-items:center;gap:7px}
.demo-badge{
  display:inline-flex;align-items:center;gap:5px;
  height:22px;padding:0 8px;border-radius:999px;
  background:var(--accent-weak);color:var(--accent);
  font-size:10.5px;font-weight:650;white-space:nowrap;
}
.demo-badge .dot{width:5px;height:5px;border-radius:50%;background:var(--accent)}
.role-switch{
  display:flex;padding:2px;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:8px;
}
.role-switch button{
  height:26px;padding:0 10px;border-radius:6px;
  font-size:11.5px;color:var(--text-3);
  transition:background var(--t-fast),color var(--t-fast),box-shadow var(--t-fast);
}
.role-switch button:hover{color:var(--text-2)}
.role-switch button.active{background:var(--surface);color:var(--text);font-weight:650;box-shadow:var(--shadow-1)}
.user-chip{
  display:flex;align-items:center;gap:7px;
  padding-left:9px;border-left:1px solid var(--border);
  font-size:12px;color:var(--text-2);white-space:nowrap;
}

/* ============================================================
   4. Buttons / inputs
   ============================================================ */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:6px;
  height:32px;padding:0 12px;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--surface);
  color:var(--text-2);
  font-size:12.5px;font-weight:550;
  white-space:nowrap;
  transition:background var(--t-fast),border-color var(--t-fast),color var(--t-fast),box-shadow var(--t-fast);
}
.btn:hover{background:var(--surface-2);border-color:var(--border-strong);color:var(--text)}
.btn:active{background:var(--surface-3)}
.btn-primary{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}
.btn-primary:hover{background:var(--accent-strong);border-color:var(--accent-strong);color:var(--on-accent)}
.btn-primary:active{transform:translateY(.5px)}
.btn-ghost{border-color:transparent;background:transparent;color:var(--text-3)}
.btn-ghost:hover{background:var(--surface-2);color:var(--text)}
.btn-sm{height:28px;padding:0 9px;font-size:11.5px;border-radius:6px}
.btn:disabled{opacity:.46;cursor:not-allowed;transform:none}
.btn-primary:disabled{background:var(--accent);border-color:var(--accent)}

.icon-btn{
  width:30px;height:30px;display:grid;place-items:center;
  border-radius:7px;color:var(--text-3);
  transition:background var(--t-fast),color var(--t-fast);
}
.icon-btn:hover{background:var(--surface-2);color:var(--text)}
.icon-btn:active{background:var(--surface-3)}

.input,.select,.textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--surface);
  padding:7px 9px;
  outline:none;
  font-size:13px;
  transition:border-color var(--t-fast),box-shadow var(--t-fast),background var(--t-fast);
}
.input:hover,.select:hover,.textarea:hover{border-color:var(--border-strong)}
.input:focus,.select:focus,.textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--ring)}
.textarea{resize:vertical;min-height:72px;line-height:1.55}
.select-sm{height:30px;padding:0 7px;font-size:11.5px;width:auto}
.input-sm{height:30px;padding:0 7px;font-size:11.5px}
.form-hint{font-size:10.5px;color:var(--text-3);line-height:1.55;margin-top:5px}
.check{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--text-3);cursor:pointer;white-space:nowrap}
.check input{width:13px;height:13px;accent-color:var(--accent);margin:0}

/* ============================================================
   5. Shell / sidebar / header
   ============================================================ */
.shell{flex:1;display:flex;min-height:0}
.sidebar{
  width:238px;flex:0 0 238px;
  background:var(--surface);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;
  min-height:0;
}
.sidebar-head{
  padding:14px 16px 7px;
  font-size:10px;letter-spacing:.1em;text-transform:uppercase;
  color:var(--text-3);font-weight:700;
}
.nav{flex:1;overflow:auto;padding:3px 8px 12px}
.nav-item{
  width:100%;display:flex;align-items:center;gap:9px;
  padding:7px 9px;border-radius:7px;
  color:var(--text-2);text-align:left;
  transition:background var(--t-fast),color var(--t-fast);
}
.nav-item:hover{background:var(--surface-2)}
.nav-item.active{background:var(--accent-weak);color:var(--accent);font-weight:650}
.nav-num{
  width:21px;height:21px;flex:0 0 21px;
  border-radius:5px;background:var(--surface-2);
  display:grid;place-items:center;
  font:10.5px/1 var(--font-mono);color:var(--text-3);
}
.nav-item.active .nav-num{background:var(--accent);color:var(--on-accent)}
.nav-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12.5px}
.nav-count{font-size:10.5px;color:var(--text-3);font-variant-numeric:tabular-nums}
.nav-item.active .nav-count{color:var(--accent)}
.sidebar-foot{
  padding:11px 16px 14px;border-top:1px solid var(--border);
  font-size:10.5px;color:var(--text-3);line-height:1.7;
}
.sidebar-foot .entry{font-family:var(--font-mono);font-size:9.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sidebar-foot .scope{display:flex;align-items:center;gap:5px;margin-top:3px}
.sidebar-foot .scope .icon{width:12px;height:12px}

.workspace{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--bg);min-height:0}
.pagehead{display:flex;align-items:center;gap:16px;padding:9px 22px 0}
.pagehead-main{
  min-width:0;flex:1;
  display:flex;align-items:baseline;gap:9px;flex-wrap:wrap;
}
.breadcrumb{
  font:9.5px/1.4 var(--font-mono);color:var(--text-3);
  margin-left:auto;padding-left:10px;
  max-width:46%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.pagehead h1{margin:0;font-size:16.5px;line-height:1.25;font-weight:720;letter-spacing:-.015em;color:var(--text);white-space:nowrap}
.pagehead-sub{
  margin:0;font-size:11px;line-height:1.3;color:var(--text-3);
  white-space:nowrap;font-variant-numeric:tabular-nums;
}
.pagehead-actions{margin-left:auto;display:flex;align-items:center;gap:8px;flex:0 0 auto}

.viewtabs{
  display:flex;gap:3px;padding:6px 22px 0;
  overflow-x:auto;overflow-y:hidden;
}
.viewtab{
  height:29px;padding:0 11px;
  border-bottom:2px solid transparent;
  border-radius:6px 6px 0 0;
  color:var(--text-3);font-size:12.5px;
  display:inline-flex;align-items:center;gap:7px;
  white-space:nowrap;
  transition:color var(--t-fast),background var(--t-fast),border-color var(--t-fast);
}
.viewtab:hover{color:var(--text-2);background:var(--surface-2)}
.viewtab.active{color:var(--text);border-bottom-color:var(--accent);font-weight:650;background:transparent}
.viewtab .count{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;height:17px;padding:0 5px;border-radius:9px;
  background:var(--surface);border:1px solid var(--border);
  font-size:9.5px;color:var(--text-3);font-variant-numeric:tabular-nums;
}
.viewtab.active .count{border-color:var(--accent);color:var(--accent);background:var(--accent-weak)}

.demo-hint{
  display:flex;align-items:center;gap:8px;
  margin:0 22px 10px;padding:7px 9px;
  border:1px solid var(--border);border-left:3px solid var(--accent);
  border-radius:6px;background:var(--surface);
  font-size:11px;color:var(--text-3);line-height:1.5;
}
.demo-hint .dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:0 0 6px}
.demo-hint strong{color:var(--text-2);font-weight:650}
.demo-hint .icon-btn{width:23px;height:23px;margin-left:auto}

/* ============================================================
   6. Toolbar
   ============================================================ */
.toolbar{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:6px 22px;
  background:var(--surface);
  border-bottom:1px solid var(--border);
}
.toolbar-left{display:flex;align-items:center;gap:5px;flex-wrap:wrap;flex:1 1 auto;min-width:0}
.toolbar-right{margin-left:auto;display:flex;align-items:center;gap:8px;flex-wrap:wrap;flex:0 0 auto}
/* 宽屏一行放得下，条件 chip 太多时横向滚动，不再折行挤掉表格 */
@media(min-width:1121px){
  .toolbar{flex-wrap:nowrap}
  .toolbar-left{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
  .toolbar-left::-webkit-scrollbar{height:0}
}
.tool-label{font-size:10.5px;color:var(--text-3);white-space:nowrap}
.chip{
  display:inline-flex;align-items:center;gap:5px;
  height:25px;padding:0 7px;
  border-radius:5px;
  background:var(--surface-2);
  border:1px solid var(--border);
  font-size:10.5px;color:var(--text-2);
  white-space:nowrap;
}
.chip .icon{width:12px;height:12px;color:var(--text-3)}
.chip.fixed{background:transparent;border-style:dashed;color:var(--text-3)}
.chip .x{
  display:inline-grid;place-items:center;width:15px;height:15px;margin-right:-3px;
  border-radius:3px;color:var(--text-3);font-size:12px;line-height:1;
}
.chip .x:hover{background:var(--surface-3);color:var(--danger)}
.result-count{font-size:10.5px;color:var(--text-3);white-space:nowrap;font-variant-numeric:tabular-nums}

/* ============================================================
   7. Data grid
   ============================================================ */
.table-stage{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--surface)}
.table-scroll{flex:1;min-height:0;overflow:auto;background:var(--surface);position:relative}
.grid{width:100%;border-collapse:separate;border-spacing:0;table-layout:fixed}
.grid th{
  position:sticky;top:0;z-index:3;
  background:var(--surface-2);
  border-bottom:1px solid var(--border-strong);
  padding:7px 9px;
  text-align:left;
  font-size:10px;font-weight:700;letter-spacing:.035em;
  color:var(--text-3);text-transform:uppercase;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  user-select:none;
}
.grid th[data-sort]{cursor:pointer;transition:background var(--t-fast),color var(--t-fast)}
.grid th[data-sort]:hover{background:var(--surface-3);color:var(--text-2)}
.grid th.sorted{color:var(--text-2)}
.grid th .sort-ind{display:inline-block;width:11px;margin-left:2px;color:var(--accent);font-size:10px}
.grid th:first-child{left:0;z-index:5;padding-left:22px;box-shadow:1px 0 0 var(--grid-line)}
.grid th:last-child{padding-right:22px}
/* 竖向细线：每格只画右边，配合 border-collapse:separate 不会出现双线 */
.grid th,.grid td{border-right:1px solid var(--grid-line)}
.grid th:last-child,.grid td:last-child{border-right:0}
.grid td{
  padding:7px 9px;
  border-bottom:1px solid var(--grid-line);
  vertical-align:middle;
  font-size:12px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.grid td:first-child{padding-left:22px}
.grid td:last-child{padding-right:22px}
.grid tbody tr{transition:background var(--t-fast)}
.grid tbody tr[data-note]:hover td{background:var(--surface-2)}
.grid td.cell-title{
  position:sticky;left:0;z-index:1;
  background:var(--surface);
  box-shadow:1px 0 0 var(--grid-line);
}
.grid tbody tr[data-note]:hover td.cell-title{background:var(--surface-2)}
.grid td.cell-edit{cursor:text;border-radius:3px}
.grid td.cell-edit:hover{background:var(--accent-weak)!important}
.grid td.cell-edit:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.inline-select,.inline-input{
  width:100%;height:24px;
  border:1px solid var(--accent);
  border-radius:4px;
  background:var(--surface);
  padding:0 4px;
  font-size:11px;
  outline:none;
  box-shadow:0 0 0 3px var(--ring);
}
.inline-select{padding-right:2px}
.grid tr.row-index td.cell-title{background:linear-gradient(90deg,var(--surface-2),var(--surface) 60%)}

.group-row td{
  height:31px;padding:0!important;
  background:var(--bg);
  border-bottom:1px solid var(--border);
}
.group-toggle{
  display:flex;align-items:center;gap:7px;
  width:100%;height:31px;padding:0 22px;
  color:var(--text-2);font-size:11px;font-weight:700;
  text-align:left;
}
.group-toggle:hover{background:var(--surface-2)}
.group-label{max-width:60%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.group-count{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;height:17px;padding:0 5px;border-radius:9px;
  background:var(--surface);border:1px solid var(--border);
  font-size:9.5px;color:var(--text-3);font-weight:600;
  font-variant-numeric:tabular-nums;
}
.chev{transition:transform var(--t-fast);color:var(--text-3)}
.chev.collapsed{transform:rotate(-90deg)}

.cell-title .title-btn{display:block;width:100%;text-align:left;overflow:hidden}
.title-main{
  display:block;font-size:12.5px;font-weight:650;color:var(--text);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.35;
}
.title-sub{
  display:block;margin-top:1px;
  font:9.5px/1.3 var(--font-mono);color:var(--text-3);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.title-btn:hover .title-main{color:var(--accent)}
.cell-text span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cell-text .empty-text{color:var(--text-3)}

.tag{
  display:inline-flex;align-items:center;max-width:100%;
  height:19px;padding:0 5px;
  border-radius:4px;
  background:var(--surface-2);border:1px solid var(--border);
  color:var(--text-2);font-size:10px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.tag-blue{background:var(--accent-weak);border-color:transparent;color:var(--accent)}
.tag-index{background:var(--purple-weak);border-color:transparent;color:var(--purple);margin-left:6px;height:17px;font-size:9px;vertical-align:1px}

/* ============================================================
   8. Badges / owner / date
   ============================================================ */
.badge{
  display:inline-flex;align-items:center;gap:5px;
  height:21px;padding:0 7px;border-radius:999px;
  font-size:10.5px;font-weight:650;white-space:nowrap;
  max-width:100%;
}
.badge i{width:5px;height:5px;border-radius:50%;background:currentColor;flex:0 0 5px}
.status-idle{background:var(--danger-weak);color:var(--danger)}
.status-doing{background:var(--warn-weak);color:var(--warn)}
.status-blocked{background:var(--orange-weak);color:var(--orange)}
.status-done{background:var(--success-weak);color:var(--success)}
.status-paused{background:var(--surface-2);color:var(--text-3);border:1px solid var(--border)}
.status-pending{background:var(--purple-weak);color:var(--purple)}
.status-empty{background:var(--surface-2);color:var(--text-3);border:1px dashed var(--border-strong)}
.status-unknown{background:var(--danger-weak);color:var(--danger)}

.prio{
  display:inline-flex;align-items:center;justify-content:center;
  height:19px;min-width:28px;padding:0 6px;border-radius:5px;
  font:10px/1 var(--font-mono);font-weight:750;letter-spacing:.02em;
}
.prio-p0{background:var(--danger-weak);color:var(--danger)}
.prio-p1{background:var(--warn-weak);color:var(--warn)}
.prio-p2{background:var(--success-weak);color:var(--success)}
.prio-p3{background:var(--surface-2);color:var(--text-3);border:1px solid var(--border)}
.prio-empty{color:var(--text-3);font-weight:500}

.owner{display:inline-flex;align-items:center;gap:6px;min-width:0;max-width:100%}
.avatar-sm{
  width:20px;height:20px;flex:0 0 20px;border-radius:50%;
  background:var(--accent-weak);color:var(--accent);
  display:grid;place-items:center;
  font-size:9.5px;font-weight:750;
}
.owner-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.date{font-family:var(--font-mono);font-size:11px;color:var(--text-2);font-variant-numeric:tabular-nums}
.date.overdue{color:var(--danger);font-weight:650}
.date.due-soon{color:var(--warn)}

/* ============================================================
   9. Drawer
   ============================================================ */
.overlay{
  position:fixed;inset:0;z-index:40;
  background:rgba(15,23,34,.28);
  opacity:0;pointer-events:none;
  transition:opacity var(--t-base);
}
.overlay.show{opacity:1;pointer-events:auto}
.drawer{
  position:fixed;top:0;right:0;bottom:0;z-index:50;
  width:min(660px,94vw);
  background:var(--surface);
  border-left:1px solid var(--border);
  box-shadow:var(--shadow-3);
  transform:translateX(102%);
  transition:transform .22s cubic-bezier(.2,.7,.3,1);
  display:flex;flex-direction:column;
  min-height:0;
}
.drawer.open{transform:translateX(0)}
.drawer.full{width:100vw;border-left:0}
.drawer-head{
  flex:0 0 auto;
  display:flex;align-items:flex-start;gap:12px;
  padding:16px 18px 12px;
  border-bottom:1px solid var(--border);
}
.drawer-head-main{flex:1;min-width:0}
.drawer-kicker{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-bottom:6px}
.path-chip{
  display:inline-flex;align-items:center;
  height:19px;padding:0 6px;border-radius:4px;
  background:var(--surface-2);border:1px solid var(--border);
  font:9.5px/1 var(--font-mono);color:var(--text-3);
}
.warn-chip{
  display:inline-flex;align-items:center;gap:4px;
  height:20px;padding:0 6px;border-radius:5px;
  background:var(--warn-weak);color:var(--warn);
  font-size:10px;font-weight:650;
}
.warn-chip .icon{width:11px;height:11px}
.drawer-title{
  margin:0;font-size:18px;line-height:1.25;font-weight:720;letter-spacing:-.012em;
  color:var(--text);
  overflow-wrap:anywhere;
}
.drawer-path{
  margin-top:5px;font:10px/1.45 var(--font-mono);color:var(--text-3);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.drawer-meta{margin-top:3px;font-size:10.5px;color:var(--text-3)}
.dirty-badge{
  display:inline-flex;align-items:center;
  height:18px;padding:0 6px;margin-left:6px;border-radius:4px;
  background:var(--warn-weak);color:var(--warn);
  font-size:9.5px;font-weight:700;
}
.drawer-actions{display:flex;gap:1px;flex:0 0 auto}
.drawer-tabs{
  flex:0 0 auto;
  display:flex;gap:1px;
  padding:0 18px;
  border-bottom:1px solid var(--border);
}
.drawer-tab{
  height:38px;padding:0 11px;
  border-bottom:2px solid transparent;
  color:var(--text-3);font-size:12px;font-weight:550;
  transition:color var(--t-fast),border-color var(--t-fast);
}
.drawer-tab:hover{color:var(--text-2)}
.drawer-tab.active{color:var(--text);border-bottom-color:var(--accent);font-weight:650}
.drawer-body{flex:1;min-height:0;overflow:auto;padding:16px 18px 22px}
.drawer-foot{
  flex:0 0 auto;
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
  padding:10px 18px;
  border-top:1px solid var(--border);
  background:var(--surface);
}
.lock-hint{display:inline-flex;align-items:center;gap:5px;font-size:11px;color:var(--text-3)}
.lock-hint .icon{width:13px;height:13px}

/* ============================================================
   10. Detail properties
   ============================================================ */
.props{display:flex;flex-direction:column;gap:0}
.prop{
  display:grid;grid-template-columns:92px minmax(0,1fr);gap:10px;
  align-items:start;
  padding:6px 0;
  border-bottom:1px solid var(--border);
}
.prop:last-child{border-bottom:0}
.prop-label{
  padding-top:7px;
  font-size:11px;color:var(--text-3);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.prop-control{min-width:0}
.prop-control .input,.prop-control .select,.prop-control .textarea{
  background:var(--surface-2);
  border-color:var(--border);
  font-size:12px;
  padding:6px 8px;
}
.prop-control .input:hover,.prop-control .select:hover,.prop-control .textarea:hover{border-color:var(--border-strong)}
.prop-control .input:focus,.prop-control .select:focus,.prop-control .textarea:focus{background:var(--surface);border-color:var(--accent);box-shadow:0 0 0 3px var(--ring)}
.prop-control .select{height:32px}
.control-inline{display:flex;align-items:center;gap:8px}
.control-inline .select{flex:1;min-width:0}
.control-inline .badge,.control-inline .prio{flex:0 0 auto}
.prop-group-title{
  font-size:9.5px;letter-spacing:.1em;text-transform:uppercase;
  color:var(--text-3);font-weight:750;
  margin:2px 0 4px;
}
.notice{
  display:flex;gap:8px;align-items:flex-start;
  padding:8px 10px;border-radius:7px;
  margin-bottom:10px;
  font-size:11px;line-height:1.5;
}
.notice .icon{width:14px;height:14px;margin-top:1px}
.notice.warn{background:var(--warn-weak);color:var(--warn)}
.notice strong{display:block;font-size:10.5px;margin-bottom:1px}
details.more{margin-top:9px;border-top:1px solid var(--border);padding-top:8px}
details.more summary{
  list-style:none;cursor:pointer;
  display:flex;align-items:center;gap:6px;
  padding:4px 0;
  font-size:11px;color:var(--text-3);font-weight:600;
  user-select:none;
}
details.more summary::-webkit-details-marker{display:none}
details.more summary .icon{width:12px;height:12px;transition:transform var(--t-fast)}
details.more[open] summary .icon{transform:rotate(90deg)}
details.more summary .count{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:17px;height:16px;padding:0 4px;border-radius:8px;
  background:var(--surface-2);border:1px solid var(--border);
  font-size:9px;font-weight:600;
}
.new-prop{margin-top:10px}
.new-prop-form{display:flex;gap:6px;flex-wrap:wrap}
.new-prop-form .input{flex:1;min-width:110px;height:30px;font-size:11.5px;padding:0 7px}

/* ============================================================
   11. Detail body / editor / history
   ============================================================ */
.body-toolbar{
  display:flex;align-items:center;gap:8px;
  padding-bottom:8px;margin-bottom:10px;
  border-bottom:1px solid var(--border);
}
.body-badge{
  font:9.5px/1 var(--font-mono);color:var(--text-3);
  border:1px solid var(--border);border-radius:4px;padding:3px 5px;
}
.body-footnote{
  margin-top:18px;padding-top:10px;
  border-top:1px dashed var(--border);
  font-size:10.5px;color:var(--text-3);line-height:1.65;
}
.md{font-size:13px;line-height:1.72;color:var(--text);overflow-wrap:anywhere}
.md h1{font-size:18px;line-height:1.3;margin:18px 0 7px;font-weight:720;letter-spacing:-.01em}
.md h1:first-child{margin-top:0}
.md h2{font-size:14.5px;line-height:1.35;margin:17px 0 5px;font-weight:700}
.md h3{font-size:13px;margin:13px 0 4px;font-weight:700}
.md p{margin:5px 0}
.md ul,.md ol{margin:5px 0;padding-left:20px}
.md li{margin:3px 0}
.md strong{font-weight:700}
/* 现场图片：抽屉只有 660px，先按宽度铺满，点开再放大 */
.md img{
  display:block;
  max-width:100%;
  height:auto;
  margin:8px 0;
  border:1px solid var(--border);
  border-radius:7px;
  background:var(--surface-2);
  cursor:zoom-in;
}
/* 表格里的图片列：一行小缩略图，点击看大图 */
.grid td.cell-images{padding:5px 8px;white-space:nowrap}
.cell-images .thumb{
  width:34px;height:34px;object-fit:cover;
  border:1px solid var(--border);border-radius:5px;
  background:var(--surface-2);cursor:zoom-in;
  margin-right:3px;vertical-align:middle;
  transition:transform .12s ease;
}
.cell-images .thumb:hover{transform:scale(1.12);border-color:var(--accent)}
.cell-images .thumb-more{
  display:inline-block;vertical-align:middle;
  font-size:10.5px;color:var(--muted);margin-left:1px;
}
/* 正文里的 Markdown 表格：Obsidian 每格都有细线，这里共用同一套 --grid-line */
.md table{
  border-collapse:collapse;
  margin:9px 0;width:100%;
  font-size:11.5px;line-height:1.5;
}
.md th,.md td{
  border:1px solid var(--grid-line);
  padding:4px 7px;
  text-align:left;vertical-align:top;
  white-space:normal;overflow-wrap:anywhere;
}
.md th{background:var(--surface-2);font-weight:700;color:var(--text-2)}
.md code{
  font-family:var(--font-mono);font-size:11px;
  background:var(--surface-2);border:1px solid var(--border);
  border-radius:4px;padding:1px 4px;
}
.md pre{
  background:var(--surface-2);border:1px solid var(--border);border-radius:7px;
  padding:10px 12px;overflow:auto;
}
.md pre code{border:0;background:none;padding:0}
.md blockquote{
  margin:8px 0;padding:7px 10px;
  border-left:3px solid var(--border-strong);
  background:var(--surface-2);
  color:var(--text-2);font-size:12px;border-radius:0 5px 5px 0;
}
.md .wikilink{
  color:var(--accent);
  border-bottom:1px dashed var(--accent);
  cursor:pointer;
}
.md .wikilink:hover{background:var(--accent-weak)}
/* 任务项用绝对定位放复选框：用 flex 会把 "a · b · c" 拆成多个 flex item，
   每段各占一列，长清单会变成错位的栏 */
.md li.task{list-style:none;margin-left:-20px;padding-left:20px;position:relative}
.md .checkbox{
  position:absolute;left:0;top:5px;
  width:13px;height:13px;
  border:1.5px solid var(--border-strong);border-radius:3px;background:var(--surface);
}
.md .md-tag{
  color:var(--accent);background:var(--accent-weak);
  border-radius:9px;padding:0 5px;font-size:11.5px;white-space:nowrap;
}
.md .checkbox.checked{background:var(--accent);border-color:var(--accent);position:relative}
.md .checkbox.checked::after{
  content:"";position:absolute;left:3px;top:1px;
  width:5px;height:8px;
  border-right:2px solid var(--on-accent);border-bottom:2px solid var(--on-accent);
  transform:rotate(42deg);
}
.editor-split{display:grid;grid-template-columns:1fr 1fr;gap:10px;align-items:start}
.editor-pane{min-width:0}
.editor-pane textarea{
  width:100%;min-height:460px;
  font-family:var(--font-mono);font-size:11.5px;line-height:1.65;
  resize:vertical;
}
.preview-pane{
  max-height:560px;overflow:auto;
  border:1px solid var(--border);border-radius:7px;
  background:var(--surface-2);
  padding:12px;
}
.preview-pane .md{font-size:12px}
.timeline{position:relative;padding-left:17px;margin-top:4px}
.timeline::before{content:"";position:absolute;left:5px;top:5px;bottom:5px;width:1px;background:var(--border)}
.timeline-item{position:relative;padding:0 0 15px 11px}
.timeline-item::before{
  content:"";position:absolute;left:-16px;top:4px;
  width:8px;height:8px;border-radius:50%;
  background:var(--surface);border:2px solid var(--accent);
}
.timeline-ts{font:9.5px/1.4 var(--font-mono);color:var(--text-3)}
.timeline-text{font-size:12px;color:var(--text-2);line-height:1.55;margin-top:1px}
.timeline-user{color:var(--text);font-weight:650}
.history-head{display:flex;align-items:center;gap:8px;margin-bottom:10px}

/* ============================================================
   12. Popovers / inline cell editor
   ============================================================ */
.popover{
  position:fixed;z-index:60;
  display:none;
  min-width:260px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:9px;
  box-shadow:var(--shadow-2);
  padding:11px;
}
.popover.open{display:block}
.popover-title{font-size:11px;font-weight:700;color:var(--text-2);margin-bottom:8px}
.field-row{display:flex;align-items:center;gap:6px;margin-bottom:7px}
.field-row .select,.field-row .input{min-width:0}
.popover-foot{display:flex;align-items:center;gap:8px;margin-top:2px}
.popover-foot .btn{margin-left:auto}
.check-list{max-height:280px;overflow:auto;margin:0 -4px}
.check-row{
  display:flex;align-items:center;gap:8px;
  padding:5px 5px;border-radius:5px;
  font-size:11.5px;color:var(--text-2);cursor:pointer;
}
.check-row:hover{background:var(--surface-2)}
.check-row input{width:13px;height:13px;accent-color:var(--accent);margin:0}

.cell-editor{
  position:fixed;z-index:80;
  width:320px;max-width:calc(100vw - 24px);
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:9px;
  box-shadow:var(--shadow-2);
  padding:9px;
}
.cell-editor-head{display:flex;align-items:center;gap:6px;font-size:11px;font-weight:700;color:var(--text-2);margin-bottom:6px}
.cell-editor-head .icon-btn{width:22px;height:22px;margin-left:auto}
.cell-editor textarea{min-height:96px;font-size:12px}
.cell-editor-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:7px}

/* ============================================================
   13. Modals
   ============================================================ */
.modal-backdrop{
  position:fixed;inset:0;z-index:70;
  display:none;place-items:center;
  padding:24px;
  background:rgba(15,23,34,.38);
}
.modal-backdrop.open{display:grid}
/* 正文图片放大：整屏黑底，图按比例缩到窗口内 */
.img-viewer{
  position:fixed;inset:0;z-index:80;
  display:flex;align-items:center;justify-content:center;
  padding:32px;
  background:rgba(10,15,22,.9);
}
.img-viewer img{
  max-width:100%;max-height:calc(100vh - 64px);
  border-radius:var(--r-md);
  box-shadow:var(--shadow-3);
  cursor:default;
}
.img-viewer-close{
  position:absolute;top:16px;right:16px;
  width:38px;height:38px;display:grid;place-items:center;
  border:1px solid rgba(255,255,255,.22);border-radius:50%;
  background:rgba(255,255,255,.08);color:#fff;
  cursor:pointer;transition:background var(--t-fast);
}
.img-viewer-close:hover{background:rgba(255,255,255,.18)}
.img-viewer-close .icon{width:18px;height:18px}
.modal{
  width:min(560px,100%);max-height:calc(100vh - 48px);
  overflow:auto;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--r-xl);
  box-shadow:var(--shadow-3);
}
.modal-head{display:flex;align-items:flex-start;gap:12px;padding:17px 19px 11px}
.modal-head-main{flex:1;min-width:0}
.modal-head h2{margin:0;font-size:16px;font-weight:720;letter-spacing:-.01em}
.modal-head p{margin:4px 0 0;font-size:11px;color:var(--text-3);line-height:1.55}
.modal-body{padding:4px 19px 18px}
.modal-foot{display:flex;justify-content:flex-end;gap:7px;padding:11px 19px;border-top:1px solid var(--border);background:var(--surface)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:11px}
.form-field{display:flex;flex-direction:column;gap:4px;min-width:0}
.form-field.full{grid-column:1/-1}
.form-field label{font-size:10.5px;color:var(--text-3);font-weight:650}
.form-field .input,.form-field .select{height:34px;font-size:12.5px}
.form-error{
  margin-top:10px;padding:8px 10px;border-radius:6px;
  background:var(--danger-weak);color:var(--danger);
  font-size:11.5px;line-height:1.5;
}
.conflict-banner{
  display:flex;gap:9px;align-items:flex-start;
  padding:10px 11px;margin-bottom:12px;
  background:var(--warn-weak);color:var(--warn);
  border-radius:7px;
}
.conflict-banner .icon{width:16px;height:16px;margin-top:1px}
.conflict-banner strong{display:block;font-size:11.5px;margin-bottom:2px}
.conflict-banner p{margin:0;font-size:11px;line-height:1.55}
.conflict-table{width:100%;border-collapse:collapse;font-size:11.5px}
.conflict-table th{
  text-align:left;font-size:9.5px;letter-spacing:.04em;text-transform:uppercase;
  color:var(--text-3);font-weight:700;
  padding:6px 8px;border-bottom:1px solid var(--border);
}
.conflict-table td{padding:7px 8px;border-bottom:1px solid var(--border);vertical-align:top}
.conflict-table tr:last-child td{border-bottom:0}

/* ============================================================
   14. Toasts / empty / utility
   ============================================================ */
.toast-wrap{
  position:fixed;left:50%;top:60px;z-index:90;
  transform:translateX(-50%);
  display:flex;flex-direction:column;align-items:center;gap:7px;
  pointer-events:none;
}
.toast{
  display:flex;align-items:center;gap:7px;
  max-width:min(560px,92vw);
  padding:9px 14px;
  border-radius:8px;
  background:var(--toast-bg);color:var(--toast-fg);
  font-size:12px;line-height:1.45;
  box-shadow:var(--shadow-2);
  animation:toastIn .18s ease-out;
}
.toast .icon{width:13px;height:13px;flex:0 0 13px;color:var(--ok,#2f9e6e)}
.toast.out{opacity:0;transform:translateY(-4px);transition:opacity .16s,transform .16s}
@keyframes toastIn{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}
@keyframes spin{to{transform:rotate(360deg)}}
.spin .icon{animation:spin .6s linear}

.empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  min-height:320px;padding:40px 20px;gap:5px;text-align:center;color:var(--text-3);
}
.empty-icon{
  width:40px;height:40px;border-radius:11px;
  display:grid;place-items:center;margin-bottom:4px;
  background:var(--surface-2);border:1px solid var(--border);color:var(--text-3);
}
.empty-title{font-size:13.5px;font-weight:650;color:var(--text-2)}
.empty-sub{font-size:11.5px;max-width:360px;line-height:1.6}
.empty .btn{margin-top:7px}

body.viewer .editor-only{display:none!important}

@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
}

/* ============================================================
   15. Responsive
   ============================================================ */
@media(max-width:1180px){
  .brand{min-width:160px}
  .search{max-width:380px}
  .demo-badge{display:none}
  .grid td .cell-text span{max-width:230px}
}
@media(max-width:980px){
  .topbar{height:auto;flex-wrap:wrap;gap:8px;padding:8px 12px}
  .brand{min-width:0}
  .search{order:3;flex-basis:100%;max-width:none}
  .top-actions{margin-left:auto}
  .shell{flex-direction:column}
  .sidebar{
    width:100%;flex:0 0 auto;
    border-right:0;border-bottom:1px solid var(--border);
  }
  .sidebar-head,.sidebar-foot{display:none}
  .nav{display:flex;gap:4px;overflow-x:auto;padding:7px 10px}
  .nav-item{width:auto;flex:0 0 auto;padding:6px 9px}
  .nav-title{max-width:118px}
  .nav-count{display:none}
  .pagehead{padding:8px 14px 0}
  .pagehead h1{font-size:15.5px}
  .pagehead-sub{font-size:10.5px}
  .breadcrumb{max-width:100%;margin-left:0;padding-left:0}
  .viewtabs{padding:6px 14px 0}
  .demo-hint{margin:0 14px 8px}
  .toolbar{padding:6px 14px}
  .grid th:first-child,.grid td:first-child{padding-left:14px}
  .grid th:last-child,.grid td:last-child{padding-right:14px}
  .group-toggle{padding:0 14px}
  .drawer{width:100vw}
  .editor-split{grid-template-columns:1fr}
  .preview-pane{max-height:340px}
}
@media(max-width:640px){
  .brand-sub{display:none}
  .role-switch button{padding:0 8px}
  .user-chip{padding-left:6px}
  .user-chip span:last-child{display:none}
  .pagehead-actions .btn{padding:0 9px}
  .pagehead-actions .btn .icon{display:none}
  .form-grid{grid-template-columns:1fr}
  .prop{grid-template-columns:74px minmax(0,1fr);gap:8px}
  .drawer-head{padding:13px 14px 10px}
  .drawer-tabs,.drawer-body,.drawer-foot{padding-left:14px;padding-right:14px}
  .drawer-title{font-size:16px}
  .modal-backdrop{padding:12px}
}

/* ============================================================
   12. 平台补充（只读底座的少量样式）
   ============================================================ */
.th-open{width:28px;padding-left:0!important;padding-right:10px!important;color:var(--text-3)}
.grid tbody tr[data-note]{cursor:pointer}
.grid tbody tr[data-note]:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.chip-user{border-color:var(--accent);color:var(--accent);background:var(--accent-weak)}
.chip-user .icon-btn{width:16px;height:16px;margin-right:-3px}
.chip .icon{width:12px;height:12px}
.prop-long{font-size:12px;line-height:1.65;color:var(--text-2);white-space:pre-wrap;overflow-wrap:anywhere}
.prop-text{font-size:12px;color:var(--text-2);overflow-wrap:anywhere}
.wikilink-off{color:var(--text-2);border-bottom:1px dotted var(--border-strong);cursor:help}
details.more summary .icon{transition:transform var(--t-fast)}

/* ============================================================
   16. 账号：登录页、用户菜单、账号管理
   ============================================================ */
.login-body{display:grid;place-items:center;min-height:100vh;background:var(--bg)}
.login-card{
  width:352px;max-width:92vw;
  background:var(--surface);
  border:1px solid var(--border);border-radius:var(--r-xl);
  box-shadow:var(--shadow-2);
  padding:26px 24px 20px;
}
.login-brand{display:flex;align-items:center;gap:11px;margin-bottom:20px}
.login-title{font-size:15px;font-weight:720;letter-spacing:-.01em}
.login-sub{font-size:10.5px;color:var(--text-3);margin-top:1px}
.login-form{display:flex;flex-direction:column;gap:11px}
.login-field{display:flex;flex-direction:column;gap:4px}
.login-field span{font-size:10.5px;color:var(--text-3);font-weight:650}
.login-field .input{height:36px;font-size:13px}
.login-submit{height:36px;margin-top:3px}
.login-error{
  margin:0;padding:7px 9px;border-radius:6px;
  background:var(--danger-weak);color:var(--danger);font-size:11.5px;line-height:1.5;
}
.login-foot{margin:16px 0 0;font-size:10.5px;color:var(--text-3);text-align:center}

.user-wrap{position:relative}
.user-chip{
  display:flex;align-items:center;gap:7px;
  height:30px;padding:0 8px 0 4px;border-radius:999px;
  border:1px solid var(--border);background:var(--surface);
  font-size:12px;color:var(--text-2);
  transition:background var(--t-fast),border-color var(--t-fast);
}
.user-chip:hover{background:var(--surface-2);border-color:var(--border-strong)}
.user-chip .icon{width:12px;height:12px;color:var(--text-3)}
.user-avatar{
  width:22px;height:22px;border-radius:50%;
  display:grid;place-items:center;
  background:var(--accent-weak);color:var(--accent);
  font-size:10.5px;font-weight:700;
}
.user-name{max-width:88px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.user-pop{
  position:absolute;right:0;top:calc(100% + 6px);z-index:60;
  width:188px;padding:5px;
  background:var(--surface);
  border:1px solid var(--border);border-radius:var(--r-md);
  box-shadow:var(--shadow-2);
}
.user-pop-head{
  display:flex;flex-direction:column;gap:1px;
  padding:7px 9px 8px;border-bottom:1px solid var(--border);margin-bottom:4px;
}
.user-pop-head strong{font-size:12.5px}
.user-pop-head span{font-size:10.5px;color:var(--text-3)}
.menu-item{
  display:block;width:100%;text-align:left;
  padding:7px 9px;border-radius:5px;
  font-size:12px;color:var(--text-2);
}
.menu-item:hover{background:var(--surface-2);color:var(--text)}
.menu-item.danger{color:var(--danger)}

.users-list{display:flex;flex-direction:column;gap:1px;margin-bottom:16px}
.user-row{
  display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:10px;
  padding:8px 2px;border-bottom:1px solid var(--border);
}
.user-row:last-child{border-bottom:0}
.user-row-main{min-width:0}
.user-row-name{font-size:12.5px;font-weight:600}
.user-row-sub{font-size:10.5px;color:var(--text-3);font-family:var(--font-mono)}
.user-row .select{height:28px;font-size:11.5px}
.user-row-actions{display:flex;gap:5px;align-items:center}
.users-add{border-top:1px solid var(--border);padding-top:14px}
.users-add-title{font-size:10.5px;font-weight:700;color:var(--text-3);letter-spacing:.03em;text-transform:uppercase;margin-bottom:9px}
.users-add-foot{display:flex;justify-content:flex-end;margin-top:10px}
.badge-role{font-size:10px;padding:1px 6px;border-radius:9px;background:var(--surface-3);color:var(--text-2)}
.badge-role.admin{background:var(--accent-weak);color:var(--accent)}
.badge-role.editor{background:var(--success-weak);color:var(--success)}
.badge-disabled{font-size:10px;color:var(--danger);margin-left:5px}
details.more:not([open]) summary .icon{transform:rotate(-90deg)}

/* ============================================================
   17. 编辑态：字段控件、保存条、正文编辑器
   ============================================================ */
.prop-input{
  width:100%;
  background:var(--surface-2);
  border:1px solid var(--border);border-radius:var(--r-sm);
  color:var(--text);font:inherit;font-size:12px;line-height:1.5;
  padding:6px 8px;
}
select.prop-input{height:32px;padding:0 7px}
textarea.prop-input{resize:vertical;min-height:64px}
.prop-input::placeholder{color:var(--text-3)}
.prop-input:hover{border-color:var(--border-strong)}
.prop-input:focus{
  outline:none;background:var(--surface);
  border-color:var(--accent);box-shadow:0 0 0 3px var(--ring);
}
.prop-blank .prop-label{color:var(--text-3)}

.save-foot{justify-content:space-between}
.save-actions{display:flex;align-items:center;gap:6px}

.body-toolbar .body-badge{margin-right:auto}
.body-editor{
  width:100%;min-height:52vh;
  font-family:var(--font-mono);font-size:12px;line-height:1.7;
}

.add-field{margin-bottom:10px}
.add-field-form{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:7px}
.add-field-form .prop-input{flex:1 1 130px;min-width:110px;height:30px;padding:0 7px}
.add-field-form .btn{flex:0 0 auto}

.user-row-self{
  font-size:9.5px;font-weight:600;color:var(--accent);
  border:1px solid var(--accent);border-radius:8px;
  padding:0 5px;margin-left:5px;vertical-align:1px;
}
.modal-sm{width:min(400px,100%)}

/* ============================================================
   18. 文档树（13-生产版本）
   ============================================================ */
[hidden]{display:none!important}
.sidebar-navfoot{flex:0 0 auto;padding:6px 8px;border-top:1px solid var(--border)}
.nav-audit .nav-num{background:var(--surface-2)}
.nav-audit .nav-num .icon{width:12px;height:12px}

.doc-stage{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--surface)}
.doc-split{flex:1;min-height:0;display:flex}
.doc-tree{
  width:226px;flex:0 0 226px;min-height:0;
  display:flex;flex-direction:column;
  background:var(--surface-2);
  border-right:1px solid var(--border);
}
.doc-tree-head{
  display:flex;align-items:center;gap:6px;
  padding:10px 12px 8px;
  font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;
  color:var(--text-3);
}
.doc-tree-head > span:nth-child(2){flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.doc-tree-head .icon{width:13px;height:13px}
.doc-tree-count{font-variant-numeric:tabular-nums}
.doc-tree-body{flex:1;min-height:0;overflow:auto;padding:0 6px 12px}
.doc-folder,.doc-note{
  width:100%;display:flex;align-items:center;gap:5px;
  padding:5px 7px;border-radius:6px;
  text-align:left;color:var(--text-2);font-size:12px;
  transition:background var(--t-fast),color var(--t-fast);
}
.doc-folder:hover,.doc-note:hover{background:var(--surface-3);color:var(--text)}
.doc-folder .chev{width:12px;height:12px;flex:0 0 12px}
.doc-node-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.doc-node-count{font-size:9.5px;color:var(--text-3);font-variant-numeric:tabular-nums}
.doc-children{padding-left:11px;border-left:1px solid var(--border);margin-left:10px}
.doc-note{padding-left:8px}
.doc-note.active{background:var(--accent-weak);color:var(--accent);font-weight:650}
.doc-note.active .doc-node-name{white-space:normal;line-height:1.4}
.doc-tree-empty{
  padding:14px 10px;font-size:11.5px;color:var(--text-3);
  display:flex;flex-direction:column;align-items:flex-start;gap:6px;line-height:1.6;
}

.doc-main{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;background:var(--surface)}
.doc-toolbar{
  flex:0 0 auto;display:flex;align-items:center;gap:10px;
  padding:10px 20px;border-bottom:1px solid var(--border);
}
.doc-toolbar-main{display:flex;align-items:center;gap:8px;min-width:0;flex:1}
.doc-title{
  margin:0;font-size:14px;font-weight:700;line-height:1.35;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.doc-tools{display:flex;align-items:center;gap:6px;flex:0 0 auto}
.doc-edit-hint{font-size:10.5px;color:var(--text-3);white-space:nowrap}
.doc-content{flex:1;min-height:0;overflow:auto;padding:18px 22px 28px}
.doc-read{max-width:860px}
.doc-content.editing{padding:12px 16px 16px;display:flex;min-height:0}
.doc-content.editing .editor-split{flex:1;min-height:0;width:100%;align-items:stretch}
.doc-edit .editor-pane,.doc-edit .preview-pane{display:flex;flex-direction:column;min-height:0;height:100%}
.doc-edit .editor-pane textarea{flex:1;min-height:0;height:100%;resize:none}
.doc-edit .preview-pane{max-height:none;height:100%}
.doc-edit .preview-pane .md{min-height:0}

/* ============================================================
   19. 变更记录（平台 + 本地）
   ============================================================ */
.changes-stage{flex:1;min-height:0;display:flex;flex-direction:column;background:var(--surface)}
.changes-head{flex:0 0 auto;border-bottom:1px solid var(--border);background:var(--surface)}
.changes-note{
  display:flex;align-items:center;gap:6px;
  padding:8px 22px;border-bottom:1px solid var(--border);
  background:var(--surface-2);
  color:var(--text-3);font-size:10.5px;line-height:1.5;
}
.changes-note .icon{width:13px;height:13px;flex:0 0 13px}
.changes-note b{color:var(--text-2);font-variant-numeric:tabular-nums}
.changes-toolbar{display:flex;align-items:center;gap:7px;flex-wrap:wrap;padding:7px 22px}
.changes-scroll{flex:1;min-height:0;overflow:auto;padding:0 22px 28px}

.change-day{margin-top:10px}
.change-day-head{
  position:sticky;top:0;z-index:2;
  display:flex;align-items:center;gap:7px;
  padding:6px 0;background:var(--surface);
  font-size:10px;font-weight:750;letter-spacing:.06em;text-transform:uppercase;
  color:var(--text-3);
}
.change-day-count{
  display:inline-flex;align-items:center;justify-content:center;
  min-width:18px;height:17px;padding:0 5px;border-radius:9px;
  background:var(--surface-2);border:1px solid var(--border);
  font-size:9.5px;font-weight:600;font-variant-numeric:tabular-nums;
}
.change-row{border-bottom:1px solid var(--border)}
.change-line{
  display:flex;align-items:center;gap:10px;
  padding:8px 2px;cursor:pointer;
  transition:background var(--t-fast);
}
.change-line:hover{background:var(--surface-2)}
.change-row.open .change-line{background:var(--surface-2)}
.change-time{flex:0 0 44px;font:10px/1.4 var(--font-mono);color:var(--text-3);font-variant-numeric:tabular-nums}
.change-source{display:inline-flex;align-items:center;gap:5px;flex:0 0 auto;font-size:10.5px;color:var(--text-2);white-space:nowrap}
.change-source .icon{width:12px;height:12px}
.src-local{color:var(--purple)}
.avatar-xs{
  width:18px;height:18px;border-radius:50%;
  display:grid;place-items:center;
  background:var(--accent-weak);color:var(--accent);
  font-size:9.5px;font-weight:700;
}
.change-note-link{
  flex:0 1 auto;min-width:0;max-width:36%;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  text-align:left;font-size:12.5px;font-weight:650;color:var(--text);
}
.change-note-link:hover{color:var(--accent);text-decoration:underline}
.change-chips{flex:1;min-width:0;display:flex;gap:4px;overflow:hidden}
.change-chip{
  display:inline-flex;align-items:center;gap:4px;
  max-width:100%;height:21px;padding:0 6px;border-radius:4px;
  background:var(--surface-2);border:1px solid var(--border);
  color:var(--text-2);font-size:10px;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
}
.change-chip s{color:var(--text-3);text-decoration:none}
.change-chip b{color:var(--text-3);font-weight:400}
.chip-create{background:var(--success-weak);border-color:transparent;color:var(--success);font-weight:650}
.chip-delete{background:var(--danger-weak);border-color:transparent;color:var(--danger);font-weight:650}
.chip-body{background:var(--accent-weak);border-color:transparent;color:var(--accent)}
.change-line > .chev{width:13px;height:13px;flex:0 0 13px}
.change-detail{padding:2px 2px 12px 54px}
.change-line-note{font-size:11.5px;color:var(--text-3);margin:4px 0 6px;line-height:1.6}
.change-fields{width:100%;border-collapse:collapse;font-size:11.5px;margin:2px 0 6px}
.change-fields th{
  width:108px;text-align:left;font-weight:650;color:var(--text-3);
  padding:3px 8px 3px 0;vertical-align:top;
}
.change-fields td{padding:3px 8px;vertical-align:top;overflow-wrap:anywhere;border-radius:3px}
.cf-old{color:var(--danger);background:var(--danger-weak)}
.cf-new{color:var(--success);background:var(--success-weak)}
.cf-arrow{width:16px;text-align:center;color:var(--text-3);background:none!important}
.change-body{
  display:flex;align-items:center;gap:7px;flex-wrap:wrap;
  font-size:11.5px;color:var(--text-2);margin-top:4px;
}
.diff-stat{font:10.5px/1.4 var(--font-mono);color:var(--text-3)}
pre.diff{
  flex-basis:100%;margin:6px 0 0;
  max-height:420px;overflow:auto;
  background:var(--surface-2);
  border:1px solid var(--border);border-radius:7px;
  padding:8px 0;
  font:11px/1.6 var(--font-mono);
}
.diff-line{display:block;padding:0 10px;white-space:pre;min-height:1.6em}
.diff-line.add{background:var(--success-weak);color:var(--success)}
.diff-line.del{background:var(--danger-weak);color:var(--danger)}
.diff-line.hunk{background:var(--accent-weak);color:var(--accent)}

/* ============================================================
   20. 账号可见范围
   ============================================================ */
.scope-picker{
  display:grid;grid-template-columns:1fr 1fr;gap:14px;
  margin-top:12px;padding-top:12px;border-top:1px solid var(--border);
}
.scope-col{min-width:0}
.scope-title{font-size:10.5px;font-weight:700;color:var(--text-2);margin-bottom:4px}
.scope-title .muted{font-weight:400;font-size:9.5px}
.scope-req{font-size:9.5px;color:var(--warn);font-weight:650}
.scope-picker .check-list{border:1px solid var(--border);border-radius:6px;padding:3px 5px;max-height:150px}
.user-row-scope{font-size:10px;color:var(--text-3);margin-top:1px;overflow-wrap:anywhere}
.user-scope{
  grid-column:1/-1;
  display:grid;grid-template-columns:1fr 1fr;gap:14px;
  padding:8px 0 10px;
}
.user-scope .check-list{border:1px solid var(--border);border-radius:6px;padding:3px 5px;max-height:132px}
.user-scope-wide{grid-column:1/-1;border-top:1px dashed var(--border);margin-top:2px;padding-top:6px}
.scope-list-off{opacity:.42;pointer-events:none}
.scope-all{border-bottom:1px dashed var(--border);border-radius:0;margin-bottom:3px;padding-bottom:5px}

@media(max-width:980px){
  .sidebar{flex-direction:row;align-items:stretch}
  .sidebar-navfoot{border-top:0;border-left:1px solid var(--border);padding:4px 6px;display:flex;align-items:center}
  .nav-audit{width:auto}
  .doc-split{flex-direction:column}
  .doc-tree{
    width:100%;flex:0 0 auto;max-height:190px;
    border-right:0;border-bottom:1px solid var(--border);
  }
  .doc-toolbar{padding:8px 14px}
  .doc-content{padding:14px}
  .doc-content.editing{display:block;overflow:auto}
  .doc-content.editing .doc-edit{height:auto}
  .doc-content.editing .editor-split{grid-template-columns:1fr}
  .doc-edit .editor-pane textarea{min-height:320px;height:auto}
  .doc-edit .preview-pane{max-height:420px;height:auto}
  .changes-note,.changes-toolbar{padding-left:14px;padding-right:14px}
  .changes-scroll{padding:0 14px 24px}
  .change-line{flex-wrap:wrap;gap:6px 8px}
  .change-chips{order:5;flex-basis:100%;padding-left:54px}
  .change-detail{padding-left:2px}
  .user-scope,.scope-picker{grid-template-columns:1fr}
}
