:root {
  --bg: #f4efe4;
  --bg-alt: #fbf7ef;
  --ink: #162133;
  --ink-soft: #516076;
  --line: rgba(22, 33, 51, 0.12);
  --line-strong: rgba(22, 33, 51, 0.22);
  --panel: rgba(255, 252, 247, 0.82);
  --panel-strong: rgba(255, 250, 242, 0.94);
  --accent: #f05d3d;
  --accent-deep: #c74b30;
  --teal: #1f7a8c;
  --teal-soft: rgba(31, 122, 140, 0.15);
  --gold: #f5a623;
  --gold-soft: rgba(245, 166, 35, 0.26);
  --gold-line: rgba(245, 166, 35, 0.46);
  --success: #20684f;
  --warning: #8f5f00;
  --danger: #8d2b2b;
  --shadow: 0 24px 60px rgba(20, 28, 44, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(240, 93, 61, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 122, 140, 0.14), transparent 26%),
    linear-gradient(180deg, #f9f4e8 0%, #f2eadb 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  max-width: 1520px;
  margin: 0 auto;
  padding: 32px 20px 36px;
}

.hero {
  display: grid;
  gap: 18px;
  align-items: end;
  margin-bottom: 24px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.hero h1,
.panel-head h2,
.card-head h3 {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
}

.hero h1 {
  max-width: 16ch;
  font-size: clamp(2.4rem, 5vw, 4.9rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 62ch;
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.workspace {
  --control-column-width: 530px;
  display: grid;
  gap: 0;
  grid-template-columns: var(--control-column-width) 8px minmax(0, 1fr);
}

@media (min-width: 1161px) {
  #workspace {
    column-gap: 0;
  }
}

.control-column {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.workspace-divider {
  position: sticky;
  top: 24px;
  align-self: start;
  justify-self: center;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 22px;
  height: clamp(220px, 60vh, 520px);
  padding-top: 48px;
  border-radius: 12px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(22, 33, 51, 0.12) 18%,
    rgba(22, 33, 51, 0.12) 82%,
    transparent
  ) center / 1px 100% no-repeat;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.workspace-divider-grip {
  display: block;
  width: 2px;
  height: 96px;
  border-radius: 999px;
  background: rgba(31, 122, 140, 0.42);
  transition: background-color 150ms ease;
}

.workspace-divider:hover .workspace-divider-grip,
.workspace-divider.is-dragging .workspace-divider-grip,
.workspace-divider:focus-visible .workspace-divider-grip {
  background: var(--teal);
}

.workspace-divider:focus-visible {
  outline: 3px solid rgba(31, 122, 140, 0.36);
  outline-offset: -3px;
}

body.workspace-divider-resizing,
body.workspace-divider-resizing * {
  cursor: col-resize !important;
}

body.workspace-divider-resizing {
  user-select: none;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.graph-panel {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.panel-head,
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-head h2 {
  font-size: clamp(1.45rem, 2vw, 2rem);
  letter-spacing: -0.03em;
}

.panel-head p,
.card-head p,
.plot-caption {
  margin: 6px 0 0;
  line-height: 1.5;
  color: var(--ink-soft);
}

.card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.objective-card {
  background:
    linear-gradient(180deg, rgba(255, 249, 239, 0.7), rgba(255, 231, 190, 0.84)),
    var(--gold-soft);
  border-color: var(--gold-line);
}

.card-head h3 {
  font-size: 1.12rem;
}

.card-head.compact {
  margin-bottom: 14px;
}

.pill-row,
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.spotlight-row {
  margin-top: -4px;
}

.problem-file-actions .button {
  flex: 1 1 140px;
}

.spotlight-button {
  min-width: 220px;
}

.return-link-row {
  margin-bottom: 2px;
}

.return-link-button,
.return-link-button:visited,
.return-link-button:hover,
.return-link-button:active {
  color: var(--ink);
  text-decoration: none;
}

.return-link-button {
  background: #dce7e6;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}

.return-link-button:hover {
  background: #d3e0de;
}

.model-editor-card {
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(31, 122, 140, 0.07), rgba(255, 255, 255, 0.84)),
    var(--panel-strong);
}

.editor-tab-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tab-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.74);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background-color 0.16s ease;
}

.tab-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.92);
}

.tab-button.is-active {
  color: var(--ink);
  background: rgba(31, 122, 140, 0.16);
  border-color: rgba(31, 122, 140, 0.28);
  font-weight: 700;
}

.model-editor-panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.model-editor-panel.is-hidden {
  display: none;
}

.editor-textarea-label {
  display: grid;
  gap: 8px;
}

.editor-textarea-label textarea {
  min-height: 160px;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}

.editor-sheet-block {
  display: grid;
  gap: 10px;
}

.editor-sheet-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.editor-sheet-caption {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.table-sheet-scroller {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}

.table-sheet {
  min-width: 770px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.table-sheet-row {
  display: grid;
  grid-template-columns: 48px 64px minmax(120px, 1.2fr) repeat(2, minmax(92px, 1fr)) minmax(104px, 0.9fr) minmax(92px, 1fr);
}

.table-sheet-body .table-sheet-row {
  border-top: 1px solid var(--line);
}

.table-sheet-header {
  background: rgba(31, 122, 140, 0.12);
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.table-sheet-index,
.table-sheet-cell {
  min-height: 46px;
}

.table-sheet-index {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-right: 1px solid var(--line);
  background: rgba(31, 122, 140, 0.07);
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.table-sheet-header .table-sheet-index {
  background: rgba(31, 122, 140, 0.14);
}

.table-sheet-cell {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.table-sheet-row > :last-child {
  border-right: none;
}

.table-sheet-header .table-sheet-cell {
  background: rgba(31, 122, 140, 0.12);
}

.table-sheet-cell:focus-within {
  background: rgba(31, 122, 140, 0.11);
  box-shadow: inset 0 0 0 1.5px rgba(31, 122, 140, 0.28);
}

.table-sheet-enabled {
  justify-content: center;
  padding-inline: 8px;
}

.table-sheet-cell:has(.table-sheet-field[aria-invalid="true"]) {
  background: rgba(141, 43, 43, 0.08);
  box-shadow: inset 0 0 0 2px rgba(141, 43, 43, 0.5);
}

.table-sheet-field {
  width: 100%;
  min-height: 46px;
  padding: 0 2px;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
}

.table-sheet-field:focus {
  outline: none;
}

.table-sheet-field[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: auto;
  padding: 0;
  accent-color: var(--teal);
  cursor: pointer;
}

.sheet-row-actions {
  margin-top: -2px;
}

.editor-note {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.editor-note code,
.editor-inline-toggle code {
  font-size: 0.92em;
  color: var(--ink);
}

.editor-inline-toggle {
  display: inline-flex;
  align-items: start;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.editor-inline-toggle input {
  width: auto;
  min-height: auto;
  margin-top: 2px;
}

.table-loader-objective-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.table-loader-setup-grid {
  grid-template-columns: minmax(180px, 1.2fr) repeat(2, minmax(0, 1fr));
}

.table-loader-setup-grid.is-xy-mode {
  grid-template-columns: minmax(220px, 340px);
}

.table-variable-name-field.is-hidden {
  display: none;
}

.inline-validation {
  margin: 0;
  padding: 8px 10px;
  border-left: 3px solid var(--warning);
  border-radius: 9px;
  color: var(--warning);
  background: rgba(245, 166, 35, 0.12);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
}

.inline-validation[data-state="error"] {
  border-left-color: var(--danger);
  color: var(--danger);
  background: rgba(141, 43, 43, 0.09);
}

.inline-validation[data-state="success"] {
  border-left-color: var(--success);
  color: var(--success);
  background: rgba(32, 104, 79, 0.09);
}

.inline-validation[hidden] {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent-deep);
  background: rgba(240, 93, 61, 0.1);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  color: var(--ink);
  background: rgba(31, 122, 140, 0.12);
  text-decoration: none;
  box-shadow: none;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
  background: rgba(31, 122, 140, 0.2);
}

.button-primary {
  color: var(--ink);
  background: rgba(31, 122, 140, 0.12);
  box-shadow: none;
}

.button-secondary {
  color: var(--ink);
  background: rgba(31, 122, 140, 0.12);
}

.button-ghost {
  color: var(--ink);
  background: rgba(31, 122, 140, 0.12);
}

.constraint-list {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.constraint-row {
  padding: 14px;
  border: 1px solid var(--constraint-line, var(--line));
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.22)),
    var(--constraint-fill, rgba(255, 255, 255, 0.52));
}

.constraint-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.constraint-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  flex-wrap: wrap;
}

.constraint-label {
  min-width: 24px;
}

.constraint-name-input {
  width: 88px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.92);
}

.constraint-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.constraint-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: rgba(31, 122, 140, 0.12);
  transition:
    transform 0.16s ease,
    background-color 0.16s ease;
}

.icon-button:hover {
  transform: translateY(-1px);
  background: rgba(31, 122, 140, 0.2);
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid + .button-row {
  margin-top: 10px;
}

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

.objective-line-editor {
  display: grid;
  gap: 12px;
  min-width: 0;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(143, 95, 0, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
}

.objective-line-editor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.objective-line-editor h4 {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 1rem;
}

.objective-line-editor-head p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.45;
}

.equation-chip {
  flex: 0 0 auto;
  max-width: 100%;
  padding: 8px 11px;
  border: 1px solid rgba(143, 95, 0, 0.2);
  border-radius: 999px;
  color: #654400;
  background: rgba(245, 166, 35, 0.16);
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}

.objective-line-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.objective-line-fields[hidden] {
  display: none;
}

.constraint-grid {
  grid-template-columns: minmax(130px, 1.3fr) minmax(78px, 0.72fr) minmax(78px, 0.72fr);
  gap: 10px;
  margin-bottom: 10px;
}

.constraint-grid label span {
  font-size: 0.78rem;
}

.constraint-grid input,
.constraint-grid select {
  min-height: 40px;
  padding: 0 10px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(141, 43, 43, 0.18);
}

input:focus,
select:focus,
textarea:focus,
.tab-button:focus,
.button:focus,
.icon-button:focus {
  outline: 2px solid rgba(31, 122, 140, 0.35);
  outline-offset: 2px;
}

.constraint-equation {
  margin: 0;
  min-height: 1.4em;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.status-card {
  background:
    linear-gradient(180deg, rgba(31, 122, 140, 0.08), rgba(255, 255, 255, 0.75)),
    var(--panel-strong);
}

.status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-tile {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.status-tile.wide {
  grid-column: 1 / -1;
}

.status-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--ink-soft);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.status-badge.success {
  color: var(--success);
  background: rgba(32, 104, 79, 0.14);
}

.status-badge.warning {
  color: var(--warning);
  background: rgba(245, 166, 35, 0.18);
}

.status-badge.danger {
  color: var(--danger);
  background: rgba(141, 43, 43, 0.14);
}

.status-badge.neutral {
  color: var(--ink-soft);
  background: rgba(22, 33, 51, 0.08);
}

.status-tile p {
  margin: 0;
  line-height: 1.5;
  color: var(--ink-soft);
}

#optimum-text {
  white-space: pre-line;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.lp-celebration {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
  isolation: isolate;
}

.lp-celebration * {
  pointer-events: none;
}

.lp-celebration[data-state="active"] {
  visibility: visible;
}

.celebration-toggle {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 10px;
  max-width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid rgba(31, 122, 140, 0.23);
  border-radius: 14px;
  background: rgba(255, 250, 242, 0.85);
  cursor: pointer;
}

.celebration-toggle input {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  min-height: 19px;
  margin: 0;
  padding: 0;
  accent-color: var(--teal);
  cursor: pointer;
}

.celebration-toggle span {
  color: var(--ink);
  font-size: 0.9rem;
}

.lp-confetti {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.lp-confetti-piece {
  position: absolute;
  top: var(--lp-confetti-start-y);
  width: var(--lp-confetti-width);
  height: var(--lp-confetti-height);
  border-radius: 2px;
  background: var(--lp-confetti-color);
  opacity: 0;
  will-change: transform, opacity;
  animation: lp-confetti-flight var(--lp-confetti-duration) cubic-bezier(0.18, 0.72, 0.32, 1)
    var(--lp-confetti-delay) both;
}

.lp-confetti-piece--left {
  left: -18px;
}

.lp-confetti-piece--right {
  right: -18px;
}

.lp-confetti-piece--top {
  left: var(--lp-confetti-start-x);
  animation-timing-function: linear;
}

.lp-confetti-piece.is-round {
  border-radius: 999px;
}

.lp-celebration-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vh, 12px);
  width: 96%;
  opacity: 0;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

.lp-celebration-stage::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12% -2%;
  background: radial-gradient(ellipse, rgba(255, 250, 242, 0.95) 8%, rgba(255, 250, 242, 0.88) 38%, rgba(255, 250, 242, 0) 72%);
}

.lp-celebration[data-state="active"] .lp-celebration-stage {
  animation: lp-celebration-arrival 4200ms cubic-bezier(0.22, 0.7, 0.3, 1) both;
}

.lp-celebration-title {
  margin: 0;
  max-width: 100%;
  font-family: "Cooper Black", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-size: clamp(1.65rem, min(9.4vw, 13vh), 9rem);
  font-weight: 1000;
  font-style: italic;
  line-height: 0.98;
  letter-spacing: -0.055em;
  text-align: center;
  text-transform: uppercase;
  color: var(--accent);
  -webkit-text-stroke: clamp(1px, 0.2vw, 3px) #fffaf2;
  paint-order: stroke fill;
  text-shadow: 0.035em 0.045em 0 #fffaf2, 0.065em 0.075em 0 var(--teal), 0.09em 0.1em 0 var(--gold);
  filter: drop-shadow(0 8px 14px rgba(22, 33, 51, 0.16));
}

.lp-celebration-title span {
  display: block;
  white-space: nowrap;
}

.lp-celebration-title span + span {
  color: var(--teal);
  text-shadow: 0.035em 0.045em 0 #fffaf2, 0.065em 0.075em 0 var(--accent), 0.09em 0.1em 0 var(--gold);
}

.lp-celebration[data-state="active"] .lp-celebration-title {
  animation: lp-title-bounce 4200ms ease-in-out both;
}

.lp-happy-dancer {
  display: block;
  flex: 0 0 auto;
  width: clamp(104px, 37vmin, 320px);
  height: auto;
  max-height: 42vh;
  overflow: visible;
  filter: drop-shadow(0 12px 12px rgba(22, 33, 51, 0.15));
}

.lp-happy-dancer__figure,
.lp-happy-dancer__head-group,
.lp-happy-dancer__arm--left,
.lp-happy-dancer__arm--right,
.lp-happy-dancer__leg--left,
.lp-happy-dancer__leg--right {
  transform-box: view-box;
}

.lp-happy-dancer__figure {
  transform-origin: 140px 210px;
}

.lp-celebration[data-state="active"] .lp-happy-dancer__figure {
  animation: lp-dancer-sway 4200ms ease-in-out both;
}

.lp-happy-dancer__head-group {
  transform-origin: 140px 125px;
}

.lp-celebration[data-state="active"] .lp-happy-dancer__head-group {
  animation: lp-dancer-head 4200ms ease-in-out both;
}

.lp-happy-dancer__head,
.lp-happy-dancer__body,
.lp-happy-dancer__shoe,
.lp-happy-dancer__glove,
.lp-happy-dancer__hat,
.lp-happy-dancer__bow {
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linejoin: round;
}

.lp-happy-dancer__head,
.lp-happy-dancer__glove {
  fill: #fff1d5;
}

.lp-happy-dancer__body {
  fill: var(--teal);
}

.lp-happy-dancer__belly {
  fill: #52aab3;
}

.lp-happy-dancer__eye-white,
.lp-happy-dancer__tooth {
  fill: #fffaf2;
}

.lp-happy-dancer__eye-white {
  stroke: var(--ink);
  stroke-width: 2;
}

.lp-happy-dancer__eye,
.lp-happy-dancer__smile,
.lp-happy-dancer__moustache,
.lp-happy-dancer__button {
  fill: var(--ink);
}

.lp-happy-dancer__limb {
  fill: none;
  stroke: var(--ink);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lp-happy-dancer__shoe,
.lp-happy-dancer__hat,
.lp-happy-dancer__nose {
  fill: var(--accent);
}

.lp-happy-dancer__shoe-stripe,
.lp-happy-dancer__hat-stripe {
  fill: none;
  stroke: #fff1d5;
  stroke-width: 4;
  stroke-linecap: round;
}

.lp-happy-dancer__bow,
.lp-happy-dancer__pom,
.lp-happy-dancer__spark {
  fill: var(--gold);
}

.lp-happy-dancer__bow-knot {
  fill: var(--accent);
  stroke: var(--ink);
  stroke-width: 3;
}

.lp-happy-dancer__shadow {
  fill: rgba(22, 33, 51, 0.13);
}

.lp-happy-dancer__spark {
  transform-box: fill-box;
  transform-origin: center;
}

.lp-happy-dancer__spark--two {
  fill: var(--accent);
}

.lp-celebration[data-state="active"] .lp-happy-dancer__spark {
  animation: lp-party-spark 4200ms ease-in-out both;
}

.lp-happy-dancer__arm--left {
  transform-origin: 107px 150px;
}

.lp-happy-dancer__arm--right {
  transform-origin: 170px 143px;
}

.lp-happy-dancer__leg--left,
.lp-happy-dancer__leg--right {
  transform-origin: 140px 200px;
}

.lp-celebration[data-state="active"] .lp-happy-dancer__arm--left,
.lp-celebration[data-state="active"] .lp-happy-dancer__leg--right {
  animation: lp-dancer-limb-left 4200ms ease-in-out both;
}

.lp-celebration[data-state="active"] .lp-happy-dancer__arm--right,
.lp-celebration[data-state="active"] .lp-happy-dancer__leg--left {
  animation: lp-dancer-limb-right 4200ms ease-in-out both;
}

@keyframes lp-confetti-flight {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.6);
  }
  8% {
    opacity: 1;
  }
  52% {
    opacity: 1;
    transform: translate3d(var(--lp-confetti-mid-x), var(--lp-confetti-mid-y), 0)
      rotate(var(--lp-confetti-mid-rotation)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--lp-confetti-end-x), var(--lp-confetti-end-y), 0)
      rotate(var(--lp-confetti-end-rotation)) scale(0.84);
  }
}

@keyframes lp-celebration-arrival {
  0% {
    opacity: 0;
    transform: translate(-50%, -32%) scale(0.35) rotate(-8deg);
  }
  12% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1.02) rotate(2deg);
  }
  20%, 82% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  91% {
    opacity: 1;
    transform: translate(-50%, -52%) scale(1.02) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72%) scale(0.78) rotate(5deg);
  }
}

