.segmented-control {
  display: flex;
  flex-wrap: wrap;
  margin-top: 5px;
  background: var(--chrome-1);
  padding: var(--sp-1);
  border-radius: var(--radius-md);
  gap: var(--sp-1);
  margin-bottom: var(--sp-3-5);
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.SettingsHeader{
font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  text-align: center;
}
.segmented-control button {
  border: none;
  background: none;
  color: var(--fg-75);
  padding: var(--sp-2) var(--sp-3-5);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  cursor: pointer;
  font-weight: var(--fw-medium);
  min-width: 0;
  flex: 1 1 0;
  white-space: nowrap;
}

.segmented-control button.active {
  background: var(--accent-color);
  color: var(--fg-1);
  font-weight: var(--fw-medium);
}

.segmented-control button:hover {
  background: var(--border-color);
}

.theme-switch {
  position: absolute;
  top: 10px;
  /* Anchored to the panel's right edge, not a pixel offset measured off the
     logo. `left: 286px` plus a fourth mode button ran past --ui-width and put
     a horizontal scrollbar on #ui. */
  right: 10px;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 10;
  border: solid 1px var(--panel-border, var(--line-2));
  border-radius: 40px;
}

/* auto/light/dark mode row */
.theme-btn {
  display: inline-flex;
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: 40px;
}

.theme-btn:hover:not([disabled]) {
  background: var(--hover-color);
}

.theme-btn.active {
  background: var(--highlight-color);
}

/* Which way Auto went. Selecting Auto leaves the concrete mode invisible
   otherwise, so the resolved one gets a wash — dimmer than .active, which
   stays on Auto itself. */
.theme-btn.resolved:not(.active) {
  background: var(--wash-2);
}

/* A palette that doesn't offer this mode. Dimmed rather than hidden so the
   row doesn't reflow when you switch palettes. */
.theme-btn[disabled] {
  opacity: 0.35;
  cursor: default;
}

/* Auto is a glyph, not an <img>, so it needs its own box to match the 18px
   icon plus the button's padding. */
.theme-btn-auto {
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: var(--panel-fg, var(--fg-1));
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
}

.theme-icon {
  width: 18px;
  height: 18px;
  filter: var(--icon-filter);
}

/* Small dropdown arrow that opens the full theme list (ui/ThemeManager.js) */
.theme-menu-toggle {
  background: none;
  border: none;
  border-left: 1px solid var(--panel-border, var(--line-2));
  color: var(--panel-fg, var(--fg-1));
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
  line-height: var(--lh-tight);
  cursor: pointer;
  border-radius: 0 40px 40px 0;
}

.theme-menu-toggle:hover {
  background: var(--hover-color);
}

.theme-menu {
  position: absolute;
  top: calc(100% + var(--sp-1));
  right: 0;
  margin: 0;
  padding: var(--sp-1);
  list-style: none;
  min-width: 130px;
  background: var(--menu-bg);
  border: 1px solid var(--panel-border, var(--line-2));
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgb(var(--shadow-rgb) / 0.35);
  z-index: var(--z-overlay-widget);
}

.theme-menu[hidden] {
  display: none;
}

.theme-menu-item {
  padding: var(--sp-2) var(--sp-3-5);
  border-radius: var(--radius-sm);
  color: var(--panel-fg, var(--fg-1));
  cursor: pointer;
  font-size: var(--fs-base);
}

.theme-menu-item:hover {
  background: var(--hover-color);
}

.theme-menu-item.active {
  background: var(--highlight-color);
}

/* ===========================================================================
   Planes panel styling — restored from the newmain branch. The retrofit ported
   ui/PlanesPanel.js but not its CSS, so the Planes box rendered unstyled. These
   .planes-* / #hklInputs / .plane-delete-btn rules follow the rest of the UI
   (accent via --accent-color / --highlight-color).
   =========================================================================== */
/* ── Planes Panel ─────────────────────────────────────── */
.planes-input-section {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  width: 100%;
  margin-bottom: var(--sp-4);
}

.planes-input-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-3-5);
}

.planes-radio-label {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  width: 100%;
}

.planes-radio-label input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent-color);
}

.planes-row-inputs {
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: stretch;
  gap: var(--sp-3);
}

/* uvwd layout: uvw cluster + d cluster separated */
.planes-uvwd-layout {
  grid-template-columns: none;
}

/* Cartesian x/y/z: single horizontal row of compact fields, same treatment
   as the Miller row below. The d value/slider/bounds stay their own
   vertically-stacked rows via .planes-d-cluster's display:contents. */
