@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700&display=swap');

:root {
  /* Brand & palette */
  --brand: #ff8c00;           /* primary accent */
  --brand-hover: #e67e00;     /* hover accent */
  --brand-contrast: #ffffff;  /* text on brand */
  --bg: #f7f8fb;              /* app background */
  --card: #ffffff;            /* surfaces/cards */
  --text: #0f172a;            /* primary text */
  --muted: #6b7280;           /* secondary text */
  --border: #e5e7eb;          /* hairlines */
  --ring: rgba(255, 140, 0, 0.35); /* focus ring */
  --shadow: 0 10px 30px rgba(2, 6, 23, 0.06); /* soft shadow */
  --brand-grad-end: #ffb34d; /* gradient end */
  --radius: 12px;            /* default radius */
  --brand-weak: rgba(255, 140, 0, 0.12); /* subtle brand bg */
  --card-blur-bg: rgba(255, 255, 255, 0.7); /* translucent card */
  --menu-bar-height: 52px;   /* mobile menu bar height for sticky offset */
  /* Generic color aliases for charts and components */
  --color-primary: var(--brand);
  --color-accent: var(--brand-grad-end);
}

/* Use border-box sizing to include padding/border in element width and prevent horizontal overflow */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

/* Reserve scrollbar space to prevent width jumps when toggling overflow */
html { scrollbar-gutter: stable both-edges; }

/* Disable transitions/animations before first reveal to prevent jank */
html.ui-preinit *,
html.ui-preinit *::before,
html.ui-preinit *::after {
  transition: none !important;
  animation: none !important;
}

/* During preinit, keep overlay visible and hide the rest of the page */
/* We rely on the fixed #loading-screen overlay, so no need to hide body */

/* General Styles */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 180ms ease;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader {
  position: relative;
  width: 160px;
  height: 160px;
  border-radius: 12px;
  background: radial-gradient(120px 120px at 50% 50%, var(--brand-weak), transparent 70%);
  box-shadow: var(--shadow);
}

/* Animated scatter dots reminiscent of the charts */
.loader .dot {
  position: absolute;
  width: 6px;
  height: 6px;
  background: var(--brand);
  border-radius: 50%;
  opacity: 0.85;
  transform: translate3d(0, 0, 0);
  animation:
    dot-float var(--dur, 2600ms) ease-in-out var(--delay, 0ms) infinite alternate,
    dot-alpha 1800ms ease-in-out var(--alphaDelay, 0ms) infinite alternate;
}

/* Gentle float movement */
@keyframes dot-float {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(var(--tx, 6px), var(--ty, -6px), 0) scale(1.05); }
}

/* Subtle alpha pulsation for depth */
@keyframes dot-alpha {
  from { opacity: 0.55; }
  to   { opacity: 0.95; }
}


body {
  font-family: 'Lato', ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
  margin: 0;
  padding: 0;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* avoid tiny horizontal scrollbars on small screens */
}

main {
  width: 100% ; 
  max-width: 1200px;
  padding: 0 16px; /* consistent horizontal breathing room */
}

.equation-wrapper {
  max-width: 100%;
  overflow-y: hidden;
  overflow-x: auto;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
} 

.equation-wrapper .MathJax_Display {
  overflow-y: visible;
  overflow-x: auto;
  max-width: 100%;
}

.equation-wrapper .MathJax_Display > .MathJax_SVG {
  max-width: none !important;
  white-space: nowrap;
}

/* Custom scrollbar styles for better visibility */
.equation-wrapper::-webkit-scrollbar {
  width: 8px;
}

.equation-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.equation-wrapper::-webkit-scrollbar-thumb {
  background: #ffa500;
  border-radius: 4px;
}

.equation-wrapper::-webkit-scrollbar-thumb:hover {
  background: #ff8c00;
}

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
  width: auto;
  height: auto;
  padding: 8px 12px;
  z-index: 10000;
  background: var(--card);
  color: var(--text);
  border: 2px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

a {
  color: var(--text);
  text-underline-offset: 3px;
}

/* Container Styles */
.container {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  padding: 16px 0;
  margin-bottom: 20px;
}

.chart-wrapper {
  display: contents;
}

.chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--card);
  grid-column: span 4;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.chart-loss-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--card);
  grid-column: span 8;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Chart canvas sizing */
.chart-container canvas,
.chart-loss-container canvas {
  width: 100% !important;
  height: auto;
  display: block;
}

