/* File List */
.file-list {
  margin-top: var(--nd-space-xs);
  max-height: 280px;
  overflow-y: auto;
}

.file-item {
  display: grid;
  gap: var(--nd-space-xs);
  padding: var(--nd-space-xs) var(--nd-space-sm);
  background: var(--nd-color-surface-elevated);
  border: 1px solid var(--nd-color-border);
  border-radius: var(--nd-radius-sm);
  margin-bottom: var(--nd-space-xs);
  font-size: 0.75rem;
}

.file-item-row {
  display: flex;
  align-items: center;
  gap: var(--nd-space-xs);
  min-width: 0;
}

.file-entry-controls {
  display: grid;
  gap: var(--nd-space-xs);
}

.file-role-select {
  font-size: 0.72rem;
}

.file-view-button {
  width: 100%;
}

.file-segment-toggle {
  font-size: 0.72rem;
}

.file-segment-toggle input:disabled + span,
.file-segment-toggle:has(input:disabled) {
  color: var(--nd-color-text-dim);
  cursor: not-allowed;
}

.param-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--nd-space-xs);
  margin-top: var(--nd-space-xs);
}

.imf-option-group {
  margin-top: var(--nd-space-xs);
}

select:disabled,
input[type="number"]:disabled,
input[type="text"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.viewer-unavailable-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nd-space-lg);
  color: var(--nd-color-text-muted);
  background: #000;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

body.viewer-fallback-2d .viewer-canvas-wrapper #gl1 {
  visibility: hidden;
}

/* Viewer Info Bar */
.viewer-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--nd-space-sm);
  padding: var(--nd-space-xs) var(--nd-space-md);
  background: var(--nd-color-surface);
  border-top: 1px solid var(--nd-color-border);
  font-size: 0.7rem;
  font-family: 'SF Mono', 'Consolas', monospace;
  color: var(--nd-color-text-muted);
}


/* Stage Buttons Grid (Results sidebar) */
.stage-buttons-grid {
  display: flex;
  flex-direction: column;
  gap: var(--nd-space-xs);
}

/* Volume Toggle Rows */
.volume-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-toggle .viewer-checkbox:has(input:not(:checked)) {
  color: var(--nd-color-text-dim);
}

.segmentation-result-list {
  display: flex;
  flex-direction: column;
  gap: var(--nd-space-xs);
}

.segmentation-result-row {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: var(--nd-space-xs);
  padding: var(--nd-space-xs);
  background: var(--nd-color-surface);
  border: 1px solid var(--nd-color-border);
  border-radius: var(--nd-radius-sm);
}

.segmentation-result-label {
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
  white-space: normal;
}

.segmentation-result-label input {
  flex-shrink: 0;
}

.segmentation-download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: var(--nd-space-xs) var(--nd-space-sm);
  background: var(--nd-color-surface-elevated);
  border: 1px solid var(--nd-color-border);
  border-radius: var(--nd-radius-sm);
  color: var(--nd-color-text);
  font-size: 0.72rem;
  cursor: pointer;
  white-space: nowrap;
}

.segmentation-download-button:hover {
  border-color: var(--nd-color-border-light);
  color: var(--nd-color-primary);
}

.segmentation-download-button svg {
  width: 12px;
  height: 12px;
}

.metrics-summary-inline {
  margin-top: var(--nd-space-sm);
  padding-top: var(--nd-space-sm);
  border-top: 1px solid var(--nd-color-border);
}

/* Responsive */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
  }

  .app-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--nd-color-border);
    max-height: 50vh;
  }
}

/* Header Links */
.header-links {
  display: flex;
  align-items: center;
  gap: var(--nd-space-sm);
  justify-content: flex-end;
  flex-wrap: wrap;
}

.about-modal-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

/* Muscle Legend */
#muscleLegend {
  border-bottom: none;
}

.legend-header {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--nd-color-text-muted);
  padding: var(--nd-space-sm) var(--nd-space-md);
  border-bottom: 1px solid var(--nd-color-border);
}

.legend-list {
  max-height: 300px;
  overflow-y: auto;
  padding: var(--nd-space-xs) var(--nd-space-md) var(--nd-space-md);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--nd-space-sm);
  padding: 2px 0;
  font-size: 0.7rem;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-name {
  flex: 1;
  color: var(--nd-color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-index {
  color: var(--nd-color-text-dim);
  font-size: 0.6rem;
  flex-shrink: 0;
}

.legend-volume {
  color: var(--nd-color-text-dim);
  font-size: 0.6rem;
  flex-shrink: 0;
  text-align: right;
  min-width: 50px;
}

.legend-empty {
  padding: var(--nd-space-sm) var(--nd-space-md);
  font-size: 0.75rem;
  color: var(--nd-color-text-dim);
}

/* Metrics Summary */
.metrics-header {
  display: flex;
  gap: var(--nd-space-md);
  justify-content: space-around;
}

.metrics-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.metrics-stat-value {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--nd-color-primary);
}

.metrics-stat-label {
  font-size: 0.55rem;
  color: var(--nd-color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
