/* Interaction contract for every palette:
   --accent = actions/selection, --ink = content, --muted = secondary copy.
   Pointer/autofocus: one existing border. Keyboard: a single border or bottom mark.
   Stage, status, user tag and repeat-membership colors remain semantic data. */
:root{--interaction-tint:color-mix(in srgb,var(--accent) 10%,var(--surface))}
/* Remove outer system rings without moving focus or removing the text caret.
   Domain selection on nodes/cells/stages is deliberately outside this selector. */
html[data-focus-source] :is(button,input,textarea,select,summary,a[href],[tabindex]:not(.node):not(.grid):not(.cell):not(.stage),[role="button"],[contenteditable]):focus{outline:none!important;outline-offset:0!important;box-shadow:none!important}
html[data-focus-source] :is(button,input,textarea,select,summary,a[href],[tabindex]:not(.node):not(.grid):not(.cell):not(.stage),[role="button"],[contenteditable]){-webkit-tap-highlight-color:transparent}
html[data-focus-source] :is(input,textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]){-webkit-appearance:none;appearance:none}
html[data-focus-source="pointer"] :is(.field input,.field textarea,.field select,.workspace-finder input,.round-name-input,.rich-link-editor input):focus{border-color:var(--line)}
html[data-focus-source="pointer"] .expanded-text-scroll:focus-within{border-color:var(--line)}
/* A keyboard cue uses the current theme, never an extra rectangular outer frame. */
html[data-focus-source="keyboard"] :is(button,summary,a[href],[tabindex]:not(.node):not(.grid):not(.cell):not(.stage),[role="button"]):not(.layout-drag-handle):not(.inline-name-input):focus-visible{box-shadow:inset 0 -2px 0 var(--accent)!important}
html[data-focus-source="keyboard"] :is(button,summary,a[href],[tabindex]:not(.node):not(.grid):not(.cell):not(.stage),[role="button"]):not(.primary):not(.active):not([aria-pressed="true"]):not(.layout-drag-handle):not(.inline-name-input):focus-visible{background-color:var(--interaction-tint)}
html[data-focus-source="keyboard"] :is(.tool-btn.primary,.unit-round.active):focus-visible{box-shadow:inset 0 -2px 0 var(--accent-ink)!important}
html[data-focus-source="keyboard"] :is(input,textarea,select,.rich-text):not(.inline-name-input):not(.check-name):not([type="file"]):focus{border-color:var(--accent)!important}
html[data-focus-source="keyboard"] :is(input[type="checkbox"],input[type="radio"],input[type="range"]):focus{box-shadow:0 2px 0 var(--accent)!important}
html[data-focus-source="keyboard"] :is(.home-search,.search,.ai-composer,.expanded-text-scroll):focus-within{border-color:var(--accent)!important}
/* Borderless editors keep their caret, with the cue on the surrounding form. */
html[data-focus-source] :is(.home-search input,.search input,.ai-composer textarea):focus{border:0!important;box-shadow:none!important}
html[data-focus-source] .layout-drag-handle:focus-visible{box-shadow:none!important}
/* Primary and selected controls share the same roles in light and dark themes. */
:root[data-color-scheme] :is(.home-nav.active,.nav button.active,.run-nav button.active,.stage-nav .tree-node.active,.map-nav-row,.settings-nav button.active,.tool-btn.active,.map-view-switch .tool-btn[aria-pressed="true"],.stage-options button.keyboard-current){background:var(--interaction-tint);color:var(--accent);border-color:var(--line)}
:root[data-color-scheme] .map-nav-row>.tree-toggle{color:var(--accent)}
:root[data-color-scheme] :is(.tab,.page-tab,.editor-tab){color:var(--muted)}
:root[data-color-scheme] :is(.tab.active,.page-tab.active,.editor-tab.active,#editorTabs>.tab.active){color:var(--accent);background:transparent}
:root[data-color-scheme] .tab.active::after{background:var(--accent)}
:root[data-color-scheme] #editorTabs>.tab.active{border-bottom-color:var(--accent)}
:root[data-color-scheme] .layout-tab-row.active{background:var(--interaction-tint)}
:root[data-color-scheme] .layout-tab-row.active>[data-layout-tab]{color:var(--accent)}
:root[data-color-scheme] :is(.tool-btn.primary,.ai-plan-preview .tool-btn.primary,.calendar-grid button[aria-pressed="true"]){background:var(--accent);color:var(--accent-ink)}
:root[data-color-scheme] .tool-btn.primary:hover{background:color-mix(in srgb,var(--accent) 90%,var(--ink));color:var(--accent-ink)}
:root[data-color-scheme] :is(.field-link,.text-btn,.markdown-preview a,.rich-text a){color:var(--accent)}
:root[data-color-scheme] :is(input[type="checkbox"],input[type="radio"],input[type="range"]){accent-color:var(--accent)}
:root[data-color-scheme] :is(.field input,.field textarea,.field select,.layout-add-field select,.stage-name-combo input,.round-name-input){background:var(--surface);color:var(--ink);border-color:var(--line)}
:root[data-color-scheme] :is(#workspaceView,#workspaceSort){background:var(--surface);color:var(--ink);border-color:var(--line)}
:root[data-color-scheme] :is(.calendar-grid span,.image-note,.field-meta,.settings-panel p,.settings-tree-actions>span,.template-row small,.attachment-row small,.recovery-compare p,.recovery-preview>p,.recovery-notice,.engineering-tools summary,.node-meta){color:var(--muted)}
:root[data-color-scheme] :is(.node-date-picker button:hover,.stage-options button:hover,.layout-field button:hover,.tree-toggle:hover){background:var(--raised)}
:root[data-color-scheme] :is(.display-choice:has(input:checked),.unit-members label:has(input:checked)){background:var(--interaction-tint)}
:root[data-color-scheme] .import-drop-zone{border-color:var(--line)}
:root[data-color-scheme] .import-drop-zone.drag-active{background:var(--interaction-tint);border-color:var(--accent)}
:root[data-color-scheme] .workspace-finder input{border-color:var(--line)}
:root[data-color-scheme] .workspace-find-result.active{color:var(--accent);background:var(--interaction-tint)}
:root[data-color-scheme] :is(.search,.help-tip span){background:var(--raised);color:var(--ink)}
:root[data-color-scheme] .expanded-text-scroll{border-color:var(--line);scrollbar-color:var(--muted) var(--raised)}
:root[data-color-scheme] .expanded-text-scroll:focus-within{border-color:var(--line)}
:root[data-color-scheme] .connections .connection-draft{stroke:var(--accent)!important}
:root[data-color-scheme] .marquee-box{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,transparent)}
:root[data-color-scheme] .preview:not(.invalid){border-color:var(--accent);background:color-mix(in srgb,var(--accent) 10%,var(--surface));color:var(--accent)}
/* High-contrast OS mode needs a non-color-only keyboard cue. */
@media(forced-colors:active){html[data-focus-source="keyboard"] :is(button,input,textarea,select,summary,a[href],[tabindex]:not(.node):not(.grid):not(.cell):not(.stage),[role="button"]):focus-visible{outline:1px solid Highlight!important;outline-offset:0!important}}
