.panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-color: var(--border);
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--border);
}

.panel-right {
  border-left: 1px solid var(--border);
}

.panel-header {
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.8462rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.top-bar-icon {
  display: block;
  flex-shrink: 0;
  margin-right: -8px;
}

.top-bar-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.0769rem;
  color: var(--accent);
  white-space: nowrap;
}

.top-bar-version {
  color: var(--text-muted);
  font-size: 0.8462rem;
}

.top-bar-spacer {
  flex: 1;
}

.progress-spinner {
  display: none;
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: progress-spin 0.7s linear infinite;
}

.progress-spinner.active {
  display: inline-block;
}

@keyframes progress-spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-bar {
  width: 160px;
  height: 6px;
  background: var(--bg-dark);
  border-radius: 3px;
  overflow: hidden;
  display: none;
}

.progress-bar.active {
  display: block;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s;
}

.progress-label {
  font-size: 0.8462rem;
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

.top-bar-btn {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9231rem;
  font-family: inherit;
  cursor: pointer;
}

.top-bar-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent-dim);
}

.hierarchy-list {
  list-style: none;
}

.hierarchy-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}

.hierarchy-item:hover {
  background: var(--bg-hover);
}

.hierarchy-item.selected {
  background: var(--bg-hover);
  outline: 1px solid var(--accent-dim);
}

.hierarchy-item-icon {
  width: 14px;
  text-align: center;
  color: var(--accent);
  flex-shrink: 0;
}

.hierarchy-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hierarchy-item-count {
  font-size: 0.7692rem;
  color: var(--text-muted);
}

.hierarchy-item-vis {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9231rem;
  line-height: 1;
  cursor: pointer;
}

.hierarchy-item-vis:hover {
  background: var(--bg-dark);
  color: var(--text);
}

.hierarchy-item-vis.is-off {
  opacity: 0.35;
}

.hierarchy-item.is-invisible .hierarchy-item-name,
.hierarchy-item.is-invisible .hierarchy-item-icon,
.hierarchy-item.is-invisible .hierarchy-item-count {
  opacity: 0.4;
}

.hierarchy-item-action {
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8462rem;
  line-height: 1;
  cursor: pointer;
}

.hierarchy-item:hover .hierarchy-item-action {
  display: inline-flex;
}

.hierarchy-item-delete:hover {
  background: var(--danger);
  color: #fff;
}

.hierarchy-item-duplicate:hover {
  background: var(--bg-dark);
  color: var(--text);
}

.header-menu {
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-menu .btn {
  flex: 1;
  min-width: 0;
  padding: 6px 4px;
  font-size: 0.7692rem;
}

.header-menu-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
}

