/*
 * Updated global stylesheet for HyPINO demo (Plotly version)
 */
:root {
  --accent: #0d6efd;
  --accent-hover: #0b5ed7;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1f2937;
  --subtext: #6b7280;
  --border-color: #d7dbe6;
  --muted: #eff2f8;
  --success: #0f9d58;
  --warning: #f4b400;
  --danger: #d93025;
}

body {
  margin: 0;
  padding: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(180deg, #f3f5fa 0%, #f9fbff 100%);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.page-header {
  text-align: center;
  padding: 0 1rem 0.5rem;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: 2.25rem;
  font-weight: 700;
}

.page-header .sub {
  margin: 0;
  color: var(--subtext);
  margin-inline: auto;
}

.demo-callout p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.6;
}

.cta-buttons {
  margin: 1.25rem auto 1.5rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: linear-gradient(135deg, #2563eb 0%, #0ea5e9 100%);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

.cta-button:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(14, 165, 233, 0.3);
}

.cta-button .icon {
  font-size: 1.1rem;
}

.feature-list {
  list-style: disc;
  list-style-position: inside;
  padding: 0;
  margin: 10px 0px 10px 0px;
  text-align: left;
  color: var(--text);
}

code {
  word-break: break-word;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .cta-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .feature-list {
    margin-top: 1.25rem;
  }
}

.section-card {
  background: var(--card-bg);
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  z-index: 0;
}

.section-card:hover,
.section-card:focus-within {
  z-index: 50;
}

.section-card:not(.action-card) {
  backdrop-filter: blur(6px);
}

.section-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.section-heading {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.section-subtitle {
  margin: 0;
  color: var(--subtext);
  font-size: 0.95rem;
}

/* Controls */
.controls {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: end;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.controls .wide {
  grid-column: span 2;
}

.controls input,
.controls select {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.equation-preview {
  font-family: 'Fira Code', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--text);
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.inline-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--subtext);
  background: rgba(15, 23, 42, 0.05);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.inline-hint--warning {
  border-color: rgba(244, 180, 0, 0.4);
  background: rgba(244, 180, 0, 0.12);
}

.inline-hint__warning {
  display: block;
  margin-top: 0.35rem;
  color: var(--warning);
  font-weight: 600;
}

.inline-hint-list {
  margin: 0.5rem 0 0 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--subtext);
}

.inline-hint-list li {
  margin-bottom: 0.25rem;
}

.inline-hint-list li:last-child {
  margin-bottom: 0;
}

.info-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--subtext);
}

.info-hint__label {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.info-tooltip__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 1px solid rgba(13, 110, 253, 0.4);
  background: rgba(13, 110, 253, 0.12);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.info-tooltip__trigger:hover,
.info-tooltip__trigger:focus-visible {
  background: rgba(13, 110, 253, 0.2);
  box-shadow: 0 8px 18px rgba(13, 110, 253, 0.18);
  transform: translateY(-1px);
  outline: none;
}

.info-tooltip__panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  max-width: 80vw;
  width: 100%;
  padding: 1rem 1.15rem;
  border-radius: 14px;
  border: 1px solid rgba(13, 110, 253, 0.2);
  background: #fff;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
  pointer-events: none;
}

.info-tooltip__panel::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 18px;
  width: 14px;
  height: 14px;
  background: inherit;
  border-left: 1px solid rgba(13, 110, 253, 0.2);
  border-top: 1px solid rgba(13, 110, 253, 0.2);
  transform: rotate(45deg);
}

.info-tooltip[data-align="left"] .info-tooltip__panel {
  left: 0;
  right: auto;
}

.info-tooltip[data-align="left"] .info-tooltip__panel::before {
  right: auto;
  left: 18px;
}

.info-tooltip:hover .info-tooltip__panel,
.info-tooltip:focus-within .info-tooltip__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.info-tooltip__title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.info-tooltip__list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.9rem;
  color: var(--subtext);
}

.info-tooltip__list li {
  margin: 0;
}

.info-tooltip__note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--subtext);
}

.prediction-controls__title {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}


.controls input:focus,
.controls select:focus {
  border-color: rgba(13, 110, 253, 0.6);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
  outline: none;
}

.prediction-controls input:focus {
  border-color: rgba(13, 110, 253, 0.6);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
  outline: none;
}

@media (max-width: 600px) {
  .controls .wide {
    grid-column: span 1;
  }
}

/* Uploads */
.uploads { 
  margin-top: 0.25rem;
}

.custom-inputs-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  align-items: stretch;
}

.custom-coefficients {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.custom-subheading {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
}

.custom-subtext {
  margin: 0;
  color: var(--subtext);
  font-size: 0.9rem;
}

.uploads-header {
  font-weight: 600;
  color: var(--accent);
  margin: 0.25rem 0;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.uploads .inner {
  display: grid;
  gap: 1rem;
  margin-top: 0.5rem;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
}

.uploads label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.12);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.uploads label:hover {
  border-color: rgba(13, 110, 253, 0.35);
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.2), 0 10px 20px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.uploads label:focus-within {
  border-color: rgba(13, 110, 253, 0.5);
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.3), 0 0 0 4px rgba(13, 110, 253, 0.12);
}

