*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --overlay-accent: #42ca76;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050507;
  color: #e6eef7;
}

body {
  display: flex;
  flex-direction: column;
}

.header {
  padding: 0 2rem;
  border-bottom: 1px solid #222633;
  background: radial-gradient(circle at top, #151c2b, #050507);
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  column-gap: 1.5rem;
}

.header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.equation {
  font-size: 1.1rem;
}

.header-tagline {
  font-size: 0.9rem;
  line-height: 1.4;
  min-width: 400px;
  max-width: 42rem;
  color: #a5b4cf;
  text-align: right;
  justify-self: end;
  margin-left: auto;
  display: block;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 4px 10px 5px 0;
  border-bottom: 1px solid #222633;
  background: #05070c;
  font-size: 0.9rem;
}

.top-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e2537;
  border: 1px solid #3a4260;
  color: #e6eef7;
  border-radius: 999px;
  height: 2.1rem;
  padding: 0 0.9rem;
  min-width: 2.4rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.top-control.upload-setting .top-button {
  height: 1.6rem;
  padding: 0 0.7rem;
  font-size: 0.8rem;
}

.top-button:hover {
  background: #283149;
}

.top-button[disabled] {
  opacity: 0.35;
  cursor: default;
}

.top-button[disabled]:hover {
  background: #1e2537;
}

.record-button {
  gap: 0.35rem;
  border-color: #555b70;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.record-label {
  opacity: 0.9;
}

.record-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: #ff4b4b;
}

.record-dot-blinking {
  animation: record-dot-blink 1.6s ease-in-out infinite;
}

@keyframes record-dot-blink {
  0% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.25;
  }
}

.record-button.recording {
  border-color: #ff4b4b;
  box-shadow: 0 0 0 1px rgba(255, 75, 75, 0.7);
  background:
    linear-gradient(135deg, rgba(255, 75, 75, 0.24), rgba(255, 122, 122, 0.16)),
    #1e2537;
}

.pip-icon,
.fullscreen-icon {
  width: 1.3rem;
  height: 1.3rem;
  display: block;
}

.pip-button-active {
  border-color: var(--overlay-accent);
  box-shadow: 0 0 0 1px rgba(66, 202, 118, 0.7);
  background:
    linear-gradient(135deg, rgba(66, 202, 118, 0.22), rgba(66, 202, 118, 0.16)),
    #1e2537;
}

.fullscreen-button-active {
  border-color: var(--overlay-accent);
  box-shadow: 0 0 0 1px rgba(66, 202, 118, 0.7);
  background:
    linear-gradient(135deg, rgba(66, 202, 118, 0.22), rgba(66, 202, 118, 0.16)),
    #1e2537;
}

.stop-icon {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 2px;
  background: #e6eef7;
}

.stop-button:hover .stop-icon {
  background: #ffffff;
}

.top-separator,
.top-separator-left {
  width: 1px;
  align-self: stretch;
  background: #222633;
}

.top-separator {
  margin-left: auto;
}

.transport-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  font-size: 1.3rem;
  line-height: 1;
  text-align: center;
}

.history-button {
  min-width: 0;
  padding: 0 0.5rem;
  height: 1.5rem;
}

