/* ==========================================================================
   Build Plan — tokens + components
   Plain CSS, no build step. Theme: set data-theme="light|dark" on <html>,
   or leave it off to follow the OS.
   ========================================================================== */

/* ---------- 1. Tokens: light (default) ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* surfaces */
  --bp-bg: #F6F6F3;              /* app ground, behind panes */
  --bp-surface: #FFFFFF;         /* panes, cards, dialogs */
  --bp-surface-sunken: #F0F0EC;  /* code, inputs at rest, wells */
  --bp-surface-hover: #EEEEEA;   /* row / button hover */
  --bp-surface-active: #E5E5E0;  /* pressed */
  --bp-border: #E3E3DE;
  --bp-border-strong: #C9C9C2;
  --bp-guide: #DADAD4;           /* tree indentation guides */

  /* text */
  --bp-text: #1B1C1E;            /* 16.4:1 on surface */
  --bp-text-2: #46494E;          /* 9.0:1  */
  --bp-text-3: #62656B;          /* 5.9:1 on surface, 5.4:1 on bg */
  --bp-text-on-accent: #FFFFFF;

  /* accent (ink blue) */
  --bp-accent: #2852C4;          /* fills; white on it 6.9:1 */
  --bp-accent-hover: #1F43A6;
  --bp-accent-text: #2147B0;     /* links, accent text 7.6:1 */
  --bp-accent-soft: #E9EEFB;     /* selected row */
  --bp-accent-soft-2: #D6E0F8;   /* selected + focused, drop-into */
  --bp-focus: #2852C4;

  /* feedback */
  --bp-danger: #B3261E;  --bp-danger-soft: #FCEBE9;  --bp-danger-text: #9C2019;
  --bp-warn: #B54708;    --bp-warn-soft: #FDF0E4;    --bp-warn-text: #8F3A07;
  --bp-ok: #22764A;      --bp-ok-soft: #E4F2E9;      --bp-ok-text: #1B5E3B;

  /* status — always paired with a glyph shape + a word */
  --st-planned: #6E7178;  --st-planned-soft: #EFEFEC;
  --st-active:  #2860D8;  --st-active-soft:  #E7EEFC;
  --st-blocked: #C2410C;  --st-blocked-soft: #FDEEE5;
  --st-done:    #22804F;  --st-done-soft:    #E3F2E9;
  --st-dropped: #8A8D93;  --st-dropped-soft: #F0F0EE;

  /* chrome */
  --bp-scrim: rgba(20, 21, 24, .40);
  --bp-sel-text: #14306F;

  /* shadows */
  --sh-1: 0 1px 2px rgba(20, 22, 26, .06);
  --sh-2: 0 4px 12px rgba(20, 22, 26, .10), 0 1px 2px rgba(20, 22, 26, .06);
  --sh-3: 0 16px 40px rgba(20, 22, 26, .16), 0 2px 6px rgba(20, 22, 26, .08);
  --sh-drag: 0 8px 20px rgba(20, 22, 26, .18);
}

