/* The canvas is a separate document with its own color tokens. */
:root:has(.canvas-app) {
  --line: var(--border);
  --field-bg: var(--surface-raised);
  --drop-bg: var(--surface);
  --shadow: 0 12px 32px color-mix(in srgb, var(--text) 12%, transparent);
}
select.glide-native {
  position: absolute !important; width: 1px !important; height: 1px !important;
  min-height: 0 !important; min-width: 0 !important; padding: 0 !important;
  margin: 0 !important; border: 0 !important; opacity: 0; pointer-events: none;
  clip-path: inset(50%);
}
button.glide-trigger {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--field-bg, var(--field, var(--panel))); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; letter-spacing: 0;
  transition: border-color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}
.glide-trigger.hidden { display: none !important; }
.glide-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.glide-trigger.field {
  gap: 12px;
  min-width: 0; min-height: 48px; max-width: 280px; border-radius: 10px;
}
.bench .glide-trigger.field { max-width: none; }
.model-block .glide-trigger { width: 100%; font-size: 14px; }
.market-shell .glide-trigger.field,
.admin-search .glide-trigger.field,
.cards-fields .glide-trigger.field,
.market-admin-row .glide-trigger.field {
  min-height: 36px; border-radius: 8px;
}
.market-shell .glide-trigger.field { width: 100%; max-width: none; }
.admin-search .glide-trigger.field, .cards-fields .glide-trigger.field { max-width: none; }
#poolJob + .glide-trigger.field { width: 90px; max-width: none; min-height: 36px; height: 36px; }
.glide-trigger:not(:disabled):hover {
  border-color: color-mix(in srgb, var(--text) 20%, var(--line));
  background: color-mix(in srgb, var(--text) 3%, var(--field-bg, var(--field, var(--panel))));
}
.glide-trigger[aria-expanded="true"] { border-color: var(--accent); }
.glide-trigger:disabled { cursor: not-allowed; opacity: .55; }
.glide-trigger:not(:disabled):active, .glide-option:active { filter: none; }
.glide-value { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.glide-chevron {
  flex: 0 0 7px; width: 7px; height: 7px; margin: -4px 3px 0 0;
  border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform 180ms ease;
}
.glide-trigger[aria-expanded="true"] .glide-chevron { transform: translateY(3px) rotate(225deg); }
.glide-menu {
  box-sizing: border-box; position: fixed; inset: auto; margin: 0; max-width: none; max-height: none; overflow: visible; z-index: 2147483000; padding: 5px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--drop-bg, var(--panel)); color: var(--text);
  box-shadow: var(--shadow); font: inherit; font-size: 14px; letter-spacing: 0;
  transform-origin: top center; animation: glide-pop-in 180ms cubic-bezier(.2,.8,.2,1) both;
}
.glide-menu[data-placement="top"] { transform-origin: bottom center; }
.glide-menu.glide-closing { animation: glide-pop-out 120ms ease-in both; pointer-events: none; }
.glide-list {
  position: relative; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--muted) transparent; border-radius: 6px;
}
.glide-highlight {
  position: absolute; top: 0; left: 0; right: 0; pointer-events: none; border-radius: 6px;
  background: color-mix(in srgb, var(--text) 8%, transparent); opacity: .6;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), height 220ms ease, opacity 150ms ease;
}
.glide-group-label {
  position: relative; padding: 10px 10px 5px; color: var(--muted);
  font-size: 11px; line-height: 1.5; font-weight: 600;
}
.glide-option {
  position: relative; display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 44px; padding: 10px; border: 0; border-radius: 6px;
  box-sizing: border-box; background: transparent; color: inherit; font: inherit; text-align: left;
  cursor: pointer; touch-action: pan-y; line-height: 1.45;
}
.glide-option[aria-disabled="true"] { opacity: .4; cursor: not-allowed; }
.glide-option-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.glide-option-tag { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.glide-option-check { flex: 0 0 12px; width: 12px; height: 12px; }
.glide-option[aria-selected="true"] .glide-option-check::after {
  content: ""; display: block; width: 5px; height: 9px; margin: 0 0 0 3px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
:root:has(.canvas-app) .glide-menu { z-index: 1100; }
.select-wrap > button.glide-trigger {
  flex: 1 1 auto; width: auto; max-width: 100px; min-width: 0;
  height: 30px; min-height: 0; padding: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--text); font-size: 12px;
}
.select-wrap > button.glide-trigger:not(:disabled):hover,
.select-wrap > button.glide-trigger[aria-expanded="true"] {
  border: 0; background: transparent;
}
.select-wrap > button.glide-trigger .glide-value {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.select-wrap > button.glide-trigger .glide-chevron {
  flex-basis: 6px; width: 6px; height: 6px; margin-right: 2px;
}
.workflow-body .glide-trigger,
:root[data-theme="light"] .workflow-body .glide-trigger {
  width: 100%; min-height: 36px; padding: 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--field-bg, var(--field, var(--panel))); color: var(--text);
  font-size: 12px;
}
.workflow-body .glide-trigger:not(:disabled):hover,
:root[data-theme="light"] .workflow-body .glide-trigger:not(:disabled):hover {
  border-color: color-mix(in srgb, var(--text) 20%, var(--line));
  background: color-mix(in srgb, var(--text) 3%, var(--field-bg, var(--field, var(--panel))));
}
.glide-canvas-trigger { cursor: pointer; }
.glide-canvas-trigger[aria-expanded="true"] { border-color: var(--accent); }
body .canvas-model-popover { animation: glide-pop-in 180ms cubic-bezier(.2,.8,.2,1) both; }
body .canvas-model-options { position: relative; }
body .canvas-model-options::before {
  content: ""; position: absolute; top: 0; left: 5px; right: 5px;
  height: var(--glide-h, 0px); transform: translateY(var(--glide-y, 0px));
  border-radius: 6px; background: color-mix(in srgb, var(--text) 8%, transparent);
  pointer-events: none; opacity: 0;
  transition: transform 220ms cubic-bezier(.2,.8,.2,1), height 220ms ease, opacity 150ms ease;
}
body .canvas-model-options[data-glide-hover]::before { opacity: 1; }
body .canvas-model-option { position: relative; z-index: 1; }
body .canvas-model-option:hover, body .canvas-model-option:focus-visible,
html[data-mode="light"] body .canvas-model-option:hover,
html[data-mode="light"] body .canvas-model-option:focus-visible,
body .canvas-model-options[data-glide-hover] .canvas-model-option[aria-selected="true"],
html[data-mode="light"] body .canvas-model-options[data-glide-hover] .canvas-model-option[aria-selected="true"] {
  background: transparent;
}
body .canvas-model-option[aria-selected="true"],
html[data-mode="light"] body .canvas-model-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
.canvas-model-trigger > svg:last-child { transition: transform 180ms ease; }
.canvas-model-trigger[aria-expanded="true"] > svg:last-child { transform: rotate(180deg); }
@keyframes glide-pop-in {
  from { opacity: 0; transform: translateY(-3px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes glide-pop-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(.97); }
}
@media (max-width: 720px) {
  .glide-trigger.field, .model-block .glide-trigger { font-size: 16px; }
  body.in-app .bench .row > .glide-trigger.field { flex: 1 1 0; width: auto !important; max-width: none; }
  .glide-menu { font-size: 16px; }
  .glide-option { min-height: 48px; }
}
@media (max-width: 760px) {
  .select-wrap > button.glide-trigger { max-width: 70px; }
}
@media (max-width: 390px) {
  .select-wrap > button.glide-trigger { max-width: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .glide-menu, .glide-menu.glide-closing, body .canvas-model-popover { animation: none; }
  .glide-highlight, .glide-chevron, .glide-trigger,
  body .canvas-model-options::before, .canvas-model-trigger > svg:last-child { transition: none; }
}


/* One menu for plain forms, dynamic editors and isolated control panels. */
button.glide-trigger[hidden], .glide-menu[hidden] { display: none !important; }
button.glide-trigger { box-sizing: border-box; appearance: none; background-image: none; }
button.glide-trigger:hover, button.glide-trigger:active { transform: none; }
.glide-menu::backdrop { background: transparent; pointer-events: none; }
.glide-value { flex: 1; text-align: start; }
.glide-option-detail { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 400; }
.glide-option-tag:has(small) { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; line-height: 1.4; white-space: nowrap; }
.glide-option-tag small { color: var(--muted); font-size: 11px; font-weight: 400; }
.glide-trigger-tag { margin-left: auto; }
.glide-option-tag[hidden] { display: none; }
.glide-option.is-selected:not(.is-active) { background: color-mix(in srgb, var(--text) 4%, transparent); }
.glide-option-check { flex-shrink: 0; }
.glide-list { -webkit-overflow-scrolling: touch; }
.toolbar > button.glide-trigger, .filters > button.glide-trigger { width: auto; flex: 0 1 220px; max-width: 100%; }
.form-grid button.glide-trigger, .login-card button.glide-trigger, dialog button.glide-trigger, [role="dialog"] button.glide-trigger { max-width: 100%; }
.gen-parameter button.glide-trigger, .agent-model-wrap button.glide-trigger { width: 100%; max-width: none; }
.agent-effort-wrap button.glide-trigger { width: auto; min-width: 84px; }
.admin-edit-section button.glide-trigger { width: 100%; max-width: none; }
@media (pointer: coarse) {
  button.glide-trigger { min-height: 44px; }
  .select-wrap > button.glide-trigger { min-height: 32px; height: 32px; }
}