/* Max sizes for plots and aligned stats */
.chart-loss-container {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Center the single loss plot on Page 2 across the 12-column grid (desktop only) */
@media (min-width: 769px) {
  body.page2 #interactive-loss .chart-loss-container {
    /* place in the middle of the 12-col grid */
    grid-column: 3 / -3;
    justify-self: center;
    margin-left: auto;
    margin-right: auto;
  }
}
/* Keep wrapper as contents so the loss container is the grid item */
body.page2 #interactive-loss .chart-wrapper {
  display: contents;
}
.chart-loss-container canvas {
  max-height: 520px;
  min-height: 320px;
}
.chart-container canvas {
  max-height: 380px;
  min-height: 260px;
}
/* Ensure stats block below loss plot matches plot width */
.chart-loss-container + .equation-wrapper {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

/* Ensure full-width placement for top button bar and stats block on large screens */
.container > .button-container,
.container .equation-wrapper,
.container > .chart-wrapper {
  grid-column: 1 / -1;
}

/* Two-column layout (loss + stats) on large screens */
.container .equation-wrapper {
  grid-column: span 4;
  align-self: start;
}

/* Column utilities for specific layouts */
.container.two > .chart-container {
  grid-column: span 6;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

.container.three > .chart-container {
  grid-column: span 4;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* List Styles */
.styled-list { 
  margin-bottom: 20px;
  list-style-type: decimal;
  color: #333;
  font-size: 1em;
  line-height: 1.5;
}

.styled-list li {
  margin-bottom: 10px;
}
.assumption-box {
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.assumption-box:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.assumption-box h5 {
  margin-top: 0;
  color: var(--brand);
  font-size: 1.05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.assumption-box p {
  line-height: 1.5;
  color: #333;
}

/* Input Styles */
.input-container { 
  display: flex;
  flex-wrap: wrap;
  align-items: center; 
  background: var(--card-blur-bg);
  backdrop-filter: blur(6px);
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 12px 0 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.input-content {
  margin: 0px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px; /* row-gap, column-gap */
  background: transparent;
  justify-content: center;
  width: 100%;
  box-sizing: border-box; 
  padding: 0px; 
} 

.input-content > div {
  display: flex;
  align-items: center;
  margin-right: 0;   /* normalize spacing: handled by gap */
  padding-bottom: 0; /* normalize spacing: handled by gap */
}

.input-content label {
  margin-right: 5px;
  white-space: nowrap;
}

.InputLabel,
.InputRange  {
  margin: 0px !important;
}

.InputLabel  {
  padding: 0px !important;
} 

.InputValue {
  font-variant-numeric: tabular-nums; /* stable widths to avoid jitter */
  font-weight: 600;
}

.label-value-wrapper {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.input-content button {
  flex: 0 0 auto;
}

.input-container {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--card-blur-bg);
  border-bottom: 1px solid var(--border);
}

.ui-sticky-ready .input-container {
  position: sticky;
  top: 0;
  z-index: 950;
}

.input-container.sticky {
  position: sticky;
  top: 0;
  left: auto;
  transform: none;
  z-index: 1000;
  max-width: 100%;
  border-radius: 16px;
  backdrop-filter: blur(6px);
}


.input-content input[type="number"] {
  width: 50px;
}

/* Form Element Styles */
input[type="number"], input[type="range"] {
  margin: 0 10px;
  padding: 5px;
  border: 1px solid #ffa500;
  border-radius: 4px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 130px;
  height: 18px;
  background: transparent;
  border: none;
  outline: none;
  opacity: 1;
  cursor: pointer;
}

/* Range track styling */
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
}
input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--border);
  border-radius: 999px;
}
input[type="range"]::-ms-track {
  height: 4px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}
input[type="range"]::-ms-fill-lower,
input[type="range"]::-ms-fill-upper {
  background: var(--border);
  border-radius: 999px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #ffa500;
  cursor: pointer;
  border: 2px solid #ffffff;
  border-radius: 50%;
  margin-top: -7px; /* Center the thumb on a ~4px track */
}
/* Firefox thumb */
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #ffa500;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer;
}
/* Firefox filled progress */
input[type="range"]::-moz-range-progress {
  background: var(--brand);
  height: 4px;
  border-radius: 999px;
}
input[type="range"]::-ms-thumb {
  width: 18px;
  height: 18px;
  background: #ffa500 !important;
  border: 2px solid #ffffff;
  border-radius: 50%;
  cursor: pointer; 
}
button {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  color: var(--brand-contrast);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 140, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
 
.orange-button {
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  color: var(--brand-contrast);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

/* Stats Styles */
.stats-container {
  flex: 1;
}

.stats-table {
  table-layout: auto; /* allow browser to size columns based on content to avoid overlap */
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}
.stats-table th:first-child,
.stats-table td:first-child {
  width: 1%;
}
.stats-table th,
.stats-table td {
  text-align: left;
  white-space: normal;
}
.stats-table th, .stats-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top; /* keep multi-line cells from overlapping */
  line-height: 1.4;
}

/* Prefer wider formula column for readability */
.stats-table th:nth-child(1),
.stats-table td:nth-child(1) { width: 22%; }
.stats-table th:nth-child(2),
.stats-table td:nth-child(2) { width: 48%; }
.stats-table th:nth-child(3),
.stats-table td:nth-child(3) { width: 15%; }
.stats-table th:nth-child(4),
.stats-table td:nth-child(4) { width: 15%; }

.stats-table th {
  font-weight: 600;
  background-color: var(--card);
}

.stats-table tr:nth-child(even) {
  background-color: var(--bg);
}

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

.stats-table .measure {
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
}

.stats-table .formula {
  text-align: left;
  font-style: italic;
  word-break: normal;
  overflow-wrap: anywhere; /* allow breaks inside long tokens like ε₁³*ε₂ */
}

.stats-table .value {
  text-align: left;
  white-space: nowrap;        /* keep numbers on one line */
  word-break: keep-all;       /* avoid breaking digits */
  overflow-wrap: normal;      /* don't wrap arbitrarily */
}

.stats-tables-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
}


/* Other Container Styles */
#formula-container,
.text-container {
  background-color: var(--card);
  padding: 15px;
  margin-bottom: 20px;
  text-align:justify;
  font-size: 1.2em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.text-container h2,
.text-container h3 {
  margin-top: 0;
  margin-bottom: 8px;
  line-height: 1.25;
}

/* provide consistent vertical rhythm inside sections */
.text-container > * + * {
  margin-top: 12px;
}

.button-container {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.input-list {
  list-style-type: none;
  padding-left: 0;
}

.input-list li {
  position: relative;
  padding-left: 30px;
  margin-bottom: 15px;
}

.input-list li::before {
  content: "⚙";
  position: absolute;
  left: 0;
  color: #ffa500;
  font-size: 1.2em; 
  top: -0.2em;   
}

.input-list li:hover::before {
  transform: rotate(45deg);
  transition: transform 0.3s ease; 
}

/* Navigation Styles */
/* Header Styles */
header {
  width: 100%;
  margin: 0;
  padding: 12px 16px; /* desktop/tablet padding; mobile is set in media query */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-blur-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

header h1 {
  max-width: 1200px;
  margin: 4px auto;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.2px;
  font-size: clamp(1.5rem, 1.15rem + 1.1vw, 2.25rem);
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header h1::after {
  content: "";
  display: block;
  height: 3px;
  width: 56px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  opacity: 0.9;
}

/* Navigation Styles */
nav {
  width: 100%;
  background: transparent;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

nav ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
}

nav ul li {
  margin: 0;
}

nav ul li a {
  display: block;
  color: var(--text);
  text-align: center;
  padding: 10px 14px;
  text-decoration: none;
  border-radius: 10px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

/* Hover for non-active links */
nav ul li a:hover {
  background: var(--brand-weak);
}

nav ul li a.active {
  color: var(--brand-contrast);
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  box-shadow: 0 8px 20px rgba(255, 140, 0, 0.25);
}

/* Also style current page set via aria-current for accessibility */
nav ul li a[aria-current="page"] {
  color: var(--brand-contrast);
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  box-shadow: 0 8px 20px rgba(255, 140, 0, 0.25);
}

/* Page Styles */
.page {
  display: none;
}

.active {
  display: block;
}

/* Menu Toggle Styles */
#menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
}

.menu-bar {
  display: none;
  width: 100%;
  background: transparent;
  display: flex;
  justify-content: center;  
  align-items: center;
}

/* Footer Styles */
footer {
  width: 100%;
  background: transparent;
  color: var(--text);
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

footer p {
  margin: 0;
}

.menu-bar { 
  justify-content: space-between;
  padding: 10px;
  background-color: #ffa500;
  display: none;
}

#menu-toggle,
#input-toggle {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-grad-end));
  color: var(--brand-contrast);
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1em;
  box-shadow: 0 8px 20px rgba(255, 140, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}
 
button:hover,
#menu-toggle:hover,
#input-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(255, 140, 0, 0.28);
}

a:hover { text-decoration: underline; opacity: 0.9; }

/* Accessible focus styles */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
#menu-toggle:focus-visible,
#input-toggle:focus-visible,
nav a:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: var(--radius);
}

#menu-toggle .icon,
#input-toggle .icon {
  margin-right: 5px;
  font-size: 1.2em;
}

#menu-toggle .text,
#input-toggle .text {
  display: none;
}

.input-content-wrapper { padding: 8px 6px; }

/* Responsive Styles */
@media (max-width: 768px) {
  /* Ensure full-width layout for sticky to behave predictably on mobile */
  body {
    align-items: stretch;
  }

  /* Match main's horizontal padding on small screens */
  header {
    width: 100%;
    max-width: 1200px;
    padding: 0 16px;
    box-sizing: border-box;
  }

  /* Stack footer content nicely on small screens */
  .footer-container {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
  }

  .menu-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-blur-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
    padding: 8px 10px;
    margin-bottom: 8px;
    position: -webkit-sticky; /* Safari */
    position: sticky;
    top: 0;
    z-index: 1001; /* above container */
  }

  .ui-sticky-ready .input-container {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  .input-content input[type="range"] {
    width: 130px;
  }

  
  .input-content-wrapper {
    padding: 0px;
    padding-top: 15px; 
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    display: none;
  }

  .input-content-wrapper.expanded { 
      max-height: 1000px; /* Adjust this value based on your content's height */
      transition: max-height 0.3s ease-in;
      display:block;
  }

  /* Stack charts on small screens */
  .container {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .chart-container,
  .chart-loss-container {
    grid-column: span 6;
  }
  /* Ensure Page 1 charts (container.three) truly span full width on small screens */
  .container.three > .chart-container {
    grid-column: span 6 !important;
  }

  /* Ensure top button bar and loss plot wrapper span full width */
  .container > .button-container,
  .container > .chart-wrapper {
    grid-column: 1 / -1;
  }

  /* On small screens, stats block should also span full width */
  .container .equation-wrapper {
    grid-column: 1 / -1;
  }

  #input-toggle {
      display: flex;
  }

  .input-content > div {
    margin-bottom: 5px; 
    justify-content: center;
    align-items: center;
    text-align: center;
  }
 
 

  .orange-button {
    flex: 1 1 100%;
  }

  .chart-wrapper{
    display: block;
    /* Ensure wrapper fits full grid width */
    grid-column: 1 / -1;
    width: 100%;
  }
  .chart-container {
    min-width:200px  !important;
    margin: 0 !important;
  }
  /* Remove max-width caps so charts can fill the grid on small screens */
  .container.two > .chart-container,
  .container.three  .chart-container {
    min-width:200px  !important;
    margin: 0 !important;
  }

  .chart-loss-container {
    width:100% !important;
    margin: 0 auto !important;
  }

  /* Ensure loss plot has a concrete height on small screens */
  #lossplot {
    height: 320px !important; /* explicit height so Chart.js can size canvas */
    min-height: 280px;        /* safety lower bound */
    max-height: 420px;        /* avoid overly tall plot */
  }
  #lossplot2 {
    height: 320px !important; /* explicit height so Chart.js can size canvas */
    min-height: 280px;        /* safety lower bound */
    max-height: 420px;        /* avoid overly tall plot */
  }
  
  nav {
    display: block;
    max-height: 0;
    padding: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    /* nav expands/collapses inside sticky .input-container */
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 8px;
    opacity: 0;
  }

  nav.expanded {
    max-height: 500px; /* Adjust this value based on your menu's height */
    transition: max-height 0.5s ease-in, opacity 0.2s ease-in;
    padding: 8px;
    opacity: 1;
  }

  /* Keep other existing styles for small screens */
  #menu-toggle {
    display: flex;
  }

  nav ul {
    flex-direction: column;
    gap: 6px;
  }

  nav ul li {
    margin: 0;
  }

  nav ul li a {
    font-size: 1em;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: transparent;
  }

  /* Show button text labels on small screens */
  #menu-toggle .text,
  #input-toggle .text {
    display: inline;
  }
}