.history-icon {
  width: 0.70rem;
  height: 0.70rem;
  display: block;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.top-history-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.top-control label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.top-control input[type="range"] {
  width: 120px;
}

.top-control.potential-setting {
  position: relative;
  align-items: center;
}

.top-control.function-setting {
  position: relative;
  display: none;
}

.top-control-label {
  font-size: 0.8rem;
  opacity: 0.9;
}

.top-control-value {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.top-control-value input[type="number"] {
  width: 3.75rem;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #2c3348;
  background: #070a11;
  color: #e6eef7;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.top-control-value input[type="number"]:focus {
  outline: none;
  border-color: #2c7be5;
  box-shadow: 0 0 0 1px rgba(44, 123, 229, 0.6);
}

.top-control-value input[type="text"] {
  width: 16rem;
  max-width: 24rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #2c3348;
  background: #070a11;
  color: #e6eef7;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.top-control.function-setting .top-control-value input[type="text"] {
  height: 1.6rem;
  padding: 0 0.75rem;
}

.top-control-value input[type="text"]:focus {
  outline: none;
  border-color: #2c7be5;
  box-shadow: 0 0 0 1px rgba(44, 123, 229, 0.6);
}

.numeric-drag-label {
  cursor: ew-resize;
}

.slider-toggle {
  border: 1px solid #3a4260;
  border-radius: 999px;
  background: #1e2537;
  color: #e6eef7;
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
}

.slider-toggle:hover {
  background: #283149;
}

.slider-popup {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 0.35rem);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #2c3348;
  background: #05070c;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 5;
}

.slider-popup input[type="range"] {
  width: 150px;
}

.top-control.slider-open .slider-popup {
  display: block;
}

.top-control.shape-setting {
  position: relative;
}

.help-tooltip {
  position: fixed;
  z-index: 100;
  max-width: 20rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #2c3348;
  background: rgba(5, 7, 12, 0.96);
  color: #e6eef7;
  font-size: 0.8rem;
  line-height: 1.4;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease-out;
}

.help-tooltip.is-visible {
  opacity: 1;
}

.top-control.upload-setting {
  position: relative;
  display: none;
}

.shape-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  min-width: 2.2rem;
  border-radius: 999px;
  border: 1px solid #3a4260;
  background: #1e2537;
  color: #e6eef7;
  cursor: pointer;
  font-size: 0.78rem;
  line-height: 1;
}

.shape-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.shape-display:hover {
  background: #283149;
}

.shape-dropdown-arrow {
  font-size: 0.7rem;
  opacity: 0.9;
}

.shape-icon {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 2px;
  position: relative;
  box-sizing: border-box;
}

.shape-icon-line::before,
.shape-icon-square::before,
.shape-icon-circle::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  border: 1.5px solid #e6eef7;
}

.shape-icon-line::before {
  border: none;
  border-top: 1.5px solid #e6eef7;
  top: 50%;
  bottom: auto;
  transform: translateY(-50%);
}

.shape-icon-triangle::before {
  content: none;
}

.shape-icon-square::before {
  border-radius: 2px;
}

.shape-icon-circle::before {
  border-radius: 999px;
}

.shape-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  padding: 0.35rem;
  border-radius: 12px;
  border: 1px solid #2c3348;
  background:
    linear-gradient(#05070c, #05070c) padding-box,
    linear-gradient(135deg, #4ade80, #7873f5, #ff6ec4) border-box;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(120, 115, 245, 0.12);
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 6;
}

.shape-setting.is-open .shape-menu {
  display: flex;
}

.shape-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(11, 18, 32, 0.92);
  color: #e6eef7;
  font-size: 0.8rem;
  cursor: pointer;
}

.shape-option:hover {
  border-color: rgba(74, 222, 128, 0.7);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.4);
}

.shape-option[aria-checked="true"] {
  border-color: rgba(74, 222, 128, 0.8);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.7);
}


.shape-fill-setting {
  margin-left: 0.25rem;
}

.shape-fill-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}

.shape-fill-label input[type="checkbox"] {
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #2c3348;
  background: #070a11;
  position: relative;
}

.shape-fill-label input[type="checkbox"]::after {
  content: "";
  width: 4px;
  height: 7px;
  border: solid #4da5ff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  position: absolute;
  top: 50%;
  left: 50%;
  transition: transform 0.12s ease;
}

.shape-fill-label input[type="checkbox"]:checked::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.canvas-shell {
  flex: 1;
  display: flex;
  min-height: 0;
}

.canvas-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.potential-editor {
  width: 80px;
  padding: 4px 0.5rem 0.75rem;
  border-right: 1px solid #222633;
  background: #05070c;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.potential-editor h2 {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  text-align: center;
}

.potential-editor h2 .potential-editor-r {
  text-transform: none;
}

.potential-editor-separator {
  align-self: stretch;
  border: 0;
  border-top: 1px solid #222633;
  margin-top: 0.2rem;
}

.potential-tool-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tool-button {
  background: transparent;
  border: none;
  padding: 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool-button img {
  width: 28px;
  height: 28px;
  display: block;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.6));
}