/* ---------- 1b. Tokens: dark ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bp-bg: #131417;
  --bp-surface: #1B1C20;
  --bp-surface-sunken: #16171A;
  --bp-surface-hover: #24262B;
  --bp-surface-active: #2C2E34;
  --bp-border: #2C2E34;
  --bp-border-strong: #41444B;
  --bp-guide: #30333A;
  --bp-text: #E8E9EB;            /* 14.8:1 */
  --bp-text-2: #B6B9BF;          /* 9.1:1  */
  --bp-text-3: #8F929A;          /* 5.4:1  */
  --bp-text-on-accent: #FFFFFF;
  --bp-accent: #3F66D6;          /* white on it 5.1:1 */
  --bp-accent-hover: #5277E0;
  --bp-accent-text: #93AEF8;     /* 7.6:1 */
  --bp-accent-soft: #1E2843;
  --bp-accent-soft-2: #263559;
  --bp-focus: #93AEF8;
  --bp-danger: #F0716A;  --bp-danger-soft: #3A1E1F;  --bp-danger-text: #F59C96;
  --bp-warn: #F0954F;    --bp-warn-soft: #3A2716;    --bp-warn-text: #F5B07A;
  --bp-ok: #4CC07F;      --bp-ok-soft: #173024;      --bp-ok-text: #7DD6A3;
  --st-planned: #9A9DA4;  --st-planned-soft: #26282D;
  --st-active:  #6F9BFF;  --st-active-soft:  #1E2843;
  --st-blocked: #F08A4B;  --st-blocked-soft: #3A2716;
  --st-done:    #4CC07F;  --st-done-soft:    #173024;
  --st-dropped: #7C7F86;  --st-dropped-soft: #24262A;
  --bp-scrim: rgba(0, 0, 0, .55);
  --bp-sel-text: #DCE5FF;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-2: 0 6px 16px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .04);
  --sh-3: 0 20px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .05);
  --sh-drag: 0 10px 24px rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bp-bg: #131417;
    --bp-surface: #1B1C20;
    --bp-surface-sunken: #16171A;
    --bp-surface-hover: #24262B;
    --bp-surface-active: #2C2E34;
    --bp-border: #2C2E34;
    --bp-border-strong: #41444B;
    --bp-guide: #30333A;
    --bp-text: #E8E9EB;            /* 14.8:1 */
    --bp-text-2: #B6B9BF;          /* 9.1:1  */
    --bp-text-3: #8F929A;          /* 5.4:1  */
    --bp-text-on-accent: #FFFFFF;
    --bp-accent: #3F66D6;          /* white on it 5.1:1 */
    --bp-accent-hover: #5277E0;
    --bp-accent-text: #93AEF8;     /* 7.6:1 */
    --bp-accent-soft: #1E2843;
    --bp-accent-soft-2: #263559;
    --bp-focus: #93AEF8;
    --bp-danger: #F0716A;  --bp-danger-soft: #3A1E1F;  --bp-danger-text: #F59C96;
    --bp-warn: #F0954F;    --bp-warn-soft: #3A2716;    --bp-warn-text: #F5B07A;
    --bp-ok: #4CC07F;      --bp-ok-soft: #173024;      --bp-ok-text: #7DD6A3;
    --st-planned: #9A9DA4;  --st-planned-soft: #26282D;
    --st-active:  #6F9BFF;  --st-active-soft:  #1E2843;
    --st-blocked: #F08A4B;  --st-blocked-soft: #3A2716;
    --st-done:    #4CC07F;  --st-done-soft:    #173024;
    --st-dropped: #7C7F86;  --st-dropped-soft: #24262A;
    --bp-scrim: rgba(0, 0, 0, .55);
    --bp-sel-text: #DCE5FF;
    --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-2: 0 6px 16px rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .04);
    --sh-3: 0 20px 48px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .05);
    --sh-drag: 0 10px 24px rgba(0, 0, 0, .55);
  }
}

/* ---------- 1c. Scales (theme-independent) ---------- */
:root {
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", system-ui, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* spacing — 4px base, 2 and 6 for dense UI */
  --sp-1: 2px;  --sp-2: 4px;  --sp-3: 6px;  --sp-4: 8px;  --sp-5: 12px;
  --sp-6: 16px; --sp-7: 20px; --sp-8: 24px; --sp-9: 32px; --sp-10: 48px; --sp-11: 64px;

  /* radii */
  --r-xs: 3px; --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 12px; --r-pill: 999px;

  /* type scale: size / line-height */
  --fs-11: 11px; --lh-11: 14px;  /* counts, type names, kbd */
  --fs-12: 12px; --lh-12: 16px;  /* chips, meta, table headers */
  --fs-13: 13px; --lh-13: 18px;  /* UI base, tree rows */
  --fs-14: 14px; --lh-14: 22px;  /* reading text in the detail pane */
  --fs-16: 16px; --lh-16: 24px;  /* section titles */
  --fs-20: 20px; --lh-20: 28px;  /* page titles */
  --fs-26: 26px; --lh-26: 32px;  /* item title */

  /* layout */
  --row-h: 26px;       /* tree row */
  --indent: 14px;      /* per depth */
  --topbar-h: 44px;
  --tree-w: 340px;     /* default, resizable 240–640 */
  --dur-1: 90ms; --dur-2: 160ms; --ease: cubic-bezier(.2, .6, .2, 1);
}

