/* Shared foundation for the application and its reference views. */
:root {font-family:var(--md-ref-typeface-plain);font-size:14px;color:var(--md-sys-color-on-surface);background:var(--md-sys-color-surface);font-synthesis:none}
button,input,select,textarea {font:inherit}
button {min-width:var(--mr-control-size);min-height:var(--mr-control-size);border-radius:var(--md-sys-shape-corner-full);padding:var(--mr-space-3) var(--mr-space-6);border:1px solid var(--md-sys-color-outline-variant);background:var(--md-sys-color-surface-container-lowest);color:var(--md-sys-color-primary);font-weight:600;cursor:pointer;transition:background-color var(--mr-motion-duration),box-shadow var(--mr-motion-duration)}
button:hover {background:var(--md-sys-color-surface-container-high)}
button:active {background:var(--md-sys-color-secondary-container)}
button.primary {background:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);border-color:transparent}
button.primary:hover {background:var(--md-sys-color-on-primary-container)}
button.secondary,.tonal {background:var(--md-sys-color-secondary-container);color:var(--md-sys-color-on-secondary-container);border-color:transparent}
button.text-button {background:transparent;border-color:transparent}
button.danger {color:var(--md-sys-color-error)}
button:disabled {opacity:1;background:var(--mr-color-disabled-container);color:var(--mr-color-disabled);border-color:transparent;cursor:default;box-shadow:none}
:where(button,a,input,select,textarea,summary,[tabindex]):focus-visible,#stage:focus-visible {outline:3px solid var(--mr-color-focus);outline-offset:3px}
input,select,textarea {min-height:var(--mr-control-size);min-width:0;width:100%;border:1px solid var(--md-sys-color-outline);border-radius:var(--md-sys-shape-corner-extra-small);background:var(--md-sys-color-surface-container-lowest);color:var(--md-sys-color-on-surface);padding:12px;line-height:1.5}
input::placeholder,textarea::placeholder {color:var(--md-sys-color-on-surface-variant);opacity:1}
input[aria-invalid=true],textarea[aria-invalid=true] {border:2px solid var(--md-sys-color-error)}
label {font-size:var(--md-sys-typescale-label-small-size);font-weight:600}
input[type=checkbox],input[type=radio] {accent-color:var(--md-sys-color-primary);min-height:20px;width:20px}
.muted,.small,.eyebrow {color:var(--md-sys-color-on-surface-variant)}
.eyebrow {font-size:var(--md-sys-typescale-label-small-size);letter-spacing:.08em;font-weight:600}
h1,h2,h3 {font-family:var(--md-ref-typeface-brand);letter-spacing:-.025em;line-height:1.3}
h2 {font-size:var(--md-sys-typescale-headline-medium-size);font-weight:600}
dialog {border:1px solid var(--md-sys-color-outline-variant);border-radius:var(--md-sys-shape-corner-extra-large);background:var(--md-sys-color-surface-container-low);color:var(--md-sys-color-on-surface);box-shadow:var(--mr-shadow-dialog)}
dialog::backdrop {background:var(--md-sys-color-scrim)}
.topbar {background:var(--md-sys-color-surface-container-lowest)}
.brand {color:var(--md-sys-color-primary)}
.brand-icon {display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;background:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);border-radius:var(--md-sys-shape-corner-medium)}
.brand-icon::before {width:24px!important;height:24px!important}
.sidebar {background:var(--md-sys-color-surface-container-low)}
.sidebar .nav-item {min-height:48px;border-radius:var(--md-sys-shape-corner-full);font-size:14px;padding:12px 16px;color:var(--md-sys-color-on-surface-variant);background:transparent}
.sidebar .nav-item:hover {background:var(--md-sys-color-surface-container-high)}
.sidebar .nav-item.active {color:var(--md-sys-color-on-secondary-container);background:var(--md-sys-color-secondary-container)}
.sidebar nav {gap:var(--mr-space-2)}
.badge {background:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface-variant);font-size:12px}
.stage-wrap {border-radius:var(--md-sys-shape-corner-large)}
.toolbar button,.map-actions button,.file-actions button {font-size:var(--md-sys-typescale-label-large-size)}
.toolbar button {padding:10px 14px}
.canvas-controls {border-radius:var(--md-sys-shape-corner-large)}
.canvas-controls button {min-width:48px;min-height:48px;font-size:12px}
.node {border-radius:var(--md-sys-shape-corner-medium);color:var(--md-sys-color-on-surface);box-shadow:var(--mr-shadow-low);font-weight:500}
.node.selected {box-shadow:0 0 0 4px var(--mr-color-selection-ring)}
.node.root {color:var(--md-sys-color-on-primary);background:var(--md-sys-color-primary)}
.node .node-meta {font-size:11px;color:var(--md-sys-color-on-surface-variant)}
.node.root .node-meta {color:var(--md-sys-color-primary-container)}
.map-card,.requirement-card {border-radius:var(--md-sys-shape-corner-large);color:var(--md-sys-color-on-surface)}
.requirement-id,.requirement-meta,.requirement-statement,.map-card .map-summary {color:var(--md-sys-color-on-surface-variant);font-size:12px}
.requirement-card strong {font-size:var(--md-sys-typescale-title-medium-size)}
.req-dialog-actions,.relationship-footer {background:var(--md-sys-color-surface-container-low)}
.req-checks label {min-height:48px;border-radius:var(--md-sys-shape-corner-small)}
.relationship-row {border-radius:var(--md-sys-shape-corner-medium);background:var(--md-sys-color-surface-container-lowest)}
.relationship-conflict {background:var(--md-sys-color-error-container);border-left-color:var(--md-sys-color-error)}
.relationship-conflict .eyebrow {color:var(--md-sys-color-on-error-container)}
.relationship-actions button {border-radius:var(--md-sys-shape-corner-small)}
.file-state.dirty {color:var(--mr-color-warning)}
.storage-error {color:var(--md-sys-color-on-error-container);background:var(--md-sys-color-error-container);border-color:var(--md-sys-color-error)}
.design-reference-link {display:inline-flex;align-items:center;gap:8px;color:var(--md-sys-color-primary);font-size:12px;min-height:48px;padding:8px;text-decoration:underline;text-underline-offset:3px}
[data-icon]::before {content:'';display:inline-block;flex-shrink:0;width:var(--mr-icon-size);height:var(--mr-icon-size);background-color:currentColor;mask:var(--mr-icon) center/contain no-repeat;-webkit-mask:var(--mr-icon) center/contain no-repeat;vertical-align:middle}
button[data-icon],a[data-icon] {display:inline-flex;align-items:center;justify-content:center;gap:8px}
#outline button[data-icon] {display:flex;align-items:center;gap:var(--mr-space-2)}
.sidebar button[data-icon],.design-reference-link[data-icon] {justify-content:flex-start}
.icon-only {padding:12px!important}
.map-icon[data-icon]::before {width:28px;height:28px}
@media(max-width:700px) {
  .sidebar nav {display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}
  .sidebar .nav-item {font-size:12px;justify-content:flex-start;padding:10px 12px}
  .file-actions button {font-size:12px;min-height:48px;padding:8px}
  .file-actions button::before {width:16px;height:16px}
  .toolbar button {font-size:12px;padding:8px}
  .toolbar button::before {width:18px;height:18px}
  .canvas-controls {flex-wrap:wrap}
  .canvas-controls button {padding:8px;font-size:12px}
  .canvas-controls #center,.canvas-controls #fit {min-width:48px}
  h2 {font-size:var(--md-sys-typescale-title-large-size)}
}
@media(prefers-reduced-motion:reduce) {* {transition:none!important;animation:none!important}}
@media(forced-colors:active) {[data-icon]::before {background:ButtonText}button {border:1px solid ButtonText}.node.selected {outline:3px solid Highlight}input[aria-invalid=true] {border:2px dashed Mark}}