@keyframes lp-title-bounce {
  0%, 20%, 40%, 60%, 80%, 100% {
    transform: rotate(-2deg) scale(0.98);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: rotate(2deg) scale(1.01);
  }
}

@keyframes lp-dancer-sway {
  0%, 20%, 40%, 60%, 80%, 100% {
    transform: translateY(0) rotate(-7deg) scale(1.03, 0.96);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateY(-10px) rotate(7deg) scale(0.97, 1.03);
  }
}

@keyframes lp-dancer-head {
  0%, 20%, 40%, 60%, 80%, 100% { transform: rotate(10deg); }
  10%, 30%, 50%, 70%, 90% { transform: rotate(-12deg); }
}

@keyframes lp-dancer-limb-left {
  0%, 20%, 40%, 60%, 80%, 100% { transform: rotate(-18deg); }
  10%, 30%, 50%, 70%, 90% { transform: rotate(16deg); }
}

@keyframes lp-dancer-limb-right {
  0%, 20%, 40%, 60%, 80%, 100% { transform: rotate(16deg); }
  10%, 30%, 50%, 70%, 90% { transform: rotate(-18deg); }
}

@keyframes lp-party-spark {
  0%, 40%, 80% { transform: scale(0.65) rotate(-12deg); }
  20%, 60%, 100% { transform: scale(1.12) rotate(14deg); }
}

