/* Shared UI primitives for the workspace and experiment monitor.
   Page-specific layout and scientific visualizations stay in their own sheets. */
:root {
  --ui-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, "Noto Sans", "DejaVu Sans", Arial, sans-serif;
  --ui-radius: 10px;
  --ui-space: 8px;
  --ui-focus: #6658d9;
  --ui-muted: #626a7d;
  --accent: #6658d9;
  --accent-strong: #5345bb;
  --accent-soft: #f0eefb;
  --muted: var(--ui-muted);
  --bg: #f8f9fc;
  --bg-deep: #eef0f6;
  --surface-soft: #f0f1f7;
  --text: #202332;
  --text-soft: #42495b;
}
:root[data-theme="dark"] {
  --ui-focus: #b5a7ff;
  --ui-muted: #a4acc1;
  --accent: #b5a7ff;
  --accent-strong: #c8bdff;
  --accent-soft: #282942;
  --bg: #131722;
  --bg-deep: #10131c;
  --surface: #1c2230;
  --surface-raised: #222a3a;
  --surface-soft: #282942;
  --canvas: #131722;
  --text: #e4e6f0;
  --text-soft: #c5cada;
}
body, button, input, select, textarea { font-family: var(--ui-font); }
:where(button, .button, input, select, textarea) { border-radius: var(--ui-radius); }
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--ui-focus);
  outline-offset: 3px;
}
.skip-link {
  position: fixed;
  top: var(--ui-space);
  left: var(--ui-space);
  z-index: 1000;
  padding: 10px 16px;
  color: var(--text);
  background: var(--surface, #fff);
  border: 1px solid var(--ui-focus);
  border-radius: var(--ui-radius);
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }
.composer-help { margin: 10px 0 24px; max-width: 760px; }
.language-picker { display: inline-flex; align-items: center; max-width: 100%; flex-shrink: 0; }
.language-picker .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.language-picker select { width: auto; min-width: 0; max-width: 100%; min-height: 34px; padding: 6px 26px 6px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background-color: var(--surface, #fff); font: inherit; font-size: 12px; }
[data-i18n] { overflow-wrap: anywhere; }
dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog::backdrop { backdrop-filter: blur(3px); }
button, .button { transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
.toast.error { background: var(--danger, #a74435); color: #fff; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
@media (max-width: 650px) {
  .benchmark-publication-bar label { white-space: normal; flex-wrap: wrap; }
  .benchmark-publication-bar select { max-width: 100%; min-width: 0; }
  .benchmark-bar-row { grid-template-columns: 18px minmax(70px, 1fr) minmax(25px, .7fr) 72px; gap: 5px; }
}
/* Keep white button text legible when the dark palette uses pale link colors. */
.shell .primary:hover:not(:disabled) { background: #5345bb; color: #fff; }

/* Peer views of the same investigation, with the current view selected. */
.study-navigation { margin: 0 0 20px; font-size: 13px; color: var(--muted); }
.study-navigation ul { display: inline-flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 4px; max-width: 100%; border-radius: 10px; background: var(--surface-soft); }
.study-navigation li { display: flex; min-width: 0; }
.study-navigation a, .study-navigation span { display: block; padding: 7px 12px; border-radius: 7px; line-height: 1.5; color: var(--muted); text-decoration: none; }
.study-navigation a:hover { color: var(--text); background: var(--white, var(--surface, #fff)); }
.study-navigation [aria-current="page"] { color: var(--text); font-weight: 600; background: var(--white, var(--surface, #fff)); box-shadow: 0 1px 3px #0000000d; }
.study-navigation [aria-disabled="true"] { opacity: .55; }

.study-budget { margin: 12px 0; }
.study-budget button, .study-budget-dialog button { min-height: 36px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, #fff); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.study-budget button:hover, .study-budget-dialog button:hover { border-color: var(--accent); }
.study-budget-dialog button[type="submit"] { background: #6658d9; border-color: #6658d9; color: #fff; }
.study-budget-dialog button:disabled { cursor: wait; opacity: .6; }
.study-budget-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.study-budget-request { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.study-budget-request p, .study-budget details p { overflow-wrap: anywhere; }
.study-budget-dialog { width: min(540px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); box-sizing: border-box; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; color: var(--text); background: var(--surface, var(--white, #fff)); box-shadow: 0 20px 80px #0003; }
.study-budget-dialog::backdrop { background: #07121b80; }
.study-budget-dialog { font-family: var(--ui-font); font-size: 14px; line-height: 1.5; }
.study-budget-dialog form { display: block; padding: 0; }
.study-budget-dialog .field-help { color: var(--muted); font-size: 13px; }
.study-budget-dialog .form-error:empty { display: none; }
.study-budget-dialog h2 { margin: 0 0 12px; }
.study-budget-dialog label { display: grid; gap: 6px; margin: 16px 0 10px; }
.study-budget-dialog input, .study-budget-dialog textarea { width: 100%; min-width: 0; box-sizing: border-box; padding: 10px; font: inherit; color: var(--text); background: var(--surface, var(--white, #fff)); border: 1px solid var(--line); border-radius: 8px; }
.study-budget-presets, .study-budget-dialog .study-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.study-budget-preview { display: grid; gap: 5px; margin: 18px 0; }
.study-budget-preview dt { color: var(--muted); font-size: 12px; }
.study-budget-preview dd { margin: 0 0 8px; overflow-wrap: anywhere; }
.study-card.selected-study { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.study-card .study-selection { font-size: 12px; margin-left: auto; }
.study-card h3 a { color: inherit; text-decoration: none; }
.study-card h3 a:hover { text-decoration: underline; }
/* The explicit conversation return label must fit alongside advanced controls. */
.topbar-actions { flex-wrap: wrap; min-width: 0; }
#conversation-return { max-width: 100%; white-space: normal; }
/* One outlined brand asset family for both surfaces. The workspace sidebar stays
   dark independently of the canvas theme; monitor artwork follows its header. */
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  width: 180px;
  max-width: 100%;
}
.brand-logo {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 288.824 / 64;
}
.brand .brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand .brand-logo-dark,
.sidebar .brand .brand-logo-dark { display: block; }
.brand small {
  display: block;
  margin-top: 0;
  padding-left: 25%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.sidebar .brand small { color: #a4acc1; }

/* Bound the tab strip to the inspector, so every tab stays reachable when
   the panel is narrow. Web Awesome supplies the overflow arrow buttons. */
#inspector-tabs { width: 100%; min-width: 0; flex: 1; min-height: 0; }
#inspector-tabs::part(base) { width: 100%; min-width: 0; height: 100%; min-height: 0; }
#inspector-tabs::part(nav) { min-width: 0; max-width: 100%; flex-shrink: 0; }
#inspector-tabs::part(tabs) { flex: 0 0 max-content; }
#inspector-tabs wa-tab { flex: 0 0 auto; font-size: 12px; padding-inline: 9px; white-space: nowrap; }
#inspector-tabs::part(scroll-button) { background: var(--paper); color: var(--ink); }
#inspector-tabs::part(scroll-button__base) { padding-inline: 3px; }

/* Keep navigation visible and scroll history independently of the selected run. */
#research-inspector { display: flex; flex-direction: column; overflow: hidden; }
#research-inspector .inspector-heading { flex-shrink: 0; }
#inspector-tabs::part(body) { flex: 1; min-height: 0; overflow: hidden; }
#inspector-tabs wa-tab-panel { height: 100%; min-height: 0; overflow: auto; overscroll-behavior-y: contain; }
#inspector-tabs wa-tab-panel:is([name="simulations"], [name="commands"]) { overflow: hidden; }
#inspector-tabs wa-tab-panel:is([name="simulations"], [name="commands"])::part(base) {
  display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; box-sizing: border-box;
}
#simulation-list, #command-list {
  flex: 0 1 auto; min-height: 0; max-height: 32%; overflow: auto;
  overscroll-behavior-y: contain; scrollbar-gutter: stable;
}
:is(#simulation-list, #command-list):not(:empty) { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
#simulation-detail, #command-detail {
  flex: 1; min-height: 0; overflow: auto; overscroll-behavior-y: contain; scrollbar-gutter: stable;
}
@media (max-width: 1000px) {
  #research-inspector { height: min(650px, 80dvh); min-height: 0; }
}
