/* ==========================================================================
   MillBench Pro — Industrial-Metrology Design System (.mb- namespace)
   Surface Modes: Operate (calculators), Read (reference & docs), Hub (catalog)
   Light: Drafting Paper (#F8F7F3 / #FFFFFF / #F1EFE9 / #DCD9CF / #171614)
   Dark:  Anodized Charcoal (#151513 / #1E1E1B / #181815 / #2F2E29 / #F0EFE9)
   Accent: Machined Cobalt (#1E56C5 light / #5B92FF dark)
   ========================================================================== */

:root,
[data-theme="light"] {
  --mb-canvas: #F8F7F3;
  --mb-surface: #FFFFFF;
  --mb-well: #F1EFE9;
  --mb-border: #DCD9CF;
  --mb-border-strong: #C5C1B5;
  --mb-ink: #171614;
  --mb-ink-muted: #5A5850;
  --mb-ink-subtle: #5A5850;

  --mb-accent: #1E56C5;
  --mb-accent-hover: #17449E;
  --mb-accent-btn: #1E56C5;
  --mb-accent-btn-hover: #17449E;
  --mb-accent-soft: #EEF3FC;
  --mb-accent-ink: #1E56C5;
  --mb-accent-border: #B8CBEF;

  --mb-pass: #166534;
  --mb-pass-soft: #ECFDF3;
  --mb-pass-border: #B8DEC6;

  --mb-caution: #92400E;
  --mb-caution-soft: #FEF7E6;
  --mb-caution-border: #E5C787;

  --mb-error: #B91C1C;
  --mb-error-soft: #FEF2F2;
  --mb-error-border: #E8B4B4;

  /* CAD Blueprint SVG semantic tokens */
  --mb-svg-bg: #F1EFE9;
  --mb-svg-grid: #E4E1D8;
  --mb-svg-stock: #E6E3DA;
  --mb-svg-stock-stroke: #9A968A;
  --mb-svg-cut: rgba(30, 86, 197, 0.14);
  --mb-svg-tool: #FFFFFF;
  --mb-svg-tool-stroke: #171614;
  --mb-svg-dim: #5A5850;
  --mb-svg-bar-2: #5A5850;
  --mb-svg-bar-3: #9E9B90;
  --mb-svg-bar-4: #DCD9CF;

  color-scheme: light;
}

[data-theme="dark"] {
  --mb-canvas: #151513;
  --mb-surface: #1E1E1B;
  --mb-well: #181815;
  --mb-border: #2F2E29;
  --mb-border-strong: #45433C;
  --mb-ink: #F0EFE9;
  --mb-ink-muted: #B0AEA5;
  --mb-ink-subtle: #9B9990;

  --mb-accent: #5B92FF;
  --mb-accent-hover: #7AA7FF;
  --mb-accent-btn: #2A63D4;
  --mb-accent-btn-hover: #1E56C5;
  --mb-accent-soft: rgba(91, 146, 255, 0.12);
  --mb-accent-ink: #85B0FF;
  --mb-accent-border: rgba(91, 146, 255, 0.34);

  --mb-pass: #4ADE80;
  --mb-pass-soft: rgba(34, 197, 94, 0.12);
  --mb-pass-border: rgba(74, 222, 128, 0.30);

  --mb-caution: #FBBF24;
  --mb-caution-soft: rgba(245, 158, 11, 0.14);
  --mb-caution-border: rgba(251, 191, 36, 0.30);

  --mb-error: #F87171;
  --mb-error-soft: rgba(239, 68, 68, 0.14);
  --mb-error-border: rgba(248, 113, 113, 0.32);

  /* CAD Blueprint SVG semantic tokens (anodized dark) */
  --mb-svg-bg: #181815;
  --mb-svg-grid: #262621;
  --mb-svg-stock: #282722;
  --mb-svg-stock-stroke: #636056;
  --mb-svg-cut: rgba(91, 146, 255, 0.20);
  --mb-svg-tool: #1E1E1B;
  --mb-svg-tool-stroke: #E8E6DE;
  --mb-svg-dim: #B0AEA5;
  --mb-svg-bar-2: #8E8C83;
  --mb-svg-bar-3: #5A5850;
  --mb-svg-bar-4: #2F2E29;

  color-scheme: dark;
}

:root {
  /* Functional type families + tabular monospace */
  --mb-font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --mb-font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mb-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* 4px / 8px spacing token scale */
  --mb-space-1: 4px;
  --mb-space-2: 8px;
  --mb-space-3: 12px;
  --mb-space-4: 16px;
  --mb-space-5: 20px;
  --mb-space-6: 24px;
  --mb-space-8: 32px;
  --mb-space-10: 40px;
  --mb-space-12: 48px;

  /* Structural dimensions */
  --mb-rail-w: 264px;
  --mb-rail-collapsed-w: 60px;
  --mb-topbar-h: 52px;
  --mb-workspace-max: 1200px;

  /* Sharp machined corner radii */
  --mb-radius-none: 0px;
  --mb-radius-xs: 2px;
  --mb-radius-sm: 3px;
  --mb-radius-md: 4px;
  --mb-radius-lg: 4px;

  /* Crisp mechanical motion (150–200ms) */
  --mb-ease: cubic-bezier(0.2, 0, 0, 1);
  --mb-dur-fast: 160ms;
  --mb-dur-base: 180ms;
}

/* ======================== Reset, Base & Browser Surfaces ======================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  background: var(--mb-canvas);
  color: var(--mb-ink);
  scrollbar-color: var(--mb-border-strong) var(--mb-canvas);
  scrollbar-width: thin;
}

body {
  margin: 0;
  font-family: var(--mb-font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  background: var(--mb-canvas);
  color: var(--mb-ink);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--mb-accent);
}

[data-theme="dark"] body {
  letter-spacing: 0.005em;
  line-height: 1.64;
}

::selection {
  background: var(--mb-accent);
  color: #FFFFFF;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--mb-canvas);
}

::-webkit-scrollbar-thumb {
  background: var(--mb-border-strong);
  border-radius: var(--mb-radius-none);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mb-ink-muted);
}

body.mb-no-scroll {
  overflow: hidden;
}

html.mb-theme-switching *,
html.mb-theme-switching *::before,
html.mb-theme-switching *::after {
  transition: none !important;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--mb-accent-ink);
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--mb-accent);
  outline-offset: 2px;
}

.mb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mb-skip-link {
  position: fixed;
  top: -100px;
  left: var(--mb-space-3);
  z-index: 200;
  padding: var(--mb-space-2) var(--mb-space-4);
  background: var(--mb-accent-btn);
  color: #FFFFFF;
  border-radius: var(--mb-radius-xs);
  font-weight: 600;
  font-size: 0.875rem;
}

.mb-skip-link:focus {
  top: var(--mb-space-3);
}

.mb-mono {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
}

/* ======================== AdSense Placeholder Slots ======================== */

