:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  --color-primary: #2d3870;
  --color-accent: #47c6ef;
  --color-text: #141414;
  --color-bg: #ffffff;
  --color-surface: #f2f3f2;
  --color-border: #dbe2e9;
  --color-highlight: #c4e0fd;
  --color-text-muted: color-mix(in srgb, var(--color-text) 55%, var(--color-bg));
  --color-text-subtle: color-mix(in srgb, var(--color-text) 70%, var(--color-bg));
  --color-button-bg: #c4e0fd;
  --color-button-hover: #2d3870;
  --color-button-hover-text: #ffffff;
  background: var(--color-bg);
  color: var(--color-text);
}

* {
  box-sizing: border-box;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
  border-color: var(--color-accent);
}

button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  background: inherit;
  color: inherit;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.tree-collapse-toggle {
  border: none;
  background: #f2f3f2;
  color: #8a8a8a;
  border-radius: 8px;
  padding: 0 0.7rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  width: 2.2rem;
  height: 2.2rem;
  align-self: center;
  flex-shrink: 0;
}

.tree-collapse-toggle:hover {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  background: var(--color-button-bg);
  color: var(--color-text);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  transition: all 0.15s ease;
  font-weight: 500;
}

.button:hover:not(:disabled) {
  background: var(--color-button-hover);
  color: var(--color-button-hover-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.button.button-primary {
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  font-weight: 400;
  border-radius: 8px;
  padding: 0 0.9rem;
  height: 2.2rem;
}

.button.button-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--color-primary) 85%, black);
  border-color: color-mix(in srgb, var(--color-primary) 85%, black);
  color: #ffffff;
}

.file-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  min-width: 0;
  width: 100%;
}

.file-actions .button {
  flex-shrink: 0;
}

.tree-view-header-top .file-actions {
  flex: 1;
  min-width: 0;
}

.file-switcher {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 0;
  margin: 0.6rem 0 0;
}

.file-switcher-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.file-switcher-buttons .tree-item {
  margin: 0;
}

.file-switcher-buttons .tree-row {
  width: 100%;
  gap: 0.35rem;
}

.file-switcher-buttons .tree-toggle {
  width: 1.6rem;
  height: 1.6rem;
}

.file-switcher-buttons .tree-label {
  justify-content: flex-start;
  width: auto;
  flex: 1;
  padding: 0.3rem 0.6rem;
  font-size: 0.9rem;
  border-radius: 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: normal;
}

.file-switcher-close {
  border: 1px solid var(--color-border);
  background: #f2f3f2;
  color: var(--color-text-subtle);
  cursor: pointer;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 300;
  line-height: 1;
  transition: all 0.15s ease;
}

.file-switcher-close:hover,
.file-switcher-close:focus-visible {
  background: #dbe2e9;
  color: var(--color-text);
  transform: scale(1.05);
}

.file-actions .file-error {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.file-input {
  display: none;
}

.main-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.main-layout.tree-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.main-layout.tree-collapsed .tree-view {
  display: none;
}

.tree-view,
.data-view {
  background: transparent;
  border: none;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.tree-view {
  padding: 0.1rem 0.4rem 0 0;
  border-right: 1px solid var(--color-border);
}

.data-view {
  grid-column: 2;
  padding: 0 0 0 0.5rem;
}

#dashboard-panels {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.data-view:not(.dashboard-active) #dashboard-panels {
  display: none;
}

.data-view.dashboard-active #dashboard-panels {
  flex: 1 1 auto;
  min-height: 0;
}

.main-layout.tree-collapsed .data-view {
  grid-column: 1 / -1;
  padding-left: 0;
}

.tree-view-header,
.data-view-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tree-view-header {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
}

.tree-view-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.data-view-header {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.data-view-controls-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-width: 0;
}

#plot-controls-slot {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.data-view-controls-row:has(#plot-controls-slot:not([hidden])) .viewer-tabs {
  border-right: 1px solid var(--color-border);
  padding-right: 0.5rem;
}

