:root {
  color-scheme: light;
  --bg: #f2f5f5;
  --paper: #ffffff;
  --ink: #182024;
  --muted: #627077;
  --line: #d7dee2;
  --line-strong: #aebbc1;
  --accent: #0c7c71;
  --accent-strong: #07584f;
  --before: #7b61ff;
  --after: #d55f3b;
  --demand: #1f2a30;
  --success: #0d7b4f;
  --warning: #b65f00;
  --chart-paper: #f9fbfb;
  --shadow: 0 18px 50px rgb(30 41 46 / 0.08);
  --shadow-active: 0 20px 70px rgb(12 124 113 / 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.58), transparent 22rem),
    repeating-linear-gradient(90deg, rgb(24 32 36 / 0.025) 0 1px, transparent 1px 5rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 20;
  transform: translateY(-140%);
  background: var(--ink);
  color: white;
  padding: 0.7rem 1rem;
  border-radius: 6px;
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 3.9rem;
  padding: 0 1.5rem;
  background: rgb(245 247 248 / 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-glyph {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  border: 2px solid var(--ink);
  position: relative;
  background: conic-gradient(from 210deg, var(--accent) 0 32%, transparent 32% 100%);
}

.brand-glyph::before,
.brand-glyph::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.2rem;
  height: 2px;
  background: var(--ink);
  transform-origin: left center;
}

.brand-glyph::before {
  transform: rotate(-34deg);
}

.brand-glyph::after {
  transform: rotate(34deg);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  overflow-x: auto;
  scrollbar-width: none;
}

.topbar-nav::-webkit-scrollbar {
  display: none;
}

.topbar-nav a {
  flex: 0 0 auto;
  padding: 0.55rem 0.8rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar-nav a:hover {
  color: var(--ink);
  background: rgb(24 32 36 / 0.06);
}

main {
  padding: 0 1.5rem 4rem;
}

.app-intro {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(22rem, 0.75fr);
  gap: clamp(1.25rem, 3vw, 3rem);
  align-items: center;
  max-width: 94rem;
  margin: 0 auto;
  padding: clamp(1rem, 1.8vw, 1.8rem) 0 clamp(0.85rem, 1.4vw, 1.25rem);
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-intro h1,
.chart-header h2,
.inspector-panel h2,
.section-heading h2,
.method-copy h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.02;
}

.app-intro h1 {
  max-width: 32ch;
  font-size: clamp(2rem, 3.2vw, 3.65rem);
  font-weight: 850;
}

.intro-copy {
  margin: 0;
  max-width: 40rem;
  color: var(--muted);
  font-size: clamp(1rem, 1.1vw, 1.12rem);
  line-height: 1.55;
}

.simulator-shell {
  display: grid;
  grid-template-columns: minmax(18rem, 0.8fr) minmax(28rem, 1.7fr) minmax(18rem, 0.85fr);
  gap: 1rem;
  align-items: stretch;
  max-width: 94rem;
  margin: 0 auto;
}

.control-panel,
.chart-panel,
.inspector-panel {
  min-width: 0;
}

.control-panel,
.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-block,
.chart-panel,
.inspector-section {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-block,
.inspector-section {
  padding: 1rem;
}

.control-block-advanced {
  background: rgb(255 255 255 / 0.72);
  box-shadow: none;
}

.control-block details {
  display: grid;
  gap: 0.9rem;
}

.control-block summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  list-style: none;
  cursor: pointer;
}

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

.control-block summary span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.control-block summary strong {
  color: var(--ink);
  font-size: 0.84rem;
  text-align: right;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.panel-heading strong {
  color: var(--ink);
  font-size: 0.9rem;
  text-align: right;
}

.preset-list {
  display: grid;
  gap: 0.45rem;
}

.preset-button {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.8rem;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.preset-button:hover {
  background: rgb(12 124 113 / 0.07);
  transform: translateX(2px);
}

.preset-button[aria-pressed="true"] {
  border-color: rgb(12 124 113 / 0.38);
  background: rgb(12 124 113 / 0.1);
  box-shadow: inset 3px 0 0 var(--accent);
}

.preset-title {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
}

.preset-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.preset-risk {
  color: var(--after);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.text-button {
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
}

.text-button:hover {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.slider-stack {
  display: grid;
  gap: 1rem;
}

.slider-row {
  display: grid;
  gap: 0.45rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 760;
}

.slider-label output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.slider-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.chart-panel {
  display: grid;
  grid-template-rows: auto minmax(24rem, 1fr) auto auto auto;
  padding: 1rem;
  box-shadow: var(--shadow-active);
}

.chart-header {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(16rem, 0.75fr);
  gap: 1rem;
  align-items: end;
  padding: 0.2rem 0.2rem 0.75rem;
}

.chart-header h2,
.section-heading h2,
.method-copy h2 {
  font-size: clamp(1.65rem, 2.25vw, 2.45rem);
  font-weight: 850;
}

.chart-header p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.5;
}

.chart-wrap {
  position: relative;
  min-height: 24rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgb(12 124 113 / 0.08), transparent 32%),
    linear-gradient(to right, rgb(24 32 36 / 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(24 32 36 / 0.05) 1px, transparent 1px),
    var(--chart-paper);
  background-size: 100% 100%, 4rem 4rem, 4rem 4rem, auto;
  overflow: hidden;
}

.chart-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 74%, rgb(249 251 251 / 0.82));
}

.market-chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 24rem;
  position: relative;
  z-index: 1;
}

.axis-line {
  stroke: var(--ink);
  stroke-width: 2;
}

.grid-line {
  stroke: #dfe5e8;
  stroke-width: 1;
}

.axis-label,
.tick-label,
.curve-label,
.point-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.axis-label {
  fill: var(--ink);
  font-size: 13px;
}

.curve {
  fill: none;
  stroke-linecap: round;
  stroke-width: 4;
}

.curve-demand {
  stroke: var(--demand);
}

.curve-before {
  stroke: var(--before);
  stroke-dasharray: 8 8;
  opacity: 0.82;
}

.curve-after {
  stroke: var(--after);
  stroke-width: 5;
}

.curve-after-full {
  stroke: var(--after);
  stroke-width: 2.5;
  opacity: 0.35;
  stroke-dasharray: 5 9;
}

.supply-band {
  fill: rgb(213 95 59 / 0.1);
  stroke: none;
}

.equilibrium-guide {
  stroke: rgb(24 32 36 / 0.28);
  stroke-dasharray: 5 6;
}

.equilibrium-guide-active {
  stroke: rgb(213 95 59 / 0.48);
}

.point-before {
  fill: var(--before);
}

.point-after {
  fill: var(--after);
}

.point-full {
  fill: var(--paper);
  stroke: var(--after);
  stroke-width: 2;
}

.shock-ring {
  fill: none;
  stroke: var(--after);
  stroke-width: 2;
  opacity: 0.45;
}

.delta-arrow {
  stroke: var(--after);
  stroke-width: 2.5;
  marker-end: url(#arrow-head);
}

.delta-fill {
  fill: rgb(213 95 59 / 0.08);
  stroke: rgb(213 95 59 / 0.32);
}

.full-shock-guide {
  stroke: rgb(213 95 59 / 0.35);
  stroke-dasharray: 4 7;
}

.curve-label-active,
.point-label-active {
  fill: var(--after);
}

.chart-badge {
  fill: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.model-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.95fr);
  gap: 1rem;
  align-items: center;
  padding: 0.9rem 0.2rem 0;
}

.lens-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.lens-button,
.run-button {
  min-height: 2.25rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 850;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.lens-button:hover,
.run-button:hover {
  border-color: rgb(12 124 113 / 0.36);
  color: var(--ink);
  transform: translateY(-1px);
}

.lens-button[aria-pressed="true"],
.run-button {
  border-color: rgb(12 124 113 / 0.38);
  background: rgb(12 124 113 / 0.1);
  color: var(--accent-strong);
}

.shock-control {
  display: grid;
  grid-template-columns: auto minmax(10rem, 1fr);
  gap: 0.9rem;
  align-items: center;
}

.progress-control {
  display: grid;
  gap: 0.3rem;
}

.progress-control span {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lens-readout {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
  margin-top: 0.8rem;
  padding: 0.85rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: rgb(12 124 113 / 0.07);
}

.lens-readout span {
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.lens-readout strong {
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.45;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  margin-top: 0.9rem;
}

.result-grid div {
  min-width: 0;
  padding: 1rem 0.8rem 0.2rem;
  border-right: 1px solid var(--line);
}

.result-grid div:last-child {
  border-right: 0;
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-grid strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--ink);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.inspector-section h2 {
  margin-bottom: 0.75rem;
  font-size: clamp(1.35rem, 2vw, 2rem);
  font-weight: 850;
}

.inspector-section p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.value-bars {
  display: grid;
  gap: 0.8rem;
}

.value-bar {
  display: grid;
  gap: 0.35rem;
}

.value-bar-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.value-bar-track {
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf0;
}

.value-bar-fill {
  height: 100%;
  width: var(--bar-value);
  border-radius: inherit;
  background: var(--bar-color, var(--accent));
  transform-origin: left center;
  transition: width 220ms ease;
}

.bundle-list {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.bundle-list li {
  padding-left: 0.85rem;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.bundle-list strong {
  display: block;
  margin-bottom: 0.12rem;
  color: var(--ink);
}

.path-stack {
  display: grid;
  gap: 0.45rem;
}

.path-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.path-row:last-child {
  border-bottom: 0;
}

.path-row span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 760;
}

.path-row strong {
  color: var(--ink);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.market-strip,
.method-section {
  max-width: 94rem;
  margin: 1rem auto 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.market-strip {
  padding: clamp(1.1rem, 2vw, 1.5rem);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1rem;
}

.section-heading h2 {
  max-width: 17ch;
}

.comparison-table-wrap {
  overflow-x: auto;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 54rem;
}

.comparison-table th,
.comparison-table td {
  padding: 1rem 0.85rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.comparison-table th {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.comparison-table td {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.comparison-table strong {
  color: var(--ink);
}

.method-section {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(18rem, 0.65fr);
  gap: clamp(1.5rem, 3vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2rem);
}

.method-copy p:not(.eyebrow) {
  max-width: 60rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.source-list {
  display: grid;
  gap: 0.6rem;
  align-content: start;
}

.source-list a {
  display: block;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent-strong);
  background: #fbfcfc;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.source-list a:hover {
  border-color: rgb(12 124 113 / 0.4);
  background: rgb(12 124 113 / 0.07);
}

@media (max-width: 1180px) {
  .simulator-shell {
    grid-template-columns: minmax(17rem, 0.75fr) minmax(0, 1.55fr);
  }

  .inspector-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  main {
    padding-inline: 1rem;
  }

  .app-intro,
  .simulator-shell,
  .chart-header,
  .method-section {
    grid-template-columns: 1fr;
  }

  .app-intro h1 {
    max-width: 100%;
  }

  .inspector-panel {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    grid-template-rows: auto auto auto;
  }

  .model-toolbar,
  .shock-control,
  .lens-readout {
    grid-template-columns: 1fr;
  }

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

  .result-grid div:nth-child(2n) {
    border-right: 0;
  }

  .result-grid div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding-inline: 1rem;
  }

  .brand span:last-child {
    max-width: 11rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-nav a {
    padding-inline: 0.65rem;
  }

  .app-intro h1 {
    font-size: clamp(2rem, 11vw, 3.05rem);
  }

  .chart-panel,
  .control-block,
  .inspector-section,
  .market-strip,
  .method-section {
    border-radius: 6px;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-grid div,
  .result-grid div:nth-child(2n) {
    border-right: 0;
  }

  .result-grid div + div {
    border-top: 1px solid var(--line);
  }

  .lens-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lens-button,
  .run-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .curve,
  .equilibrium-guide,
  .delta-arrow,
  .delta-fill,
  .full-shock-guide,
  .market-chart circle,
  .lens-readout,
  .preset-button,
  .value-bar-fill {
    transition: 220ms ease;
  }

  .curve-after {
    animation: curve-flare 520ms ease both;
  }

  .shock-ring {
    animation: shock-pulse 1600ms ease-out infinite;
  }

  .point-after {
    animation: point-pop 420ms ease both;
  }
}

@keyframes shock-pulse {
  0% {
    r: 8;
    opacity: 0.55;
  }

  70% {
    r: 25;
    opacity: 0;
  }

  100% {
    r: 25;
    opacity: 0;
  }
}

@keyframes point-pop {
  from {
    opacity: 0.2;
  }

  to {
    opacity: 1;
  }
}

@keyframes curve-flare {
  from {
    opacity: 0.28;
  }

  to {
    opacity: 1;
  }
}
