/* Theme tokens and page structure intentionally mirror ClimbingBoardGPT. */
:root {
  --base00: #1A1B26;
  --base01: #16161E;
  --base02: #2F3549;
  --base03: #444B6A;
  --base04: #787C99;
  --base05: #A9B1D6;
  --base07: #D5D6DB;
  --base08: #F7768E;
  --base0a: #0DB9D7;
  --base0b: #9ECE6A;
  --base0c: #B4F9F8;
  --base0d: #2AC3DE;
  --base0e: #BB9AF7;
  --base0f: #F7768E;
  --bg: var(--base00);
  --off-bg: var(--base01);
  --inner-bg: var(--base02);
  --fg: var(--base05);
  --off-fg: var(--base04);
  --muted: var(--base03);
  --link: var(--base0d);
  --hover: var(--base0c);
  --highlight: var(--base0a);
  --logo: var(--base0b);
  --danger: var(--base08);
  --border: rgba(120, 124, 153, 0.3);
  --sans: "Inter", sans-serif;
  --mono: "Fira Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6rem;
  background: var(--bg);
  color: var(--fg);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  max-width: 78rem;
  margin: 1rem auto 0;
  padding: 0 1rem;
}

.eyebrow {
  margin: 0;
  color: var(--logo);
  font-size: 1rem;
}

.site-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.site-header h1::before { content: none; }

.site-header p {
  margin: 0;
  color: var(--off-fg);
}

.health {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--highlight);
  white-space: nowrap;
  border: 1px solid var(--border);
  padding: 0.25rem 0.5rem;
  background: var(--inner-bg);
}

.layout {
  display: grid;
  grid-template-columns: 22rem minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "col-top   col-viewer"
    "col-info  col-viewer";
  gap: 2rem;
  padding: 2rem 1rem 1rem;
  max-width: 78rem;
  margin: 0 auto;
  align-items: start;
}

#col-top    { grid-area: col-top; }
#col-viewer { grid-area: col-viewer; }
#col-info   { grid-area: col-info; }

.controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card, .result-card {
  background: var(--off-bg);
  border: 1px solid var(--border);
  padding: 1rem;
}

.card h2, .result-card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

.card h2::before, .result-card h2::before { content: none; }

label {
  display: block;
  margin: 0.7rem 0;
  font-size: 0.82rem;
  color: var(--off-fg);
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.28rem;
  border: 1px solid var(--border);
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--fg);
  background: var(--inner-bg);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(137, 221, 255, 0.28);
  border-color: var(--hover);
}

button {
  width: 100%;
  border: 1px solid var(--link);
  padding: 0.68rem 0.9rem;
  margin-top: 0.4rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--link);
  cursor: pointer;
  font-family: var(--sans);
}

button:hover {
  border-color: var(--hover);
  background: var(--hover);
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

/* Keep the run control reachable while scrolling through the long parameter card. */
#mc-run-btn {
  position: sticky;
  bottom: 0.6rem;
  z-index: 5;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}

.card.collapsible > h2 {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.card.collapsible > h2::after {
  content: "▾";
  font-size: 2rem;
  color: var(--muted);
  margin-left: auto;
  padding-left: 0.5rem;
  flex-shrink: 0;
}

.card.collapsible.collapsed > h2::after { content: "▸"; }
.card.collapsible > h2:hover::after { color: var(--off-fg); }
.card.collapsible.collapsed > *:not(h2) { display: none; }

.field-help {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--fg);
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

input[type="range"] {
  padding: 0;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--inner-bg);
  border: 1px solid var(--border);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--link);
  border-radius: 50%;
  cursor: pointer;
}

.range-row {
  display: flex;
  gap: 0.55rem;
  align-items: center;
}

.range-row input[type="range"] { flex: 1; }

.range-row input[type="number"] {
  width: 7.5rem;
  flex-shrink: 0;
  -moz-appearance: textfield;
}

.range-row input[type="number"]::-webkit-inner-spin-button,
.range-row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.note p, .small {
  color: var(--off-fg);
  font-size: 0.82rem;
  line-height: 1.45;
}

.note p:first-of-type { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }

.result-header {
  text-align: center;
  margin-bottom: 0.85rem;
}

.result-header h2 { margin-bottom: 0.25rem; }

.result-header p {
  margin: 0;
  color: var(--off-fg);
  font-size: 0.84rem;
}

.headline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  max-width: 820px;
  margin: 0 auto 1rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.6rem 0.4rem;
  border: 1px solid var(--border);
  background: var(--inner-bg);
  text-align: center;
}

.tile-num {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--highlight);
  line-height: 1.1;
  white-space: nowrap;
}

.tile-lab {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--fg);
  margin-top: 0.2rem;
}

.tile-sub {
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 0.1rem;
  line-height: 1.25;
}

.result-note {
  max-width: 760px;
  margin: 0 auto 0.85rem;
  color: var(--off-fg);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
}

.chart-stage {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  min-height: 420px;
  border: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
}

.chart-stage .js-plotly-plot { width: 100% !important; }

.warning-box {
  margin: 0.7rem auto 0.85rem;
  max-width: 760px;
  border: 1px solid rgba(255, 203, 107, 0.55);
  background: rgba(255, 203, 107, 0.12);
  color: var(--highlight);
  padding: 0.65rem 0.8rem;
  font-size: 0.8rem;
  text-align: left;
  white-space: pre-line;
}

.advanced-opts {
  margin-top: 0.9rem;
}

.advanced-opts summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
  user-select: none;
}

.advanced-opts summary:hover { color: var(--highlight); }

.method-note {
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  color: var(--off-fg);
  font-size: 0.8rem;
  line-height: 1.45;
}

.method-note ol {
  margin: 0.65rem 0 0.45rem;
  padding-left: 1.25rem;
}

.method-note li + li { margin-top: 0.32rem; }
.method-note p { margin: 0.45rem 0 0; }
.method-note strong { color: var(--fg); }

.explain dl { margin: 0; }

.explain dt {
  color: var(--highlight);
  font-size: 0.78rem;
  margin-top: 0.75rem;
}

.explain dt:first-child { margin-top: 0; }

.explain dd {
  margin: 0.22rem 0 0;
  color: var(--off-fg);
  font-size: 0.78rem;
  line-height: 1.45;
}

.explain p {
  color: var(--off-fg);
  font-size: 0.82rem;
  line-height: 1.45;
}

.explain p:first-of-type { margin-top: 0; }
.explain p:last-child { margin-bottom: 0; }

.link-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--off-fg);
  font-size: 0.82rem;
  line-height: 1.6;
}

.link-list li::marker {
  content: '·\00A0\00A0';
  color: var(--muted);
}

.json-block {
  margin-top: 1rem;
  color: var(--off-fg);
}

.json-block summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--muted);
}

.json-block summary:hover { color: var(--highlight); }

.json-block pre {
  overflow: auto;
  max-height: 300px;
  padding: 1rem;
  background: var(--inner-bg);
  color: var(--off-fg);
  border: 1px solid var(--border);
  font-size: 0.76rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  max-width: 78rem;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
  color: var(--off-fg);
  font-size: 0.82rem;
}

.site-footer a, .link-list a {
  color: var(--link);
  transition: color 0.15s ease;
}

.site-footer a:hover, .link-list a:hover { color: var(--hover); }

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "col-top"
      "col-viewer"
      "col-info";
  }

  .site-header { flex-direction: column; }
  .headline { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .headline { grid-template-columns: 1fr; }
  .range-row { align-items: stretch; flex-direction: column; }
  .range-row input[type="number"] { width: 100%; }
}