.data-view-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.tree-filter input {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0 0.6rem;
  font-size: 0.85rem;
  min-width: 0;
  width: 100%;
  height: 2.2rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.tree-filter {
  flex: 0 0 auto;
  width: 100%;
}

.tree-container {
  overflow: auto;
  flex: 1;
  overscroll-behavior: contain;
  min-height: 0;
}

.tree-footer {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  align-self: center;
}

.tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-item {
  margin: 0.15rem 0;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0;
}

.tree-toggle {
  width: 1.6rem;
  height: 1.6rem;
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 1.6rem;
}

.tree-toggle svg {
  width: 1.2rem;
  height: 1.2rem;
  stroke-width: 2.5;
}

/* Dataset labels (without toggle) need left margin for alignment */
.tree-row > .tree-label:first-child {
  margin-left: 1.6rem;
}

.tree-label {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  text-align: left;
  flex: 1;
  font-size: 0.9rem;
  min-width: 0;
  word-break: break-word;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.tree-label svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.tree-label.group svg {
  opacity: 0.7;
}

.tree-label.dataset {
  color: var(--color-text);
  font-weight: 400;
}

.tree-label.group {
  color: var(--color-text-subtle);
  font-weight: 400;
}


.tree-label:hover {
  background: #f2f3f2;
  border-color: var(--color-border);
}

.tree-item.selected > .tree-row > .tree-label {
  background: var(--color-highlight);
  border-color: var(--color-accent);
  border-left: 3px solid var(--color-accent);
  padding-left: calc(0.5rem - 2px);
  color: var(--color-text);
  font-weight: 600;
}

.tree-file-close {
  margin-left: 0.35rem;
}

.tree-children {
  list-style: none;
  padding-left: 1rem;
  margin: 0.2rem 0 0;
}

.tree-empty {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  padding-left: 1.8rem;
}

.tree-label.tree-match {
  background: #fffbcc;
  border-color: #f4c430;
}

.tree-label.tree-match:hover {
  background: #fff5b3;
  border-color: #f4c430;
}

:root {
  --tab-font-size: 0.85rem;
  --tab-padding-y: 0.45rem;
  --tab-height: calc(var(--tab-font-size) + (var(--tab-padding-y) * 2));
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.dashboard-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  position: relative;
}

.tab-button {
  border: none;
  background: #f2f3f2;
  padding: 0 0.9rem;
  font-size: var(--tab-font-size);
  cursor: pointer;
  color: #8a8a8a;
  border-radius: 8px;
  transition: all 0.15s ease;
  height: 2.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab-button:hover:not(:disabled) {
  background: #c4e0fd;
  color: var(--color-text);
}

.dashboard-tab-button {
  padding-right: 3.1rem;
  display: inline-flex;
  align-items: center;
  max-width: 14rem;
}

.dashboard-tab-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-tab-text {
  font-size: var(--tab-font-size);
  font-weight: inherit;
}

.dashboard-tab-input {
  position: absolute;
  inset: 0.25rem 2.2rem 0.25rem 0.35rem;
  width: auto;
  border-radius: 8px 8px 0 0;
  border: 1px solid var(--color-border);
  padding: 0 0.6rem;
  font-size: 0.85rem;
  display: none;
  background: var(--color-bg);
  color: var(--color-text);
}

.dashboard-tab.is-editing .dashboard-tab-label {
  visibility: hidden;
}

.dashboard-tab.is-editing .dashboard-tab-input {
  display: block;
}

.dashboard-tab-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin-bottom: -1px;
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
}

.dashboard-tab-action {
  border: none;
  background: transparent;
  color: var(--color-text);
  border-radius: 6px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  transition: all 0.15s ease;
  opacity: 0.6;
}

.dashboard-tab-action svg {
  width: 0.8rem;
  height: 0.8rem;
}

.dashboard-tab-action:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
  transform: scale(1.1);
}

.dashboard-tab-action--danger:hover {
  color: var(--color-button-hover-text);
}

.tab-button[aria-selected="true"] {
  color: var(--color-text);
  background: var(--color-button-bg);
  font-weight: 600;
}

.viewer-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.viewer-tab-button {
  border: none;
  border-radius: 8px;
  background: #f2f3f2;
  color: #8a8a8a;
  padding: 0;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viewer-tab-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.viewer-tab-button:hover:not(:disabled) {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.viewer-tab-button[aria-selected="true"] {
  background: #c4e0fd;
  color: var(--color-text);
  font-weight: 600;
}

.tab-add-button {
  border: 1px dashed var(--color-border);
  background: #f2f3f2;
  padding: var(--tab-padding-y) 0.9rem;
  font-size: var(--tab-font-size);
  cursor: pointer;
  color: var(--color-text);
  border-radius: 10px 10px 0 0;
  margin-bottom: -1px;
}

.tab-add-button:hover {
  border-color: var(--color-button-hover);
  color: var(--color-text);
  background: #dbe2e9;
}

.data-view.dashboard-active .data-view-controls-row,
.data-view.dashboard-active .data-meta,
.data-view.dashboard-active .slice-controls {
  display: none;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin-top: 0;
  overflow: hidden;
  scroll-behavior: auto;
  min-height: 0;
}

.view-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.view-panel[hidden] {
  display: none;
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.dashboard-content {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.dashboard-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  justify-content: space-between;
}

/* Grid layout toggle (tab-style design) */
.dashboard-grid-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.2rem;
  background: var(--color-surface);
  flex-shrink: 0;
}

.dashboard-grid-toggle-button {
  border: none;
  background: transparent;
  padding: 0.35rem 0.7rem;
  min-width: 2rem;
  font-size: 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #8a8a8a;
  justify-content: center;
}

.dashboard-grid-toggle-button:hover {
  background: #c4e0fd;
  color: var(--color-text);
}

.dashboard-grid-toggle-button.active,
.dashboard-grid-toggle-button[aria-selected="true"] {
  background: var(--color-button-bg);
  color: var(--color-text);
  font-weight: 600;
}

.dashboard-compact-toggle.is-active {
  background: #dbe2e9;
  font-weight: 600;
}

.dashboard-file-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border-radius: 0;
  background: transparent;
  font-size: inherit;
  color: var(--color-text);
  max-width: 100%;
}

.dashboard-file-meta-label {
  color: var(--color-text-subtle);
}

.dashboard-file-meta-value {
  font-weight: 400;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-file-warning {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-highlight);
  color: var(--color-text);
  font-size: 0.85rem;
}

.dashboard-file-warning-text {
  flex: 1 1 240px;
}

.button.button-secondary {
  background: #f2f3f2;
  color: #8a8a8a;
  border: none;
  font-weight: 400;
  border-radius: 8px;
}

.button.button-secondary.dashboard-tab-action {
  background: #f2f3f2;
  color: var(--color-text);
}

.button.button-secondary:hover {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button.button-secondary.dashboard-tab-action:hover {
  background: #dbe2e9;
  color: var(--color-button-hover-text);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-content: start;
  align-items: start;
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-bottom: 0.5rem;
}

.dashboard-grid.is-compact {
  gap: 0;
}

.dashboard-grid[data-columns="1"] {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.dashboard-grid[data-columns="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-grid[data-columns="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-customize-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-text) 20%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.dashboard-customize-overlay.is-open {
  opacity: 1;
}

.dashboard-customize-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 90%);
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 30px color-mix(in srgb, var(--color-text) 12%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 0 0.5rem;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 3;
}

.dashboard-customize-panel.is-open {
  transform: translateX(0);
}

.dashboard-plot {
  background: var(--color-surface);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}

.dashboard-plot.is-disabled {
  opacity: 0.6;
}

.dashboard-plot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: var(--tab-height);
  padding: var(--tab-padding-y) 0.9rem;
}

.dashboard-grid.is-compact .dashboard-plot-header {
  display: none;
}

.dashboard-plot-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  order: 3;
}

.dashboard-plot-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.0;
}

