/* Shared AI Workbench adapter.
 * References: ai-material Input (outline), FilterTrigger (circle),
 * Button (glass primary), and the operations workbench segmented tabs.
 * Load after page styles so every route uses the same design tokens.
 */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Work Sans", sans-serif;
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-soft: #f7f7fa;
  --surface-tint: #f2f2f7;
  --surface-hover: #53608f12;
  --surface-active: #53608f1f;
  --ink: #1c1f23;
  --ink-strong: #09090b;
  --ink-soft: #52525b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --rule: #e4e4e7;
  --rule-soft: rgba(45, 66, 107, 0.12);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-faint: #f5f7ff;
  --success: #258a58;
  --success-soft: #edf8f1;
  --warning: #b76a13;
  --warning-soft: #fff6e9;
  --danger: #ca3f4b;
  --danger-soft: #fff1f2;
  --black-button: #222222;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.03);
  --focus-ring: rgba(37, 99, 235, 0.16);
  --ui-control-height: 36px;
  --ui-radius: 8px;
  --ui-filter-radius: 9999px;
  --ui-page-padding: 28px 32px 36px;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
}

button, input, textarea, select {
  font-family: var(--font-ui);
}

body .dashboard,
body .direction-page,
body .sample-page:not(.is-detail),
body .model-page,
body .data-page {
  min-width: 0;
  padding: var(--ui-page-padding);
  background: var(--surface);
  scrollbar-gutter: stable;
}

body .dashboard,
body .direction-page,
body .sample-page,
body .model-page,
body .data-page {
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

body .dashboard::-webkit-scrollbar,
body .direction-page::-webkit-scrollbar,
body .sample-page::-webkit-scrollbar,
body .model-page::-webkit-scrollbar,
body .data-page::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

body .dashboard::-webkit-scrollbar-thumb,
body .direction-page::-webkit-scrollbar-thumb,
body .sample-page::-webkit-scrollbar-thumb,
body .model-page::-webkit-scrollbar-thumb,
body .data-page::-webkit-scrollbar-thumb {
  border-radius: 9999px;
  background: var(--rule);
}

body .direction-page {
  max-width: none;
  margin: 0;
}

body .wb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
  white-space: nowrap;
}

body .wb-breadcrumb svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: var(--faint);
}

body .wb-page-header {
  display: flex;
  min-height: var(--ui-control-height);
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 24px;
}

body .wb-page-header .wb-page-title {
  margin: 0;
  color: var(--ink-strong);
  font-size: 20px;
  font-weight: 600;
  line-height: 28px;
  letter-spacing: 0;
  white-space: nowrap;
}

body .wb-page-header > .s-button {
  height: var(--ui-control-height);
  flex: 0 0 auto;
  padding: 0 12px;
  font-size: 14px;
  line-height: 20px;
}

body .dashboard > .toolbar {
  margin-top: 0;
}

body .direction-page > .wb-page-header {
  margin-bottom: 0;
}

body .direction-page > .content-grid {
  height: calc(100dvh - 154px);
  min-height: 0;
  margin-top: 24px;
}

body .page-header .version-view-chip,
body .page-user-tag {
  color: var(--ink);
  border-color: var(--rule-soft);
}

body .header-actions.page-meta,
body .page-text-action {
  color: var(--ink-soft);
}

/* Section titles and supporting labels share one hierarchy. */
body .content-grid .panel-title,
body .content-grid .overview-head .card-title,
body .metric-section > .section-heading .section-title {
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
}

body .s-list-fields dt,
body .m-card-field > span,
body .d-card-fields dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

body .s-list-fields dd,
body .m-card-field > div,
body .d-card-fields dd {
  color: var(--ink);
  font-size: 14px;
  line-height: 20px;
}