.ad-slot {
  display: none;
}

html.mb-ads-enabled .ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  margin: var(--mb-space-6) 0;
  padding: var(--mb-space-3);
  background: var(--mb-well);
  border: 1px dashed var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink-muted);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
}

/* ======================== Shell & Collapsible Left Index Rail ======================== */

.mb-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.mb-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--mb-rail-w);
  flex: 0 0 var(--mb-rail-w);
  display: flex;
  flex-direction: column;
  background: var(--mb-surface);
  border-right: 1px solid var(--mb-border);
  z-index: 60;
  transition: width var(--mb-dur-base) var(--mb-ease), flex-basis var(--mb-dur-base) var(--mb-ease);
}

.mb-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-2);
  height: var(--mb-topbar-h);
  padding: 0 var(--mb-space-3) 0 var(--mb-space-4);
  border-bottom: 1px solid var(--mb-border);
  flex-shrink: 0;
}

.mb-brand-link {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-space-2);
  min-width: 0;
  text-decoration: none;
}

.mb-brand-link:hover {
  text-decoration: none;
}

.mb-brand-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

[data-theme="dark"] .mb-brand-logo,
[data-theme="dark"] .mb-mobile-brand img {
  filter: brightness(1.22) contrast(1.06);
}

.mb-brand-mark {
  display: none;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.mb-rail-collapse-btn,
.mb-drawer-close-btn,
.mb-drawer-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  background: var(--mb-surface);
  color: var(--mb-ink-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease), border-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-collapse-btn:hover,
.mb-drawer-close-btn:hover,
.mb-drawer-trigger:hover {
  background: var(--mb-well);
  color: var(--mb-ink);
  border-color: var(--mb-border-strong);
}

.mb-drawer-close-btn {
  display: none;
}

.mb-rail-search-wrap {
  padding: var(--mb-space-2) var(--mb-space-3);
  border-bottom: 1px solid var(--mb-border);
  flex-shrink: 0;
}

.mb-rail-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.mb-rail-search-icon {
  position: absolute;
  left: var(--mb-space-3);
  color: var(--mb-ink-muted);
  pointer-events: none;
}

.mb-rail-filter {
  width: 100%;
  padding: var(--mb-space-2) var(--mb-space-3) var(--mb-space-2) var(--mb-space-8);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--mb-ink);
  transition: border-color var(--mb-dur-fast) var(--mb-ease), background-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-filter::placeholder {
  color: var(--mb-ink-muted);
  opacity: 1;
}

.mb-rail-filter:focus {
  background: var(--mb-surface);
  border-color: var(--mb-accent);
  outline: none;
}

.mb-rail-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--mb-space-3) var(--mb-space-2) var(--mb-space-4);
}

.mb-rail-home-link {
  display: flex;
  align-items: center;
  gap: var(--mb-space-2);
  padding: var(--mb-space-2) var(--mb-space-3);
  margin-bottom: var(--mb-space-3);
  border-radius: var(--mb-radius-xs);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mb-ink);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), border-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-home-link:hover {
  background: var(--mb-well);
  text-decoration: none;
}

.mb-rail-home-link.is-active {
  background: var(--mb-accent-soft);
  border-color: var(--mb-accent-border);
  color: var(--mb-accent-ink);
}

.mb-rail-home-code {
  display: none;
  font-family: var(--mb-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--mb-ink-muted);
}

.mb-rail-home-link.is-active .mb-rail-home-code {
  color: var(--mb-accent-ink);
}

.mb-rail-group {
  margin-bottom: var(--mb-space-2);
  border-top: 1px solid var(--mb-border);
  padding-top: var(--mb-space-2);
}

.mb-rail-group:first-child {
  border-top: 0;
  padding-top: 0;
}

.mb-rail-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--mb-space-2);
  padding: var(--mb-space-2) var(--mb-space-2);
  background: transparent;
  border: 0;
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-group-toggle:hover {
  background: var(--mb-well);
}