.tool-button.active {
  background: rgba(66, 202, 118, 0.25);
  box-shadow: 0 0 0 1px rgba(66, 202, 118, 0.8);
}

.tool-button:hover {
  background: rgba(66, 202, 118, 0.18);
}

.particle-controls {
  width: min(360px, 100%);
  max-width: 100%;
  padding: 0.75rem 1rem;
  border-left: 1px solid #222633;
  background: #05070c;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #4da5ff #0c1020;
}

.particle-controls.particle-controls-collapsed {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-left: none;
  overflow: hidden;
}

.particle-controls::-webkit-scrollbar {
  width: 2px;
}

.particle-controls::-webkit-scrollbar-track {
  background: #0c1020;
  border-radius: 8px;
}

.particle-controls::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4da5ff, #42ca76);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.particle-controls::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #66b7ff, #5edd92);
}

.panel-resizer {
  width: 10px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid #222633;
  border-right: 1px solid #222633;
  background: #05070c;
}

.panel-toggle {
  width: 1.1rem;
  height: 1.4rem;
  border-radius: 0;
  border: none;
  background: transparent;
  color: #e6eef7;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  font-size: 0.65rem;
  line-height: 1;
}

.panel-toggle:hover {
  background: #283149;
}
.particle-controls-title {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.controls-section-title {
  margin: 0 0 0.05rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  cursor: pointer;
}

.controls-section-title .section-title-text {
  flex: 1 1 auto;
}

.controls-section-title .section-toggle {
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.controls-section-title .section-reset {
  flex-shrink: 0;
  font-size: 1rem;
}

.controls-section-title .section-toggle[aria-expanded="false"] {
  transform: rotate(-90deg);
}

.global-controls {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 0.5rem;
  padding: 0.6rem 0.65rem 0.7rem;
  margin: 0 -0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #222633;
  background: radial-gradient(circle at top left, #131827, #05070c);
  overflow: hidden;
  max-height: none;
  transition: max-height 200ms ease, opacity 200ms ease, padding 200ms ease,
    margin 200ms ease;
}
.global-controls:not(.is-collapsed) {
  overflow: visible;
}

.wave-function-controls {
  background: #131827;
}

.global-controls.is-collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
}

.particle-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
}

.particle-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.overlays-field {
  align-items: flex-start;
}

.particle-field label {
  opacity: 0.9;
  white-space: nowrap;
  flex: 0 1 35%;
}

.global-toggle-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  column-gap: 0.75rem;
  row-gap: 0.35rem;
  flex: 0 1 65%;
  max-width: 65%;
}

.psi-rescale-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.lattice-input-row {
  /* Shares layout with .global-toggle-row to align with neighboring controls. */
}

.lattice-input-cell {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lattice-input-cell input[type="number"] {
  flex: 0 1 auto;
  max-width: 5rem;
}

.lattice-inline-label {
  font-size: 0.85rem;
  opacity: 0.9;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.9;
  line-height: 1;
}

.toggle-label.is-frozen-search,
.toggle-label.is-frozen-imm {
  opacity: 0.5;
}

.toggle-label.is-frozen-search input[type="checkbox"],
.toggle-label.is-frozen-imm input[type="checkbox"] {
  box-shadow: none;
}

.toggle-label input[type="checkbox"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #2c3348;
  border-radius: 3px;
  background: #070a11;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
  margin: 0;
  flex-shrink: 0;
}

.toggle-label input[type="checkbox"]::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #4da5ff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  position: absolute;
  top: 50%;
  left: 50%;
  transition: transform 0.12s ease;
}

.toggle-label input[type="checkbox"]:checked::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.toggle-label input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: #4da5ff;
  box-shadow: 0 0 0 1px rgba(77, 165, 255, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.boundary-radio-group {
  gap: 0.75rem;
}

.boundary-radio {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #e6eef7;
  opacity: 0.9;
  user-select: none;
  line-height: 1;
  padding: 0.05rem 0;
}

.boundary-radio input[type="radio"] {
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid #2c3348;
  border-radius: 3px;
  background: #070a11;
  position: relative;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
  margin: 0;
  flex-shrink: 0;
}

.boundary-radio input[type="radio"]::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #4ade80;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0);
  position: absolute;
  top: 50%;
  left: 50%;
  transition: transform 0.12s ease;
}

