  :root {
    --bg: #f7f6f3; --panel: #ffffff; --text: #1f2328; --muted: #6b7078; --line: #e3e1dc;
    --hover: #efede8; --active: #e4e8ff; --accent: #5b5bd6; --danger: #c4343a; --ok: #2f8a4c; --warn: #b7791f;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #17181a; --panel: #1e1f22; --text: #e6e6e6; --muted: #9a9ca3; --line: #2e3034;
      --hover: #26282c; --active: #2d3157; --accent: #8f8ff0; --danger: #ef6b70; --ok: #5cc27e; --warn: #e0a84a;
    }
  }
  :root[data-theme="dark"] {
    --bg: #17181a; --panel: #1e1f22; --text: #e6e6e6; --muted: #9a9ca3; --line: #2e3034;
    --hover: #26282c; --active: #2d3157; --accent: #8f8ff0; --danger: #ef6b70; --ok: #5cc27e; --warn: #e0a84a;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
    font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
  #app { display: flex; height: 100vh; height: 100dvh; }
  aside { width: 280px; min-width: 220px; display: flex; flex-direction: column; background: var(--panel);
    border-right: 1px solid var(--line); }
  aside.hidden { display: none; }
  .head { padding: 12px 12px 8px; display: flex; align-items: center; gap: 8px; }
  .head h1 { font-size: 15px; margin: 0; flex: 1; font-weight: 650; }
  .search { margin: 0 12px 8px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px;
    background: var(--bg); color: var(--text); font: inherit; width: calc(100% - 24px); }
  .actions { display: flex; gap: 6px; padding: 0 12px 8px; }
  button { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
    border-radius: 7px; padding: 5px 9px; cursor: pointer; }
  button:hover { background: var(--hover); }
  button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
  button.icon { padding: 3px 7px; border-color: transparent; background: transparent; }
  button.icon:hover { background: var(--hover); }
  .tree { flex: 1; overflow: auto; padding: 4px 6px 12px; }
  .row { display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-radius: 6px; cursor: pointer;
    user-select: none; white-space: nowrap; }
  .row:hover { background: var(--hover); }
  .row.selected { background: var(--active); }
  .row.target { box-shadow: inset 3px 0 0 var(--accent); }
  .row.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
  .row .tw { width: 14px; color: var(--muted); font-size: 10px; text-align: center; flex: none; }
  .row .ic { width: 16px; flex: none; text-align: center; }
  .row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; }
  .row .more { visibility: hidden; }
  .row:hover .more, .row.selected .more { visibility: visible; }
  .rootrow .nm { font-weight: 600; }
  .empty { color: var(--muted); padding: 6px 10px 6px 30px; font-size: 13px; }
  .foot { border-top: 1px solid var(--line); padding: 8px 12px 10px; display: grid; gap: 6px; }
  .foot .btns { display: flex; flex-wrap: wrap; gap: 6px; }
  .meter { height: 5px; background: var(--hover); border-radius: 3px; overflow: hidden; }
  .meter > div { height: 100%; background: var(--accent); width: 0; }
  .meter.full > div { background: var(--danger); }
  .small { font-size: 12px; color: var(--muted); }
  main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .bar { height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 10px;
    border-bottom: 1px solid var(--line); background: var(--panel); }
  .bar .crumb { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  .bar .crumb b { color: var(--text); font-weight: 600; }
  .status { font-size: 12px; white-space: nowrap; }
  .status.ok { color: var(--ok); } .status.dirty { color: var(--warn); } .status.err { color: var(--danger); }
  #canvas { flex: 1; position: relative; min-height: 0; }
  .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted);
    text-align: center; padding: 24px; }
  .menu { position: fixed; z-index: 1000; background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.18); padding: 4px; min-width: 190px; }
  .menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 10px; }
  .menu button:hover { background: var(--hover); }
  .menu button.danger { color: var(--danger); }
  .menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
  dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text);
    padding: 16px; width: min(420px, calc(100vw - 32px)); }
  dialog::backdrop { background: rgba(0,0,0,.35); }
  dialog h2 { font-size: 15px; margin: 0 0 10px; }
  dialog p { margin: 0 0 12px; color: var(--muted); }
  dialog input, dialog select { width: 100%; font: inherit; padding: 7px 9px; border: 1px solid var(--line);
    border-radius: 7px; background: var(--bg); color: var(--text); margin-bottom: 12px; }
  dialog .row-btns { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  .toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--text);
    color: var(--panel); padding: 8px 14px; border-radius: 8px; z-index: 2000; font-size: 13px; max-width: 90vw; }
  .fatal { padding: 24px; max-width: 640px; }
  .lock { position: fixed; inset: 0; z-index: 900; background: var(--bg); display: grid; place-items: center; padding: 16px; }
  .lock[hidden] { display: none; }
  .lockcard a { color: var(--accent); }
  .lockcard { width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 22px; }
  .lockcard h2 { margin: 0 0 6px; font-size: 18px; }
  .lockcard p { margin: 0 0 14px; color: var(--muted); }
  .lockcard label { display: block; font-size: 13px; margin: 0 0 4px; }
  .lockcard input[type=password] { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 7px; background: var(--bg); color: var(--text); margin-bottom: 12px; }
  .lockcard .check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin-bottom: 12px; color: var(--text); }
  .lockcard .check input { margin-top: 3px; }
  .lockcard button.primary { width: 100%; padding: 8px; }
  .lockcard .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
  .lockcard .note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
  .lockcard .warnbox { background: var(--hover); border-radius: 8px; padding: 9px 11px; font-size: 13px; margin-bottom: 12px; color: var(--text); }
  @media (max-width: 720px) {
    aside { position: absolute; z-index: 50; top: 0; bottom: 0; left: 0; width: 85vw; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  }