.popup {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.4);
  backdrop-filter: blur(5px);
}

.popup-content {
  background-color: #f8f8f8;
  padding: 20px;
  border: 1px solid #ffa500;
  border-radius: 8px;
  width: 80%;
  max-width: 500px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  font-family: Arial, sans-serif;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 80vh;
  overflow-y: auto;
}

/* Inline info/reference popups attached to icons */
.info-popup,
.ref-popup {
  position: absolute;
  z-index: 2000; /* above sticky input container/nav (z-index: 1000) */
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  line-height: 1.4;
  max-width: 460px;
}

.info-popup a,
.ref-popup a {
  color: var(--brand);
  text-decoration: underline;
}

.popup-content h3 {
  color: #333; /* Switched to dark text for better contrast */
  margin-top: 0;
  font-size: 1.2em;
}

.popup-content p {
  color: #666;
  font-size: 0.9em;
  line-height: 1.5;
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close:hover,
.close:focus {
  color: #ffa500;
  text-decoration: none;
}

.InputLabel {
  cursor: help;
}

.InputLabel:hover {
  color: #ff8c00;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 0px;
}

.label-value-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

.InputLabel {
  margin-right: 5px;
}
 

.InputRange {
  width: 100%;
}

/* Inline info icon badge */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: var(--brand-weak);
  color: var(--brand);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  vertical-align: super;
  margin-left: -2px; /* pull icon closer to preceding text */
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.info-icon:hover {
  background: var(--brand);
  color: var(--brand-contrast);
}

.info-icon:active {
  transform: translateY(1px);
}

.info-icon:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--ring);
}