.uploads input[type="file"] {
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px dashed rgba(148, 163, 184, 0.6);
  background: rgba(248, 250, 252, 0.9);
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.uploads input[type="file"]:hover {
  border-color: rgba(13, 110, 253, 0.6);
  background: rgba(219, 234, 254, 0.9);
}

.uploads input[type="file"]::file-selector-button {
  padding: 0.5rem 1rem;
  margin-right: 0.75rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 10px 20px rgba(13, 110, 253, 0.25);
}

.uploads input[type="file"]::file-selector-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(13, 110, 253, 0.3);
  filter: brightness(1.05);
}

.uploads input[type="file"]::file-selector-button:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(13, 110, 253, 0.22);
}
.mode-panel {
  margin-top: 1.25rem;
  display: block;
}

.mode-panel[hidden] {
  display: none !important;
}

.preset-note {
  margin: 0;
  font-size: 0.9rem;
  color: var(--subtext);
}

.input-mode-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.mode-toggle-btn {
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.85);
  color: var(--subtext);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mode-toggle-btn:not(.selected):hover,
.mode-toggle-btn:not(.selected):focus-visible {
  background: rgba(13, 110, 253, 0.12);
  color: var(--text);
  border-color: rgba(13, 110, 253, 0.35);
  outline: none;
}

.mode-toggle-btn.selected {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(13, 110, 253, 0.25);
}

.mode-toggle-btn:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.28);
  outline-offset: 2px;
}

.uploads-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--subtext);
}

.uploads label.disabled {
  opacity: 0.45;
  pointer-events: none;
}

@media (max-width: 1024px) {
  .uploads .inner {
    grid-template-columns: repeat(2, minmax(200px, 1fr));
  }
}

@media (max-width: 640px) {
  .uploads .inner {
    grid-template-columns: 1fr;
  }
}

/* Hide unused legacy fields */
#scaleD,
#scaleN,
#scaleF,
label[for="scaleD"],
label[for="scaleN"],
label[for="scaleF"] {
  display: none !important;
}

.uploads .required-note,
.uploads .note-required,
.uploads .small {
  display: none !important;
}

.small {
  color: var(--subtext);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Preset selector */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 10px;
}

.preset-btn {
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(13, 110, 253, 0.25);
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.preset-btn.selected {
  background: rgba(13, 110, 253, 0.12);
  border-color: rgba(13, 110, 253, 0.6);
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.25);
}

.preset-btn:hover:not(.selected) {
  background: rgba(13, 110, 253, 0.08);
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.3);
}

/* Primary buttons */
#loadDataBtn,
#predictBtn {
  padding: 0.65rem 1.5rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 12px 24px rgba(13, 110, 253, 0.25);
}

#loadDataBtn:hover:not(:disabled),
#predictBtn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(13, 110, 253, 0.3);
  filter: brightness(1.05);
}

#loadDataBtn:active:not(:disabled),
#predictBtn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 10px 20px rgba(13, 110, 253, 0.22);
}

#loadDataBtn:disabled,
#predictBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.section-actions {
  margin-top: 0.5rem;
  display: flex;
  justify-content: flex-end;
}

/* Loaded data preview */
.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
}

.preview-equation {
  flex: 1 1 280px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preview-equation__heading {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtext);
}

.preview-placeholder {
  padding: 1rem;
  border: 1px dashed rgba(15, 23, 42, 0.15);
  border-radius: 12px;
  color: var(--subtext);
  font-size: 0.9rem;
  background: rgba(15, 23, 42, 0.02);
}

.loaded-data {
  margin-top: 0.5rem;
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 1024px) {
  .loaded-data {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

.loaded-cell {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem;
  border: 1px solid rgba(15, 23, 42, 0.07);
  border-radius: 12px;
  background: var(--muted);
}

.intro {
  text-align: left;
}

.loaded-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.loaded-meta {
  font-size: 0.8rem;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.loaded-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(13, 110, 253, 0.12);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

/* Prediction controls */
.prediction-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.prediction-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.prediction-controls input {
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
/* Status & progress */
.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  background: rgba(15, 23, 42, 0.05);
  color: var(--subtext);
}

.status-chip::before {
  content: '';
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--subtext);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.2);
}

.status-chip[data-tone="info"] {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.status-chip[data-tone="info"]::before {
  background: #1d4ed8;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

.status-chip[data-tone="success"] {
  background: rgba(15, 157, 88, 0.12);
  color: var(--success);
}

.status-chip[data-tone="success"]::before {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(15, 157, 88, 0.18);
}

.status-chip[data-tone="warning"] {
  background: rgba(244, 180, 0, 0.15);
  color: var(--warning);
}

.status-chip[data-tone="warning"]::before {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(244, 180, 0, 0.22);
}

.status-chip[data-tone="danger"] {
  background: rgba(217, 48, 37, 0.12);
  color: var(--danger);
}

.status-chip[data-tone="danger"]::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(217, 48, 37, 0.22);
}

.status-chip[data-tone="idle"] {
  background: rgba(15, 23, 42, 0.05);
  color: var(--subtext);
}

.progress {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.2rem;
}

#prog {
  width: 260px;
  height: 14px;
  accent-color: var(--accent);
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 1s linear infinite;
  margin: 0.25rem 0 0.25rem auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Plotly containers */
.plotly-heatmap {
  width: 100%;
  min-height: 260px;
}

/* Iteration results */
#iterContainer {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.iter-accordion {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.iter-accordion details {
  background: transparent;
}

.iter-accordion details[open] {
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.05);
}

