/* Tree, side pane and dragged rows (TreeView, SidePane, DataTable Draggable). The demo's folder list (endpoint.css `.ep-browse`,
   `.ep-tree`) gives the values: a 216px panel beside the table with a 17px gutter, 6px inner padding, 13px lines with 6.5px 10px
   padding on the small radius, Sunken on hover, Accent Soft and Accent for the current line, 11.5px counts in Ink 3 and a hairline
   between groups. The demo has no nesting, menu, rename or drop target: those reuse its twisty-free spacing, the 16px child
   indent rounded from its 22px child padding, the icon button, the field and the accent ring. */

/* ---------- Tree ---------- */

.tree { min-width: 0; }
.tree-list, .tree-group { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; }
.tree-item { display: grid; gap: 1px; min-width: 0; outline: none; }
.tree-item.divided { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line); }
.tree-row {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  padding: 6.5px 6px 6.5px calc(4px + var(--depth, 0) * 16px); border-radius: var(--r-sm);
  font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.tree-row:hover { background: var(--sunken); color: var(--ink); }
.tree-row.strong { font-weight: 600; color: var(--ink); }
.tree-row.is-current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree-item:focus-visible > .tree-row { outline: 2px solid var(--accent); outline-offset: -2px; }
.tree-twist { flex: none; display: grid; place-items: center; width: 14px; height: 14px; margin-right: -2px; border-radius: 4px; color: var(--ink-3); }
.tree-twist:not(:empty):hover { background: var(--line); color: var(--ink); }
.tree-twist .icon { transition: transform 0.15s var(--ease-out); }
.tree-item[aria-expanded="true"] > .tree-row .tree-twist .icon { transform: rotate(90deg); }
.tree-icon { flex: none; color: var(--ink-3); }
.tree-row.is-current .tree-icon { color: var(--accent); }
.tree-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count { flex: none; margin-left: auto; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.tree-row.is-current .tree-count { color: var(--accent); }
.tree-more-wrap { flex: none; display: inline-flex; margin: -4px -2px -4px -2px; }
.tree-more { width: 23px; height: 23px; opacity: 0; transition: opacity 0.12s, background 0.15s, color 0.15s; }
.tree-row:hover .tree-more, .tree-row.is-current .tree-more, .tree-more[aria-expanded="true"], .tree-item:focus-visible > .tree-row .tree-more { opacity: 1; }
.tree-row.is-current .tree-more:hover { background: color-mix(in oklab, var(--accent) 14%, var(--surface)); }
@media (hover: none) { .tree-more { opacity: 1; } }

/* Inline create and rename: the field takes the label's place without changing the line height. */
.tree-row.is-editing { cursor: default; background: var(--surface); }
.tree-input.field { flex: 1 1 auto; width: 0; min-width: 0; height: 26px; margin: -3.25px 0; padding: 0 7px; font-size: 13px; font-weight: 500; color: var(--ink); }
.tree-err { padding: 1px 6px 4px calc(4px + var(--depth, 0) * 16px + 40px); }

/* Drop targets: every node that takes the dragged rows gets a dashed accent outline, the one under the pointer fills in. */
.tree-list.is-dragging .tree-item[data-drop="true"] > .tree-row { outline: 1px dashed var(--accent-line); outline-offset: -1px; }
.tree-list .tree-item[data-drop="true"] > .tree-row.drop-over {
  background: var(--accent-soft); color: var(--accent); outline: 1.5px solid var(--accent); outline-offset: -1.5px;
}
.tree-row.drop-over .tree-icon, .tree-row.drop-over .tree-count { color: var(--accent); }
/* A node dragged onto another: the same outlines on the nodes that take it, the dragged branch dimmed. */
.tree-list.is-moving-node .tree-item[data-take="true"] > .tree-row { outline: 1px dashed var(--accent-line); outline-offset: -1px; }
.tree-list.is-moving-node .tree-item.is-moving .tree-row { outline: none; opacity: 0.45; }
.tree-list .tree-item[data-take="true"] > .tree-row.drop-over {
  background: var(--accent-soft); color: var(--accent); outline: 1.5px solid var(--accent); outline-offset: -1.5px;
}

/* ---------- Check tree ---------- */

/* CheckTree: the tree's lines with the kit's 16px checkbox (kit.css `.check input`: 4.5px radius, 1.5px Control Line, action fill,
   white tick, indeterminate bar) drawn on a span, since the line itself is the focusable tree item. Children step in 20px so a
   child's box sits under its parent's label. Counts « 4/7 » turn Ink 2 once something is checked. */
.ctree { display: grid; gap: 6px; min-width: 0; }
.ctree-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ctree-search { flex: 1 1 220px; min-width: 0; max-width: 340px; }
.ctree-bar-end { display: inline-flex; gap: 2px; margin-left: auto; }
.dialog-body .ctree-bar { position: sticky; top: 0; z-index: 1; padding: 6px 0; background: var(--surface); }
.ctree-empty { padding: 6px 4px; }
.ctree-row { gap: 7px; padding-left: calc(4px + var(--depth, 0) * 20px); }
.ctree-row.is-branch:not(.strong) { color: var(--ink); font-weight: 500; }
.ctree-box {
  flex: none; display: grid; place-items: center; width: 16px; height: 16px; border-radius: 4.5px;
  border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.ctree-row:hover .ctree-box { border-color: var(--ink-3); }
.ctree-box[data-state="true"], .ctree-box[data-state="mixed"] { background: var(--btn); border-color: var(--btn); }
.ctree-box[data-state="true"]::after {
  content: ""; width: 8px; height: 4.5px; border: 2px solid #FFFFFF; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg);
}
.ctree-box[data-state="mixed"]::after { content: ""; width: 8px; height: 2px; border-radius: 1px; background: #FFFFFF; }
.ctree-item.is-disabled > .ctree-row { opacity: 0.5; cursor: not-allowed; }
.ctree-item.is-disabled > .ctree-row .ctree-box { cursor: not-allowed; }
.ctree-text { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: baseline; gap: 1px 8px; min-width: 0; }
.ctree-label { min-width: 0; overflow-wrap: anywhere; }
.ctree-detail { font-size: 11.5px; color: var(--ink-3); overflow-wrap: anywhere; }
.ctree-desc { flex-basis: 100%; font-size: 11.5px; color: var(--ink-3); }
.ctree-row .tree-count.has-some { color: var(--ink-2); }

/* ---------- Side pane ---------- */

.side-split { display: grid; grid-template-columns: var(--side-w, 216px) 17px minmax(0, 1fr); align-items: start; min-width: 0; }
.side-split.is-collapsed { grid-template-columns: 41px 17px minmax(0, 1fr); }
/* The handle is hidden while folded: the main area keeps the third column instead of sliding into the 17px gutter. */
.side-split > .side-main { grid-column: 3; }
.side-pane {
  position: sticky; top: calc(var(--top-h) + 16px); display: flex; flex-direction: column; min-width: 0;
  max-height: calc(var(--view-h, 100dvh) - var(--top-h) - 32px); overflow: hidden;
}
.side-head { flex: none; display: flex; align-items: center; gap: 2px; min-height: 38px; padding: 6px 6px 2px 14px; }
.side-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.side-actions { display: inline-flex; align-items: center; gap: 2px; }
.side-head .icon-btn { width: 27px; height: 27px; }
.side-body { flex: 1 1 auto; min-height: 0; overflow: hidden auto; overscroll-behavior: contain; padding: 2px 6px 6px; }
.side-split.is-collapsed .side-head { flex-direction: column-reverse; justify-content: flex-end; gap: 8px; padding: 6px 6px 12px; }
.side-split.is-collapsed .side-title { flex: none; writing-mode: vertical-rl; transform: rotate(180deg); overflow: visible; cursor: default; }
.side-handle { position: relative; align-self: stretch; min-height: 48px; cursor: col-resize; touch-action: none; outline: none; }
.side-handle::after {
  content: ""; position: absolute; left: 7.5px; top: 10px; bottom: 10px; width: 2px; border-radius: 2px;
  background: transparent; transition: background 0.15s;
}
.side-handle:hover::after { background: var(--line-strong); }
.side-handle:focus-visible::after, .side-split.is-resizing .side-handle::after { background: var(--accent); }
.side-split.is-resizing { cursor: col-resize; user-select: none; }
.side-main { display: grid; gap: 10px; min-width: 0; }
.side-compact { display: none; }
@media (min-width: 861px) and (min-height: 560px) {
  .frame .side-split { min-height: 0; align-items: stretch; grid-template-rows: minmax(0, 1fr); }
  .frame .side-pane { position: static; align-self: start; max-height: 100%; }
  .frame .side-main { display: flex; flex-direction: column; min-height: 0; }
  .frame .side-main > .dt { flex: 1 1 auto; }
}
@media (max-width: 860px) {
  .side-split, .side-split.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .side-split > .side-main { grid-column: 1; }
  .side-pane, .side-handle { display: none; }
  .side-compact { display: flex; align-items: center; gap: 8px; min-width: 0; }
}

/* ---------- Dragged rows ---------- */

.dt[data-drag="true"] tbody tr[draggable="true"] { -webkit-user-drag: element; }
.dt-table tbody tr.dt-dragging td { opacity: 0.45; }
.dt-ghost {
  position: fixed; top: -200px; left: -200px; z-index: 90; display: inline-flex; align-items: center; gap: 7px;
  padding: 6.5px 11px; border-radius: 9px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop);
  font-size: 12.5px; font-weight: 600; white-space: nowrap; pointer-events: none;
}
.dt-ghost .icon { flex: none; opacity: 0.8; }
