/* Explorer (left) and Inspector (right) around the panel grid. */
.mech-body {
  position: relative;
  display: flex;
  flex: 1;
  gap: 0.875rem;
  min-height: 0;
}
.mech-body > .mech-grid-frame {
  min-width: 0;
}
.mech-explorer,
.mech-inspector {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  margin-block: 7px;
  overflow: hidden;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
}
.mech-explorer {
  flex: 0 0 clamp(280px, 19vw, 340px);
  flex-direction: row;
}
.mech-explorer[data-collapsed] {
  flex-basis: 3rem;
}
.mech-inspector {
  flex: 0 0 clamp(300px, 22vw, 368px);
}
.mech-inspector[hidden] {
  display: none;
}
@media (max-width: 1180px) {
  .mech-body > .mech-inspector {
    position: absolute;
    z-index: 30;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, calc(100% - 1rem));
    box-shadow: var(--shadow-lg);
  }
}
@media (max-width: 850px) {
  .mech-body > .mech-explorer:not([data-collapsed]) {
    position: absolute;
    z-index: 31;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, calc(100% - 3.5rem));
    box-shadow: var(--shadow-lg);
  }
}

/* Shared primitives, also usable by other system-model views. */
.mech-sys-icon {
  flex-shrink: 0;
}
.mech-sys-glyph {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  min-width: 1.45rem;
  height: 1.3rem;
  padding: 0 0.2rem;
  border-radius: 0.3rem;
  background: var(--glyph-color, var(--muted-foreground));
  color: #fff;
  font:
    600 0.58rem/1 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  letter-spacing: -0.02em;
}
.mech-sys-pill {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 1.15rem;
  padding: 0 0.4rem;
  border-radius: 0.3rem;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.65rem;
  font-weight: 550;
  white-space: nowrap;
}
.mech-sys-pill[data-tone="ok"] {
  background: var(--mech-ok-soft);
  color: var(--mech-ok);
}
.mech-sys-pill[data-tone="warn"] {
  background: var(--mech-warn-soft);
  color: var(--mech-warn);
}
.mech-sys-pill[data-tone="err"] {
  background: var(--mech-err-soft);
  color: var(--mech-err);
}
.mech-sys-dot[data-domain="power"] {
  background: var(--domain-power);
}
.mech-sys-dot[data-domain="signal"] {
  background: var(--domain-signal);
}
.mech-sys-dot[data-domain="data"] {
  background: var(--domain-data);
}
.mech-sys-dot[data-domain="mechanical"] {
  background: var(--domain-mechanical);
}
.mech-sys-badge {
  color: var(--mech-err);
  font-size: 0.6rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.mech-sys-tag {
  background: var(--card);
  color: var(--foreground);
  font: inherit;
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}
button.mech-sys-tag {
  cursor: pointer;
}
.mech-sys-tag[aria-current="true"] {
  border-color: var(--mech-accent);
  background: var(--mech-accent-soft);
}
.mech-sys-tag .mech-icon-button {
  width: 1.1rem;
  height: 1.1rem;
  margin-right: -0.35rem;
  font-size: 0.85rem;
  color: var(--muted-foreground);
}
.mech-sys-menu {
  position: fixed;
  z-index: 60;
  min-width: 12rem;
  max-width: 19rem;
  max-height: 70vh;
  padding: 0.3rem;
  overflow: auto;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: var(--shadow-lg);
  font-size: 0.78rem;
}
.mech-sys-menu-item {
  display: block;
  width: 100%;
  padding: 0.42rem 0.6rem;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mech-sys-menu-item:hover,
.mech-sys-menu-item:focus-visible {
  background: var(--muted);
  outline: none;
}
.mech-sys-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}
.mech-sys-menu-item[data-tone="danger"],
.mech-tool[data-tone="danger"],
.mech-sys-danger {
  color: var(--destructive);
}
.mech-sys-menu-heading {
  padding: 0.5rem 0.6rem 0.2rem;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 600;
}
.mech-sys-menu-separator {
  height: 1px;
  margin: 0.25rem 0.15rem;
  background: var(--border);
}

/* Explorer */
.mech-explorer-tab {
  border-radius: 0.35rem;
  background: transparent;
  color: var(--muted-foreground);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
}
.mech-explorer-tab span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.mech-explorer-tab[aria-selected="true"] {
  background: var(--card);
  color: var(--foreground);
  box-shadow: var(--shadow-xs);
}
.mech-explorer-tab:hover {
  background: var(--card);
  color: var(--foreground);
}
.mech-explorer-pane[hidden],
.mech-explorer-pane [hidden] {
  display: none !important;
}
.mech-explorer-search {
  background: var(--card);
  color: var(--muted-foreground);
}
.mech-explorer-search:focus-within {
  border-color: var(--ring);
}
.mech-explorer-search input {
  flex: 1;
  min-width: 0;
  padding: 0.38rem 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--foreground);
  font: inherit;
  font-size: 0.75rem;
}
.mech-explorer-chips .mech-tool {
  min-height: 1.45rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  color: var(--muted-foreground);
  font-size: 0.65rem;
}
.mech-explorer-chips .mech-tool[aria-pressed="true"] {
  color: var(--foreground);
}
.mech-explorer-tree:focus-visible,
.mech-explorer-virtual:focus-visible {
  outline: none;
}
.mech-explorer-spacer {
  position: relative;
}
.mech-explorer-row {
  user-select: none;
  white-space: nowrap;
}
.mech-explorer-virtual .mech-explorer-row {
  position: absolute;
  right: 0;
  left: 0;
}
.mech-explorer-row:hover {
  background: var(--muted);
}
.mech-explorer-row[aria-selected="true"] {
  background: var(--mech-accent-soft);
}
.mech-explorer-row[data-linked] {
  box-shadow: inset 2px 0 0 var(--mech-accent);
}
.mech-explorer-row[data-linking] {
  box-shadow: inset 0 0 0 1px var(--mech-accent);
}
.mech-explorer-row[data-drop] {
  background: var(--mech-accent-soft);
  box-shadow: inset 0 0 0 1px var(--mech-accent);
}
.mech-explorer-tree:focus-visible .mech-explorer-row.is-active,
.mech-explorer-virtual:focus-visible .mech-explorer-row.is-active {
  box-shadow: inset 0 0 0 2px var(--ring);
}
.mech-explorer-section {
  margin-top: 0.3rem;
  color: var(--muted-foreground);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.mech-explorer-cad-row .mech-explorer-name {
  color: var(--muted-foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
}
.mech-explorer-cad-row[data-node-kind="part"] .mech-explorer-name,
.mech-explorer-cad-row[aria-selected="true"] .mech-explorer-name {
  color: var(--foreground);
}
.mech-explorer-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.mech-explorer-owner {
  flex-shrink: 1;
}
.mech-explorer-status[data-status="realized"] {
  background: var(--mech-ok);
}
.mech-explorer-status[data-status="specified"] {
  box-shadow: inset 0 0 0 1.5px var(--mech-warn);
}
.mech-explorer-status[data-status="broken"] {
  background: var(--mech-err);
}
.mech-explorer-status[data-status="unconfirmed"] {
  background: var(--mech-warn);
}
.mech-explorer-state[data-state="covered"] {
  background: var(--mech-ok);
}
.mech-explorer-state[data-state="hardware"] {
  background: var(--muted-foreground);
  opacity: 0.6;
}
.mech-explorer-state[data-state="unmapped"] {
  box-shadow: inset 0 0 0 1.5px var(--mech-warn);
}
.mech-explorer-state[data-state="ignore"],
.mech-explorer-state[data-state="group"] {
  box-shadow: inset 0 0 0 1.5px var(--ring);
}
.mech-explorer-state[data-state="subsystem"] {
  box-shadow: inset 0 0 0 1.5px var(--mech-ok);
}
.mech-explorer-rename {
  font: inherit;
}
.mech-explorer-confirm {
  gap: 0.25rem;
  background: var(--mech-err-soft);
}
.mech-explorer-confirm .mech-tool {
  min-height: 1.3rem;
  padding: 0 0.4rem;
  font-size: 0.65rem;
}
.mech-explorer-legend {
  font-size: 0.65rem;
}
.mech-explorer-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.mech-explorer-library-head .mech-muted {
  flex: 1;
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.4;
}
.mech-explorer-library-head .mech-tool {
  flex-shrink: 0;
}
.mech-explorer-kind {
  cursor: grab;
  outline: none;
}
.mech-explorer-kind:hover {
  background: var(--muted);
}
.mech-explorer-kind[aria-current="true"] {
  background: var(--mech-accent-soft);
}
.mech-explorer-kind:focus-visible {
  box-shadow: inset 0 0 0 2px var(--ring);
}
.mech-explorer-domains .mech-sys-dot {
  width: 6px;
  height: 6px;
}
.mech-explorer-library .mech-explorer-hint {
  padding: 0.75rem;
}

/* Inspector */
.mech-inspector-head .mech-tool[hidden] {
  display: none;
}
.mech-inspector-section:last-child {
  border-bottom: 0;
}
.mech-inspector-section[data-drop] {
  background: var(--mech-accent-soft);
  box-shadow: inset 0 0 0 1px var(--mech-accent);
}
.mech-inspector-section-head h3 {
  flex: 1;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 650;
}
.mech-inspector-section-head .mech-tool,
.mech-inspector-props > .mech-tool,
.mech-inspector-add .mech-tool {
  min-height: 1.55rem;
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
}
.mech-inspector-section > button:not(.mech-inspector-owner),
.mech-inspector-section > a,
.mech-inspector-section-body > button:not(.mech-inspector-owner),
.mech-inspector-section-body > a {
  align-self: flex-start;
}
.mech-inspector-identity > .mech-sys-glyph {
  margin-top: 0.3rem;
}
.mech-inspector-name.mech-inspector-input {
  margin-left: -0.35rem;
  padding: 0.2rem 0.35rem;
  border-color: transparent;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.mech-inspector-name.mech-inspector-input:hover {
  border-color: var(--border);
}
.mech-inspector-name.mech-inspector-input:focus {
  border-color: var(--ring);
  background: var(--card);
}
.mech-inspector-tag code,
.mech-inspector-code,
.mech-inspector-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.68rem;
}
.mech-inspector-remove.mech-icon-button {
  width: 1.4rem;
  height: 1.4rem;
  color: var(--muted-foreground);
  font-size: 0.95rem;
}
.mech-inspector-input,
.mech-inspector-select,
.mech-kind-form input:not([type="checkbox"]),
.mech-kind-form select {
  width: 100%;
  min-width: 0;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  background: var(--card);
  color: var(--foreground);
  font: inherit;
  font-size: 0.75rem;
}
textarea.mech-inspector-input {
  resize: vertical;
  line-height: 1.5;
}
.mech-inspector-input:focus,
.mech-inspector-select:focus,
.mech-kind-form input:focus,
.mech-kind-form select:focus {
  border-color: var(--ring);
  outline: none;
}
.mech-inspector-input:disabled,
.mech-inspector-select:disabled {
  opacity: 0.5;
}
.mech-inspector-list.mech-properties {
  margin-top: 0;
  grid-template-columns: minmax(6rem, 0.9fr) minmax(0, 1.4fr);
}
.mech-inspector-list dd {
  font-variant-numeric: tabular-nums;
}
.mech-inspector-list dd .mech-tool {
  max-width: 100%;
  min-height: 1.5rem;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
}
.mech-inspector-list dt:last-of-type,
.mech-inspector-list dd:last-of-type {
  border-bottom: 0;
}
.mech-inspector-locked.mech-properties {
  grid-template-columns: max-content minmax(0, 1fr);
}
.mech-inspector-locked dt {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.mech-inspector-locked dd {
  min-width: 0;
  overflow-wrap: anywhere;
  padding-left: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  text-align: right;
}
.mech-inspector-stat span {
  color: var(--muted-foreground);
  font-size: 0.65rem;
}
.mech-inspector-stat strong {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.7rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mech-inspector-stat strong[data-tone="ok"],
.mech-inspector-callout[data-tone="ok"] {
  color: var(--mech-ok);
}
.mech-inspector-stat strong[data-tone="warn"] {
  color: var(--mech-warn);
}
.mech-inspector-stat strong[data-tone="err"] {
  color: var(--mech-err);
}
.mech-inspector-binding,
.mech-inspector-ref,
.mech-inspector-requirement,
.mech-inspector-owner {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  padding: 0.3rem 0.45rem;
  border: 0;
  border-radius: 0.4rem;
  background: var(--muted);
  color: var(--foreground);
  font: inherit;
  text-align: left;
}
.mech-inspector-binding[data-state="broken"] {
  background: var(--mech-err-soft);
}
[data-state="broken"] > .mech-inspector-binding-mark {
  background: var(--mech-err);
}
.mech-inspector-binding[data-state="unconfirmed"] {
  background: var(--mech-warn-soft);
}
[data-state="unconfirmed"] > .mech-inspector-binding-mark {
  background: var(--mech-warn);
}
.mech-inspector-binding-name,
.mech-inspector-locator {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
a.mech-inspector-locator {
  color: var(--primary);
}
.mech-inspector-binding .mech-muted,
.mech-inspector-port .mech-muted {
  flex-shrink: 0;
  font-size: 0.65rem;
}
.mech-inspector-requirement,
.mech-inspector-owner {
  cursor: pointer;
}
.mech-inspector-requirement:hover,
.mech-inspector-owner:hover {
  filter: brightness(0.97);
}
.mech-inspector-requirement code {
  flex-shrink: 0;
  padding-top: 0.1rem;
  color: var(--muted-foreground);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.65rem;
}
.mech-inspector-requirement-text small {
  color: var(--muted-foreground);
  font-size: 0.65rem;
}
.mech-inspector-owner > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.mech-inspector-props > .mech-tool {
  justify-self: start;
}
.mech-inspector-prop .mech-inspector-input,
.mech-inspector-prop .mech-inspector-select,
.mech-inspector-port .mech-inspector-input,
.mech-inspector-port .mech-inspector-select {
  padding: 0.25rem 0.3rem;
  font-size: 0.7rem;
}
.mech-inspector-source {
  justify-self: start;
}
.mech-inspector-row > .mech-inspector-select {
  flex: 1;
}
.mech-inspector-row > .mech-inspector-input {
  flex: 2;
}
.mech-inspector-ref .mech-sys-pill {
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mech-inspector-cad-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 550;
  overflow-wrap: anywhere;
}
.mech-inspector-check,
.mech-kind-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.mech-inspector-form .mech-inspector-row {
  justify-content: flex-end;
}
.mech-inspector-form .mech-button:disabled {
  opacity: 0.5;
  cursor: default;
}
.mech-inspector-confirm p {
  flex-basis: 100%;
  margin: 0;
  line-height: 1.5;
}
.mech-inspector-confirm .mech-tool[data-tone="danger"] {
  border-color: var(--destructive);
}
.mech-inspector-callout[data-tone="warn"] {
  border-color: transparent;
  background: var(--mech-warn-soft);
}
.mech-inspector-callout[data-tone="err"] {
  border-color: transparent;
  background: var(--mech-err-soft);
}
.mech-inspector-callout[data-tone="ok"] {
  border-color: transparent;
  background: var(--mech-ok-soft);
}
.mech-inspector-keys kbd {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.25rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 0.25rem;
  color: var(--foreground);
  font:
    500 0.62rem/1.3 ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  text-align: center;
}

/* Kind editor dialog */
.mech-kind-form {
  display: grid;
  gap: 0.85rem;
  max-height: calc(100vh - 9rem);
  overflow: auto;
  font-size: 0.78rem;
}
.mech-kind-form > .mech-muted {
  margin: 0;
}
.mech-kind-field {
  display: grid;
  gap: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}
.mech-kind-field input[type="color"] {
  height: 2rem;
  padding: 0.15rem;
}
.mech-kind-group {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  border: 0;
}
.mech-kind-group legend {
  margin-bottom: 0.3rem;
  color: var(--muted-foreground);
  font-size: 0.7rem;
}
.mech-kind-aspects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}
.mech-kind-group > .mech-tool {
  justify-self: start;
}
.mech-kind-rows {
  display: grid;
  gap: 0.3rem;
}
.mech-kind-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem 4.5rem 1.8rem;
  gap: 0.3rem;
  align-items: center;
}
.mech-kind-foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 0.25rem;
}
.mech-kind-foot .mech-button:disabled {
  opacity: 0.5;
  cursor: default;
}