.header-menu-icon {
  font-size: 1.0769rem;
  line-height: 1;
  color: var(--text);
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

.dialog {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.dialog-close {
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9231rem;
  cursor: pointer;
}

.dialog-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.dialog-body {
  padding: 14px;
}

.dialog-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.dialog-section-title {
  margin-bottom: 10px;
  font-size: 0.7692rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.dialog-section-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.dialog-section-description {
  margin: 12px 0 0;
  font-size: 0.7692rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.dialog-load {
  width: 520px;
}

.format-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.format-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-dark);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.format-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.format-card.todo {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.format-card.todo:hover {
  background: var(--bg-dark);
  border-color: var(--border);
}

.format-card.todo .format-name,
.format-card.todo .format-ext {
  color: var(--text-muted);
}

.format-input {
  display: none;
}

.format-icon {
  font-size: 1.5385rem;
  line-height: 1;
}

.format-name {
  font-size: 0.8462rem;
  font-weight: 600;
  color: var(--text);
}

.format-ext {
  font-size: 0.6923rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.dialog-about {
  width: 480px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.dialog-about .dialog-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.dialog-colorimetry {
  width: 560px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.dialog-colorimetry .dialog-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.dialog-settings {
  width: 360px;
}

.settings-body .field-row label {
  flex: 0 0 88px;
}

.colorimetry-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.colorimetry-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}

.colorimetry-meta-label {
  font-size: 0.7692rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.colorimetry-meta-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--text);
}

.colorimetry-section {
  margin-top: 14px;
}

.colorimetry-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.9231rem;
  color: var(--text);
}

.colorimetry-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.colorimetry-swatch {
  width: 14px;
  height: 3px;
  border-radius: 1px;
}

.colorimetry-swatch-x { background: #e57373; }
.colorimetry-swatch-y { background: #81c784; }
.colorimetry-swatch-z { background: #64b5f6; }
.colorimetry-swatch-v { background: #ffd54f; }

.colorimetry-chart {
  margin-top: 0;
  min-height: 180px;
}

.colorimetry-line {
  fill: none;
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.colorimetry-note {
  margin: 6px 0 0;
  font-size: 0.8462rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.about-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.about-icon {
  flex-shrink: 0;
  border-radius: 8px;
}

.about-app-name {
  font-size: 1.2308rem;
  font-weight: 600;
}

.about-meta {
  margin-top: 2px;
  font-size: 0.9231rem;
  color: var(--text-muted);
}

.about-meta-sep {
  margin: 0 4px;
}

.about-text {
  margin: 0 0 8px;
  line-height: 1.45;
  color: var(--text);
}

.about-text:last-child {
  margin-bottom: 0;
}

.about-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.5;
}

.about-list li + li {
  margin-top: 4px;
}

.about-refs li {
  word-break: break-word;
}

.about-link {
  color: var(--accent);
  text-decoration: none;
}

.about-link:hover {
  text-decoration: underline;
}

.btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-dark);
  color: var(--text);
  font-size: 0.9231rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent);
}

.btn-danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm {
  padding: 3px 8px;
  font-size: 0.8462rem;
}

.btn-group {
  flex: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.btn-group .btn {
  flex: 1;
  min-width: 0;
}

.inspector-empty {
  padding: 16px;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9231rem;
}

.inspector-element-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  padding: 6px 4px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

.inspector-section {
  margin-bottom: 12px;
}

.inspector-section-title {
  font-size: 0.7692rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.inspector-section-title.collapsible {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.inspector-section-title.collapsible:hover {
  color: var(--text);
}

.inspector-section-title.collapsible::before {
  content: '';
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.inspector-section.collapsed .inspector-section-title.collapsible::before {
  transform: rotate(0deg);
}

.inspector-section.collapsed .inspector-section-title {
  margin-bottom: 0;
}

.inspector-section.collapsed .inspector-section-body {
  display: none;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.field-hint {
  margin: -2px 0 8px 98px;
  font-family: var(--font-mono);
  font-size: 0.7692rem;
  color: var(--text-muted);
}

.field-row label {
  flex: 0 0 90px;
  color: var(--text-muted);
  font-size: 0.8462rem;
}

.field-row input[type='number'],
.field-row input[type='text'],
.field-row select {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-size: 0.9231rem;
  font-family: var(--font-mono);
}

.field-row input[type='range'] {
  flex: 1;
  min-width: 0;
}

.field-input-compact {
  flex: 0 0 64px !important;
  width: 64px;
  padding: 4px 4px !important;
  text-align: left;
}

.field-row-xyz .xyz-inputs {
  flex: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
}

.field-row-xyz .xyz-inputs input {
  flex: 1;
  min-width: 0;
}

.field-row input[type='file'] {
  flex: 1;
  font-size: 0.8462rem;
  color: var(--text-muted);
}

.field-row input[type='checkbox'] {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

#intensity-scale-bar,
#plane-scale-bar,
#camera-scale-bar {
  margin-top: 4px;
}

.plane-preview {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-dark);
  image-rendering: pixelated;
}

.plane-preview.map-probe-active {
  cursor: crosshair;
}

.map-probe-readout {
  margin-top: 2px;
  min-height: 14px;
  font-family: var(--font-mono);
  font-size: 0.8462rem;
  color: var(--text-muted);
  text-align: center;
}

.field-value {
  flex: 0 0 48px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.8462rem;
  color: var(--text-muted);
}

.colormap-scale {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin: 4px 0 2px;
}

.colormap-track {
  flex: 1;
  min-width: 0;
  /* First label is always "0" — keep a tiny left inset so it can center. */
  padding-left: 0.35em;
  /* Room for half of the last numeric label (unit sits outside). */
  padding-right: 2.2em;
}

.colormap-bar {
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.colormap-ticks {
  display: flex;
  justify-content: space-between;
  height: 5px;
}

.colormap-ticks-above {
  margin-bottom: 1px;
}

.colormap-ticks-below {
  margin-top: 1px;
}

.colormap-tick {
  width: 1px;
  height: 100%;
  background: var(--text-muted);
  opacity: 0.7;
}

.colormap-tick-spacer {
  width: 1px;
  height: 100%;
  visibility: hidden;
}

.colormap-labels {
  position: relative;
  height: 1.15em;
  font-size: 0.6923rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.colormap-labels-above {
  margin-bottom: 2px;
}

.colormap-labels-below {
  margin-top: 2px;
}

.colormap-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}

.colormap-unit {
  flex: 0 0 auto;
  font-size: 0.6923rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 14px;
}

.spectrum-chart {
  width: 100%;
  margin-top: 4px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.spectrum-chart svg {
  display: block;
}

.spectrum-axis path,
.spectrum-axis line {
  stroke: var(--border);
}

.spectrum-axis text {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.6923rem;
}

.spectrum-axis-label {
  fill: var(--text);
  font-family: var(--font);
  font-size: 0.8462rem;
}

.spectrum-area {
  opacity: 0.75;
}

.spectrum-line {
  stroke: var(--text);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.spectrum-guide {
  stroke: var(--accent);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.spectrum-focus {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 1;
  pointer-events: none;
}

.spectrum-rgb {
  margin-top: 4px;
  min-height: 14px;
  font-family: var(--font-mono);
  font-size: 0.8462rem;
  color: var(--text);
  text-align: center;
}

.spectrum-readout {
  margin-top: 2px;
  min-height: 14px;
  font-family: var(--font-mono);
  font-size: 0.8462rem;
  color: var(--text-muted);
  text-align: center;
}

.warning-banner {
  background: #3e2723;
  border: 1px solid #bf360c;
  color: #ffcc80;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 0.8462rem;
  margin-bottom: 8px;
  white-space: pre-line;
}

.hierarchy-item-static {
  opacity: 0.6;
  cursor: default;
}

.hidden {
  display: none !important;
}

.field-value-wide {
  flex: 1;
  text-align: left;
}

.inspector-header-fields .field-row label {
  flex: 0 0 110px;
  word-break: break-word;
}

.inspector-header-fields .field-value-wide {
  word-break: break-word;
  white-space: pre-wrap;
}

.ray-data-table-wrap {
  overflow-x: auto;
  margin-top: 2px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-dark);
}

.ray-data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.7692rem;
  color: var(--text-muted);
}

.ray-data-table th,
.ray-data-table td {
  padding: 3px 6px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.ray-data-table th:first-child,
.ray-data-table td:first-child {
  text-align: left;
  color: var(--text);
}

.ray-data-table th {
  color: var(--text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
}

.ray-data-table tr:last-child td {
  border-bottom: none;
}

.ray-data-table tr.ray-data-ellipsis td {
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.15em;
}