.graph-head {
  align-items: end;
}

.graph-hint {
  margin: 0;
  align-self: center;
  font-weight: 600;
  color: var(--accent-deep);
}

.plot-control-stack {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.plot-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.axis-equal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}

.axis-equal-toggle input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--teal);
}

.axis-settings {
  max-width: 100%;
  margin-left: auto;
}

.axis-settings[open] {
  flex-basis: 100%;
  min-width: 0;
  margin-left: 0;
}

.axis-settings summary {
  width: fit-content;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.axis-settings summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.axis-settings-body {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-strong);
}

.axis-range-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.axis-range-grid label,
.axis-range-grid input {
  min-width: 0;
}

.axis-range-grid input[aria-invalid="true"] {
  border-color: var(--danger);
  outline-color: var(--danger);
}

.axis-settings-body p,
.view-status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.85rem;
  line-height: 1.45;
}

.axis-keyboard-hint {
  flex: 1 1 150px;
  align-self: center;
}

.axis-settings-body .axis-range-error {
  color: var(--danger);
  font-weight: 600;
}

.plot-shell {
  border-radius: 24px;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 244, 235, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.plot-action-bar {
  display: flex;
  justify-content: center;
  padding: 16px 10px 8px;
}

.snap-optimum-button {
  min-width: min(100%, 310px);
  min-height: 48px;
  padding-inline: 24px;
  border: 1px solid rgba(143, 95, 0, 0.28);
  color: #3f2a00;
  background: var(--gold);
  box-shadow: 0 9px 20px rgba(143, 95, 0, 0.18);
  font-weight: 700;
}

.snap-optimum-button:hover {
  background: #f7b33f;
  box-shadow: 0 11px 24px rgba(143, 95, 0, 0.24);
}

.plot-reset-button {
  justify-self: end;
  min-height: 38px;
  padding: 0 14px;
}

.plot-lock-button {
  min-height: 38px;
  padding: 0 14px;
}

.plot-lock-button.is-locked {
  color: #fffaf2;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 122, 140, 0.18);
}

.graph-panel[data-view-locked="true"] #plot {
  box-shadow: inset 0 0 0 3px rgba(31, 122, 140, 0.38);
}

