:root {
  --paper: #fffefb;
  --page: #f7f5ef;
  --ink: #203129;
  --muted: #66756e;
  --rule: #d8ded7;
  --accent: #2f6b4f;
  --accent-soft: #e7f0ea;
  --rust: #a94f2a;
  --blue: #496e87;
  --amber: #986b22;
}

* { box-sizing: border-box; }

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

body {
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

.demo-shell {
  height: 100svh;
  min-height: 600px;
  padding: 16px 22px 10px;
  background: var(--paper);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
}

.masthead { display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.eyebrow, .method-kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.masthead h1 { margin: 0; font-size: clamp(24px, 2.3vw, 32px); line-height: 1.05; }

.back-link {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--rule);
  background: #fff;
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-family: inherit;
  font-size: .8em;
}

.method-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 7px; border-bottom: 1px solid var(--rule); }

.method-tabs a {
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.method-tabs a span { margin-right: 6px; color: #8b9690; font-size: 10px; letter-spacing: .1em; }
.method-tabs a:hover { background: var(--accent-soft); color: var(--ink); }
.method-tabs a[aria-current="page"] { background: var(--ink); color: #fff; }
.method-tabs a[aria-current="page"] span { color: #b9d3c3; }

.lab-grid { display: grid; }

.stage-card, .control-rail {
  border: 1px solid var(--rule);
  background: #fff;
}

.stage-card { display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 10px 12px 10px; gap: 6px; }

.stage-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; min-height: 22px; }

.stage-bar h2 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status { margin: 0; color: var(--ink); font-size: 13px; font-weight: 600; text-align: right; }
.status.warn { color: var(--rust); }

.canvas-wrap { position: relative; min-height: 0; }

canvas#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: #fbfaf6;
}

.control-rail { display: flex; flex-direction: column; gap: 10px; padding: 13px 15px 12px; }

.method-copy h2 { margin: 0 0 4px; font-family: Georgia, "Times New Roman", serif; font-size: 21px; line-height: 1.1; }
.method-copy p:last-child { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.controls { display: grid; gap: 8px; }

.range-label { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 700; }
.range-label output { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 700; color: var(--accent); }
.controls input[type="range"] { width: 100%; margin: 2px 0 0; accent-color: var(--accent); }

.segmented { display: flex; gap: 4px; }

.segmented button {
  flex: 1;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.button-row { display: flex; gap: 6px; }

.button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.button.primary { flex: 1; background: var(--accent); color: #fff; }
.button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.button:disabled { opacity: .45; cursor: default; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }

.metrics > div { padding: 6px 8px; border-radius: 7px; background: var(--accent-soft); min-width: 0; }

.metrics dt { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metrics dd { margin: 2px 0 0; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.metrics dd small { color: var(--muted); font-size: 11px; font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: auto; color: var(--muted); font-size: 11.5px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.legend i.dot { width: 9px; height: 9px; border-radius: 50%; }
.legend i.ring { width: 9px; height: 9px; border-radius: 50%; background: transparent !important; border: 2px solid currentColor; }
.legend i.dash { height: 0; border-top: 2px dashed currentColor; background: transparent !important; }

.demo-footer { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; }
.demo-footer p { margin: 0; }

button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(47, 107, 79, .45); outline-offset: 2px; }

.fallback { max-width: 760px; margin: 40px auto; padding: 0 20px; line-height: 1.5; }

html.is-bento-embedded .demo-shell { min-height: 0; }
html.is-bento-embedded .control-rail { padding: 11px 13px 10px; gap: 8px; }

@media (max-width: 800px) {
  .demo-shell { height: auto; overflow: visible; }
  .stage-bar { flex-direction: column; gap: 2px; }
  .status { text-align: left; }
  .canvas-wrap { height: 70vw; min-height: 300px; }
  .demo-footer { flex-direction: column; }
}