.mb-rail-cat-code {
  display: none;
  font-family: var(--mb-font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  letter-spacing: 0.02em;
}

.mb-rail-cat-label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mb-rail-cat-count {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

.mb-rail-chevron {
  flex-shrink: 0;
  color: var(--mb-ink-muted);
  transition: transform var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-group.is-collapsed .mb-rail-chevron {
  transform: rotate(-90deg);
}

.mb-rail-list {
  list-style: none;
  margin: var(--mb-space-2) 0 var(--mb-space-2);
  padding: 0;
}

.mb-rail-group.is-collapsed .mb-rail-list {
  display: none;
}

.mb-rail-link {
  display: flex;
  align-items: baseline;
  gap: var(--mb-space-2);
  padding: var(--mb-space-2) var(--mb-space-2);
  border-radius: var(--mb-radius-xs);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--mb-ink-muted);
  text-decoration: none;
  transition: color var(--mb-dur-fast) var(--mb-ease), background-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-rail-link:hover {
  background: var(--mb-well);
  color: var(--mb-ink);
  text-decoration: none;
}

.mb-rail-link.is-active {
  background: var(--mb-accent-soft);
  color: var(--mb-accent-ink);
  font-weight: 600;
}

.mb-rail-code {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  flex-shrink: 0;
  min-width: 44px;
}

.mb-rail-link.is-active .mb-rail-code {
  color: var(--mb-accent-ink);
}

.mb-rail-link-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mb-rail-empty {
  padding: var(--mb-space-3) var(--mb-space-2);
  margin: 0;
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

.mb-rail-footer {
  padding: var(--mb-space-3) var(--mb-space-4);
  border-top: 1px solid var(--mb-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--mb-space-2) var(--mb-space-4);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  flex-shrink: 0;
}

.mb-rail-footer a {
  color: var(--mb-ink-muted);
}

.mb-rail-footer a:hover {
  color: var(--mb-ink);
}

/* Desktop collapsed rail state (60px) */
@media (min-width: 1024px) {
  .mb-shell.is-rail-collapsed .mb-rail {
    width: var(--mb-rail-collapsed-w);
    flex-basis: var(--mb-rail-collapsed-w);
  }

  .mb-shell.is-rail-collapsed .mb-rail-header {
    padding: var(--mb-space-2);
    justify-content: center;
    flex-direction: column;
    height: auto;
    gap: var(--mb-space-2);
  }

  .mb-shell.is-rail-collapsed .mb-brand-logo {
    display: none;
  }

  .mb-shell.is-rail-collapsed .mb-brand-mark {
    display: block;
  }

  .mb-shell.is-rail-collapsed .mb-rail-collapse-btn svg {
    transform: rotate(180deg);
  }

  .mb-shell.is-rail-collapsed .mb-rail-search-wrap,
  .mb-shell.is-rail-collapsed .mb-rail-cat-label,
  .mb-shell.is-rail-collapsed .mb-rail-cat-count,
  .mb-shell.is-rail-collapsed .mb-rail-chevron,
  .mb-shell.is-rail-collapsed .mb-rail-list,
  .mb-shell.is-rail-collapsed .mb-rail-footer,
  .mb-shell.is-rail-collapsed .mb-rail-home-label {
    display: none;
  }

  .mb-shell.is-rail-collapsed .mb-rail-home-code,
  .mb-shell.is-rail-collapsed .mb-rail-cat-code {
    display: inline-block;
  }

  .mb-shell.is-rail-collapsed .mb-rail-home-link,
  .mb-shell.is-rail-collapsed .mb-rail-group-toggle {
    justify-content: center;
    padding: var(--mb-space-2) 0;
  }
}

.mb-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(21, 21, 19, 0.54);
  z-index: 55;
}

.mb-drawer-backdrop.is-visible {
  display: block;
}

/* ======================== Main Column & Top Utility Strip ======================== */

.mb-main-column {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mb-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--mb-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-3);
  padding: 0 var(--mb-space-6);
  background: var(--mb-surface);
  border-bottom: 1px solid var(--mb-border);
}

.mb-topbar-left {
  display: flex;
  align-items: center;
  gap: var(--mb-space-3);
  min-width: 0;
}

.mb-drawer-trigger {
  display: none;
}

.mb-mobile-brand {
  display: none;
  align-items: center;
  gap: var(--mb-space-2);
}

.mb-mobile-brand img {
  height: 24px;
  width: auto;
}

.mb-breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--mb-space-2);
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mb-breadcrumbs a {
  color: var(--mb-ink-muted);
}

.mb-breadcrumbs a:hover {
  color: var(--mb-ink);
}

.mb-breadcrumb-sep {
  color: var(--mb-border-strong);
  user-select: none;
}

.mb-breadcrumb-current {
  color: var(--mb-ink);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mb-topbar-controls {
  display: flex;
  align-items: center;
  gap: var(--mb-space-2);
  flex-shrink: 0;
}

/* Segmented US / SI Unit Switch */
.mb-unit-toggle {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: var(--mb-well);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
}

.mb-unit-btn {
  border: 0;
  background: transparent;
  padding: var(--mb-space-2) var(--mb-space-3);
  border-radius: var(--mb-radius-none);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
  color: var(--mb-ink-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-unit-btn + .mb-unit-btn {
  border-left: 1px solid var(--mb-border);
}

.mb-unit-btn:hover {
  color: var(--mb-ink);
}

.mb-unit-btn.is-active {
  background: var(--mb-surface);
  color: var(--mb-accent-ink);
  font-weight: 600;
}

/* Theme Toggle */
.mb-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-space-2);
  height: 32px;
  padding: 0 var(--mb-space-3);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink-muted);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease), border-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-theme-toggle:hover {
  background: var(--mb-well);
  color: var(--mb-ink);
  border-color: var(--mb-ink);
}

.mb-theme-icon-sun {
  display: none;
}

[data-theme="dark"] .mb-theme-icon-sun {
  display: block;
}

[data-theme="dark"] .mb-theme-icon-moon {
  display: none;
}

/* ======================== Workspace Container & Page Header ======================== */

.mb-workspace {
  width: 100%;
  max-width: var(--mb-workspace-max);
  margin: 0 auto;
  padding: var(--mb-space-6) var(--mb-space-6) var(--mb-space-12);
  flex: 1 0 auto;
}

.mb-hero {
  padding-bottom: var(--mb-space-5);
  margin-bottom: var(--mb-space-6);
  border-bottom: 1px solid var(--mb-border);
}

.mb-hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--mb-space-3) var(--mb-space-6);
}

.mb-hero-copy {
  max-width: 72ch;
}

.mb-h1 {
  margin: 0 0 var(--mb-space-2);
  font-family: var(--mb-font-serif);
  font-weight: 500;
  font-size: clamp(1.625rem, 2.5vw, 2.125rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--mb-ink);
  text-wrap: balance;
}

.mb-h2 {
  margin: 0 0 var(--mb-space-2);
  font-family: var(--mb-font-serif);
  font-weight: 500;
  font-size: clamp(1.1875rem, 1.7vw, 1.4375rem);
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--mb-ink);
  text-wrap: balance;
}

.mb-h3 {
  margin: 0 0 var(--mb-space-2);
  font-family: var(--mb-font-sans);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.35;
  color: var(--mb-ink);
}

.mb-lead {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--mb-ink-muted);
  max-width: 68ch;
  text-wrap: pretty;
}

.mb-hero-code {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  margin-right: var(--mb-space-2);
}

/* ======================== Split-Bench Instrument Panels ======================== */

.mb-calc-stack {
  display: flex;
  flex-direction: column;
  gap: var(--mb-space-5);
  margin-bottom: var(--mb-space-8);
}