.dashboard-add-dataset {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
}

.dashboard-add-dataset-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--color-text-subtle);
}

.dashboard-add-dataset-input {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.dashboard-add-dataset-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.dashboard-selectors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.5rem;
}

.dashboard-selector {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.dashboard-selector-label {
  color: var(--color-text-subtle);
}

.dashboard-selector-input {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.dashboard-slice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.dashboard-axis-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.dashboard-axis-select,
.dashboard-axis-input {
  border-radius: 8px;
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.5rem;
}

.dashboard-status,
.dashboard-error {
  margin: 0;
  font-size: 0.8rem;
}

.dashboard-error {
  color: #b00020;
}

.dashboard-plot-header .dashboard-error {
  flex: 0 1 auto;
  margin-right: 0.5rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-plot-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  background: var(--color-bg);
  border-top-left-radius: 0px;
  border-top-right-radius: 0px;
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 12px;
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.dashboard-grid.is-compact .dashboard-plot-area {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.dashboard-plot-area.has-aspect-ratio {
  flex: 0 0 auto;
  min-height: 0;
}

.dashboard-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
}

.dashboard-plot-canvas {
  width: 100%;
  height: 100%;
}

.panel-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#raw-panel.panel-content {
  overflow: hidden;
}

#plot-panel.panel-content {
  overflow: hidden;
}

.section-block {
  padding-top: 0;
}

.section-block + .section-block {
  border-top: 1px solid var(--color-border);
}

.section-block + .section-block.section-block--no-divider {
  border-top: none;
}

.section-block h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--color-text);
}

.section-block p {
  margin: 0;
}

.section-block--compact p {
  margin: 0.15rem 0;
}

.meta-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.meta-row--stack {
  flex-direction: column;
  align-items: flex-start;
}