/* One visual contract for view switches, library selection and testing navigation. */
.segmented-control {display:flex;flex-wrap:wrap;align-items:center;gap:4px;padding:3px;max-width:100%;min-width:0;width:fit-content;border:1px solid var(--md-sys-color-outline-variant);border-radius:var(--md-sys-shape-corner-medium);background:var(--md-sys-color-surface-container)}
.segmented-control button {min-height:44px;padding:8px 12px;border:0;border-radius:var(--md-sys-shape-corner-small);background:transparent;color:var(--md-sys-color-on-surface-variant);font-size:13px;box-shadow:none}
.segmented-control button:hover {background:var(--md-sys-color-surface-container-highest)}
.segmented-control button[aria-pressed=true] {background:var(--md-sys-color-surface-container-lowest);color:var(--md-sys-color-primary);box-shadow:var(--mr-shadow-low)}
.segmented-control button:focus-visible {outline-offset:0}
/* State color supplements explicit text and never connects the three status axes. */
.status-badge {display:inline-flex;align-items:center;gap:5px;justify-self:start;max-width:100%;padding:4px 7px;border-radius:var(--md-sys-shape-corner-extra-small);font-size:12px;font-weight:500;line-height:1.4;white-space:normal;background:var(--md-sys-color-surface-container-high);color:var(--md-sys-color-on-surface-variant)}
.status-axis {font-weight:400}
.status-badge[data-tone=positive] {background:var(--md-sys-color-primary-container);color:var(--md-sys-color-on-primary-container)}
.status-badge[data-tone=info] {background:var(--mr-color-info-container);color:var(--mr-color-info)}
.status-badge[data-tone=warning] {background:var(--mr-color-warning-container);color:var(--mr-color-warning)}
.status-badge[data-tone=negative] {background:var(--md-sys-color-error-container);color:var(--md-sys-color-on-error-container)}
/* Titles lead; descriptions and counts no longer inherit button emphasis. */
.requirement-card,.library-card,.map-card {font-weight:400}
.requirement-card strong,.library-card strong,.map-card strong {font-weight:600}
.requirement-card .requirement-id {font-weight:500;letter-spacing:.025em}
.requirement-card .requirement-statement {font-size:14px;font-weight:400;line-height:1.5}
.requirement-card .requirement-meta {font-size:12px;font-weight:400}
.requirement-badges {row-gap:6px}
.requirement-card:hover,.library-card:hover,.map-card:hover {border-color:var(--md-sys-color-outline);background:var(--md-sys-color-surface-container-low)}
.requirement-card[aria-pressed=true],.library-card[aria-pressed=true] {background:var(--md-sys-color-secondary-container)}
.map-link {display:inline-flex;align-items:center;gap:6px;font-weight:500}
.map-link[data-icon]::before {width:16px;height:16px;order:1}
.navigation-entry {gap:12px;padding:12px 16px}
.navigation-copy {display:flex;flex:1;flex-direction:column;gap:3px;min-width:0;font-weight:600}
.navigation-copy>.small {font-weight:400}
.navigation-arrow {display:inline-flex;flex-shrink:0}
.navigation-arrow::before {width:16px;height:16px}
.count-badge {margin-inline-start:auto;min-width:24px;padding:2px 7px;text-align:center;border-radius:var(--md-sys-shape-corner-full);background:var(--md-sys-color-surface-container);color:var(--md-sys-color-on-surface-variant);font-size:12px;font-weight:500;font-variant-numeric:tabular-nums}
.overview-groups button {gap:12px;padding:10px 12px}
@media(hover:hover){.navigation-entry:hover .navigation-arrow {color:var(--md-sys-color-primary)}}
@media(forced-colors:active){.status-badge {border:1px solid CanvasText}.segmented-control button[aria-pressed=true] {outline:2px solid Highlight;outline-offset:-2px}}

@media(pointer:coarse){.segmented-control button {min-height:48px}}