.iter-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0.75rem;
  cursor: pointer;
  list-style: none;
  border-left: 4px solid rgba(148, 163, 184, 0.45);
}

.iter-summary::-webkit-details-marker {
  display: none;
}

.iter-summary::marker {
  content: '';
}

.iter-summary::after {
  content: '';
  width: 10px;
  height: 10px;
  border-right: 2px solid rgba(15, 23, 42, 0.35);
  border-bottom: 2px solid rgba(15, 23, 42, 0.35);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  justify-self: end;
  grid-column: 3;
  align-self: center;
}

.iter-accordion details[open] .iter-summary::after {
  transform: rotate(-135deg);
}

.iter-summary[data-trend="improved"] {
  border-left-color: rgba(15, 157, 88, 0.55);
}

.iter-summary[data-trend="worsened"] {
  border-left-color: rgba(217, 48, 37, 0.45);
}

.iter-summary[data-trend="steady"] {
  border-left-color: rgba(37, 99, 235, 0.35);
}

.iter-summary .iter-label {
  font-weight: 700;
  color: var(--text);
  grid-column: 1;
}

.iter-summary .iter-losses {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  grid-column: 2;
}

/* badges removed from iteration summary */

.iter-content {
  padding: 0 0.75rem 1rem 0.75rem;
}

.iter-tiles {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.result-metrics-wrapper {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.result-metrics-heading {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.result-metrics {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.result-metric {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.result-metric h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--subtext);
}

.plotly-metric {
  width: 100%;
  min-height: 220px;
}

.iter-cell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.iter-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}

.iter-cell .plotly-heatmap {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: unset;
}

/* Export section */
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.export-actions button {
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(13, 110, 253, 0.35);
  background: rgba(13, 110, 253, 0.08);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.export-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(13, 110, 253, 0.18);
  background: rgba(13, 110, 253, 0.16);
}

.export-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}
.code-collapse {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  padding: 0.75rem 1rem;
}

.code-collapse > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}

.code-collapse > summary::marker,
.code-collapse > summary::-webkit-details-marker {
  display: none;
}

.code-collapse > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.5rem;
  transition: transform 0.2s ease;
}

.code-collapse[open] > summary::before {
  transform: rotate(90deg);
}

.code-toolbar {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.4rem;
}

.code-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(148, 163, 184, 0.08);
  color: inherit;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

.code-action svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.code-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.code-action:hover {
  background: rgba(94, 234, 212, 0.12);
  border-color: rgba(94, 234, 212, 0.4);
}

.code-action:active {
  transform: translateY(1px);
}

.code-action.is-success {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
}

.code-block {
  margin-top: 0.75rem;
  padding: 1rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  font-family: 'Fira Code', 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  line-height: 1.4;
}

.citation-card {
  padding-bottom: 2rem;
}

.citation-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.citation-text {
  margin: 0;
  padding: 1rem 1.25rem;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  font-family: 'Fira Code', 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-x: auto;
}

.code-block code,
.citation-text code {
  display: block;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  word-break: normal;
  overflow-wrap: normal;
}

.citation-copy {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(37, 99, 235, 0.25);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9) 0%, rgba(14, 165, 233, 0.8) 100%);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.citation-copy:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(14, 165, 233, 0.28);
}

.citation-copy:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

.citation-copy.is-success {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.92) 0%, rgba(16, 185, 129, 0.9) 100%);
  box-shadow: 0 16px 32px rgba(16, 185, 129, 0.3);
}

.citation-copy__label {
  display: inline-block;
}

.page-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--subtext);
  padding: 0 1rem 1.5rem;
}

.page-footer p {
  margin: 0;
}

.page-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.page-footer a:hover,
.page-footer a:focus-visible {
  text-decoration: underline;
}

/* Responsive tweaks */
@media (max-width: 900px) {
  .container {
    padding: 2rem 1rem 2.5rem;
  }

  .section-card {
    padding: 1.35rem;
  }

  .loaded-data {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .iter-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
}

@media (max-width: 640px) {
  .preset-buttons {
    margin-top: 10px;
    gap: 0.4rem;
  }

  .preset-btn {
    padding-inline: 0.85rem;
  }

  .status-line {
    flex-direction: column;
    align-items: flex-start;
  }

  #prog {
    width: 100%;
  }

  .citation-text {
    font-size: 0.82rem;
  }

  .citation-copy {
    width: 100%;
    justify-content: center;
  }
}

