@import url('./base.css');
@import url('./shell-widgets.css');
@import url('./chrome.css');
@import url('./links.css');
@import url('./help.css');

.hidden {
  display: none !important;
}

.model-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  background:
    radial-gradient(1200px 480px at 12% -10%, color-mix(in srgb, #0f766e 18%, transparent), transparent 60%),
    radial-gradient(900px 420px at 90% 0%, color-mix(in srgb, #b45309 12%, transparent), transparent 55%),
    var(--bg);
  color: var(--text);
}

.prototype-badge {
  margin-left: 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #0f766e 45%, var(--border));
  color: color-mix(in srgb, #0f766e 80%, var(--text));
  background: color-mix(in srgb, #0f766e 12%, var(--surface));
}

.model-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  z-index: 30;
}

.model-toolbar__left {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.toolbar-control {
  position: static;
}

.toolbar-popover {
  display: none;
  position: fixed;
  z-index: 80;
  min-width: 16rem;
  width: max-content;
  max-width: min(28rem, calc(100vw - 1.5rem));
  max-height: min(70vh, 32rem);
  overflow: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 12px 32px color-mix(in srgb, #000 18%, transparent);
}

.toolbar-popover--wide {
  min-width: 22rem;
  max-width: min(40rem, 94vw);
}

.toolbar-popover.is-open {
  display: block;
}

.model-row-count {
  display: none;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 1rem 0.55rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  flex-shrink: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: inherit;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.filter-chip--clear {
  color: var(--text-muted);
}

.columns-popover__section {
  margin-bottom: 0.75rem;
}

.columns-popover__section h4 {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.columns-popover__item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0;
  font-size: 0.82rem;
  cursor: pointer;
}

.columns-popover__item.is-pinned {
  opacity: 0.75;
  cursor: default;
}

.filter-rule {
  display: grid;
  grid-template-columns: 1fr 0.85fr 1.1fr auto;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
  align-items: start;
}

.filter-rule--multi {
  grid-template-columns: 1fr 0.85fr minmax(8rem, 1.4fr) auto;
}

.filter-multi {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 9rem;
  overflow: auto;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.filter-multi__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  cursor: pointer;
  padding: 0.1rem 0.15rem;
  border-radius: 4px;
}

.filter-multi__item:hover {
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.filter-multi__item input {
  margin: 0;
  accent-color: #0f766e;
}

.filter-rule select,
.filter-rule input[type="text"] {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.3rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  min-width: 0;
}

.filter-popover__empty {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

#btn-toggle-graph.is-active {
  border-color: color-mix(in srgb, #0f766e 50%, var(--border));
  background: color-mix(in srgb, #0f766e 12%, var(--surface));
}

.model-body {
  --graph-width: 0%;
  --drawer-width: min(520px, 42vw);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.model-body--drawer-open {
  grid-template-columns: var(--drawer-width) minmax(0, 1fr);
}

.model-body--graph-open {
  grid-template-columns: minmax(0, 1fr) 6px minmax(0, var(--graph-width));
}

.model-body--drawer-open.model-body--graph-open {
  grid-template-columns: min(480px, 36vw) minmax(0, 1fr) 6px minmax(0, var(--graph-width));
}

.param-drawer {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  z-index: 5;
}

.param-drawer[hidden] {
  display: none !important;
}

.drawer-head {
  flex-shrink: 0;
  padding: 0.75rem 0.85rem 0.65rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-2));
}

.drawer-head__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.drawer-head__titles {
  flex: 1;
  min-width: 0;
}

.drawer-head__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  word-break: break-word;
}

.drawer-head__id {
  display: block;
  margin-top: 0.15rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.drawer-head__badges-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.drawer-head__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0;
  min-width: 0;
}

.drawer-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}

.drawer-badge--role {
  color: #0f766e;
  border-color: color-mix(in srgb, #0f766e 35%, var(--border));
  background: color-mix(in srgb, #0f766e 10%, var(--surface));
}

.drawer-badge--prio {
  color: #b45309;
  border-color: color-mix(in srgb, #b45309 35%, var(--border));
  background: color-mix(in srgb, #b45309 10%, var(--surface));
}

.drawer-head__meta {
  margin: 0;
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  white-space: nowrap;
  flex-shrink: 0;
}

.drawer-head__value-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.drawer-head__value-label {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 2.75rem;
}

.drawer-head__value-control {
  flex: 1;
  min-width: 0;
}

.drawer-head__value,
.drawer-computed {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0.65rem 0.85rem 1.5rem;
}

.drawer-section {
  margin-bottom: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-2) 88%, var(--text) 4%);
  overflow: hidden;
}

.drawer-section__title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border: none;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  cursor: pointer;
}

.drawer-section__title:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface-2) 100%, transparent);
}

.drawer-section__body {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.65rem 0.7rem 0.75rem;
  background: var(--surface, #fff);
}

.drawer-section.is-collapsed .drawer-section__body {
  display: none;
}

.drawer-section.is-collapsed .drawer-section__title {
  border-bottom: none;
}

.collapse-caret {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.12s ease;
  flex-shrink: 0;
  opacity: 0.7;
}

.is-collapsed .collapse-caret,
[aria-expanded="false"] .collapse-caret {
  transform: rotate(-45deg);
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.drawer-field__label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.drawer-field__hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.drawer-input,
.drawer-select,
.drawer-textarea {
  width: 100%;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.45rem;
}

.drawer-input:focus,
.drawer-select:focus,
.drawer-textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, #0f766e 55%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, #0f766e 16%, transparent);
}

.drawer-input[readonly] {
  opacity: 0.75;
  cursor: default;
}

.drawer-input--mono,
.drawer-textarea.drawer-input--mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

.drawer-textarea {
  resize: vertical;
  min-height: 2.6rem;
  line-height: 1.4;
}

.drawer-check {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.drawer-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--danger, #b91c1c);
  vertical-align: middle;
}

.drawer-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin: 0.45rem 0 0;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
}

.drawer-banner--warn {
  background: color-mix(in srgb, #b45309 14%, transparent);
  color: #92400e;
}

.drawer-banner--info {
  background: color-mix(in srgb, #0369a1 12%, transparent);
  color: var(--text);
}

.drawer-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.drawer-refs__label {
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 100%;
}

.drawer-ref {
  font: inherit;
  font-size: 0.72rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: #0f766e;
  cursor: pointer;
}

.drawer-ref:hover {
  border-color: color-mix(in srgb, #0f766e 45%, var(--border));
  background: color-mix(in srgb, #0f766e 10%, var(--surface));
}

.model-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.model-stage__head {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  z-index: 25;
}

.model-stage__head[hidden] {
  display: none !important;
}

.model-stage__head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
}

.model-stage__head-row[hidden] {
  display: none !important;
}

.model-stage__graph-btn {
  margin-left: auto;
}

.slice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  padding: 0.35rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

.slice-bar[hidden] {
  display: none !important;
}

.slice-bar__axes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  min-width: 0;
}

.slice-bar__axes:empty {
  display: none;
}

.model-expand-slices {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.model-expand-slices[hidden] {
  display: none !important;
}

.slice-bar__title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.slice-bar__sep {
  width: 1px;
  align-self: stretch;
  min-height: 1.4rem;
  background: var(--border);
  margin: 0 0.1rem;
}

.slice-bar__hint {
  flex: 1 1 12rem;
  min-width: 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.slice-bar__axis {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.78rem;
}

.slice-bar__axis--set {
  font-weight: 600;
}

.slice-bar__axis--unused {
  opacity: 0.42;
}

.slice-bar__axis--unused select {
  cursor: default;
}

.slice-bar__label {
  color: var(--text-muted);
}

.slice-bar__axis select {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.slice-fill-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 0.25rem;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text-muted) 14%, var(--surface));
  vertical-align: middle;
  white-space: nowrap;
}

.slice-scope-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  background: color-mix(in srgb, #0f766e 10%, var(--surface));
  vertical-align: middle;
  white-space: nowrap;
}

.model-row--slice .model-cell--id .cell-input--id,
.model-row--slice .model-cell--name .cell-input--name {
  max-width: calc(100% - 4.5rem);
}

.model-cell__id-wrap,
.model-cell__name-wrap {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
}

.obs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 0;
}

.obs-table--sets .obs-table__set-col {
  min-width: 4.75rem;
  white-space: nowrap;
}

.set-values {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: flex-end;
}

.set-value-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 5.25rem;
  flex: 1 1 5.25rem;
}

.set-value-field__label {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.drawer-head__value-control .set-values {
  width: 100%;
}

.obs-table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.45rem 0 0;
}

.obs-table-scroll {
  max-height: min(16rem, 42vh);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.obs-table-scroll .obs-table {
  margin-top: 0;
}

.obs-table__readonly {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.obs-table th,
.obs-table td {
  border: 1px solid var(--border);
  padding: 0.25rem 0.35rem;
  text-align: left;
  vertical-align: middle;
}

.obs-table tr.is-active-slice {
  background: color-mix(in srgb, #0f766e 12%, var(--surface));
}

.obs-table__empty td {
  color: var(--text-muted);
  font-style: italic;
}

.obs-table__add td {
  background: color-mix(in srgb, var(--surface-2) 65%, var(--surface));
}

.obs-table__input,
.obs-table__select {
  width: 100%;
  min-width: 4.5rem;
  max-width: 9rem;
}

.scope-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.scope-chip {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.72rem;
  background: color-mix(in srgb, #0f766e 12%, var(--surface));
  color: var(--text);
}

.model-muted {
  color: var(--text-muted);
}

.registry-modal,
.axes-modal,
.chains-modal,
.calendar-modal {
  width: min(36rem, calc(100vw - 2rem));
  max-width: 36rem;
  max-height: min(85vh, 40rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px color-mix(in srgb, #000 28%, transparent);
}

.registry-modal::backdrop,
.axes-modal::backdrop,
.chains-modal::backdrop,
.calendar-modal::backdrop {
  background: var(--modal-backdrop, rgba(0, 0, 0, 0.55));
}

.registry-modal__shell,
.axes-modal__shell,
.chains-modal__shell {
  display: flex;
  flex-direction: column;
  max-height: min(85vh, 40rem);
}

.registry-modal__header,
.axes-modal__header,
.chains-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.registry-modal__header h2,
.axes-modal__header h2,
.chains-modal__header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.registry-modal__close,
.axes-modal__close,
.chains-modal__close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
}

.registry-modal__close:hover,
.axes-modal__close:hover,
.chains-modal__close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.registry-modal__body,
.axes-modal__body,
.chains-modal__body {
  padding: 0.85rem 1rem 1rem;
  overflow: auto;
  min-height: 0;
}

.registry-popover__hint,
.axes-popover__hint {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.axes-section {
  margin-top: 0.85rem;
}

.axes-section:first-of-type {
  margin-top: 0.35rem;
}

.axes-section__title {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.axes-section__hint {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.axes-block--readonly {
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
}

.axes-block__readonly-hint {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.axes-phases {
  list-style: none;
  margin: 0 0 0.55rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.axes-phase {
  display: grid;
  grid-template-columns: minmax(5rem, 1fr) auto auto auto auto;
  gap: 0.35rem;
  align-items: end;
  font-size: 0.78rem;
}

.axes-phase--empty {
  color: var(--text-muted);
  grid-template-columns: 1fr;
  padding: 0.2rem 0;
}

.axes-phase__label {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}

.axes-phase__range {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.axes-phase__range span {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.axes-phase__range select {
  font: inherit;
  font-size: 0.75rem;
  padding: 0.22rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  max-width: 8.5rem;
}

.axes-phase__arrow {
  align-self: end;
  padding-bottom: 0.35rem;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .axes-phase {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .axes-phase__range {
    grid-column: 1 / -1;
  }

  .axes-phase__arrow {
    display: none;
  }
}

.registry-popover__list,
.axes-popover__list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: none;
  overflow: visible;
}

.registry-block,
.axes-block,
.chains-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.registry-block__head-row,
.axes-block__head-row {
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
}

.registry-block__head,
.axes-block__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.55rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.registry-block__delete,
.axes-block__delete {
  align-self: center;
  margin-right: 0.25rem;
}

.registry-block__title,
.axes-block__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-block__meta,
.axes-block__meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.registry-block__body,
.axes-block__body {
  padding: 0 0.55rem 0.55rem;
  border-top: 1px solid var(--border);
}

.registry-suggest,
.axes-suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin: 0.65rem 0 0.35rem;
}

.registry-suggest__label,
.axes-suggest__label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-right: 0.15rem;
}

.registry-field,
.axes-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.45rem 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.registry-field input,
.registry-field select,
.registry-add-row input,
.registry-add-row select,
.axes-field input,
.axes-add-member input,
.axes-add-axis input {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
}

.registry-field__hint,
.registry-field__label {
  margin: 0.35rem 0 0.2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.registry-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
}

.registry-add-row--footer {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.chains-steps {
  list-style: none;
  margin: 0 0 0.45rem;
  padding: 0;
}

.chains-step {
  display: grid;
  grid-template-columns: auto 1fr 1.2fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.25rem 0;
  font-size: 0.78rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.chains-step--empty {
  color: var(--text-muted);
  grid-template-columns: 1fr;
  border-bottom: 0;
}

.chains-step--last {
  border-bottom: 0;
}

.chains-step.is-dragging {
  opacity: 0.45;
}

.chains-step.drop-before {
  box-shadow: inset 0 2px 0 var(--primary);
}

.chains-step.drop-after {
  box-shadow: inset 0 -2px 0 var(--primary);
}

.chains-step__drag {
  cursor: grab;
  color: var(--text-muted);
  user-select: none;
  padding: 0 0.15rem;
}

.chains-step__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.chains-step__name {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.axes-members {
  list-style: none;
  margin: 0 0 0.45rem;
  padding: 0;
}

.axes-member {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.78rem;
}

.axes-member--empty {
  color: var(--text-muted);
  grid-template-columns: 1fr;
}

.axes-add-member {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
}

.axes-add-axis {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.obs-table input,
.obs-table select {
  width: 100%;
  font: inherit;
  font-size: 0.76rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 0.15rem;
}

.obs-table input:focus,
.obs-table select:focus {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}


.model-stage__graph-btn[hidden] {
  display: none !important;
}

.model-stage__graph-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

.model-stage__head-label {
  font-size: 0.88rem;
  font-weight: 700;
  margin-right: 0.35rem;
  color: var(--text);
}

.model-stage__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  position: relative;
}

.model-stage__head .filter-chips {
  border-bottom: none;
  padding: 0 0.85rem 0.45rem;
  background: transparent;
}

.split-resizer {
  width: 6px;
  cursor: col-resize;
  background: var(--border);
  position: relative;
  z-index: 2;
}

.split-resizer:hover,
.split-resizer:focus-visible {
  background: color-mix(in srgb, #0f766e 55%, var(--border));
  outline: none;
}

body.is-resizing-split {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-split iframe {
  pointer-events: none;
}

.graph-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.graph-panel[hidden],
.split-resizer[hidden] {
  display: none !important;
}

.graph-panel__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.graph-panel__head h2 {
  margin: 0;
  font-size: 0.88rem;
  margin-right: auto;
}

#btn-close-graph {
  font-size: 1.15rem;
  line-height: 1;
  min-width: 1.75rem;
}
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.graph-selected-only input {
  margin: 0;
  accent-color: #0f766e;
}

.model-title-input {
  display: block;
  width: 100%;
  max-width: 40rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.85rem;
  letter-spacing: -0.02em;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.2rem 0.35rem;
}

.model-title-input:hover,
.model-title-input:focus {
  border-color: var(--border);
  background: var(--surface);
  outline: none;
}

.model-view {
  padding: 1rem 1.15rem 2rem;
}

.stream-block {
  margin-bottom: 1.15rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  overflow: hidden;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
}

.stream-block.is-drop-target {
  border-color: color-mix(in srgb, var(--stream-color, #0f766e) 55%, var(--border));
}

.stream-block.drop-into-empty {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--stream-color, #0f766e) 35%, transparent);
}

.model-row.drop-before td {
  box-shadow: inset 0 3px 0 0 #0f766e;
  position: relative;
}

.model-row.drop-after td {
  box-shadow: inset 0 -3px 0 0 #0f766e;
  position: relative;
}

.stream-block__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem 0.4rem 0.45rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 10%, var(--surface));
}

.stream-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: grab;
  font-size: 0.7rem;
  letter-spacing: -0.08em;
  line-height: 1;
  opacity: 0.5;
  user-select: none;
  -webkit-user-drag: element;
  flex-shrink: 0;
}

.stream-drag-handle:hover,
.stream-block__head:hover .stream-drag-handle {
  opacity: 1;
  color: var(--text);
}

.stream-drag-handle:active {
  cursor: grabbing;
}

.stream-block.is-stream-dragging {
  opacity: 0.55;
}

.stream-drop-line {
  height: 3px;
  margin: -0.575rem 0.35rem;
  background: #0f766e;
  border-radius: 2px;
  position: relative;
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, #0f766e 28%, transparent);
}

.stream-block.is-collapsed .stream-block__head {
  border-bottom: none;
}

.stream-block.is-collapsed .stream-block__table-wrap {
  display: none;
}

.stream-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
}

.stream-collapse:hover {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 16%, transparent);
  color: var(--text);
}

.stream-block__color {
  position: relative;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--stream-color, var(--primary)) 40%, var(--border));
  background: var(--stream-color, var(--primary));
  cursor: pointer;
}

.stream-block__color input[type="color"] {
  position: absolute;
  inset: -0.35rem;
  width: calc(100% + 0.7rem);
  height: calc(100% + 0.7rem);
  padding: 0;
  border: none;
  cursor: pointer;
  opacity: 0;
}

.stream-block__title-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.2rem 0.35rem;
}

.stream-block__title-input:hover,
.stream-block__title-input:focus {
  border-color: color-mix(in srgb, var(--stream-color, var(--primary)) 40%, var(--border));
  background: var(--surface);
  outline: none;
}

.stream-block__count {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 1.5rem;
}

.stream-block__actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-left: auto;
  flex-shrink: 0;
}

.stream-delete {
  opacity: 0.45;
  color: var(--text-muted);
}

.stream-block__head:hover .stream-delete,
.stream-block__head:focus-within .stream-delete {
  opacity: 1;
}

.stream-delete:hover {
  color: var(--danger, #b91c1c);
  background: color-mix(in srgb, var(--danger, #b91c1c) 12%, transparent);
}

.stream-block__swatch {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: var(--stream-color, var(--primary));
  flex-shrink: 0;
}

.stream-block__title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
}

.stream-add-row {
  margin-left: 0;
}

.stream-block__table-wrap {
  overflow-x: auto;
}

.model-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.model-grid th.is-col-draggable {
  cursor: grab;
  user-select: none;
}

.model-grid th.is-col-draggable:active {
  cursor: grabbing;
}

.model-grid th.is-col-dragging {
  opacity: 0.4;
}

.model-grid th.col-drop-before {
  box-shadow: inset 3px 0 0 0 #0f766e;
}

.model-grid th.col-drop-after {
  box-shadow: inset -3px 0 0 0 #0f766e;
}

.th-label {
  pointer-events: none;
}

.model-grid th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 3;
}

.model-grid .is-pin {
  position: sticky;
  background: var(--surface);
  z-index: 2;
}

.model-grid thead .is-pin {
  z-index: 4;
  background: var(--surface-2);
}

.model-grid .is-pin-drag {
  left: 0;
}

.model-grid .is-pin-id {
  left: 1.75rem;
}

.model-grid .is-pin-name {
  left: 8.25rem;
}

.model-cell--id {
  min-width: 6.5rem;
}

.model-cell--name {
  min-width: 8rem;
}

.model-cell--definition,
.model-cell--formula,
.model-cell--comment,
.model-cell--validationRule,
.model-cell--sourceArtifact {
  min-width: 10rem;
}

.cell-input--wide {
  min-width: 12rem;
}

.cell-select--domain {
  min-width: 11rem;
}

.model-row.has-error {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 80%, transparent);
}

.model-row.has-warn {
  box-shadow: inset 3px 0 0 color-mix(in srgb, #b45309 75%, transparent);
}

.row-issue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  margin-right: 0.15rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: middle;
}

.row-issue.is-error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.row-issue.is-warn {
  color: #b45309;
  background: color-mix(in srgb, #b45309 14%, transparent);
}

.model-row.is-selected .is-pin {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 14%, var(--surface));
}

.model-row:hover .is-pin {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 6%, var(--surface));
}

.model-row.is-selected:hover .is-pin {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 14%, var(--surface));
}

.th-drag,
.th-actions {
  width: 1.75rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
}

.model-grid td {
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  vertical-align: middle;
}

.model-row:hover {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 6%, transparent);
}

.model-row.is-selected {
  background: color-mix(in srgb, var(--stream-color, var(--primary)) 14%, transparent);
}

.model-row.is-dragging {
  opacity: 0.45;
}

.model-row__drag {
  width: 1.75rem;
  padding-left: 0.25rem !important;
  padding-right: 0.15rem !important;
}

.row-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.7rem;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: grab;
  font-size: 0.7rem;
  letter-spacing: -0.08em;
  line-height: 1;
  opacity: 0.55;
  user-select: none;
  -webkit-user-drag: element;
}

.row-drag-handle:hover,
.model-row:hover .row-drag-handle {
  opacity: 1;
  background: var(--surface-2);
  color: var(--text);
}

.row-drag-handle:active {
  cursor: grabbing;
}

.cell-input,
.cell-select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.35rem 0.4rem;
}

.cell-input:hover,
.cell-select:hover {
  border-color: color-mix(in srgb, var(--border) 80%, transparent);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.cell-input:focus,
.cell-select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--stream-color, var(--primary)) 55%, var(--border));
  background: var(--surface);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--stream-color, var(--primary)) 18%, transparent);
}

.cell-input--id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  color: var(--text-muted);
  min-width: 5.5rem;
}

.cell-input--name {
  font-weight: 600;
  min-width: 7rem;
}

.cell-input--formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 8rem;
}

.cell-input--notes {
  min-width: 7rem;
  color: var(--text-muted);
}

.cell-select--status {
  font-size: 0.72rem;
  font-weight: 600;
}

.cell-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Evidence status colors (A2) */
.evidence--unknown {
  --evidence-color: #64748b;
}
.evidence--contested {
  --evidence-color: #b91c1c;
}
.evidence--assumption {
  --evidence-color: #b45309;
}
.evidence--provisional {
  --evidence-color: #0369a1;
}
.evidence--validated {
  --evidence-color: #15803d;
}
.evidence--approved {
  --evidence-color: #166534;
}

.cell-select--status.evidence--unknown,
.cell-select--status.evidence--contested,
.cell-select--status.evidence--assumption,
.cell-select--status.evidence--provisional,
.cell-select--status.evidence--validated,
.cell-select--status.evidence--approved {
  border-color: color-mix(in srgb, var(--evidence-color) 45%, var(--border));
  color: var(--evidence-color);
}

.drawer-badge--status {
  border-color: color-mix(in srgb, var(--evidence-color, var(--border)) 55%, var(--border));
  background: color-mix(in srgb, var(--evidence-color, var(--text-muted)) 14%, var(--surface));
  color: var(--evidence-color, var(--text));
}

.drawer-head__ceiling {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.drawer-ceiling-summary {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.ceiling-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.ceiling-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
  text-align: left;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--evidence-color, var(--border));
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.ceiling-item.is-min {
  background: color-mix(in srgb, var(--evidence-color, #b45309) 12%, var(--surface));
  font-weight: 600;
}

.ceiling-item__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.ceiling-item__name {
  font-size: 0.78rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ceiling-item__status {
  font-size: 0.7rem;
  color: var(--evidence-color, var(--text-muted));
}

.sbc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  padding: 0.05rem 0.28rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: color-mix(in srgb, #0f766e 14%, var(--surface));
  color: #0f766e;
  vertical-align: middle;
}

.sbc-badge--quantity { background: color-mix(in srgb, #0369a1 14%, var(--surface)); color: #0369a1; }
.sbc-badge--rate { background: color-mix(in srgb, #0f766e 14%, var(--surface)); color: #0f766e; }
.sbc-badge--adjustment { background: color-mix(in srgb, #b45309 14%, var(--surface)); color: #b45309; }
.sbc-badge--cost { background: color-mix(in srgb, #6d28d9 14%, var(--surface)); color: #6d28d9; }
.sbc-badge--variance { background: color-mix(in srgb, #9f1239 14%, var(--surface)); color: #9f1239; }

.sbc-class-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.sbc-rate-comps {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sbc-rate-comp {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.3rem;
  align-items: center;
}

.sbc-cost-breakdown {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.graph-node.sbc-node--quantity { --node-color: #0369a1; }
.graph-node.sbc-node--rate { --node-color: #0f766e; }
.graph-node.sbc-node--adjustment { --node-color: #b45309; }
.graph-node.sbc-node--cost { --node-color: #6d28d9; }
.graph-node.sbc-node--variance { --node-color: #9f1239; }
.graph-node.sbc-node--other { --node-color: var(--evidence-color, #0f766e); }

.graph-node.evidence--contested {
  border-style: dashed;
}

.graph-node__status {
  font-weight: 700;
  color: var(--evidence-color, inherit);
}

.model-row__id {
  width: 7rem;
}

.model-row__value {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 7rem;
}

.model-row__computed {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.4rem;
  font-weight: 600;
}

.model-row__formula {
  min-width: 9rem;
}

.model-row__notes {
  min-width: 8rem;
}

.model-row__actions {
  width: 2rem;
  text-align: center;
}

.row-delete-btn {
  opacity: 0;
  pointer-events: none;
  width: 1.55rem;
  height: 1.55rem;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.model-row:hover .row-delete-btn,
.model-row:focus-within .row-delete-btn {
  opacity: 1;
  pointer-events: auto;
}

.row-delete-btn:hover {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  color: var(--danger);
}

.type-pill,
.status-pill,
.computed-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
}

.computed-tag {
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.model-row__empty {
  color: var(--text-muted);
  text-align: center;
}

.model-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.model-empty__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.model-add-stream {
  padding: 0.65rem 0.15rem 1.1rem;
}

.graph-view {
  flex: 1;
  min-height: 0;
}

.graph-canvas {
  position: relative;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  --zoom-text-boost: 1;
  --zoom-border-boost: 1;
  --grid-cell: 24px;
  --grid-x: 0px;
  --grid-y: 0px;
  background-image:
    linear-gradient(color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 1px);
  background-size: var(--grid-cell) var(--grid-cell);
  background-position: var(--grid-x) var(--grid-y);
}

.graph-canvas.is-panning {
  cursor: grabbing;
}

.graph-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.graph-nodes {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.graph-edges {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  overflow: visible;
}

.graph-edge-hit {
  pointer-events: stroke;
  stroke: transparent;
  stroke-width: 14px;
  fill: none;
  cursor: pointer;
}

.graph-edge {
  stroke: color-mix(in srgb, var(--text-muted) 70%, transparent);
  stroke-width: calc(1.75px * var(--zoom-border-boost, 1));
  stroke-linecap: round;
  pointer-events: none;
  color: color-mix(in srgb, var(--text-muted) 70%, transparent);
}

.graph-edge--formula {
  stroke-dasharray: none;
}

.graph-edge--source {
  stroke: #0369a1;
  color: #0369a1;
  stroke-width: calc(1.5px * var(--zoom-border-boost, 1));
}

.graph-edge--flow {
  stroke: #9f1239;
  color: #9f1239;
  stroke-width: calc(2.75px * var(--zoom-border-boost, 1));
}

.graph-edge--interface {
  stroke: #6d28d9;
  color: #6d28d9;
  stroke-dasharray: 5 4;
}

.graph-edge--conditional {
  stroke-dasharray: 2 3;
}

.graph-edge--gap {
  stroke: #b45309;
  color: #b45309;
  stroke-dasharray: 4 3;
  stroke-width: calc(2px * var(--zoom-border-boost, 1));
}

.graph-edge--dim {
  opacity: 0.18;
}

.graph-edge-label {
  fill: var(--text-muted);
  font-size: 10px;
  pointer-events: none;
}

.graph-node.is-gap {
  outline: 2px solid #b45309;
  outline-offset: 1px;
}

.graph-node__chain {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.graph-timeline {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.75rem 0.55rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.graph-timeline[hidden] {
  display: none !important;
}

.graph-timeline.model-timeline {
  flex: 1 1 14rem;
  min-width: 12rem;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: none;
  padding: 0 0.25rem;
  gap: 0.35rem 0.5rem;
}

.graph-timeline.model-timeline .graph-timeline__track {
  flex: 1 1 8rem;
  min-width: 0;
}

.graph-timeline.model-timeline .graph-timeline__hint {
  flex: 0 0 auto;
  white-space: nowrap;
}

.graph-timeline__modes {
  display: flex;
  gap: 0.25rem;
}

.graph-timeline__mode {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}

.graph-timeline__mode.is-active {
  color: var(--text);
  border-color: var(--accent, #0f766e);
  background: color-mix(in srgb, var(--accent, #0f766e) 12%, transparent);
}

.graph-timeline__track {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding-bottom: 0.1rem;
}

.graph-timeline__tick {
  flex: 0 0 auto;
  min-width: 3.4rem;
  border: 1px solid var(--border);
  background: var(--surface, transparent);
  border-radius: 4px;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  font-size: 0.65rem;
  line-height: 1.1;
  white-space: nowrap;
}

.graph-timeline__tick.is-active,
.graph-timeline__tick.is-range-start,
.graph-timeline__tick.is-range-end {
  border-color: var(--accent, #0f766e);
  background: color-mix(in srgb, var(--accent, #0f766e) 14%, transparent);
}

.graph-timeline__tick.is-in-range:not(.is-range-start):not(.is-range-end) {
  background: color-mix(in srgb, var(--accent, #0f766e) 8%, transparent);
}

.graph-timeline__hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.calendar-period-list,
.calendar-phase-list {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  max-height: 8rem;
  overflow: auto;
}

.calendar-phase--empty {
  color: var(--text-muted);
  list-style: none;
  padding-left: 0;
}

.chain-dashboard {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  max-height: 36%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chain-dashboard[hidden] {
  display: none !important;
}

.chain-dashboard.is-collapsed {
  max-height: none;
}

.chain-dash__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chain-dash__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  padding: 0;
}

.chain-dash__toggle:hover {
  color: var(--text);
}

.chain-dash__chevron {
  font-size: 0.85em;
  line-height: 1;
}

.chain-dash__scroll {
  overflow: auto;
  min-height: 0;
}

.chain-dash__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.chain-dash__table th,
.chain-dash__table td {
  padding: 0.28rem 0.55rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.chain-dash__table th {
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--surface);
}

.chain-dash__row.is-active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.chain-dash__name,
.chain-dash__hold,
.chain-list__name {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.chain-dash__dest {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
}

.chain-struct,
.chain-ev {
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.02em;
}

.chain-struct--MISSING,
.chain-ev--BLOCKED {
  color: #b91c1c;
}

.chain-struct--GAP {
  color: #b45309;
}

.chain-struct--PASS_STRUCTURE {
  color: #0369a1;
}

.chain-ev--PARTIAL {
  color: #a16207;
}

.chain-ev--PASS {
  color: #15803d;
}

.edge-card {
  position: absolute;
  z-index: 5;
  min-width: 180px;
  max-width: 240px;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  font-size: 0.78rem;
}

.edge-card__type {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.edge-card__path code {
  font-size: 0.72rem;
}

.edge-card__hint {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.edge-list,
.chain-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.edge-list__item,
.chain-list__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.edge-list__type {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--border) 65%, transparent);
}

.edge-list__id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  flex: 1;
  min-width: 0;
}

.edge-list__cond {
  color: var(--text-muted);
  font-size: 0.65rem;
}

.drawer-edge-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
  align-items: center;
}

.drawer-edge-add .drawer-select {
  min-width: 0;
  flex: 1 1 6rem;
}
.graph-stream-label {
  position: absolute;
  font-size: calc(0.72rem * var(--zoom-text-boost, 1));
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stream-color, var(--text-muted));
  transform: translateY(-100%);
}

.graph-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: calc(0.55rem * var(--zoom-text-boost, 1)) calc(0.65rem * var(--zoom-text-boost, 1));
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--node-color) 45%, var(--border));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--card-shadow);
  cursor: grab;
  text-align: left;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  min-height: 102px;
  transition: opacity 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.graph-node:hover {
  box-shadow: var(--card-shadow-hover);
  border-color: color-mix(in srgb, var(--node-color) 65%, var(--border));
}

.graph-node.is-selected {
  box-shadow: var(--card-shadow-selected);
  border-color: color-mix(in srgb, var(--primary) 55%, var(--node-color));
}

.graph-node.is-dim {
  opacity: 0.28;
}

.graph-node.is-filtered-out {
  opacity: 0.2;
  filter: grayscale(0.45);
}

.graph-node.is-dragging {
  cursor: grabbing;
  z-index: 3;
  transition: none;
  box-shadow: var(--card-shadow-hover);
}

.graph-node__name {
  font-size: calc(0.8rem * var(--zoom-text-boost, 1));
  font-weight: 700;
  line-height: 1.2;
}

.graph-node__value {
  font-size: calc(0.92rem * var(--zoom-text-boost, 1));
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.graph-node.is-mixed .graph-node__value,
.model-row__computed.is-mixed,
.drawer-computed.is-mixed,
.drawer-head__value.is-mixed {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.92em;
  line-height: 1.25;
}

.graph-node__meta {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  font-size: calc(0.65rem * var(--zoom-text-boost, 1));
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.graph-node__badges {
  font-family: inherit;
  font-size: 0.9em;
  opacity: 0.9;
}

.graph-canvas.is-zoomed-out .graph-node__meta {
  display: none;
}

.graph-canvas.is-zoomed-far .graph-stream-label {
  display: none;
}

@media (max-width: 860px) {
  .model-body--drawer-open {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, 42vh) minmax(0, 1fr);
  }

  .model-body--graph-open {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) 6px minmax(220px, var(--graph-width));
  }

  .model-body--drawer-open.model-body--graph-open {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 34vh) minmax(0, 1fr) 6px minmax(180px, 28vh);
  }

  .param-drawer {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .split-resizer {
    width: auto;
    height: 6px;
    cursor: row-resize;
  }
}
