:root,
[data-theme="dark"] {
  --bg: #f8f7ef;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-2: #f1eb9c;
  --border: rgba(33, 35, 34, 0.12);
  --text: #212322;
  --muted: #5f6663;
  --primary: #ffc600;
  --primary-2: #6cc24a;
  --accent: #606eb2;
  --accent-2: #8094dd;
  --warn: #fbdb65;
  --success: #4ade80;
  --danger: #f87171;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.32);
  --radius: 18px;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at top,
      color-mix(in srgb, var(--primary) 18%, transparent),
      transparent 36%
    ),
    linear-gradient(
      180deg,
      var(--bg),
      color-mix(in srgb, var(--bg) 92%, #f0e87b)
    );
  color: var(--text);
  overflow-x: hidden;
}
button,
input,
select {
  font: inherit;
}
img,
svg,
canvas {
  max-width: 100%;
  display: block;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  z-index: 999;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.app-shell {
  display: grid;
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--surface) 96%, transparent),
    color-mix(in srgb, var(--surface) 90%, transparent)
  );
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.brand-row {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--surface) 96%, transparent),
    color-mix(in srgb, var(--surface-2) 98%, transparent)
  );
}
.logo {
  width: 140px;
  height: 80px;
  display: grid;
  place-items: center;
  border-radius: 16px;
 
}
.brand-row h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
}
.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.field {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.field span {
  font-size: 0.9rem;
  color: var(--muted);
}
select,
input[type="range"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}
select:focus,
input:focus,
button:focus-visible {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}
.check {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  color: var(--text);
}
.check input {
  accent-color: var(--primary);
}
.actions-panel {
  position: sticky;
  top: 0px;
  z-index: 2;
}
.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.btn {
  
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.12s ease;

}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #212322;
  border: none;
  grid-column: 1 / -1;
}
.btn-secondary {
  background: var(--surface-2);
}
.btn-ghost {
  background: transparent;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.info {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}
.algo-desc {
  min-height: 2.7em;
}
.note {
  opacity: 0.9;
  font-style: italic;
}
.no-controls {
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 0;
}
.chip {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(188, 80, 144, 0.12);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
}
.control-stack {
  display: grid;
  gap: 12px;
}
.control-group {
  display: grid;
  gap: 8px;
}
.control-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}
.control-inline span {
  font-size: 0.9rem;
  color: var(--muted);
}
.control-inline output {
  font-size: 0.82rem;
  color: var(--muted);
  min-width: 56px;
  text-align: right;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.metrics-panel {
  position: sticky;
  top: calc(16px + 390px);
}
.metric {
  background: var(--surface-2);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.metric-label {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.metric strong {
  font-size: 1rem;
}
.main-stage {
  min-width: 0;
  min-height: 100dvh;
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}
.hero-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 2px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.hero-bar h2 {
  margin: 0;
  font-size: clamp(1.1rem, 1.7vw, 1.5rem);
  line-height: 1.15;
}
.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.86rem;
}
.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 999px;
  margin-right: 6px;
}
.dot-target {
  background: #5b8db8;
}
.dot-sample {
  background: #9ca3af;
}
.dot-path {
  background: #334155;
}
.dot-vi {
  background: var(--warn);
}
.canvas-card {
  position: relative;
  min-height: calc(100dvh - 106px);
  border: 1px solid var(--border);
  border-radius: 26px;
  overflow: hidden;
  background:
    radial-gradient(
      circle at top left,
      rgba(255, 198, 0, 0.14),
      transparent 30%
    ),
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--surface) 96%, transparent),
      color-mix(in srgb, var(--surface-2) 98%, transparent)
    );
  box-shadow: var(--shadow);
}
#plotCanvas,
.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.advi-canvas {
  pointer-events: none;
}
.xhist,
.yhist {
  pointer-events: none;
}
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    top: auto;
    height: auto;
    overflow: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .actions-panel,
  .metrics-panel {
    position: relative;
    top: auto;
  }
  .main-stage {
    min-height: auto;
    padding: 12px;
  }
  .canvas-card {
    min-height: 72vh;
  }
}
@media (max-width: 720px) {
  .sidebar {
    padding: 12px;
    gap: 10px;
  }
  .panel {
    padding: 12px;
  }
  .brand-row {
    padding: 12px;
    border-radius: 20px;
  }
  .actions-grid {
    grid-template-columns: 1fr;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .hero-bar {
    align-items: flex-start;
    flex-direction: column;
  }
  .legend {
    gap: 10px;
  }
  .canvas-card {
    min-height: 66vh;
    border-radius: 20px;
  }
}