body .s-list-lead strong,
body .m-card-title-row > strong,
body .d-card-heading strong {
  color: var(--ink-strong);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

body .s-label-stack .s-tag,
body .m-card .m-version-tag,
body .d-version .s-tag {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

body .d-status,
body .d-version-code {
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

body .m-card-title-row {
  height: 22px;
}

body .m-card-icon {
  border-color: var(--rule-soft);
  color: var(--accent);
}

body .m-card-icon svg {
  width: 20px;
  height: 20px;
}

body .m-card[data-model-type="distilled"] .m-card-icon,
body .s-sample-mark {
  color: var(--success);
}

body .s-list-card,
body .m-card,
body .d-application-card {
  border-color: var(--rule-soft);
  border-radius: var(--ui-radius);
  background: #fcfcfd;
}

body .s-list-card:hover,
body .m-card:hover,
body .d-application-card:hover {
  border-color: var(--faint);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

/* Keep search, filters and reset on one row; narrow viewports can scroll it. */
body .wb-filter-row {
  display: flex;
  min-width: 0;
  min-height: var(--ui-control-height);
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  margin: -2px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

body .d-toolbar {
  display: block;
  margin: 0;
}

body .wb-filter-row > * {
  flex: 0 0 auto;
}

body .s-search {
  height: var(--ui-control-height);
  gap: 8px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--ui-radius);
  background: var(--surface);
  padding: 0 12px;
  color: var(--faint);
}

body .wb-filter-row .s-search {
  width: 280px;
  min-width: 200px;
  grid-column: auto;
  border-radius: var(--ui-radius);
}

body .s-search input {
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

body .s-search input::placeholder {
  color: var(--faint);
}

body .s-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

body .wb-filter-row .s-select,
body .wb-filter-row .s-select.asset,
body .wb-filter-row .s-select.source {
  width: auto;
  min-width: 112px;
  max-width: none;
  grid-column: auto;
}

body .wb-filter-row .s-select select {
  width: auto;
  min-width: 112px;
  height: var(--ui-control-height);
  border: 1px solid var(--rule-soft);
  border-radius: var(--ui-filter-radius);
  background: var(--surface);
  padding: 0 32px 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

body .wb-filter-row .s-select > svg {
  right: 12px;
  width: 12px;
  height: 12px;
  color: var(--ink-soft);
}

body .wb-filter-row select:hover,
body .s-mine-filter:hover {
  background: var(--surface-soft);
}

body .wb-filter-row select:has(option:checked:not([value=""])),
body .s-mine-filter:has(input:checked) {
  background: var(--surface-tint);
  color: var(--ink);
}

body .wb-filter-row select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

body .s-mine-filter {
  height: var(--ui-control-height);
  gap: 8px;
  border: 1px solid var(--rule-soft);
  border-radius: var(--ui-filter-radius);
  padding: 0 16px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
}

body .s-mine-filter input {
  accent-color: var(--ink-strong);
}

body .wb-filter-row .s-result,
body .wb-filter-row .m-result {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 18px;
}

body .wb-filter-row .s-button.link {
  height: var(--ui-control-height);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}

body .s-button.primary,
body .button-primary {
  border: 0;
  border-radius: var(--ui-radius);
  background: linear-gradient(180deg, #323232, #222222);
  color: var(--surface);
  font-weight: 500;
}

/* Operations workbench segmented tabs are the shared source of truth. */
body .wb-tabs {
  display: inline-flex;
  min-height: 0;
  height: 38px;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--rule-soft);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 3px;
  margin: 0;
}

body .m-tabs.wb-tabs {
  margin-bottom: 20px;
}

body .period-tabs.wb-tabs {
  height: 36px;
}

body .wb-tabs .wb-tab {
  display: inline-flex;
  height: 100%;
  min-width: 108px;
  align-items: center;
  justify-content: center;
  align-self: auto;
  gap: 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  padding: 0 16px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}

body .period-tabs.wb-tabs .wb-tab {
  min-width: 48px;
  padding: 0 14px;
}

body .wb-tabs .wb-tab:hover {
  color: var(--ink-strong);
}

body .wb-tabs .wb-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--ink-strong);
  box-shadow: var(--shadow-card);
  font-weight: 600;
}

body .wb-tab svg {
  width: 16px;
  height: 16px;
}

body .wb-tab .m-tab-count {
  margin-left: 0;
  color: inherit;
  font-size: 12px;
  line-height: 18px;
}

@media (max-width: 1280px) {
  :root { --ui-page-padding: 24px; }
  body .direction-page > .content-grid { height: calc(100dvh - 138px); }
}

@media (max-width: 959px) {
  body .direction-page > .wb-page-header {
    flex-wrap: wrap;
    gap: 12px;
  }
  body .direction-page > .wb-page-header .title-row {
    min-height: var(--ui-control-height);
  }
  body .direction-page > .wb-page-header .header-actions {
    flex: 0 0 100%;
  }
  body .direction-page > .content-grid {
    height: auto;
    min-height: 0;
  }
}

@media (max-width: 860px) {
  :root { --ui-page-padding: 20px 16px 32px; }
  body .wb-filter-row .s-search { width: 240px; }
  body .s-mobile-nav {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    padding: 3px;
    border-radius: 8px;
    background: var(--surface-tint);
  }
  body .s-mobile-nav button {
    flex: 1;
    border: 0;
    border-radius: 6px;
    background: transparent;
    padding: 7px 4px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
  }
  body .s-mobile-nav button[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-card);
  }
  body #operations-workbench > .s-mobile-nav {
    margin: 20px 16px 0;
  }
}
