/* Dual-Power Model Visualization */

:root {
  --bg: #ffffff;
  --ink: #14161a;
  --subtle: #5c6169;
  --rule: #dedbd5;
  --field: #8e8a84;
  --wash: #f6f5f2;
  --invalid: #c62828;
  --backdrop: rgba(20, 22, 26, 0.45);
  --shadow: 0 12px 32px rgba(20, 22, 26, 0.18);
  --radius: 4px;
  --font-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}

/* --- Base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: clamp(16px, 0.45vw + 0.78rem, 19px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
input.dash-input.param-input:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* --- Buttons --- */

.info-btn,
.param-btn,
.preset-btn {
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: var(--bg);
  font-weight: 600;
}

.info-btn,
.param-btn {
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  line-height: 1;
}

.info-btn:hover,
.param-btn:hover,
.preset-btn:hover {
  background: var(--wash);
}

.info-btn:active,
.param-btn:active,
.preset-btn:active {
  background: var(--rule);
}

/* --- Page --- */

.app {
  max-width: 92rem;
  margin: 0 auto;
  padding: 1.1rem 2rem 1.25rem;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

/* --- Zones: one column, in the order plot, controls, caption, model --- */

.zones {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.4rem;
  max-width: 44rem;
  margin: 0 auto;
}

.plot {
  min-width: 0;
  height: 21rem;
}

.controls,
.caption,
.model {
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}

/* --- Zones: plot and caption left, model in the middle, controls right --- */

@media (min-width: 1240px) {
  .zones {
    grid-template-columns: minmax(0, 1fr) 24.5rem 14.7rem;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "plot model controls"
      "caption model controls";
    gap: 1.1rem 0;
    max-width: none;
  }

  .plot {
    grid-area: plot;
    height: 23rem;
  }

  .caption {
    grid-area: caption;
    padding-top: 0;
    border-top: 0;
  }

  .model {
    grid-area: model;
  }

  .controls {
    grid-area: controls;
  }

  .model,
  .controls {
    margin-left: 1.25rem;
    padding-top: 0;
    padding-left: 1.25rem;
    border-top: 0;
    border-left: 1px solid var(--rule);
  }
}

/* --- Caption --- */

.caption {
  font-size: 0.82rem;
  line-height: 1.6;
}

.caption p {
  max-width: 64ch;
}

.caption strong {
  font-weight: 600;
}

/* --- Parameter symbols: each wears the color of the system it shapes --- */

.sym {
  font-weight: 600;
}

.sym-weight {
  color: var(--ink);
}

.sym-positive {
  color: var(--sym-positive);
}

.sym-negative {
  color: var(--sym-negative);
}

/* --- Section labels --- */

.section-label {
  margin: 1.3rem 0 0.5rem;
  color: var(--subtle);
  font-size: max(0.68rem, 11.5px);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model > .section-label:first-child,
.controls > .section-label:first-child {
  margin-top: 0;
}

/* --- Model --- */

.equation {
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow-x: auto;
}

.param-line {
  font-family: var(--font-mono);
  font-size: max(0.7rem, 12px);
  line-height: 1.6;
}

.readout {
  margin-top: 0.7rem;
}

.readout-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: 0.4rem;
  align-items: baseline;
  padding: 0.22rem 0;
  font-size: 0.78rem;
}

.readout-label {
  color: var(--subtle);
  text-wrap: balance;
}

.readout-value {
  font-family: var(--font-mono);
  font-weight: 600;
}

.readout-note {
  margin-top: 0.4rem;
  color: var(--subtle);
  font-size: max(0.66rem, 11px);
}

.profile {
  margin-bottom: 0.55rem;
}

.profile-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.82rem;
}

.profile-name {
  font-size: inherit;
  font-weight: 600;
}

.profile .param-line {
  margin-left: 1.1rem;
  color: var(--subtle);
}

.where {
  margin-top: 1.3rem;
  border-top: 1px solid var(--rule);
}

.where > .section-label {
  margin-top: 1rem;
}

.legend-list {
  padding: 0;
  list-style: none;
  color: var(--subtle);
  font-size: 0.78rem;
}

.legend-list li {
  padding: 0.05rem 0;
}

.legend-list strong {
  margin-right: 0.15rem;
  color: var(--ink);
  font-weight: 600;
}

/* --- Controls --- */

.param {
  margin-bottom: 0.7rem;
}

.param-label {
  display: block;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.param-symbol {
  margin-right: 0.45rem;
  font-size: 0.98rem;
  font-weight: 600;
}

.param-desc {
  color: var(--subtle);
  font-size: 0.8rem;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.param-bound {
  color: var(--subtle);
  font-size: max(0.7rem, 11.5px);
}

/* These selectors, and the focus ring's above, outrank the outline rules Dash ships for its inputs */

input.dash-input.param-input {
  width: 3.9rem;
  height: 1.8rem;
  padding: 0 0.25rem;
  border: 1px solid var(--field);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}

input.dash-input.param-input::-webkit-outer-spin-button,
input.dash-input.param-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input.dash-input.param-input:invalid {
  border-color: var(--invalid);
  outline: 2px solid var(--invalid);
  outline-offset: 2px;
}

.controls > .section-label ~ .section-label {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.presets {
  display: grid;
  gap: 0.4rem;
}

.preset-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  text-align: center;
}

.mode-custom #show-custom-button,
.mode-figure1 #show-figure1-button,
.mode-figure5 #show-figure5-button {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

/* --- Info window --- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: auto;
  padding: 1.25rem;
  background: var(--backdrop);
}

.modal-card {
  position: relative;
  max-width: 32rem;
  margin: 5rem auto 0;
  padding: 1.75rem 2rem 2rem;
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.modal-title {
  margin-bottom: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.modal-card p {
  color: var(--subtle);
  font-size: 0.86rem;
  line-height: 1.6;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--subtle);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close:hover {
  background: var(--wash);
  color: var(--ink);
}

/* --- Small screens --- */

@media (max-width: 480px) {
  .app {
    padding: 1rem 1.1rem 2rem;
  }

  .title {
    font-size: 1.05rem;
  }

  .plot {
    height: 17rem;
  }
}