/* Desktop Asymmetric Split-Bench (>=1024px) for Operate calculators and Hub Quick Bench */
@media (min-width: 1024px) {
  body[data-surface="operate"] .mb-calc-stack,
  body[data-surface="hub"] .mb-calc-stack {
    display: grid;
    grid-template-columns: minmax(344px, 412px) minmax(0, 1fr);
    grid-template-areas:
      "inputs viewport"
      "notes  notes";
    gap: var(--mb-space-5);
    align-items: start;
  }

  body[data-surface="operate"] .mb-input-card,
  body[data-surface="hub"] .mb-input-card {
    grid-area: inputs;
  }

  body[data-surface="operate"] .mb-viewport-card,
  body[data-surface="hub"] .mb-viewport-card {
    grid-area: viewport;
  }

  body[data-surface="operate"] .mb-notes-card,
  body[data-surface="hub"] .mb-notes-card {
    grid-area: notes;
  }

  /* Expanded CAD diagram spans full bench width */
  body[data-surface="operate"] .mb-viewport-card.is-expanded,
  body[data-surface="hub"] .mb-viewport-card.is-expanded {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  body[data-surface="operate"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-input-card,
  body[data-surface="hub"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-input-card {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  body[data-surface="operate"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-notes-card,
  body[data-surface="hub"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-notes-card {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  /* Inside the left input ledger, keep a crisp 2-column compact field grid */
  body[data-surface="operate"] .mb-input-grid,
  body[data-surface="hub"] .mb-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* When expanded, input ledger drops full-width and uses 3 columns */
  body[data-surface="operate"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-input-grid,
  body[data-surface="hub"] .mb-calc-stack:has(.mb-viewport-card.is-expanded) .mb-input-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Select dropdown fields span full ledger width so option labels never truncate */
  body[data-surface="operate"] .mb-field:has(.mb-select),
  body[data-surface="hub"] .mb-field:has(.mb-select) {
    grid-column: 1 / -1;
  }

  /* When a 2-field ledger has a full-width select + single numeric field (e.g. Hardness), keep both full width */
  body[data-surface="operate"] .mb-input-grid:has(.mb-select):has(> .mb-field:nth-child(2):last-child) > .mb-field {
    grid-column: 1 / -1;
  }

  /* On split bench, readout panel sits directly above the CAD viewport */
  body[data-surface="operate"] .mb-viewport-body,
  body[data-surface="hub"] .mb-viewport-body {
    grid-template-columns: 1fr;
  }

  body[data-surface="operate"] .mb-readout-panel,
  body[data-surface="hub"] .mb-readout-panel {
    border-right: 0;
    border-bottom: 1px solid var(--mb-border);
  }
}

.mb-card {
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  overflow: hidden;
}

.mb-notes-card {
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  padding: var(--mb-space-5);
}

.mb-notes-card .mb-card-head {
  padding: 0 0 var(--mb-space-4);
  background: transparent;
  border-bottom: 1px solid var(--mb-border);
  margin-bottom: var(--mb-space-4);
}

.mb-notes-card .mb-notes-body {
  padding: 0;
}

.mb-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--mb-space-2) var(--mb-space-4);
  padding: var(--mb-space-3) var(--mb-space-5);
  border-bottom: 1px solid var(--mb-border);
  background: var(--mb-surface);
}

.mb-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1 1 190px;
  min-width: 0;
}

.mb-card-title {
  margin: 0;
  font-family: var(--mb-font-serif);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.3;
  color: var(--mb-ink);
}

.mb-card-subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

.mb-card-actions {
  display: flex;
  align-items: center;
  gap: var(--mb-space-2);
  flex-wrap: wrap;
}

/* Metrology Status Indicator (flat rectangular tag, high contrast, zero SaaS pill bubbles) */
.mb-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-space-2);
  padding: var(--mb-space-1) var(--mb-space-2);
  border-radius: var(--mb-radius-xs);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  border: 1px solid var(--mb-border);
  background: var(--mb-well);
  color: var(--mb-ink-muted);
}

.mb-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
  flex-shrink: 0;
}

.mb-status-badge.is-pass {
  background: var(--mb-pass-soft);
  border-color: var(--mb-pass-border);
  color: var(--mb-pass);
}

.mb-status-badge.is-caution {
  background: var(--mb-caution-soft);
  border-color: var(--mb-caution-border);
  color: var(--mb-caution);
}

.mb-status-badge.is-error {
  background: var(--mb-error-soft);
  border-color: var(--mb-error-border);
  color: var(--mb-error);
}

/* Readout & CAD Drafting Viewport */
.mb-viewport-body {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.mb-readout-panel {
  padding: var(--mb-space-4) var(--mb-space-5);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--mb-space-3);
  border-bottom: 1px solid var(--mb-border);
  background: var(--mb-surface);
}

/* Hairline-divided readout matrix (no nested rounded cards) */
.mb-readout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--mb-border);
  border: 1px solid var(--mb-border);
}

.mb-viewport-card.is-expanded .mb-readout-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mb-readout-cell {
  padding: var(--mb-space-3) var(--mb-space-4);
  background: var(--mb-well);
  min-width: 0;
}

.mb-readout-cell.is-primary {
  background: var(--mb-surface);
}

.mb-readout-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  margin-bottom: var(--mb-space-1);
}

.mb-readout-value-row {
  display: flex;
  align-items: baseline;
  gap: var(--mb-space-2);
  flex-wrap: wrap;
}

.mb-readout-value {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.25rem, 1.9vw, 1.625rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--mb-ink);
}

.mb-readout-cell.is-primary .mb-readout-value {
  color: var(--mb-accent-ink);
}

.mb-readout-unit {
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

.mb-readout-sub {
  margin-top: var(--mb-space-1);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
}

.mb-readout-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mb-space-2) var(--mb-space-5);
  padding-top: var(--mb-space-3);
  border-top: 1px solid var(--mb-border);
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

.mb-readout-strip strong {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--mb-ink);
}

.mb-svg-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--mb-space-4) var(--mb-space-5);
  background: var(--mb-svg-bg);
  min-height: 248px;
}

.mb-viewport-card.is-expanded .mb-svg-stage {
  min-height: 360px;
}

.mb-svg-stage svg {
  width: 100%;
  height: auto;
  max-height: 280px;
}

.mb-viewport-card.is-expanded .mb-svg-stage svg {
  max-height: 400px;
}

.mb-svg-caption {
  margin-top: var(--mb-space-2);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  text-align: left;
  width: 100%;
}

/* ======================== Precision Input Ledger ======================== */

.mb-input-body {
  padding: var(--mb-space-4) var(--mb-space-5) var(--mb-space-5);
}

.mb-preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-2);
  margin-bottom: var(--mb-space-4);
  padding-bottom: var(--mb-space-3);
  border-bottom: 1px solid var(--mb-border);
}

.mb-preset-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--mb-space-2);
}

.mb-preset-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  margin-right: var(--mb-space-1);
}

.mb-preset-btn {
  padding: var(--mb-space-1) var(--mb-space-3);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  background: var(--mb-surface);
  color: var(--mb-ink);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), border-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-preset-btn:hover {
  border-color: var(--mb-ink);
  background: var(--mb-well);
}

.mb-preset-btn.is-active {
  background: var(--mb-accent-soft);
  border-color: var(--mb-accent);
  color: var(--mb-accent-ink);
  font-weight: 600;
}

/* Non-destructive validation & warning banners */
.mb-validation-banner {
  margin-bottom: var(--mb-space-4);
  padding: var(--mb-space-3) var(--mb-space-4);
  border-radius: var(--mb-radius-xs);
  border: 1px solid var(--mb-error-border);
  background: var(--mb-error-soft);
  color: var(--mb-error);
  font-size: 0.8125rem;
}

.mb-validation-title {
  font-weight: 600;
  margin-bottom: var(--mb-space-1);
}