.meta-list {
  margin: 0.15rem 0 0;
  padding-left: 1.1rem;
}

.meta-list--scroll {
  max-height: 45vh;
  overflow: auto;
}

.meta-list--objects {
  margin-top: 0.05rem;
  margin-bottom: 0.45rem;
}

.data-meta {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin: 0;
  padding-top: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow-x: auto;
}

.slice-controls {
  margin: 0.35rem 0 0;
  padding-bottom: 5px;
}

.meta-value {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

#tree-status {
  padding: 0.25rem 0 0 0;
  margin: 0;
  font-size: 0.85rem;
}

.empty-state {
  font-style: italic;
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  border-radius: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spinner-rotate 0.9s linear infinite;
}

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

.preview-table-wrapper {
  width: 100%;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg);
}

.preview-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.preview-section .preview-table-wrapper {
  flex: 1 1 auto;
}

.preview-table {
  --preview-index-width: 4.5rem;
  --preview-row-height: 2.1rem;
  width: max-content;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 0.85rem;
  table-layout: auto;
}

.preview-table th,
.preview-table td {
  border: 1px solid var(--color-border);
  padding: 0.3rem 0.5rem;
  text-align: right;
  white-space: nowrap;
  height: var(--preview-row-height);
  line-height: 1.2;
  box-sizing: border-box;
}

.preview-table thead th:first-child,
.preview-table tbody th {
  width: var(--preview-index-width);
  min-width: var(--preview-index-width);
  max-width: var(--preview-index-width);
}

.preview-table thead th {
  text-align: center;
  background: #f2f3f2;
}

.preview-table tbody th {
  text-align: right;
  background: #f2f3f2;
}

.preview-table th {
  font-weight: 600;
  color: var(--color-text);
}

.preview-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.preview-controls label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  gap: 0.25rem;
}

.preview-controls input {
  width: 90px;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.preview-controls button {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-button-bg);
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  font-weight: 500;
}

.preview-controls button:hover:not(:disabled) {
  background: var(--color-button-hover);
  color: var(--color-button-hover-text);
  transform: translateY(-1px);
}

/* Compact style for preview controls in table corner */
.preview-table thead th:first-child {
  text-align: center;
}

.preview-table thead th .preview-controls {
  gap: 0.35rem;
  align-items: center;
  justify-content: center;
}

.preview-table thead th .preview-controls label {
  flex-direction: row;
  font-size: 0.7rem;
  gap: 0.25rem;
  white-space: nowrap;
}

.preview-table thead th .preview-controls input {
  width: 60px;
  padding: 0.2rem 0.3rem;
  font-size: 0.75rem;
  text-align: center;
}

.error {
  background: var(--color-highlight);
  color: var(--color-primary);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-accent);
}

.plotly-panel {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-height: 0;
  position: relative;
}

.plot-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0;
  flex: 1;
  min-width: 0;
}

.plot-customize-entry {
  display: flex;
  align-items: flex-end;
  margin-left: auto;
}