/* ---------- 2. Base ---------- */
.bp { font-family: var(--font-sans); font-size: var(--fs-13); line-height: var(--lh-13); color: var(--bp-text); background: var(--bp-bg); -webkit-font-smoothing: antialiased; }
.bp, .bp *, .bp *::before, .bp *::after { box-sizing: border-box; }
:where(.bp) :where(button, input, select, textarea) { font: inherit; color: inherit; } /* zero specificity so component classes win */
:where(.bp) a { color: var(--bp-accent-text); text-decoration: none; }
:where(.bp) a:hover { text-decoration: underline; }
.btn:hover, .chip:hover, .menu-i:hover, .nav a:hover, .set-nav a:hover, .who:hover, .child:hover, .brand:hover { text-decoration: none; }
.bp :focus-visible, .bp .is-focus { outline: 2px solid var(--bp-focus); outline-offset: 2px; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--bp-text-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 14px; height: 14px; }
.ico-xs { width: 12px; height: 12px; }

/* ---------- 3. Top bar ---------- */
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: var(--sp-5); padding: 0 var(--sp-5); background: var(--bp-surface); border-bottom: 1px solid var(--bp-border); flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; color: var(--bp-text); white-space: nowrap; }
.brand-mark { width: 20px; height: 20px; border-radius: 5px; background: var(--bp-text); display: grid; place-items: center; }
.brand-mark svg { width: 14px; height: 14px; stroke: var(--bp-bg); fill: none; stroke-width: 2; stroke-linecap: round; }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-md); color: var(--bp-text-2); font-weight: 500; white-space: nowrap; }
.nav a:hover { background: var(--bp-surface-hover); color: var(--bp-text); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--bp-surface-active); color: var(--bp-text); }
.nav-sep { width: 1px; height: 18px; background: var(--bp-border); margin: 0 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-4); }
.who { display: flex; align-items: center; gap: 6px; color: var(--bp-text-2); white-space: nowrap; }