.mb-validation-list {
  margin: 0;
  padding-left: var(--mb-space-4);
}

.mb-validation-list li + li {
  margin-top: 2px;
}

.mb-validation-banner.is-warning {
  border-color: var(--mb-caution-border);
  background: var(--mb-caution-soft);
  color: var(--mb-caution);
}

.mb-warning-banner {
  margin-bottom: var(--mb-space-4);
  padding: var(--mb-space-3) var(--mb-space-4);
  border-radius: var(--mb-radius-xs);
  border: 1px solid var(--mb-caution-border);
  background: var(--mb-caution-soft);
  color: var(--mb-ink);
  font-size: 0.8125rem;
}

.mb-warning-banner strong {
  color: var(--mb-caution);
}

.mb-input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--mb-space-4) var(--mb-space-3);
}

.mb-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--mb-space-2);
  min-width: 0;
}

.mb-field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--mb-space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mb-ink);
  margin-bottom: auto;
}

.mb-field-sym {
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.mb-input-wrap {
  display: flex;
  align-items: stretch;
  background: var(--mb-surface);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  overflow: hidden;
  transition: border-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-input-wrap:focus-within {
  border-color: var(--mb-accent);
  box-shadow: 0 0 0 2px var(--mb-accent-soft);
}

.mb-input-wrap:has(.mb-input.is-invalid) {
  border-color: var(--mb-error);
  box-shadow: 0 0 0 2px var(--mb-error-soft);
}

.mb-input-wrap.is-disabled {
  opacity: 0.65;
  background: var(--mb-well);
}

.mb-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: var(--mb-space-2) var(--mb-space-3);
  border: 0;
  background: transparent;
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--mb-ink);
}

.mb-input:focus {
  outline: none;
}

.mb-select {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: var(--mb-space-2) var(--mb-space-8) var(--mb-space-2) var(--mb-space-3);
  border: 0;
  background: transparent;
  font-family: var(--mb-font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--mb-ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%235A5850' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.mb-select:focus {
  outline: none;
}

.mb-select option {
  background: var(--mb-surface);
  color: var(--mb-ink);
}

.mb-unit-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--mb-space-2) var(--mb-space-3);
  background: var(--mb-well);
  border-left: 1px solid var(--mb-border);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--mb-ink-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.mb-field-hint {
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

/* Segmented Mode Controls inside Calculators */
.mb-seg-control {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  background: var(--mb-well);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  gap: 2px;
}

.mb-seg-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: var(--mb-space-1) var(--mb-space-3);
  border-radius: var(--mb-radius-xs);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  cursor: pointer;
  white-space: nowrap;
}

.mb-seg-btn:hover {
  color: var(--mb-ink);
}

.mb-seg-btn.is-active {
  background: var(--mb-surface);
  border-color: var(--mb-border-strong);
  color: var(--mb-accent-ink);
  font-weight: 600;
}

/* ======================== Coordinate Tables, Code Blocks & Hardness Scales ======================== */

.mb-kv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: var(--mb-space-2);
  border-top: 1px solid var(--mb-border-strong);
  border-bottom: 1px solid var(--mb-border-strong);
}

.mb-kv-table th,
.mb-kv-table td {
  padding: var(--mb-space-2) var(--mb-space-3);
  text-align: left;
  border-bottom: 1px solid var(--mb-border);
}

.mb-kv-table th {
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  background: var(--mb-well);
  border-bottom-color: var(--mb-border-strong);
}

.mb-kv-table td.mb-mono {
  color: var(--mb-ink);
}

.mb-table-scroll {
  max-height: 290px;
  overflow: auto;
  margin-top: var(--mb-space-2);
}

.mb-table-scroll .mb-kv-table {
  margin-top: 0;
}

.mb-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.mb-code-block-wrap {
  margin-top: var(--mb-space-3);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  overflow: hidden;
  background: var(--mb-well);
}

.mb-code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-2);
  padding: var(--mb-space-2) var(--mb-space-3);
  border-bottom: 1px solid var(--mb-border);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  background: var(--mb-surface);
}

.mb-code-block {
  margin: 0;
  padding: var(--mb-space-3) var(--mb-space-4);
  max-height: 220px;
  overflow: auto;
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--mb-ink);
  white-space: pre;
}

/* Hairline-ruled hardness scale matrix */
.mb-scale-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--mb-border);
  border: 1px solid var(--mb-border);
}

.mb-scale-card {
  padding: var(--mb-space-3);
  background: var(--mb-well);
  min-width: 0;
}

.mb-scale-card.is-source {
  background: var(--mb-surface);
}

.mb-scale-card.is-oor {
  opacity: 0.65;
}

.mb-scale-card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--mb-ink-muted);
  margin-bottom: var(--mb-space-1);
}

.mb-scale-card-val {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--mb-ink);
  line-height: 1.2;
}

.mb-scale-card.is-source .mb-scale-card-val {
  color: var(--mb-accent-ink);
}

.mb-scale-card-sub {
  margin-top: var(--mb-space-1);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

/* ======================== Reference Charts & Specification Tables (Read Mode) ======================== */

.mb-ref-body {
  padding: var(--mb-space-4) var(--mb-space-5) var(--mb-space-5);
}

.mb-ref-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-3) var(--mb-space-4);
  margin-bottom: var(--mb-space-4);
}

.mb-ref-search-wrap {
  position: relative;
  flex: 1 1 260px;
  max-width: 400px;
}

.mb-ref-search-wrap svg {
  position: absolute;
  left: var(--mb-space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--mb-ink-muted);
  pointer-events: none;
}

.mb-ref-search {
  width: 100%;
  padding: var(--mb-space-2) var(--mb-space-3) var(--mb-space-2) var(--mb-space-8);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  font-size: 0.875rem;
  line-height: 1.35;
  color: var(--mb-ink);
}

.mb-ref-search::placeholder {
  color: var(--mb-ink-muted);
  opacity: 1;
}

.mb-ref-search:focus {
  border-color: var(--mb-accent);
  box-shadow: 0 0 0 2px var(--mb-accent-soft);
  outline: none;
}

.mb-ref-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--mb-space-2);
}

.mb-ref-count {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

.mb-ref-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--mb-surface) 30%, transparent),
    linear-gradient(to left, var(--mb-surface) 30%, transparent),
    linear-gradient(to right, rgba(23, 22, 20, 0.12), transparent 14px),
    linear-gradient(to left, rgba(23, 22, 20, 0.12), transparent 14px);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 20px 100%, 20px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