.plot-customize-button {
  border: none;
  border-radius: 8px;
  background: #f2f3f2;
  color: #8a8a8a;
  padding: 0;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plot-customize-button:hover {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plot-dashboard-entry {
  display: flex;
  align-items: flex-end;
}

.plot-add-dashboard-button {
  border: none;
  border-radius: 8px;
  background: #f2f3f2;
  color: #8a8a8a;
  padding: 0;
  width: 2.2rem;
  height: 2.2rem;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 400;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plot-add-dashboard-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.plot-add-dashboard-button:hover:not(:disabled) {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plot-selector {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
}

.plot-selector-label {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
  font-size: 1rem;
  color: var(--color-text-subtle);
  line-height: 1;
}

.plot-selector-prefix {
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  margin-right: 0.3rem;
}

.plot-selector-search,
.plot-selector-select {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
  width: 180px;
  height: 2.2rem;
  line-height: 1.4;
  direction: rtl;
  text-align: left;
}

/* Tabbed selector container */
.plot-tabbed-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 0 1 auto;
  min-width: 0;
}

/* Tab buttons container */
.plot-selector-tabs {
  display: flex;
  gap: 0.25rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.2rem;
  background: var(--color-surface);
  flex-shrink: 0;
}

/* Individual tab button */
.plot-selector-tab {
  border: none;
  background: transparent;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-subtle);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.plot-selector-tab svg {
  width: 1rem;
  height: 1rem;
}

.plot-selector-tab:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.plot-selector-tab.active,
.plot-selector-tab[aria-selected="true"] {
  background: var(--color-button-bg);
  color: var(--color-text);
  font-weight: 600;
}

/* Hide tabs when not needed */
.plot-selector-tab[hidden] {
  display: none;
}

/* Shared input wrapper */
.plot-selector-input-wrapper {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
}

/* Shared input field - reuse existing .plot-selector-search styles but override width and direction */
.plot-tabbed-selector .plot-selector-search {
  width: 300px;
  min-width: 180px;
  max-width: 300px;
  direction: ltr;
  text-align: left;
}

.plot-status {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.plot-status:empty {
  display: none;
}

/* Hide status when all children have hidden attribute */
.plot-status:not(:has(> :not([hidden]))) {
  display: none;
}

.plot-slice-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
}

.plot-slice-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.plot-slice-controls input[type="range"] {
  flex: 1 1 auto;
  min-width: 120px;
  height: 0.6rem;
  accent-color: var(--color-primary);
}

.plot-slice-input {
  width: 60px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.7rem;
  line-height: 1;
  background: var(--color-bg);
  color: var(--color-text);
}

.plot-note {
  margin: 0;
}

.plot-error {
  margin: 0;
  background: var(--color-highlight);
  color: var(--color-primary);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--color-accent);
}

.plot-area {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  display: grid;
  place-items: start;
  padding: 0;
  overflow: hidden;
  touch-action: pan-y;
}

.plot-area.has-aspect-ratio {
  flex: 1 1 auto;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  align-self: start;
}

.plot-area > * {
  grid-area: 1 / 1;
}

.plotly-canvas {
  width: 100%;
  height: 100%;
}

.plot-placeholder {
  margin: 0;
  padding: 0 1rem;
  text-align: center;
}

.plot-customize-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-text) 20%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.plot-customize-overlay.is-open {
  opacity: 1;
}

.plot-customize-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 90%);
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: -10px 0 30px color-mix(in srgb, var(--color-text) 12%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 0 0.5rem;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 3;
}

.plot-customize-panel.is-open {
  transform: translateX(0);
}

.plot-dashboard-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-text) 25%, transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}

.plot-dashboard-overlay.is-open {
  opacity: 1;
}

.plot-dashboard-panel {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -30px);
  width: min(520px, 92%);
  max-height: 80%;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 20px 40px color-mix(in srgb, var(--color-text) 18%, transparent);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 3;
}

.plot-dashboard-panel.is-open {
  opacity: 1;
  transform: translate(-50%, 0);
}

.plot-dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.plot-dashboard-header h3 {
  margin: 0;
  font-size: 1rem;
}

.plot-dashboard-close {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--color-bg);
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--color-text);
}

.plot-dashboard-close:hover {
  background: var(--color-surface);
}

.plot-dashboard-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.plot-dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 0.25rem;
}

.plot-dashboard-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0;
  border-radius: 12px;
  border: none;
  background: transparent;
}

.plot-dashboard-row.is-disabled {
  opacity: 0.6;
}

.plot-dashboard-name {
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.plot-dashboard-name:not(.button):hover:not(:disabled) {
  text-decoration: underline;
}

.plot-dashboard-name:not(.button):disabled {
  cursor: not-allowed;
  text-decoration: none;
}

.plot-dashboard-footer {
  display: flex;
  justify-content: flex-end;
}

.plot-customize-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.plot-customize-header h3 {
  margin: 0;
  font-size: 1rem;
}

.plot-customize-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: flex-end;
  margin-left: auto;
  flex-shrink: 0;
}

.plot-customize-reset,
.plot-customize-close {
  border: none;
  border-radius: 8px;
  padding: 0;
  width: 2.2rem;
  height: 2.2rem;
  background: #f2f3f2;
  color: #8a8a8a;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


.plot-customize-reset:hover,
.plot-customize-close:hover {
  background: #c4e0fd;
  color: var(--color-text);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.plot-customize-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.plot-customize-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.plot-customize-section + .plot-customize-section {
  padding-top: 1rem;
  margin-top: 1rem;
}

.plot-customize-title {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text);
}

.plot-customize-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.plot-customize-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.plot-customize-field input,
.plot-customize-field select,
.plot-customize-json {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.plot-customize-field input:disabled,
.plot-customize-field select:disabled {
  background: var(--color-surface);
  color: var(--color-text-muted);
}

.plot-customize-checkbox {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--color-text);
}

.plot-customize-hint {
  margin: 0;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.plot-customize-advanced summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--color-text);
}

.plot-customize-json {
  width: 100%;
  min-height: 220px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  resize: vertical;
}

.plot-customize-json-error {
  margin: 0;
  color: var(--color-primary);
  font-size: 0.75rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