/* ---------- 4. Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--bp-border-strong); background: var(--bp-surface); color: var(--bp-text); font-weight: 500; font-size: 13px; white-space: nowrap; cursor: pointer; }
.btn:hover, .btn.is-hover { background: var(--bp-surface-hover); }
.btn:active, .btn.is-active { background: var(--bp-surface-active); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-primary { background: var(--bp-accent); border-color: var(--bp-accent); color: var(--bp-text-on-accent); }
.btn-primary:hover, .btn-primary.is-hover { background: var(--bp-accent-hover); border-color: var(--bp-accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--bp-text-2); }
.btn-ghost:hover, .btn-ghost.is-hover { background: var(--bp-surface-hover); color: var(--bp-text); }
.btn-danger { background: var(--bp-danger); border-color: var(--bp-danger); color: #fff; }
[data-theme="dark"] .btn-danger { background: #C0362E; border-color: #C0362E; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 36px; padding: 0 14px; font-size: 14px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r-md); border: 0; background: transparent; color: var(--bp-text-3); cursor: pointer; flex: none; }
.icon-btn:hover, .icon-btn.is-hover { background: var(--bp-surface-hover); color: var(--bp-text); }
.icon-btn-sm { width: 22px; height: 22px; border-radius: var(--r-sm); }
.kbd { display: inline-flex; align-items: center; height: 18px; padding: 0 5px; border-radius: var(--r-xs); border: 1px solid var(--bp-border-strong); border-bottom-width: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--bp-text-2); background: var(--bp-surface); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-md); background: var(--bp-surface-sunken); border: 1px solid var(--bp-border); }
.seg button { height: 24px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--bp-text-2); font-weight: 500; font-size: 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--bp-surface); color: var(--bp-text); box-shadow: var(--sh-1); }

/* ---------- 5. Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12px; font-weight: 500; color: var(--bp-text-2); }
.input, .select, .textarea { width: 100%; height: 32px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--bp-border-strong); background: var(--bp-surface); color: var(--bp-text); font-size: 13px; }
.textarea { height: auto; min-height: 96px; padding: 8px 10px; line-height: 20px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--bp-text-3); }
.input:focus, .input.is-focus, .textarea:focus, .textarea.is-focus { outline: none; border-color: var(--bp-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bp-focus) 25%, transparent); }
.input.is-error { border-color: var(--bp-danger); }
.help { font-size: 12px; color: var(--bp-text-3); }
.help.is-error { color: var(--bp-danger-text); display: flex; gap: 4px; align-items: center; }
.switch { position: relative; width: 28px; height: 16px; border-radius: 999px; background: var(--bp-border-strong); border: 0; flex: none; cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform var(--dur-1); }
.switch[aria-checked="true"] { background: var(--bp-accent); }
.switch[aria-checked="true"]::after { transform: translateX(12px); }
.cbox { width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--bp-border-strong); background: var(--bp-surface); display: inline-grid; place-items: center; flex: none; padding: 0; cursor: pointer; }
.cbox[aria-checked="true"] { background: var(--bp-accent); border-color: var(--bp-accent); }
.cbox svg { width: 10px; height: 10px; stroke: #fff; stroke-width: 2.4; fill: none; }

/* ---------- 6. Status glyph (shape + colour) ---------- */
.st { width: 10px; height: 10px; flex: none; display: inline-block; position: relative; border-radius: 50%; }
.st-planned { border: 1.5px solid var(--st-planned); }                                   /* ring        */
.st-active  { border: 1.5px solid var(--st-active); background: linear-gradient(90deg, var(--st-active) 50%, transparent 50%); } /* half */
.st-blocked { border-radius: 1px; width: 8px; height: 8px; margin: 1px; background: var(--st-blocked); transform: rotate(45deg); } /* diamond */
.st-done    { background: var(--st-done); }                                               /* filled + tick */
.st-done::after { content: ""; position: absolute; left: 3px; top: 1.5px; width: 2.5px; height: 5px; border: solid var(--bp-surface); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.st-dropped { border: 1.5px solid var(--st-dropped); }                                    /* ring + slash */
.st-dropped::after { content: ""; position: absolute; left: -1px; top: 3px; width: 9px; height: 1.5px; background: var(--st-dropped); transform: rotate(-45deg); }

/* ---------- 7. Small atoms ---------- */
.tdot { width: 8px; height: 8px; border-radius: 2px; background: var(--tc, #888); flex: none; }  /* type: rounded square, status: circle family */
.avatar { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 9px; font-weight: 600; letter-spacing: .02em; color: var(--bp-text); background: var(--bp-surface-active); flex: none; border: 1px solid var(--bp-border-strong); }
.avatar-lg { width: 24px; height: 24px; font-size: 10px; }
.claim { display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 5px 0 2px; border-radius: var(--r-pill); background: var(--bp-accent-soft); color: var(--bp-accent-text); font-size: 11px; font-weight: 600; flex: none; }
.claim .avatar { width: 14px; height: 14px; font-size: 8px; border: 0; background: var(--bp-accent); color: #fff; }
.pbar { width: 32px; height: 4px; border-radius: 2px; background: var(--bp-surface-active); overflow: hidden; flex: none; }
.pbar > i { display: block; height: 100%; width: var(--p, 0%); background: var(--bp-text-3); border-radius: 2px; }
.pbar.is-done > i { background: var(--st-done); }
.pbar-lg { width: 100%; height: 6px; border-radius: 3px; }
.count { font-size: 11px; line-height: 14px; padding: 0 5px; border-radius: var(--r-pill); background: var(--bp-surface-active); color: var(--bp-text-2); font-variant-numeric: tabular-nums; flex: none; }
.req { color: var(--bp-danger-text); font-weight: 600; }

/* ---------- 8. Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-md); border: 1px solid var(--bp-border); background: var(--bp-surface); color: var(--bp-text); font-size: 12px; white-space: nowrap; cursor: pointer; max-width: 100%; }
.chip:hover, .chip.is-hover { background: var(--bp-surface-hover); border-color: var(--bp-border-strong); }
.chip.is-open { border-color: var(--bp-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bp-focus) 22%, transparent); }
.chip .k { color: var(--bp-text-3); }
.chip .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--cc, #999); flex: none; }
.chip-st-planned { background: var(--st-planned-soft); border-color: transparent; }
.chip-st-active  { background: var(--st-active-soft);  border-color: transparent; }
.chip-st-blocked { background: var(--st-blocked-soft); border-color: transparent; }
.chip-st-done    { background: var(--st-done-soft);    border-color: transparent; }
.chip-st-dropped { background: var(--st-dropped-soft); border-color: transparent; color: var(--bp-text-2); }
.chip-missing { border: 1px dashed var(--bp-danger); background: var(--bp-danger-soft); color: var(--bp-danger-text); }
.chip-ghost { border-style: dashed; color: var(--bp-text-3); background: transparent; }
.chip-flat { cursor: default; }

/* automated check */
.ci { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px; border-radius: var(--r-md); font-size: 12px; white-space: nowrap; border: 1px solid transparent; }
.ci .ico { width: 13px; height: 13px; stroke-width: 2; }
.ci-pass    { background: var(--bp-ok-soft);     color: var(--bp-ok-text); }
.ci-fail    { background: var(--bp-danger-soft); color: var(--bp-danger-text); }
.ci-error   { background: var(--bp-warn-soft);   color: var(--bp-warn-text); }
.ci-pending { background: var(--bp-surface-sunken); color: var(--bp-text-2); border-color: var(--bp-border); border-style: dashed; }
.ci-skipped { background: transparent; color: var(--bp-text-3); border-color: var(--bp-border); }

/* ---------- 9. Tree ---------- */
.pane-tree { display: flex; flex-direction: column; background: var(--bp-surface); border-right: 1px solid var(--bp-border); min-width: 0; }
.tree-tools { display: flex; align-items: center; gap: 4px; padding: 8px 8px 6px; }
.search { position: relative; flex: 1; min-width: 0; }
.search .ico { position: absolute; left: 8px; top: 7px; color: var(--bp-text-3); width: 14px; height: 14px; }
.search .input { height: 28px; padding-left: 28px; background: var(--bp-surface-sunken); border-color: transparent; }
.filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; border-bottom: 1px solid var(--bp-border); }
.fchip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 6px; border-radius: var(--r-sm); border: 1px dashed var(--bp-border-strong); background: transparent; color: var(--bp-text-3); font-size: 12px; cursor: pointer; white-space: nowrap; }
.fchip.is-on { border-style: solid; border-color: transparent; background: var(--bp-accent-soft); color: var(--bp-accent-text); font-weight: 500; }
.tree { padding: 4px 0 24px; overflow: auto; flex: 1; font-size: var(--fs-13); }
.row { position: relative; height: var(--row-h); display: flex; align-items: center; gap: 6px; padding: 0 8px 0 6px; white-space: nowrap; cursor: default; user-select: none; }
.row .ind { align-self: stretch; flex: none; width: calc(var(--d, 0) * var(--indent)); background-image: repeating-linear-gradient(to right, transparent 0 6px, var(--bp-guide) 6px 7px, transparent 7px var(--indent)); }
.row .caret { width: 14px; height: 14px; display: grid; place-items: center; color: var(--bp-text-3); flex: none; border: 0; background: none; padding: 0; border-radius: 3px; cursor: pointer; }
.row .caret svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2; fill: none; }
.row .caret.is-open svg { transform: rotate(90deg); }
.row .caret.is-leaf { visibility: hidden; }
.row .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--bp-text); }
.row .tname { font-size: 11px; color: var(--bp-text-3); flex: none; }
.row .meta { display: flex; align-items: center; gap: 6px; flex: none; }
.row .acts { display: none; gap: 2px; flex: none; }
.row:hover, .row.is-hover { background: var(--bp-surface-hover); }
.row.is-hover .acts, .row:hover .acts { display: flex; }
.row.is-hover .tname, .row:hover .tname { display: none; }
.row.is-selected { background: var(--bp-accent-soft); }
.row.is-selected .title { color: var(--bp-sel-text); font-weight: 500; }
.row.is-kfocus { box-shadow: inset 0 0 0 2px var(--bp-focus); border-radius: 3px; }
.row.is-selected.is-kfocus { background: var(--bp-accent-soft-2); }
.row.is-dragging { opacity: .4; }
.row.is-dropped .title { text-decoration: line-through; color: var(--bp-text-3); }
.row.drop-above::before, .row.drop-below::after { content: ""; position: absolute; left: calc(26px + var(--d, 0) * var(--indent)); right: 8px; height: 2px; background: var(--bp-accent); border-radius: 1px; }
.row.drop-above::before { top: -1px; }
.row.drop-below::after { bottom: -1px; }
.row.drop-into { background: var(--bp-accent-soft-2); box-shadow: inset 0 0 0 1.5px var(--bp-accent); border-radius: 4px; }
.row .rename { flex: 1; min-width: 0; height: 22px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--bp-focus); background: var(--bp-surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bp-focus) 22%, transparent); font-size: 13px; }
.row .rename.is-new { border-style: dashed; }
.drag-ghost { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 6px; background: var(--bp-surface); box-shadow: var(--sh-drag); border: 1px solid var(--bp-border-strong); font-size: 13px; transform: rotate(-1.5deg); white-space: nowrap; }
.tree-foot { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-top: 1px solid var(--bp-border); font-size: 12px; color: var(--bp-text-3); }
.resizer { width: 5px; margin-left: -3px; cursor: col-resize; flex: none; position: relative; z-index: 2; }
.resizer::after { content: ""; position: absolute; inset: 0 2px; background: transparent; }
.resizer:hover::after, .resizer.is-hover::after { background: var(--bp-accent); }