[data-theme="dark"] .mb-ref-table-wrap {
  background:
    linear-gradient(to right, var(--mb-surface) 30%, transparent),
    linear-gradient(to left, var(--mb-surface) 30%, transparent),
    linear-gradient(to right, rgba(0, 0, 0, 0.42), transparent 14px),
    linear-gradient(to left, rgba(0, 0, 0, 0.42), transparent 14px);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 20px 100%, 20px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

.mb-scroll-hint {
  display: none;
  margin-bottom: var(--mb-space-2);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

@media (max-width: 767px) {
  .mb-scroll-hint {
    display: block;
  }
}

.mb-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.45;
  border-top: 1px solid var(--mb-border-strong);
  border-bottom: 1px solid var(--mb-border-strong);
}

.mb-ref-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: var(--mb-space-2) var(--mb-space-3);
  text-align: left;
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  background: var(--mb-well);
  border-bottom: 1px solid var(--mb-border-strong);
  white-space: nowrap;
}

.mb-ref-table tbody td {
  padding: var(--mb-space-2) var(--mb-space-3);
  border-bottom: 1px solid var(--mb-border);
  color: var(--mb-ink);
  vertical-align: middle;
}

.mb-ref-table tbody td.mb-mono,
.mb-kv-table tbody td.mb-mono {
  white-space: nowrap;
}

.mb-ref-table th.mb-num,
.mb-ref-table td.mb-num,
.mb-kv-table th.mb-num,
.mb-kv-table td.mb-num {
  text-align: right;
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mb-cell-sub {
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  white-space: nowrap;
}

.mb-cell-note {
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

.mb-cell-empty {
  text-align: center;
  padding: var(--mb-space-5);
  color: var(--mb-ink-muted);
}

.mb-ref-table tbody tr:last-child td {
  border-bottom: 0;
}

.mb-ref-table tbody tr:hover td {
  background: var(--mb-well);
}

.mb-ref-table tbody tr.is-highlight td {
  background: var(--mb-accent-soft);
}

.mb-copy-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-space-1);
  padding: var(--mb-space-1) var(--mb-space-2);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  background: var(--mb-surface);
  color: var(--mb-ink);
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--mb-dur-fast) var(--mb-ease), background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-copy-chip:hover {
  border-color: var(--mb-accent);
  background: var(--mb-accent-soft);
  color: var(--mb-accent-ink);
}

.mb-code-snippet {
  display: inline-flex;
  align-items: center;
  gap: var(--mb-space-2);
  padding: var(--mb-space-1) var(--mb-space-2);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  background: var(--mb-well);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  color: var(--mb-ink);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--mb-dur-fast) var(--mb-ease), background-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-code-snippet:hover {
  border-color: var(--mb-accent);
  background: var(--mb-accent-soft);
  color: var(--mb-accent-ink);
}

/* ISO 513 Material Group & Code Type Designations (WCAG AA, single-line) */
.mb-iso-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 var(--mb-space-2);
  border-radius: var(--mb-radius-xs);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  border: 1px solid transparent;
}

.mb-iso-P { background: #EEF3FC; color: #1E56C5; border-color: #B8CBEF; }
.mb-iso-M { background: #FEF7E6; color: #92400E; border-color: #E5C787; }
.mb-iso-K { background: #FEF2F2; color: #B91C1C; border-color: #E8B4B4; }
.mb-iso-N { background: #ECFDF3; color: #166534; border-color: #B8DEC6; }
.mb-iso-S { background: #F5EFE6; color: #7C2D12; border-color: #DEC8B0; }
.mb-iso-H { background: #F1EFE9; color: #36342F; border-color: #C5C1B5; }

[data-theme="dark"] .mb-iso-P { background: rgba(91, 146, 255, 0.14); color: #85B0FF; border-color: rgba(91, 146, 255, 0.34); }
[data-theme="dark"] .mb-iso-M { background: rgba(245, 158, 11, 0.14); color: #FBBF24; border-color: rgba(251, 191, 36, 0.32); }
[data-theme="dark"] .mb-iso-K { background: rgba(239, 68, 68, 0.14); color: #F87171; border-color: rgba(248, 113, 113, 0.32); }
[data-theme="dark"] .mb-iso-N { background: rgba(34, 197, 94, 0.14); color: #4ADE80; border-color: rgba(74, 222, 128, 0.32); }
[data-theme="dark"] .mb-iso-S { background: rgba(234, 88, 12, 0.16); color: #FDBA74; border-color: rgba(253, 186, 116, 0.32); }
[data-theme="dark"] .mb-iso-H { background: rgba(176, 174, 165, 0.14); color: #D4D2C9; border-color: rgba(176, 174, 165, 0.30); }

.mb-gdt-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 28px;
  border-radius: var(--mb-radius-xs);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  color: var(--mb-ink);
}

.mb-fit-tag {
  display: inline-block;
  padding: 2px var(--mb-space-2);
  border-radius: var(--mb-radius-xs);
  font-family: var(--mb-font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.mb-fit-clear { background: var(--mb-pass-soft); color: var(--mb-pass); border-color: var(--mb-pass-border); }
.mb-fit-trans { background: var(--mb-caution-soft); color: var(--mb-caution); border-color: var(--mb-caution-border); }
.mb-fit-press { background: var(--mb-error-soft); color: var(--mb-error); border-color: var(--mb-error-border); }

.mb-nearest-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-3) var(--mb-space-5);
  padding: var(--mb-space-3) var(--mb-space-4);
  margin-bottom: var(--mb-space-4);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
}

.mb-nearest-result {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--mb-space-2) var(--mb-space-4);
  font-size: 0.875rem;
}

/* ======================== Equations & Shop-Floor Notes ======================== */

.mb-notes-body {
  padding: var(--mb-space-4) var(--mb-space-5) var(--mb-space-5);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: var(--mb-space-6);
}

.mb-formula-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--mb-border);
}

.mb-formula-item {
  padding: var(--mb-space-3) 0;
  border-bottom: 1px solid var(--mb-border);
}

.mb-formula-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  margin-bottom: var(--mb-space-1);
}

.mb-formula-eq {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  color: var(--mb-ink);
  word-break: break-word;
}

/* Technical note block — full 1px hairline border, zero side-tab bar */
.mb-callout {
  padding: var(--mb-space-4);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--mb-ink-muted);
}

.mb-callout strong {
  color: var(--mb-ink);
}

.mb-callout p {
  margin: 0 0 var(--mb-space-2);
}

.mb-callout p:last-child {
  margin-bottom: 0;
}

.mb-callout code {
  font-family: var(--mb-font-mono);
  font-size: 0.85em;
  padding: 1px 4px;
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink);
}

.mb-related-row {
  margin-top: var(--mb-space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--mb-space-2);
}

.mb-related-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--mb-space-2) var(--mb-space-3);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--mb-ink);
  text-decoration: none;
  transition: border-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease), background-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-related-chip:hover {
  border-color: var(--mb-accent);
  color: var(--mb-accent-ink);
  background: var(--mb-accent-soft);
  text-decoration: none;
}

/* ======================== Instrument Buttons ======================== */

.mb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--mb-space-2);
  padding: var(--mb-space-2) var(--mb-space-4);
  border-radius: var(--mb-radius-xs);
  border: 1px solid var(--mb-border-strong);
  background: var(--mb-surface);
  color: var(--mb-ink);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--mb-dur-fast) var(--mb-ease), border-color var(--mb-dur-fast) var(--mb-ease), color var(--mb-dur-fast) var(--mb-ease);
}

