body {
  font-family: Arial, sans-serif;
  margin: 0;
  background: #f7f9fc;
  color: #1f2937;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav a {
  margin-right: 1rem;
}

.panel {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 1rem;
}

.form-grid,
.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

input, select, button {
  padding: 0.5rem;
  font-size: 0.95rem;
}

button {
  cursor: pointer;
}

.primary-btn {
  background: #2563eb;
  color: #fff;
  border: 1px solid #1d4ed8;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 600;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.home-open-panel {
  margin-bottom: 1rem;
}

.file-list {
  margin-top: 0.5rem;
}

.file-group {
  margin-bottom: 1rem;
}

.file-group-title {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  color: #374151;
}

.file-group-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-group-list li + li {
  margin-top: 0.25rem;
}

.file-open-btn {
  background: transparent;
  border: none;
  color: #2563eb;
  padding: 0.25rem 0;
  text-align: left;
}

.file-open-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.file-open-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fit-peak-id-input {
  width: 4rem;
  padding: 0.2rem 0.35rem;
}

.plot {
  height: 430px;
  margin-bottom: 1rem;
}

.plot-section-title {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.plot-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.plot-with-controls {
  display: flex;
  flex-direction: column;
}

.curve-controls-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.35rem 0;
}

.curve-controls-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.curve-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
}

.curve-toggle-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #ffffff;
  padding: 0.18rem 0.55rem;
  font-size: 0.82rem;
  color: #374151;
}

.curve-toggle-item.curve-toggle-peak {
  cursor: pointer;
}

.curve-toggle-item.is-selected {
  border-color: #f97316;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.35);
  background: #fff7ed;
}

.curve-toggle-item.is-selected .curve-toggle-name {
  color: #9a3412;
  font-weight: 600;
}

.curve-toggle-item.is-disabled-peak {
  border-style: dashed;
  border-color: #9ca3af;
  background: #f3f4f6;
}

.curve-toggle-item.is-disabled-peak .curve-toggle-swatch {
  background: #9ca3af !important;
}

.curve-toggle-item.is-disabled-peak .curve-toggle-name {
  color: #6b7280;
}

.curve-toggle-item input {
  margin: 0;
}

.raw-mode-toggle select {
  padding: 0.05rem 0.25rem;
  font-size: 0.8rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  background: #ffffff;
  color: #374151;
}

.curve-toggle-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  border: 1px solid #9ca3af;
}

.curve-toggle-name {
  line-height: 1;
}

.curve-toggle-delete {
  appearance: none;
  background: transparent;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  margin-left: 0.15rem;
  cursor: pointer;
  color: #dc2626;
  line-height: 1;
}

.curve-toggle-item.is-selected .curve-toggle-delete {
  display: inline-flex;
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 3px;
}

.curve-toggle-delete-icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.curve-toggle-item.is-selected .curve-toggle-delete:hover {
  color: #991b1b;
  background: #fecaca;
}

.curve-toggle-item.is-selected .curve-toggle-delete:focus-visible {
  outline: 2px solid #991b1b;
  outline-offset: 1px;
  border-radius: 2px;
}

.half.plot-small {
  height: 350px;
}

.half.plot-medium {
  height: 500px;
}

.half.plot-large {
  height: 700px;
}

.settings-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.settings-field-hint {
  grid-column: 1 / -1;
  margin: 0;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  grid-column: 1 / -1;
}

.error {
  color: #991b1b;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.success {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

.meta pre {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 0.5rem;
  overflow-x: auto;
  margin: 0;
}

.collapsible-section {
  margin-bottom: 1rem;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f8fafc;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding: 0.5rem 1rem;
  color: #374151;
}

.section-toggle:hover {
  background: #eef2f7;
}

.chevron {
  transition: transform 0.2s ease;
}

.collapsible-section.collapsed .chevron,
.meta.collapsed .chevron {
  transform: rotate(-90deg);
}

.collapsible-section.collapsed .collapsible-content,
.meta.collapsed .collapsible-content {
  display: none;
}

.fit-panel {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: #f8fafc;
}

.fit-panel h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1rem;
}

.fit-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  align-items: end;
}

.fit-tuning-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  align-items: end;
  grid-column: 1 / -1;
}

.fit-tuning-controls.hidden {
  display: none;
}

.tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-left: 0.35rem;
  border-radius: 50%;
  border: 1px solid #9ca3af;
  color: #4b5563;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 700;
  cursor: help;
  background: #ffffff;
}

.tooltip-icon:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 1px;
}

.fit-status {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: #374151;
}

.peak-preview-status {
  margin-top: 0.4rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0f766e;
  font-size: 0.85rem;
}

.peak-preview-status.peak-preview-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.viewer-global-controls {
  grid-template-columns: minmax(220px, 320px);
}

.fit-results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.spectrum-toolbar {
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.9rem;
}

.spectrum-toolbar label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
}

.spectrum-toolbar input[type="number"] {
  width: 7rem;
}

.spectrum-toolbar select {
  min-width: 10rem;
}

.spectrum-toolbar-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 0.75rem;
}

.spectrum-fit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
  align-items: end;
}

.fit-action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.spectrum-tuning-row,
.spectrum-seed-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e5e7eb;
}

.spectrum-tuning-row.hidden,
.spectrum-seed-range-row.hidden {
  display: none;
}

.spectrum-zoom-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.6rem;
  padding: 0.5rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.9rem;
}

.spectrum-zoom-controls label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.2rem;
}