/* ---------- 10. Detail pane ---------- */
.pane-detail { background: var(--bp-surface); overflow: auto; min-width: 0; }
.brief { max-width: 760px; margin: 0 auto; padding: 28px 40px 80px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; color: var(--bp-text-3); }
.crumbs a { color: var(--bp-text-3); } .crumbs a:hover { color: var(--bp-text); }
.crumbs .sep { color: var(--bp-border-strong); }
.item-title { font-size: var(--fs-26); line-height: var(--lh-26); font-weight: 650; letter-spacing: -.01em; margin: 10px 0 12px; border-radius: 4px; cursor: text; }
.item-title:hover { box-shadow: 0 0 0 4px var(--bp-surface-hover); background: var(--bp-surface-hover); }
.title-edit { font-size: var(--fs-26); line-height: var(--lh-26); font-weight: 650; height: 42px; padding: 0 6px; margin: 6px -7px 8px; width: calc(100% + 14px); }
.md { font-size: var(--fs-14); line-height: var(--lh-14); color: var(--bp-text); }
.md p { margin: 0 0 10px; }
.md h3 { font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.md ul { margin: 0 0 10px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bp-surface-sunken); border: 1px solid var(--bp-border); padding: 0 4px; border-radius: 3px; }
.md-click { border-radius: 6px; padding: 8px 10px; margin: 0 -10px; cursor: text; }
.md-click:hover { background: var(--bp-surface-hover); }
.section { margin-top: 28px; }
.sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bp .sec-h h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--bp-text); }
.sec-h .meta { font-size: 12px; color: var(--bp-text-3); }
.sec-h .end { margin-left: auto; display: flex; gap: 2px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0; border-top: 1px solid var(--bp-border); border-bottom: 1px solid var(--bp-border); margin-top: 20px; }
.check-li { display: flex; align-items: flex-start; gap: 10px; padding: 4px 6px; margin: 0 -6px; border-radius: 4px; font-size: 14px; line-height: 20px; }
.check-li .cbox { margin-top: 3px; }
.check-li.is-done span { color: var(--bp-text-3); text-decoration: line-through; }
.check-li .n { width: 18px; text-align: right; color: var(--bp-text-3); font-variant-numeric: tabular-nums; font-size: 12px; flex: none; }
.lines { margin: 0; padding: 0; list-style: none; border-left: 2px solid var(--bp-border); }
.lines li { padding: 3px 0 3px 12px; font-size: 14px; line-height: 20px; }
.note-e { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px solid var(--bp-border); font-size: 14px; line-height: 20px; }
.note-e .when { font-size: 12px; color: var(--bp-text-3); line-height: 20px; white-space: nowrap; }
.prompt { font-family: var(--font-mono); font-size: 12.5px; line-height: 20px; background: var(--bp-surface-sunken); border: 1px solid var(--bp-border); border-radius: var(--r-lg); padding: 12px 14px; white-space: pre-wrap; color: var(--bp-text); }
.children a.child { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; margin: 0 -8px; border-radius: 5px; color: var(--bp-text); }
.children a.child:hover { background: var(--bp-surface-hover); text-decoration: none; }
.children .child .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-row { display: flex; align-items: center; gap: 8px; height: 30px; color: var(--bp-text-3); font-size: 13px; }
.log { border-top: 1px solid var(--bp-border); margin-top: 28px; padding-top: 10px; }
.log-e { display: flex; gap: 8px; align-items: baseline; font-size: 12px; line-height: 18px; color: var(--bp-text-2); padding: 3px 0; }
.log-e time { color: var(--bp-text-3); margin-left: auto; white-space: nowrap; }
.missing-box { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px dashed var(--bp-danger); border-radius: var(--r-lg); background: var(--bp-danger-soft); color: var(--bp-danger-text); font-size: 13px; }