.boundary-radio input[type="radio"]:checked::after {
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}

.boundary-radio input[type="radio"]:focus-visible {
  outline: none;
  border-color: #4ade80;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.boundary-radio-label {
  letter-spacing: 0;
}

.global-controls > h2 {
  margin: 0;
  font-size: inherit;
  text-transform: none;
  letter-spacing: normal;
  opacity: 1;
}

.particle-field input[type="number"],
.particle-field input[type="text"] {
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  border: 1px solid #2c3348;
  background: #070a11;
  color: #e6eef7;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  flex: 0 1 65%;
  max-width: 65%;
}

/* Make Gaussian packet controls more compact: labels and inputs closer,
   and numeric boxes narrower so they sit nearer to their labels. */
.wave-function-controls .particle-field {
  gap: 0.1rem;
}

.wave-function-controls .particle-field input[type="number"],
.wave-function-controls .particle-field input[type="text"] {
  flex: 0 0 4rem;
  max-width: 4rem;
}

.time-step-row #time-step-edit {
  max-width: 5rem;
}

.imaginary-toggle {
  white-space: nowrap;
}

.integrator-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rescale-toggle input[type="checkbox"]::after {
  border-color: #4ade80;
}

.rescale-toggle input[type="checkbox"]:focus-visible {
  outline: none;
  border-color: #4ade80;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.5),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.particle-field input[type="number"]:focus,
.particle-field input[type="text"]:focus {
  outline: none;
  border-color: #2c7be5;
  box-shadow: 0 0 0 1px rgba(44, 123, 229, 0.6);
}

.wave-function-controls .wf-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  /* Extend over the card padding so tab outlines align with the box edges */
  margin: -0.75rem -0.75rem 0.35rem;
  padding: 0;
  width: calc(100% + 1.5rem);
  background: #05070c;
  border-bottom: 1px solid #222633;
}

.wave-function-controls .wf-tab {
  border: none;
  background: transparent;
  color: #e6eef7;
  opacity: 0.7;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.75rem;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  white-space: nowrap;
  flex: 1 1 0;
  text-align: center;
}

.wave-function-controls .wf-tab.is-active {
  background: #131827;
  opacity: 1;
  border: 1px solid #222633;
  border-bottom-color: #131827;
  margin-bottom: -1px;
}

.wave-function-controls .wf-tab:hover {
  opacity: 0.95;
}

.wave-function-controls .wf-tab-panels {
  margin-top: 0;
}

.wave-function-controls .wf-tab-panel {
  display: none;
}

.wave-function-controls .wf-tab-panel.is-active {
  display: block;
}

.eigenstates-panel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.eigenstates-find-row .eigenstates-find-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  max-width: 100%;
}

.eigenstates-find-row label {
  flex: 0 0 auto;
  margin-right: 0.25rem;
}

.eigenstates-count-prefix {
  font-size: 0.9rem;
}

.eigenstates-find-controls input[type="number"] {
  flex: 0 0 auto;
  max-width: 3rem;
}

.eigenstates-go-button {
  background: #1e2537;
  border: 1px solid #3a4260;
  color: #e6eef7;
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.eigenstates-go-button:hover:not(:disabled) {
  background: #283149;
}

.eigenstates-go-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.eigenstates-status-row {
  min-height: 1.1rem;
  font-size: 0.8rem;
  opacity: 0.85;
}

.eigenstates-count-suffix {
  font-size: 0.8rem;
  opacity: 0.85;
}

.eigenstates-threshold-row .eigenstates-threshold-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  max-width: 100%;
}

.eigenstates-threshold-row label {
  flex: 0 0 auto;
  margin-right: 0.25rem;
}

.eigenstates-max-iters-label {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-left: 0.4rem;
}

/* Make the eigenstate equation textboxes much shorter than the default 65% inputs. */
.particle-field.eigenstates-threshold-row input[type="text"] {
  flex: 0 0 3.2rem;
  max-width: 3.2rem;
}

