/* ---------------------------------------------------------------- side panels (panels.js, props.js, datatree.js)
   The icon rail, the collapsible start panel and properties panel, the property tabs and the live data tree. */
:root { --rail-w: 56px; }
@media (max-width: 1400px) { :root { --side-w: 224px; --props-w: 272px; } }
@media (max-width: 1200px) { :root { --side-w: 204px; --props-w: 256px; } }
body.side-collapsed { --side-w: 0px; }
body.props-collapsed { --props-w: 0px; }

.layout { grid-template-columns: var(--rail-w) var(--side-w) minmax(0, 1fr) var(--props-w); }
.layout > .rail { grid-column: 1; }
.layout > .side-start { grid-column: 2; }
.layout > .center { grid-column: 3; min-width: 0; }
.layout > .side-end { grid-column: 4; }
body.side-collapsed .side-start, body.props-collapsed .side-end { display: none; }
/* the agent's process window sits next to the start panel */
.af { inset-inline-start: calc(var(--rail-w) + var(--side-w) + 16px); }

/* the rail */
.rail { background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; align-items: stretch; padding: 6px 4px; gap: 2px; min-height: 0; overflow: hidden auto; }
.rail-tabs.tabs { display: flex; flex-direction: column; gap: 2px; border: 0; position: static; background: none; }
.rail .tab, .rail-btn {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 2px 5px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.2; border-bottom: 0; position: relative;
}
.rail .tab:hover, .rail-btn:hover { background: var(--panel-2); color: var(--text); }
.rail .tab:focus-visible, .rail-btn:focus-visible, .side-collapse:focus-visible, .ptab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rail-ic { display: grid; place-items: center; width: 24px; height: 24px; }
.rail-ic svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
/* the built-in icons are CSS masks in the colour of the text (no inline <svg> in the page) */
.rail-ic[class*="ic-"]::before { content: ''; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--ic) center / contain no-repeat; mask: var(--ic) center / contain no-repeat; }
.ic-tools { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Crect x='3' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='14' y='3' width='7' height='7' rx='1.5'/%3E%3Crect x='3' y='14' width='7' height='7' rx='1.5'/%3E%3Ccircle cx='17.5' cy='17.5' r='3.5'/%3E%3C/svg%3E"); }
.ic-data { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cellipse cx='12' cy='5.5' rx='8' ry='3'/%3E%3Cpath d='M4 5.5v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6M4 11.5v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6'/%3E%3C/svg%3E"); }
.ic-pages { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M14 3H6.5A1.5 1.5 0 0 0 5 4.5v15A1.5 1.5 0 0 0 6.5 21h11a1.5 1.5 0 0 0 1.5-1.5V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E"); }
.ic-agent { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8'/%3E%3C/svg%3E"); }
.ic-props { --ic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='M4 6h10M4 12h4M12 12h8M4 18h12'/%3E%3Ccircle cx='16.5' cy='6' r='2'/%3E%3Ccircle cx='10' cy='12' r='2'/%3E%3Ccircle cx='18.5' cy='18' r='2'/%3E%3C/svg%3E"); }
.rail-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail.panel-open .tab.on { background: var(--accent-soft); color: var(--accent); }
.rail.panel-open .tab.on::before { content: ''; position: absolute; inset-inline-start: -4px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.rail .tab.on { color: var(--accent); }
.rail.panel-open .tab-ai.on { background: #f3edff; color: #7c3aed; }
.rail.panel-open .tab-ai.on::before { background: #7c3aed; }
.rail-spacer { flex: 1; }
.rail-btn.on { color: var(--accent); }

/* the panel heads */
.side-start, .side-end { display: flex; flex-direction: column; overflow: hidden; }
.side-head { flex: none; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 8px 0 12px; padding-inline: 12px 6px; border-bottom: 1px solid var(--line); background: var(--panel); }
.side-title { flex: 1; margin: 0; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-collapse { border: 1px solid transparent; background: none; color: var(--muted); border-radius: 6px; width: 28px; height: 28px; display: grid; place-items: center; font-size: 16px; line-height: 1; }
.side-collapse:hover { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.side-collapse span { display: inline-block; }
/* the arrow points to where the panel goes: the start edge for the start panel, the end edge for the other */
:dir(rtl) .side-start .side-collapse span, :dir(rtl) .side-end .side-collapse span { transform: scaleX(-1); }
.side-start .tab-pane { min-height: 0; }
.props-body { flex: 1; min-height: 0; overflow: auto; }

/* ---------------------------------------------------------------- property tabs */
.ptabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 3; }
.ptab { flex: 1 1 0; min-width: 0; border: 0; background: none; padding: 9px 2px 8px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.ptab:hover { color: var(--text); }
.ptab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.ptab .ptab-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; margin-inline-start: 4px; vertical-align: middle; }
.ppane[hidden] { display: none !important; }
.ppane > .align-panel { border-bottom: 1px solid var(--line-2); }
.props-name { padding: 8px 12px 6px; }

/* a closed group tells what is set in it */
.pg > summary .pg-sum { margin-inline-start: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-weight: 400; font-size: 12px; display: flex; align-items: center; gap: 4px; }
.pg[open] > summary .pg-sum { display: none; }
.pg-sum .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(0, 0, 0, .2); vertical-align: middle; flex: none; }
.pg-sum bdi, .pg-sum .ltr { unicode-bidi: isolate; }

/* numbers: drag the label to change the value */
.f > span.scrub { cursor: ew-resize; user-select: none; touch-action: none; }
.f > span.scrub:hover { color: var(--accent); }
body.scrubbing, body.scrubbing * { cursor: ew-resize !important; user-select: none !important; }

/* {{…}} placeholders shown as isolated chips under a text */
.ph-preview { font-size: 12px; line-height: 1.9; color: var(--text); background: var(--panel-2); border: 1px dashed var(--line); border-radius: 6px; padding: 4px 8px; overflow-wrap: anywhere; }
.ph-chip { unicode-bidi: isolate; direction: ltr; display: inline-block; font-family: ui-monospace, 'Cousine', Consolas, monospace; font-size: 11.5px; line-height: 1.4; padding: 0 5px; margin: 0 1px; border-radius: 4px; background: var(--accent-soft); color: var(--accent-2); white-space: nowrap; }
.col-b bdi, .statusbar bdi { unicode-bidi: isolate; }

/* ---------------------------------------------------------------- the live data tree */
.data-pane.on { display: flex; flex-direction: column; padding-bottom: 0; }
.data-pane .data-tree { flex: 1; min-height: 0; overflow: auto; }
.dt-filter { display: flex; gap: 2px; margin: 0 10px 8px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; }
.dt-filter button { flex: 1; border: 0; background: none; border-radius: 5px; padding: 3px 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dt-filter button.on { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, .12); }
.dt-filter button:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.dt-usage { font-size: 12px; color: var(--muted); }
.dt-usage b { color: var(--ok); font-weight: 700; }
.dt-dot { display: inline-block; flex: none; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid #9aa3b2; background: transparent; box-sizing: border-box; }
.dt-dot.used { border-color: var(--ok); background: var(--ok); }
.dt-use { display: inline-flex; align-items: center; gap: 2px; flex: none; font-size: 10.5px; color: var(--ok); font-weight: 600; min-width: 7px; }
.dt-row.dt-bound { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.dt-row.dt-bound .dt-name { color: var(--accent-2); font-weight: 600; }
.dt-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.dt-sample bdi { unicode-bidi: isolate; }
.dt-legend { flex: none; border-top: 1px solid var(--line); padding: 8px 12px 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); background: var(--panel); }
.dt-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.dt-legend .hint { margin: 2px 0 0; flex-basis: 100%; font-size: 11.5px; }
.dt-empty-filter { padding: 8px 12px; }
.dt-n { flex: none; font-size: 10.5px; font-weight: 600; color: var(--ok); direction: ltr; unicode-bidi: isolate; }
.dt-n:empty { display: none; }
.dt-use.dt-icon { display: grid; place-items: center; }
.f-sample { font-size: 12px; color: var(--muted); background: var(--panel-2); border: 1px dashed var(--line); border-radius: 6px; padding: 5px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f-sample b { color: var(--text); font-weight: 600; }
/* English labels are longer than the Hebrew ones */
html[lang="en"] { --rail-w: 72px; }
html[lang="en"] .rail .tab, html[lang="en"] .rail-btn { font-size: 10.5px; letter-spacing: -.1px; }