.mb-btn:hover {
  background: var(--mb-well);
  border-color: var(--mb-ink);
  text-decoration: none;
}

.mb-btn-sm {
  padding: var(--mb-space-2) var(--mb-space-3);
  font-size: 0.75rem;
  line-height: 1.1;
}

.mb-btn-primary {
  background: var(--mb-accent-btn);
  border-color: var(--mb-accent-btn);
  color: #FFFFFF;
  font-weight: 600;
}

.mb-btn-primary:hover {
  background: var(--mb-accent-btn-hover);
  border-color: var(--mb-accent-btn-hover);
  color: #FFFFFF;
}

/* ======================== Hub Technical Catalog Directory ======================== */

.mb-hub-section {
  margin-bottom: var(--mb-space-10);
}

.mb-hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--mb-space-3) var(--mb-space-5);
  margin-bottom: var(--mb-space-6);
}

.mb-hub-search-wrap {
  position: relative;
  flex: 1 1 320px;
  max-width: 460px;
}

.mb-hub-search-icon {
  position: absolute;
  left: var(--mb-space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--mb-ink-muted);
  pointer-events: none;
}

.mb-hub-search {
  width: 100%;
  padding: var(--mb-space-2) var(--mb-space-8) var(--mb-space-2) var(--mb-space-8);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--mb-ink);
}

.mb-hub-search::placeholder {
  color: var(--mb-ink-muted);
  opacity: 1;
}

.mb-hub-search:focus {
  border-color: var(--mb-accent);
  box-shadow: 0 0 0 2px var(--mb-accent-soft);
  outline: none;
}

.mb-hub-search-clear {
  position: absolute;
  right: var(--mb-space-2);
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--mb-ink-muted);
  width: 24px;
  height: 24px;
  border-radius: var(--mb-radius-xs);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.mb-hub-search-clear.is-visible {
  display: inline-flex;
}

.mb-hub-search-clear:hover {
  background: var(--mb-well);
  color: var(--mb-ink);
}

.mb-hub-count {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
}

.mb-cat-block {
  margin-bottom: var(--mb-space-8);
}

.mb-cat-block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--mb-space-1) var(--mb-space-4);
  padding-bottom: var(--mb-space-2);
  border-bottom: 1px solid var(--mb-border-strong);
}

.mb-cat-block-title {
  margin: 0;
  font-family: var(--mb-font-serif);
  font-weight: 500;
  font-size: 1.1875rem;
  color: var(--mb-ink);
}

.mb-cat-block-desc {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

/* Hairline-ruled Swiss catalog rows (zero card grids) */
.mb-catalog-list {
  display: flex;
  flex-direction: column;
  background: var(--mb-surface);
  border-bottom: 1px solid var(--mb-border-strong);
}

.mb-catalog-row {
  display: grid;
  grid-template-columns: 64px minmax(200px, 1.05fr) minmax(0, 1.75fr) auto;
  align-items: baseline;
  gap: var(--mb-space-2) var(--mb-space-4);
  padding: var(--mb-space-3) var(--mb-space-4);
  border-bottom: 1px solid var(--mb-border);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--mb-dur-fast) var(--mb-ease);
}

.mb-catalog-row:last-child {
  border-bottom: 0;
}

.mb-catalog-row:hover {
  background: var(--mb-well);
  text-decoration: none;
}

.mb-catalog-code {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--mb-ink-muted);
  white-space: nowrap;
}

.mb-catalog-row:hover .mb-catalog-code {
  color: var(--mb-accent-ink);
}

.mb-catalog-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--mb-ink);
  line-height: 1.35;
}

.mb-catalog-row:hover .mb-catalog-title {
  color: var(--mb-accent-ink);
}

.mb-catalog-desc {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--mb-ink-muted);
}

.mb-catalog-tag {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  white-space: nowrap;
  text-align: right;
}

.mb-hub-empty {
  padding: var(--mb-space-6) var(--mb-space-5);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink-muted);
}

.mb-hub-empty p {
  margin: 0 0 var(--mb-space-2);
}

.mb-hub-empty p:last-child {
  margin-bottom: 0;
}

.mb-hub-bench-divider {
  padding-top: var(--mb-space-8);
  margin-top: var(--mb-space-2);
  border-top: 1px solid var(--mb-border-strong);
}

.mb-hub-bench-head {
  margin-bottom: var(--mb-space-4);
}

/* ======================== Read Mode: Editorial Prose & Legal / Trust Pages ======================== */

.mb-prose-card {
  max-width: 820px;
  padding: var(--mb-space-6) var(--mb-space-8);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
}

.mb-prose {
  max-width: 68ch;
}

.mb-prose h2 {
  margin: var(--mb-space-8) 0 var(--mb-space-2);
  font-family: var(--mb-font-serif);
  font-weight: 500;
  font-size: 1.3125rem;
  line-height: 1.25;
  color: var(--mb-ink);
  text-wrap: balance;
}

.mb-prose h2:first-child {
  margin-top: 0;
}

.mb-prose h3 {
  margin: var(--mb-space-5) 0 var(--mb-space-2);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--mb-ink);
}

.mb-prose p {
  margin: 0 0 var(--mb-space-4);
  color: var(--mb-ink-muted);
  text-wrap: pretty;
}

.mb-prose ul,
.mb-prose ol {
  margin: 0 0 var(--mb-space-4);
  padding-left: var(--mb-space-5);
  color: var(--mb-ink-muted);
}

.mb-prose li {
  margin-bottom: var(--mb-space-2);
}

.mb-prose strong {
  color: var(--mb-ink);
}

.mb-prose code {
  font-family: var(--mb-font-mono);
  font-size: 0.85em;
  padding: 1px var(--mb-space-1);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  color: var(--mb-ink);
}