/* ---------- 11. Popover / menu ---------- */
.pop { background: var(--bp-surface); border: 1px solid var(--bp-border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-2); padding: 4px; min-width: 200px; }
.pop-search { height: 28px; margin-bottom: 4px; }
.menu-i { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 4px; font-size: 13px; white-space: nowrap; border: 0; background: none; width: 100%; text-align: left; cursor: pointer; color: var(--bp-text); }
.menu-i:hover, .menu-i.is-hover { background: var(--bp-surface-hover); }
.menu-i.is-cur { background: var(--bp-accent-soft); }
.menu-i .end { margin-left: auto; color: var(--bp-text-3); font-size: 12px; }
.menu-sep { height: 1px; background: var(--bp-border); margin: 4px 0; }

/* ---------- 12. Dialog + toast ---------- */
.scrim { background: var(--bp-scrim); }
.dialog { background: var(--bp-surface); border-radius: var(--r-xl); box-shadow: var(--sh-3); border: 1px solid var(--bp-border); width: 520px; max-width: calc(100vw - 32px); display: flex; flex-direction: column; }
.dlg-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.dlg-h h2 { margin: 0; font-size: 15px; font-weight: 600; }
.dlg-b { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.dlg-f { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--bp-border); }
.dlg-f .grow { flex: 1; }
.toast { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 8px 8px 12px; border-radius: var(--r-lg); background: #1E1F23; color: #EDEEF0; box-shadow: var(--sh-3); font-size: 13px; width: 360px; max-width: calc(100vw - 32px); }
[data-theme="dark"] .toast { background: #2C2E34; }
.toast .t-ico { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.toast a, .toast .t-act { color: #A9C0FF; font-weight: 600; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.toast .t-x { color: #A5A8AE; }

/* ---------- 13. Settings layout ---------- */
.set-wrap { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0; }
.set-nav { flex: 1 1 220px; max-width: 240px; padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; }
.set-nav .grp { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--bp-text-3); padding: 12px 8px 4px; }
.set-nav a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 5px; color: var(--bp-text-2); }
.set-nav a:hover { background: var(--bp-surface-hover); text-decoration: none; }
.set-nav a[aria-current="page"] { background: var(--bp-surface-active); color: var(--bp-text); font-weight: 500; }
.set-main { flex: 999 1 560px; min-width: 0; padding: 24px 32px 64px; }
.set-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; max-width: 980px; }
.set-head h1 { font-size: var(--fs-20); line-height: var(--lh-20); margin: 0; font-weight: 600; }
.set-head p { margin: 2px 0 0; color: var(--bp-text-3); font-size: 13px; }
.card { background: var(--bp-surface); border: 1px solid var(--bp-border); border-radius: var(--r-lg); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--bp-text-3); padding: 8px 12px; border-bottom: 1px solid var(--bp-border); white-space: nowrap; }
.tbl td { padding: 0 12px; height: 40px; border-bottom: 1px solid var(--bp-border); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bp-surface-hover); }
.erow { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 4px; border-bottom: 1px solid var(--bp-border); font-size: 13px; }
.erow:last-child { border-bottom: 0; }
.grip { color: var(--bp-text-3); cursor: grab; display: grid; place-items: center; width: 18px; height: 24px; border-radius: 3px; }
.kind { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 6px; border-radius: 4px; background: var(--bp-surface-sunken); border: 1px solid var(--bp-border); color: var(--bp-text-2); font-size: 11px; font-family: var(--font-mono); white-space: nowrap; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.tag-req { background: var(--bp-danger-soft); color: var(--bp-danger-text); }
.tag-exp { background: var(--bp-accent-soft); color: var(--bp-accent-text); }
.tag-mute { background: var(--bp-surface-sunken); color: var(--bp-text-3); border: 1px solid var(--bp-border); }

/* ---------- 14. Map ---------- */
.canvas-dots { background-color: var(--bp-bg); background-image: radial-gradient(var(--bp-border-strong) 1px, transparent 1.2px); background-size: 16px 16px; }
.node { position: absolute; width: 208px; background: var(--bp-surface); border: 1px solid var(--bp-border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: 8px 10px 9px; display: flex; flex-direction: column; gap: 6px; }
.node .n-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.node .n-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.node .n-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--bp-text-3); white-space: nowrap; }
.node.is-selected { border-color: var(--bp-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bp-accent) 25%, transparent), var(--sh-2); }
.node.is-hit { box-shadow: 0 0 0 2px var(--bp-warn), var(--sh-1); }
.node.is-dim { opacity: .38; }
.node.is-input { border: 1.5px dashed var(--bp-accent); box-shadow: none; padding: 6px; }
.badge-col { position: absolute; right: -11px; top: 50%; margin-top: -10px; height: 20px; min-width: 20px; padding: 0 5px; border-radius: 10px; background: var(--bp-surface); border: 1px solid var(--bp-border-strong); font-size: 11px; font-weight: 600; color: var(--bp-text-2); display: grid; place-items: center; cursor: pointer; }
.node-actions { position: absolute; display: flex; gap: 2px; padding: 3px; background: var(--bp-surface); border: 1px solid var(--bp-border-strong); border-radius: var(--r-lg); box-shadow: var(--sh-2); }
.root-node { position: absolute; padding: 0 14px; height: 36px; display: flex; align-items: center; gap: 8px; border-radius: 18px; background: var(--bp-text); color: var(--bp-bg); font-weight: 600; font-size: 13px; }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; background: var(--bp-surface); border-bottom: 1px solid var(--bp-border); }
.zoom { display: inline-flex; align-items: center; border: 1px solid var(--bp-border-strong); border-radius: var(--r-md); height: 28px; overflow: hidden; }
.zoom button { width: 28px; height: 26px; border: 0; background: transparent; color: var(--bp-text-2); cursor: pointer; display: grid; place-items: center; }
.zoom span { min-width: 44px; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; border-left: 1px solid var(--bp-border); border-right: 1px solid var(--bp-border); line-height: 26px; }