.eigenstate-clear {
  padding: 0.15rem 0.4rem;
  min-width: 0;
}

.eigenstate-clear img {
  display: block;
  width: 14px;
  height: 14px;
  filter: brightness(1.1);
}

.eigenstates-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.eigenstate-pill {
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  border: 1px solid #2c3348;
  background: #070a11;
  color: #e6eef7;
  font-size: 0.8rem;
  cursor: pointer;
}

.eigenstate-pill.is-active {
  border-color: var(--overlay-accent, #42ca76);
  background: #131827;
}

.particle-field select,
.particle-field .select-display {
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #2c3348;
  background: #070a11;
  color: #e6eef7;
  font-size: 0.85rem;
  flex: 0 1 65%;
  max-width: 65%;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #e6eef7 50%),
    linear-gradient(135deg, #e6eef7 50%, transparent 50%);
  background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.particle-field .select-display {
  max-width: 100%;
  flex: 1 1 auto;
}

.particle-field select.colormap-select,
.particle-field .select-display.colormap-select {
  max-width: 100%;
  flex: 1 1 auto;
  padding: 0;
}

.select-display.colormap-select {
  position: absolute;
  inset: 0;
  padding: 0;
  background-image: none;
  border: none;
  background: transparent;
  box-shadow: none;
  justify-content: flex-start;
}

.select-display.colormap-select .select-display-label {
  font-size: 0;
}

.select-display.colormap-select::before {
  content: "";
  display: block;
  width: 100%;
  height: 0.55rem;
  border-radius: 3px;
  background-color: #ffffff;
}

.select-display.colormap-select::after {
  content: "▾";
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  opacity: 0.8;
}

.select-display.colormap-select[data-colormap-id="phase"]::before {
  background-image: linear-gradient(
    90deg,
    #ff0000,
    #ffff00,
    #00ff00,
    #00ffff,
    #0000ff,
    #ff00ff,
    #ff0000
  );
}

.select-display.colormap-select[data-colormap-id="gold"]::before {
  background-image: linear-gradient(
    90deg,
    #050507,
    #5c3b00,
    #cfa63a,
    #ffe28a,
    #fff6cf
  );
}

.select-display.colormap-select[data-colormap-id="blueRed"]::before {
  background-image: linear-gradient(
    90deg,
    #dc2626,
    #22c55e,
    #2563eb
  );
}

.select-display.colormap-select[data-colormap-id="heat"]::before {
  background-image: linear-gradient(
    90deg,
    #050712,
    #7f1d1d,
    #f97316,
    #facc15,
    #fefce8
  );
}

.select-display.colormap-select[data-colormap-id="viridis"]::before {
  background-image: linear-gradient(
    90deg,
    #020617,
    #0f172a,
    #2563eb,
    #38bdf8,
    #e0f2fe
  );
}

.select-display.colormap-select[data-colormap-id="probGray"]::before {
  background-image: linear-gradient(
    90deg,
    #000000,
    #777777,
    #ffffff
  );
}

.select-display.colormap-select[data-colormap-id="probGrayHot"]::before {
  background-image: linear-gradient(
    90deg,
    #000000,
    #777777 90%,
    #777777 92%,
    #b91c1c 92%,
    #b91c1c 100%
  );
}

.select-display.colormap-select[data-colormap-id="qualitativeSoft"]::before {
  background-image: linear-gradient(
    90deg,
    #f9a8d4 0%,
    #f9a8d4 33.3%,
    #6ee7b7 33.3%,
    #6ee7b7 66.6%,
    #93c5fd 66.6%,
    #93c5fd 100%
  );
}

.select-display.colormap-select[data-colormap-id="qualitativeBold"]::before {
  background-image: linear-gradient(
    90deg,
    #ef4444 0%,
    #ef4444 16.6%,
    #f97316 16.6%,
    #f97316 33.2%,
    #eab308 33.2%,
    #eab308 49.8%,
    #22c55e 49.8%,
    #22c55e 66.4%,
    #3b82f6 66.4%,
    #3b82f6 83%,
    #8b5cf6 83%,
    #8b5cf6 100%
  );
}

.particle-field select:focus,
.particle-field .select-display:focus-visible {
  outline: none;
  border-color: #2c7be5;
  box-shadow: 0 0 0 1px rgba(44, 123, 229, 0.6);
}

.particle-hidden-sliders {
  display: none;
}

.info {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.preset-loading {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.preset-loading.is-visible {
  display: flex;
}

.preset-loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.4);
  border-top-color: #4da5ff;
  box-sizing: border-box;
  animation: preset-loading-spin 0.8s linear infinite;
}

.preset-loading-text {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  opacity: 0.9;
  white-space: nowrap;
}

@keyframes preset-loading-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.setup-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.85rem;
}

.select-enhancer {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 2.1rem;
}

.select-enhancer.select-enhancer-colormap {
  height: 1rem;
}

.select-enhancer.is-open {
  z-index: 10;
}

.select-native-hidden {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.select-display {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 0.9rem;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  text-align: inherit;
}

.select-display:focus-visible {
  outline: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(74, 222, 128, 0.7);
}

.select-enhancer[data-align="left"] .select-display,
.select-enhancer[data-align="left"] .select-option {
  justify-content: flex-start;
  text-align: left;
}

.select-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 0.5rem);
  padding: 0.4rem 0.55rem 0.4rem 0.35rem;
  border-radius: 10px;
  border: 1px solid #2c3348;
  background:
    linear-gradient(#05070c, #05070c) padding-box,
    linear-gradient(135deg, #4ade80, #7873f5, #ff6ec4) border-box;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(120, 115, 245, 0.12);
  max-height: 280px;
  overflow-y: auto;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: #4da5ff #0c1020;
}

.select-options::-webkit-scrollbar {
  width: 3px;
}

.select-options::-webkit-scrollbar-track {
  background: #0c1020;
  border-radius: 6px;
}

.select-options::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4da5ff, #42ca76);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.select-options::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #66b7ff, #5edd92);
}

.select-enhancer .setup-select ~ .select-options {
  min-width: min(320px, calc(100vw - 2rem));
}

.select-enhancer.is-open .select-options {
  display: block;
}

.select-option {
  width: 100%;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(11, 18, 32, 0.92);
  color: #e6eef7;
  font: 0.85rem inherit;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.select-options .select-option[data-colormap-id] {
  font-size: 0;
  padding: 0.3rem 0.6rem;
}

.select-options .select-option[data-colormap-id]::before {
  content: "";
  display: block;
  width: 100%;
  height: 0.7rem;
  border-radius: 3px;
  background-color: #ffffff;
}

.select-options .select-option[data-colormap-id="phase"]::before {
  background-image: linear-gradient(
    90deg,
    #ff0000,
    #ffff00,
    #00ff00,
    #00ffff,
    #0000ff,
    #ff00ff,
    #ff0000
  );
}

.select-options .select-option[data-colormap-id="gold"]::before {
  background-image: linear-gradient(
    90deg,
    #050507,
    #5c3b00,
    #cfa63a,
    #ffe28a,
    #fff6cf
  );
}

.select-options .select-option[data-colormap-id="blueRed"]::before {
  background-image: linear-gradient(
    90deg,
    #dc2626,
    #22c55e,
    #2563eb
  );
}

.select-options .select-option[data-colormap-id="heat"]::before {
  background-image: linear-gradient(
    90deg,
    #050712,
    #7f1d1d,
    #f97316,
    #facc15,
    #fefce8
  );
}

.select-options .select-option[data-colormap-id="viridis"]::before {
  background-image: linear-gradient(
    90deg,
    #020617,
    #0f172a,
    #2563eb,
    #38bdf8,
    #e0f2fe
  );
}

.select-options .select-option[data-colormap-id="probGray"]::before {
  background-image: linear-gradient(
    90deg,
    #000000,
    #777777,
    #ffffff
  );
}

.select-options .select-option[data-colormap-id="probGrayHot"]::before {
  background-image: linear-gradient(
    90deg,
    #000000,
    #777777 90%,
    #777777 92%,
    #b91c1c 92%,
    #b91c1c 100%
  );
}

/* Group headings inside colormap dropdown (disabled options) */
.select-options .select-option[disabled] {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.75;
  cursor: default;
  text-align: center;
}

.select-options .select-option[data-colormap-id="qualitativeSoft"]::before {
  background-image: linear-gradient(
    90deg,
    #f9a8d4 0%,
    #f9a8d4 33.3%,
    #6ee7b7 33.3%,
    #6ee7b7 66.6%,
    #93c5fd 66.6%,
    #93c5fd 100%
  );
}

.select-options .select-option[data-colormap-id="qualitativeBold"]::before {
  background-image: linear-gradient(
    90deg,
    #ef4444 0%,
    #ef4444 16.6%,
    #f97316 16.6%,
    #f97316 33.2%,
    #eab308 33.2%,
    #eab308 49.8%,
    #22c55e 49.8%,
    #22c55e 66.4%,
    #3b82f6 66.4%,
    #3b82f6 83%,
    #8b5cf6 83%,
    #8b5cf6 100%
  );
}

.select-option:hover,
.select-option:focus-visible {
  outline: none;
  border-color: rgba(74, 222, 128, 0.35);
  background: linear-gradient(
    135deg,
    rgba(74, 222, 128, 0.2),
    rgba(120, 115, 245, 0.2),
    rgba(255, 110, 196, 0.2)
  );
  box-shadow: 0 0 0 1px rgba(120, 115, 245, 0.25);
}

.select-option.is-selected {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.6);
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.5);
}

.select-option:disabled {
  opacity: 0.5;
  cursor: default;
}

.setup-select {
  flex: 1 1 auto;
  min-width: 0;
  height: 2.1rem;
  padding: 0 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(#05070c, #05070c) padding-box,
    linear-gradient(135deg, #4ade80, #7873f5, #ff6ec4) border-box;
  text-align-last: center;
  color: #e6eef7;
  font-size: 0.85rem;
  appearance: none;
  background-repeat: no-repeat;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
    background-color 0.18s ease, color 0.18s ease;
}

.setup-select:focus {
  outline: none;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(74, 222, 128, 0.7);
  background:
    linear-gradient(#080f1c, #080f1c) padding-box,
    linear-gradient(135deg, #4ade80, #7873f5, #ff6ec4) border-box;
}

.particle-controls-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  text-align: center;
}

.setup-select option,
.particle-field select option {
  background-color: #0b1220;
  color: #e6eef7;
  text-align: left;
  padding-left: 0.6rem;
}

.select-options {
  text-align: left;
}

.setup-select option:hover,
.setup-select option:checked,
.particle-field select option:hover,
.particle-field select option:checked {
  background: linear-gradient(
    135deg,
    rgba(74, 222, 128, 0.25),
    rgba(120, 115, 245, 0.25),
    rgba(255, 110, 196, 0.25)
  );
  color: #4ade80;
}

.author-credit {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.8rem;
  opacity: 0.7;
  text-align: center;
  color: var(--overlay-accent, #42ca76);
}

.author-credit a {
  color: var(--overlay-accent, #42ca76);
  text-decoration: none;
}

.author-credit a:hover {
  text-decoration: underline;
}

.about-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.about-card {
  width: min(760px, 100%);
  padding: 1.5rem 1.75rem 1.25rem;
  border-radius: 8px;
  border: 1px solid #222633;
  background: radial-gradient(circle at top left, #131827, #05070c);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.65);
  color: #e6eef7;
  font-size: 0.9rem;
  line-height: 1.6;
}

.about-title {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
}

.about-card p {
  margin: 0.35rem 0;
}

.about-links {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  line-height: 1.5;
}

.canvas-container {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, #101627, #020308);
  overflow: hidden;
  min-height: 260px;
}

.canvas-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255, 255, 255, 0.1) 0,
    rgba(255, 255, 255, 0.1) 20px,
    transparent 20px,
    transparent 40px
  );
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.canvas-layer {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.brush-preview {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 2;
}

.brush-preview::before,
.brush-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.brush-preview::before {
  border: 1px solid rgba(0, 0, 0, 0.9);
}

.brush-preview::after {
  border: 1px dashed rgba(255, 255, 255, 0.7);
}

.canvas-transport {
  position: absolute;
  right: 0.9rem;
  bottom: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 4;
  pointer-events: auto;
}

body.is-resizing-panel {
  cursor: col-resize;
  user-select: none;
}

body.is-resizing-panel * {
  cursor: col-resize !important;
}

.eyedropper-overlay {
  position: absolute;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.85);
  color: #e6eef7;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -120%);
  z-index: 3;
}

#potential-canvas,
#quantum-canvas {
  z-index: 1;
  border: 2px solid #000000;
}

#quantum-canvas {
  pointer-events: none;
}

#overlay-canvas {
  z-index: 2;
  pointer-events: none;
  border: 2px solid #000000;
}

.particle-overlay {
  position: absolute;
  z-index: 3;
  pointer-events: none;
}

.canvas-container,
#potential-canvas,
#quantum-canvas,
#overlay-canvas,
.particle-center-handle,
.particle-p-head,
#particle-sigma-circle {
  touch-action: none;
}

.particle-center-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--overlay-accent, #42ca76);
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: move;
  z-index: 2;
}