.mb-alert-box {
  padding: var(--mb-space-4);
  border-radius: var(--mb-radius-xs);
  border: 1px solid var(--mb-caution-border);
  background: var(--mb-caution-soft);
  color: var(--mb-ink);
  margin: var(--mb-space-5) 0;
}

.mb-alert-box-title {
  font-weight: 600;
  color: var(--mb-caution);
  margin-bottom: var(--mb-space-1);
}

.mb-contact-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-3);
  padding: var(--mb-space-4) var(--mb-space-5);
  margin: var(--mb-space-4) 0 var(--mb-space-6);
  background: var(--mb-well);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
}

.mb-contact-label {
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  margin-bottom: 2px;
}

.mb-contact-email {
  font-family: var(--mb-font-mono);
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--mb-ink);
}

.mb-contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mb-space-2);
}

.mb-meta-date {
  font-family: var(--mb-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--mb-ink-muted);
  margin-top: var(--mb-space-2);
}

/* Hairline specification list for standards on About page */
.mb-standards-grid {
  display: flex;
  flex-direction: column;
  margin: var(--mb-space-4) 0 var(--mb-space-6);
  border-top: 1px solid var(--mb-border-strong);
  border-bottom: 1px solid var(--mb-border-strong);
}

.mb-standard-card {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
  gap: var(--mb-space-2) var(--mb-space-4);
  padding: var(--mb-space-3) 0;
  border-bottom: 1px solid var(--mb-border);
}

.mb-standard-card:last-child {
  border-bottom: 0;
}

.mb-standard-code {
  font-family: var(--mb-font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--mb-ink);
}

.mb-standard-desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--mb-ink-muted);
}

/* 404 Recovery */
.mb-notfound-card {
  padding: var(--mb-space-8);
  background: var(--mb-surface);
  border: 1px solid var(--mb-border);
  border-radius: var(--mb-radius-xs);
  text-align: left;
  max-width: 720px;
}

.mb-notfound-code {
  font-family: var(--mb-font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--mb-error);
  margin-bottom: var(--mb-space-2);
}

/* Utility spacing classes (replacing inline styles) */
.mb-mt-3 { margin-top: var(--mb-space-3); }
.mb-mt-4 { margin-top: var(--mb-space-4); }
.mb-mb-3 { margin-bottom: var(--mb-space-3); }
.mb-stage-inner { width: 100%; }
.mb-readout-compact { font-size: 1.125rem; }
.mb-scroll-tall { max-height: 460px; overflow-y: auto; }
.mb-nearest-input { flex: 0 1 230px; }

/* ======================== Footer & Toast ======================== */

.mb-footer {
  margin-top: auto;
  border-top: 1px solid var(--mb-border);
  background: var(--mb-surface);
}

.mb-footer-inner {
  max-width: var(--mb-workspace-max);
  margin: 0 auto;
  padding: var(--mb-space-4) var(--mb-space-6);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--mb-space-3) var(--mb-space-5);
  font-size: 0.8125rem;
  color: var(--mb-ink-muted);
}

.mb-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mb-space-2) var(--mb-space-4);
}

.mb-footer-links a {
  color: var(--mb-ink-muted);
}

.mb-footer-links a:hover {
  color: var(--mb-ink);
}

.mb-toast {
  position: fixed;
  bottom: var(--mb-space-5);
  right: var(--mb-space-5);
  z-index: 150;
  padding: var(--mb-space-2) var(--mb-space-4);
  background: var(--mb-ink);
  color: var(--mb-canvas);
  border: 1px solid var(--mb-border-strong);
  border-radius: var(--mb-radius-xs);
  font-family: var(--mb-font-mono);
  font-size: 0.8125rem;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity var(--mb-dur-base) var(--mb-ease), transform var(--mb-dur-base) var(--mb-ease);
}

.mb-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ======================== Responsive Breakpoints (<1024px & <640px) ======================== */

@media (max-width: 1023px) {
  .mb-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(296px, 86vw);
    flex: none;
    transform: translateX(-100%);
    transition: transform var(--mb-dur-base) var(--mb-ease);
  }

  .mb-rail.is-drawer-open {
    transform: translateX(0);
  }

  .mb-rail-collapse-btn {
    display: none;
  }

  .mb-drawer-close-btn {
    display: inline-flex;
  }

  .mb-drawer-trigger {
    display: inline-flex;
  }

  .mb-mobile-brand {
    display: inline-flex;
  }

  .mb-breadcrumbs {
    display: none;
  }

  .mb-topbar {
    padding: 0 var(--mb-space-4);
  }

  .mb-workspace {
    padding: var(--mb-space-5) var(--mb-space-4) var(--mb-space-10);
  }

  .mb-input-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mb-notes-body {
    grid-template-columns: 1fr;
  }

  .mb-catalog-row {
    grid-template-columns: 60px minmax(0, 1fr) auto;
  }

  .mb-catalog-desc {
    grid-column: 2 / -1;
  }
}

@media (max-width: 639px) {
  .mb-readout-grid,
  .mb-viewport-card.is-expanded .mb-readout-grid {
    grid-template-columns: 1fr;
  }

  .mb-input-grid {
    grid-template-columns: 1fr;
  }

  .mb-scale-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mb-catalog-row {
    grid-template-columns: 56px minmax(0, 1fr);
    padding: var(--mb-space-3);
  }

  .mb-catalog-tag {
    grid-column: 2;
    text-align: left;
  }

  .mb-standard-card {
    grid-template-columns: 1fr;
  }

  .mb-prose-card,
  .mb-notfound-card {
    padding: var(--mb-space-5) var(--mb-space-4);
  }

  .mb-card-head,
  .mb-readout-panel,
  .mb-input-body,
  .mb-ref-body {
    padding-left: var(--mb-space-4);
    padding-right: var(--mb-space-4);
  }

  .mb-theme-label {
    display: none;
  }

  .mb-unit-btn {
    padding: var(--mb-space-1) var(--mb-space-2);
    font-size: 0.72rem;
  }

  .mb-mobile-brand img {
    height: 22px;
  }

  /* Prevent iOS Safari auto-zoom on focused form controls */
  .mb-input,
  .mb-select,
  .mb-hub-search,
  .mb-ref-search,
  .mb-rail-filter {
    font-size: 1rem;
  }
}

/* Hardening: prevent extreme numeric values or long strings from forcing horizontal overflow */
.mb-readout-value,
.mb-readout-sub,
.mb-formula-eq,
.mb-validation-list,
.mb-warning-banner,
.mb-scale-card-val,
.mb-scale-card-sub {
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
