/* Result-format / tool picker: replaces the native <select id="operation"> (kept as the hidden source of truth).
   Colours follow the light palette; the dark theme inverts the whole page. */

/* Mode tabs get real icons instead of glyphs. */
body .tabs .tab { display: flex; align-items: center; justify-content: center; gap: 9px; }
body .tabs .mode-icon { display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; font-size: 0; opacity: .9; }
body .tabs .mode-icon svg { display: block; }
.tabs .tab.selected .mode-icon { opacity: 1; }
@media (max-width: 380px) { body .tabs .mode-icon { display: none; } }

/* The native control stays in the DOM (validation, templates, pipeline) but is not shown. */
#operation, #operation-label {
  position: absolute !important; width: 1px; height: 1px; margin: 0 !important; padding: 0 !important;
  border: 0 !important; overflow: hidden; clip: rect(0 0 0 0); opacity: 0; pointer-events: none;
}

/* The file-type chips now live inside the tools block; the old disclosure around them is empty. */
.op-body #tool-search-wrap { margin: 0; padding: 0 12px 8px; }
.op-body #tool-search-wrap[hidden] { display: none; }
.op-body #tool-search-wrap .search-clear-btn { right: 20px; }
.op-filters #tool-categories { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 4px 12px 10px; }
.op-filters #tool-categories[hidden] { display: none; }

.op-picker { margin: 2px 0 12px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--bg-subtle); overflow: hidden; }
.op-picker[hidden], .op-body[hidden] { display: none; }
.op-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; margin: 0; padding: 10px 14px;
  border: 0; border-radius: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  box-shadow: none; transition: background-color .14s ease;
}
.op-toggle:hover { background: var(--bg-page); }
.op-toggle:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: -2px; }
.op-title { font-size: 12.5px; font-weight: 500; color: var(--text-secondary); letter-spacing: .1px; white-space: nowrap; }
.op-current { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-primary); font-weight: 600; opacity: 0; transition: opacity .14s ease; }
.op-picker.collapsed .op-current { opacity: 1; }
.op-chevron { flex: none; width: 18px; height: 18px; margin-left: auto; color: var(--text-secondary); transition: transform .18s ease; }
.op-picker.collapsed .op-chevron { transform: rotate(-90deg); }
.op-list { max-height: 330px; overflow: auto; padding: 0 8px 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; overscroll-behavior: contain; }
.op-picker[aria-disabled="true"] .op-list { opacity: .6; pointer-events: none; }

.op-group-title {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 10px 6px 6px; background: var(--bg-subtle); font-size: 12px; font-weight: 600; color: var(--text-secondary);
}
.op-group-title svg { width: 15px; height: 15px; flex: none; }
.op-group-title span::first-letter { text-transform: uppercase; }
.op-group-title small { margin-left: auto; padding: 1px 7px; border-radius: var(--radius-lg); background: var(--bg-page); color: var(--text-secondary); font-size: 11px; font-weight: 600; }

.op-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; margin: 0 0 2px; padding: 8px 10px;
  border: 1px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--text-primary); font: inherit;
  text-align: left; cursor: pointer; transition: background-color .14s ease, border-color .14s ease;
}
.op-item:hover { background: var(--bg-page); }
.op-item[aria-selected="true"] { background: var(--bg-muted); border-color: var(--brand-accent); }
.op-item:focus-visible, .op-tile:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 1px; }
.op-ico { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-md); background: var(--bg-page); color: var(--text-secondary); transition: background-color .14s ease, color .14s ease; }
.op-ico svg { width: 18px; height: 18px; }
.op-text { min-width: 0; flex: 1; }
.op-text b { display: block; font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.op-text small {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 1px; font-size: 12px; line-height: 1.35; color: var(--text-secondary);
}
.op-check { flex: none; width: 18px; height: 18px; color: var(--text-primary); opacity: 0; transform: scale(.7); transition: opacity .14s ease, transform .14s ease; }
.op-item[aria-selected="true"] .op-check { opacity: 1; transform: none; }

.op-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; padding: 2px 6px 10px; }
.op-tile {
  min-height: 40px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary);
  font-weight: 500; font-size: 13px; line-height: 1.2; font-family: inherit; cursor: pointer; transition: background-color .14s ease, border-color .14s ease, transform .1s ease;
}
.op-tile:hover { background: var(--bg-page); border-color: var(--border-strong); }
.op-tile:active { transform: translateY(1px); }

.op-empty { padding: 20px 14px 22px; text-align: center; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }

@media (prefers-reduced-motion: reduce) {
  .op-item, .op-ico, .op-check, .op-tile, .op-chevron, .op-toggle, .op-current { transition: none; }
}
@media (max-width: 550px) {
  .op-list { max-height: 280px; }
  .op-tiles { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
}