#plot {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  touch-action: pan-y;
  user-select: none;
  background:
    radial-gradient(circle at top left, rgba(31, 122, 140, 0.08), transparent 30%),
    linear-gradient(180deg, #fffef8 0%, #faf5ec 100%);
}

#plot [data-drag-kind] {
  touch-action: none;
}

@media (max-width: 1160px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .workspace-divider {
    display: none;
  }
}

@media (max-width: 700px) {
  .page-shell {
    padding: 18px 14px 24px;
  }

  .control-panel,
  .graph-panel {
    padding: 18px;
  }

  .panel-head,
  .card-head,
  .constraint-top {
    flex-direction: column;
  }
  .constraint-grid,
  .objective-grid,
  .objective-line-fields,
  .table-loader-setup-grid,
  .table-loader-objective-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .objective-line-editor-head {
    flex-direction: column;
  }

  .equation-chip {
    align-self: start;
  }

  .problem-file-actions .button {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
  }

  .snap-optimum-button {
    width: 100%;
  }

  .hero h1 {
    max-width: none;
  }
}

/* A reduced-motion preference changes the celebration to a static success
state; it must never suppress the success state completely. */
.lp-celebration[data-motion="reduced"] .lp-confetti {
  display: none;
}

.lp-celebration[data-state="active"][data-motion="reduced"] .lp-celebration-stage {
  opacity: 1;
  transform: translate(-50%, -50%);
  animation: none !important;
}

.lp-celebration[data-motion="reduced"] .lp-celebration-title,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__figure,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__head-group,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__arm--left,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__arm--right,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__leg--left,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__leg--right,
.lp-celebration[data-motion="reduced"] .lp-happy-dancer__spark {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .lp-celebration[data-state="active"] {
    visibility: visible;
  }
}