.spectrum-zoom-controls input[type="number"] {
  width: 7rem;
}

.spectrum-zoom-controls .zoom-hint {
  color: #6b7280;
  font-style: italic;
  margin-left: auto;
}

.fit-slice-field-label {
  margin: 0 0 0.6rem 0;
  font-size: 0.95rem;
  color: #374151;
}

.selected-peak-info {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.4rem 0.75rem;
  margin-top: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #1f2937;
}

.selected-peak-info label {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: #4b5563;
}

.selected-peak-info input[type="number"] {
  width: 6.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.selected-peak-info.is-pending input[type="number"] {
  opacity: 0.65;
  pointer-events: none;
}

.selected-peak-info .selected-peak-label {
  font-weight: 600;
  color: #111827;
  padding-bottom: 0.35rem;
}

.range-bounds-heading,
.range-bounds-subheading {
  font-weight: 600;
  color: #374151;
  font-size: 0.85rem;
  width: 100%;
}

.selected-peak-range-bounds {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.4rem 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
  padding-top: 0.35rem;
  border-top: 1px dashed #e5e7eb;
}

.range-bounds-readout {
  width: 100%;
  font-size: 0.78rem;
  color: #6b7280;
  font-style: italic;
}

.fit-table {
  margin-top: 0.5rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem;
  min-height: 60px;
  overflow-x: auto;
}

.fit-table-container {
  margin-top: 0.5rem;
  overflow-x: auto;
}

.fit-table-formatted {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.9rem;
}

.fit-table-formatted th,
.fit-table-formatted td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.fit-table-formatted th {
  background-color: #f3f4f6;
  font-weight: 600;
  color: #374151;
}

.fit-table-formatted tbody tr:last-child td {
  border-bottom: none;
}

.fit-table-formatted tbody tr:hover {
  background-color: #f9fafb;
}

.fit-metrics {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: #374151;
  background: #ffffff;
  padding: 0.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}

.fit-table-controls {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
}

.notation-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
}

.notation-toggle-wrapper.hidden {
  display: none;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: #3b82f6;
}

input:focus + .slider {
  box-shadow: 0 0 1px #3b82f6;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 20px;
}

.slider.round:before {
  border-radius: 50%;
}

.param-tab-bar {
  display: flex;
  gap: 0;
  margin-top: 0.75rem;
  border-bottom: 2px solid #d1d5db;
}

.param-tab {
  padding: 0.4rem 1.2rem;
  border: 1px solid #d1d5db;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: #f3f4f6;
  font-weight: 600;
  font-size: 0.9rem;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -2px;
}

.param-tab:hover {
  background: #eef2f7;
  color: #374151;
}

.param-tab.active {
  background: #ffffff;
  color: #1f2937;
  border-bottom: 2px solid #ffffff;
}

.formula-block {
  text-align: center;
  margin: 1.2rem 0;
}

.param-list > li {
  margin-bottom: 0.8rem;
}

.param-list > li > ul {
  margin-top: 0.25rem;
}

.fit-panel-toggle {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
}

.fit-panel-toggle:hover {
  background: transparent;
  color: #111827;
}

.summary-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 1rem;
  row-gap: 0.4rem;
  margin: 0;
  padding: 0.5rem 0;
}

.summary-list dt {
  font-weight: 600;
  color: #374151;
  padding-right: 0.5rem;
}

.summary-list dd {
  margin: 0;
  color: #111827;
  word-break: break-word;
}

.summary-list dd code {
  background: #f3f4f6;
  padding: 0 0.3rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.summary-section-title {
  margin: 1rem 0 0.25rem 0;
  font-size: 0.95rem;
  color: #374151;
}

.summary-metadata {
  border-top: 1px solid #e5e7eb;
  padding-top: 0.5rem;
}

.explorer-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.6rem 1.2rem;
  margin: 0.8rem 0;
}

.explorer-controls label {
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  min-width: 0;
}

.explorer-controls label input[type="range"] {
  width: 100%;
  min-width: 0;
}

.explorer-controls select {
  grid-column: 2 / -1;
  justify-self: start;
  min-width: 80px;
}

.explorer-label {
  color: #374151;
}

.explorer-value {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #111827;
  font-weight: 600;
}

.explorer-readout {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.6rem 0;
  font-size: 0.95rem;
  color: #111827;
}

.explorer-readout #expH {
  font-weight: 600;
  color: #dc2626;
  font-variant-numeric: tabular-nums;
}

.multi-peak-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 0.75rem;
  margin: 0.8rem 0;
}

.peak-row {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  display: grid;
  gap: 0.4rem;
}

.peak-row-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #374151;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
}

.peak-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* --- General Utilities --- */
.flex-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: #2563eb;
  color: white;
}

.btn-primary:hover {
  background-color: #1d4ed8;
}

/* --- Authentication Pages --- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 180px);
  padding: 1rem;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border: 1px solid #e5e7eb;
}

.auth-title {
  text-align: center;
  margin-top: 0;
  margin-bottom: 2rem;
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.form-group label.checkbox-label {
  display: inline;
  margin-bottom: 0;
  font-weight: normal;
  cursor: pointer;
}

.form-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.auth-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f3f4f6;
  text-align: center;
  font-size: 0.9rem;
  color: #6b7280;
}

.auth-footer p {
  margin: 0.5rem 0;
}

.auth-footer a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.peak-row label {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr) 3.5rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  min-width: 0;
}

.peak-row label input[type="range"] {
  width: 100%;
  min-width: 0;
}