.planes-uvw-cluster {
  display: flex;
  flex-direction: row;
  gap: var(--sp-3-5);
}

.planes-uvw-cluster .planes-labeled-input {
  flex: 1;
  gap: var(--sp-2);
}

.planes-uvw-cluster .planes-num-input {
  padding: var(--sp-2) var(--sp-1);
}

.planes-d-cluster {
  display: contents;
}

/* Miller indices: single horizontal row of compact fields */
#hklInputs {
  flex-direction: row;
  gap: var(--sp-3-5);
}

#hklInputs .planes-labeled-input {
  flex: 1;
  gap: var(--sp-2);
}

#hklInputs .planes-num-input {
  padding: var(--sp-2) var(--sp-1);
}

.planes-labeled-input {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--sp-3-5);
  min-width: 0;
}

.planes-input-label {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  text-transform: lowercase;
  letter-spacing: 0.03em;
  text-align: left;
  min-width: 14px;
}

.planes-num-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: var(--control-h);
  padding: var(--sp-2) var(--sp-3);
  background: var(--wash-1-5);
  border: 1px solid var(--wash-4);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-size: var(--fs-md);
  text-align: center;
  box-sizing: border-box;
  -moz-appearance: textfield;
  appearance: textfield;
}

.planes-num-input::-webkit-inner-spin-button,
.planes-num-input::-webkit-outer-spin-button {
  opacity: 0.4;
}

/* Fractional-coordinate boxes in the per-atom Position editor: the slider is
   the coarse control, so the number box is text-only. Recent Chrome ignores
   appearance:textfield for hiding the spinner, so strip it here. */
.coord-num-input::-webkit-inner-spin-button,
.coord-num-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

/* Position editor axis sliders are a compact, secondary control — thinner
   track and smaller thumb than the app's default range input, so the three
   stacked axis rows stay tight. */
.coord-axis-slider {
  height: 4px;
}
.coord-axis-slider::-webkit-slider-thumb {
  width: 9px;
  height: 9px;
}
.coord-axis-slider::-moz-range-thumb {
  width: 9px;
  height: 9px;
}

.planes-num-input:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.planes-num-input:focus:not(:disabled) {
  outline: none;
  border-color: var(--accent-color);
  background: var(--wash-3);
}

/* d slider: real-time single-handle slider below the d text box, with
   user-adjustable endpoint inputs underneath. */
.planes-d-slider-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: var(--sp-1) 0;
}

.planes-d-slider {
  width: 100%;
  flex: 1;
  margin: 0;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--track-bg);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.planes-d-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
  border-radius: 999px;
}

.planes-d-slider::-moz-range-track {
  height: 4px;
  background: transparent;
  border: none;
  border-radius: 999px;
}

.planes-d-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--chrome-tint-2);
  box-shadow: 0 0 0 1px var(--line-2);
  transition: background 0.15s;
}

.planes-d-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid var(--chrome-tint-2);
  box-shadow: 0 0 0 1px var(--line-2);
  transition: background 0.15s;
}

.planes-d-slider:hover:not(:disabled)::-webkit-slider-thumb {
  background: var(--highlight-color);
}

.planes-d-slider:hover:not(:disabled)::-moz-range-thumb {
  background: var(--highlight-color);
}

.planes-d-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.planes-d-slider-bounds {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  width: 100%;
}

.planes-d-bound-input {
  flex: 0 0 56px;
  width: 56px;
  min-height: 26px;
  padding: 3px var(--sp-1);
  font-size: var(--fs-sm);
}

.planes-viz-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3-5);
  margin-bottom: var(--sp-3-5);
}

.planes-viz-label {
  font-size: var(--fs-base);
  color: var(--fg-75);
  white-space: nowrap;
}

.planes-select,
.planes-select-sm {
  background: var(--wash-1-5);
  border: 1px solid var(--wash-4);
  border-radius: var(--radius-sm);
  color: var(--fg-1);
  font-size: var(--fs-base);
  padding: var(--sp-1) var(--sp-3);
  cursor: pointer;
}

.planes-select-sm {
  padding: 3px var(--sp-2);
  font-size: var(--fs-sm);
}

.planes-buttons-row {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}

/* The panel's action buttons are regular .file-action-btn buttons (like the
   panel's own Auto Range button); only sizing lives here. They used to be a
   one-off accent-filled recipe whose hover swapped the fill to
   --highlight-color under --fg-1 text — on the light palettes both are dark,
   so the label vanished on hover. */