.particle-sigma-circle {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: default;
  z-index: 1;
}

.particle-sigma-circle * {
  cursor: inherit;
}

.particle-sigma-circle::before,
.particle-sigma-circle::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.particle-sigma-circle::before {
  border: 1.5px solid rgba(0, 0, 0, 0.9);
}

.particle-sigma-circle::after {
  border: 1.5px dashed rgba(255, 255, 255, 0.85);
}

#particle-sigma-label {
  left: calc(100% + 8px);
  top: calc(50% + 10px);
  transform: translateY(-50%);
}

.particle-p-vector {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.particle-p-line {
  position: absolute;
  height: 2px;
  background: var(--overlay-accent, #42ca76);
  transform-origin: 50% 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.particle-p-head {
  position: absolute;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: move;
  z-index: 3;
}

.particle-p-head::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-accent, #42ca76);
  clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

.particle-label {
  position: absolute;
  font-size: 12px;
  color: #ffffff;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

@media (max-width: 800px) {
  .layout {
    flex-direction: column;
  }

  .canvas-shell {
    display: block;
  }

  .canvas-main-column {
    width: 100%;
  }

  .potential-editor {
    order: 0;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #222633;
  }

  .potential-tool-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .canvas-container {
    order: 1;
    /* Let JS-controlled height take effect on mobile
       so the full-width canvas is fully visible. */
    flex: 0 0 auto;
  }

  .particle-controls {
    order: 2;
    width: 100%;
    max-width: none;
    border-left: none;
    border-top: 1px solid #222633;
    max-height: none;
    overflow: visible;
  }

  .panel-resizer {
    display: none;
  }
}

@media (max-width: 900px) {
  .header {
    grid-template-columns: 1fr;
    row-gap: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: center;
  }

  .header h1 {
    font-size: 1.4rem;
  }

  .equation {
    font-size: 0.9rem;
  }

  .header-tagline {
    min-width: 0;
    max-width: none;
    font-size: 0.85rem;
    text-align: center;
    margin: 0 auto;
    justify-self: center;
  }
}

@media (max-width: 640px) {
  .top-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 4px 8px;
  }

  .top-separator,
  .top-separator-left {
    display: none;
  }

  .top-history-buttons {
    justify-content: flex-start;
  }

  .top-control {
    width: 100%;
    justify-content: space-between;
  }

  .top-control-value {
    margin-left: auto;
  }

  .top-control-value input[type="number"] {
    width: 3.25rem;
  }

  .top-control-value input[type="text"] {
    width: 100%;
    max-width: 100%;
  }

  .record-button,
  #play-pause,
  #reset-packet {
    align-self: center;
  }

  .canvas-container {
    min-height: 220px;
  }

  .global-controls {
    margin: 0 0 0.75rem;
  }

  /* Preserve desktop ordering and two-column layout on mobile. */
  .particle-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .global-toggle-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
  }
}