/* ---------- 15. Spec-sheet helpers (canvas only, not shipped) ---------- */
.spec { font-family: var(--font-sans); color: var(--bp-text); background: var(--bp-bg); }
.spec h1 { font-size: 34px; line-height: 40px; letter-spacing: -.02em; margin: 0; font-weight: 650; }
.spec h2 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.spec .lede { font-size: 15px; line-height: 23px; color: var(--bp-text-2); max-width: 760px; margin: 8px 0 0; }
.spec .cap { font-size: 12px; color: var(--bp-text-3); }
.spec .lab { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--bp-text-3); }
.spec .panel { background: var(--bp-surface); border: 1px solid var(--bp-border); border-radius: var(--r-xl); padding: 20px; }
.sw-tile { display: flex; flex-direction: column; gap: 6px; }
.sw-tile .s { height: 44px; border-radius: 6px; border: 1px solid var(--bp-border); }
.sw-tile .n { font-family: var(--font-mono); font-size: 11px; color: var(--bp-text-2); }
.sw-tile .h { font-family: var(--font-mono); font-size: 11px; color: var(--bp-text-3); }
.code { font-family: var(--font-mono); font-size: 12px; line-height: 19px; background: var(--bp-surface-sunken); border: 1px solid var(--bp-border); border-radius: var(--r-lg); padding: 14px 16px; white-space: pre; overflow: auto; color: var(--bp-text); margin: 0; }

/* ---------- 16. Responsive + motion ---------- */
@media (max-width: 1023px) {
  :root { --tree-w: 280px; }
  .row .tname { display: none; }
}
@media (max-width: 759px) {
  :root { --row-h: 44px; --indent: 12px; }
  .brief { padding: 16px 16px 48px; }
  .set-main { padding: 16px 16px 48px; }
  .set-nav { max-width: none; flex-direction: row; flex-wrap: wrap; padding: 8px 16px; }
  .set-nav .grp { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bp *, .bp *::before, .bp *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