/* Table */
.planes-table-wrapper {
  overflow-x: auto;
}

.planes-empty-msg {
  color: var(--fg-3);
  font-size: var(--fs-base);
  text-align: center;
  margin: var(--sp-2) 0 0;
}

.planes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}

.planes-th {
  padding: 5px var(--sp-3);
  text-align: left;
  color: var(--fg-50);
  font-weight: var(--fw-medium);
  border-bottom: 1px solid var(--line-1);
}

.planes-td {
  padding: 5px var(--sp-3);
  border-bottom: 1px solid var(--wash-1-5);
  vertical-align: middle;
}

.planes-params-cell {
  font-family: var(--font-mono);
  color: var(--fg-85);
}

.plane-delete-btn {
  background: none;
  border: none;
  color: rgb(var(--danger-bright-rgb) / 0.75);
  font-size: var(--fs-xl);
  cursor: pointer;
  padding: 0 var(--sp-1);
  line-height: var(--lh-tight);
}

.plane-delete-btn:hover {
  color: var(--danger-bright);
}

/* New Planes Panel Layout Styles */
.planes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-3);
}

.planes-header h3 {
  margin: 0;
  flex: 1;
}

.planes-top-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 90px;
  padding: 5px var(--sp-4);
  font-size: var(--fs-sm);
}

/* Table container with visible border */
.planes-table-wrapper {
  border: 1px solid var(--wash-3);
  border-radius: var(--radius-sm);
  overflow: auto;
  margin-bottom: var(--sp-3);
  background: rgb(var(--shadow-rgb) / 0.15);
  max-height: 240px;
}

.planes-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  table-layout: auto;
}

.planes-th {
  padding: 5px var(--sp-2);
  text-align: left;
  color: var(--fg-3);
  font-weight: var(--fw-medium);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--wash-3);
  background: var(--wash-0);
  white-space: nowrap;
}

.planes-th-narrow {
  width: 24px;
  padding: 5px 3px;
  text-align: center;
}

.planes-td {
  padding: 5px var(--sp-2);
  border-bottom: 1px solid var(--wash-1);
  vertical-align: middle;
}

.planes-table tbody tr:last-child .planes-td {
  border-bottom: none;
}

/* Column-specific td styles */
.planes-td-cb {
  width: 24px;
  text-align: center;
  padding: 5px 3px;
}

.planes-td-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-85);
  white-space: nowrap;
}

.planes-td-vector {
  min-width: 54px;
}

.planes-td-field {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  max-width: 90px;
  overflow: hidden;
  white-space: nowrap;
}

.planes-td-cut {
  font-size: var(--fs-sm);
  color: var(--fg-2);
  white-space: nowrap;
}

.planes-td-del {
  width: 24px;
  text-align: center;
  padding: 5px 3px;
}

.planes-td-del-sticky,
.planes-th-del-sticky {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--chrome-tint-1);
  box-shadow: -1px 0 0 var(--wash-2);
}

.planes-th-del-sticky {
  z-index: 3;
}

.planes-vector {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: stretch;
  column-gap: 2px;
}

.planes-vector-tight {
  min-width: 38px;
}

.planes-vector-bracket {
  display: flex;
  align-items: center;
  font-size: 3em;
  line-height: var(--lh-tight);
  color: var(--fg-85);
}

.planes-vector-values {
  display: grid;
  grid-auto-rows: minmax(0, auto);
  justify-items: center;
  row-gap: 1px;
  line-height: 1.05;
}

.planes-uvwd-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.planes-d-inline {
  font-size: var(--fs-xs);
  line-height: var(--lh-tight);
  color: var(--fg-2);
  white-space: nowrap;
}

/* Row interaction */
.planes-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.planes-table tbody tr:hover {
  background: var(--wash-1);
}

.planes-row-selected {
  background: var(--row-selected-bg) !important;
}

.planes-row-selected .planes-td-mono {
  color: var(--fg-1);
}

.planes-row-selected .planes-td-del-sticky {
  background: var(--chrome-tint-3);
}

/* Centered row of atom-derived plane buttons (create / calculate), kept on one
   line: the pair reads as a matched set, so they share the row width evenly
   instead of wrapping when the panel is narrow. */
.planes-center-row {
  display: flex;
  justify-content: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3-5);
}

/* Both labels are broken onto two lines (an explicit <br> before "selection")
   so the pair stays on one row at panel width — file-action-btn's own
   white-space: nowrap would otherwise push the longer label past its border. */
.planes-calc-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: var(--sp-2) var(--sp-2);
  font-size: var(--fs-sm);
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.planes-calc-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* file-action-btn's hover glow has no :disabled guard because its other
   users never disable. */
.planes-calc-btn:disabled:hover {
  box-shadow: none;
}

/* Parameter / field sections */
.planes-section-title {
  margin: 0 0 var(--sp-3) 0;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.planes-params-section {
  margin-top: var(--sp-3-5);
  padding-top: var(--sp-3-5);
  border-top: 1px solid var(--line-1);
}

.planes-field-section {
  margin-top: var(--sp-3-5);
  padding-top: var(--sp-3-5);
  border-top: 1px solid var(--line-1);
}

/* Grouped field + colormap card */
.planes-field-colormap-container {
  background: var(--wash-0);
  border: 1px solid var(--wash-2);
  border-radius: var(--radius-sm);
  padding: var(--sp-3-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3-5);
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.planes-field-colormap-disabled {
  opacity: 0.55;
  background: var(--wash-0);
  border-color: var(--wash-1);
}

.planes-field-colormap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3-5);
}

.planes-field-control {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

.planes-field-control label {
  font-size: var(--fs-sm);
  color: var(--fg-2);
}

.planes-field-colormap-disabled .planes-field-control label,
.planes-field-colormap-disabled #planesRangeDisplay {
  color: var(--fg-3);
}

.planes-field-range-control {
  gap: var(--sp-2);
}

.planes-field-resolution-control {
  flex-direction: row;
  align-items: center;
  gap: var(--sp-3-5);
}

.planes-field-resolution-control label {
  flex: 0 0 auto;
  margin: 0;
}

.planes-field-resolution-control input {
  flex: 1 1 auto;
  min-width: 0;
}

.planes-full-width {
  width: 100%;
  box-sizing: border-box;
}

/* Cut mode sub-section — separated from the plane parameter inputs above by
   the same rule the Plane Parameters / Field sections are separated by, since
   it was reading as just another parameter row. */
.planes-cut-section {
  margin-top: var(--sp-3-5);
  padding-top: var(--sp-3-5);
  border-top: 1px solid var(--line-1);
}

.planes-cut-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3-5);
}

.planes-cut-label {
  font-size: var(--fs-base);
  color: var(--fg-75);
  white-space: nowrap;
  flex-shrink: 0;
}

.planes-range-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-2);
}

.planes-dual-slider {
  position: relative;
  height: 18px;
}

.planes-dual-slider-track,
.planes-dual-slider-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  border-radius: 999px;
  transform: translateY(-50%);
}

.planes-dual-slider-track {
  left: 0;
  right: 0;
  background: var(--track-bg);
}

.planes-field-colormap-disabled .planes-dual-slider-track {
  background: var(--wash-1-5);
}

.planes-dual-slider-fill {
  background: var(--accent-color);
}

.planes-field-colormap-disabled .planes-dual-slider-fill {
  background: var(--wash-4);
}

.planes-slider {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  flex: 1;
  margin: 0;
  height: 4px;
  transform: translateY(-50%);
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  outline: none;
  pointer-events: none;
}

.planes-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.planes-slider::-moz-range-track {
  height: 4px;
  background: transparent;
  border: none;
}

.planes-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  border: 2px solid var(--chrome-tint-2);
  box-shadow: 0 0 0 1px var(--line-2);
  transition: background 0.15s;
}

.planes-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent-color);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  border: 2px solid var(--chrome-tint-2);
  box-shadow: 0 0 0 1px var(--line-2);
  transition: background 0.15s;
}

.planes-slider::-webkit-slider-thumb:hover {
  background: var(--highlight-color);
}

.planes-slider::-moz-range-thumb:hover {
  background: var(--highlight-color);
}

.planes-slider:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.planes-select:disabled {
  opacity: 0.55;
  color: var(--fg-3);
  background: var(--wash-0);
  border-color: var(--wash-2);
  cursor: not-allowed;
}

.planes-slider-min {
  z-index: 2;
}

.planes-slider-max {
  z-index: 3;
}

#planesRangeDisplay {
  color: var(--fg-2);
  font-size: var(--fs-sm);
  white-space: nowrap;
  text-align: center;
}

/* The narrow-viewport override for .planes-field-colormap-grid (folded
   into the mobile/720px rung) now lives in styles/responsive.css, per
   Wave 4's single-file @media rule. */

.planes-table tbody tr .planes-params-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
