:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --code-bg: #f1f3f5;
  --text: #1b1f23;
  --muted: #5f6b76;
  --line: #dde1e5;
  --accent: #128c5e;
  --accent-soft: #e3f4ec;
  --danger: #c4372f;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #181c1f;
    --code-bg: #0d1012;
    --text: #e3e7ea;
    --muted: #93a0ab;
    --line: #2a3035;
    --accent: #3ccf91;
    --accent-soft: #163428;
    --danger: #ff7b72;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.bar h1 { margin: 0; font-size: 17px; font-weight: 650; }
.bar { gap: 12px; }
.views { display: flex; gap: 4px; margin-right: auto; }
.views button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.views button:hover { color: var(--text); background: var(--code-bg); }
.views button.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }


main { max-width: 1280px; margin: 0 auto; padding: 16px; }

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

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--code-bg); color: var(--text); border-color: var(--line); }
.icon-button:active { transform: translateY(1px); }
.icon-button svg { width: 16px; height: 16px; }
.icon-button .i-done { display: none; }
.icon-button.done { color: var(--accent); }
.icon-button.done .i-copy { display: none; }
.icon-button.done .i-done { display: block; }

.pick { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.pick label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.pick select, .pick input {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 14px;
}
.pick input { font-family: var(--mono); font-size: 13px; }

.grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 14px; align-items: start; }

.pane {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.signature { display: block; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

.pane-head { display: flex; align-items: center; gap: 8px; margin: 12px 0 6px; }
.pane-head .label { font-size: 12px; color: var(--muted); }
.status { flex: 1; min-width: 0; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }

select:focus, input:focus-visible, .pick input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

details summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 6px 0; }
.request-json { margin-top: 12px; }

/* The request form: a row per field, its input under it, a message nested in a group. */
.fields { list-style: none; margin: 0; padding: 0; }
.frow { padding: 6px 0; border-top: 1px solid var(--line); }
.fhead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; cursor: pointer; }
.fhead input { margin: 0; accent-color: var(--accent); }
.fname { font-family: var(--mono); font-size: 13px; }
.ftype { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.oneof {
  padding: 0 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
}
.fcontrol { display: grid; gap: 2px; margin: 6px 0 2px 24px; min-width: 0; }
.finput {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 13px;
}
.finput.invalid { border-color: var(--danger); }
.ferror { color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.ferror:empty { display: none; }
.switch {
  appearance: none;
  position: relative;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.group { margin: 4px 0 2px 9px; padding-left: 14px; border-left: 2px solid var(--line); }
.group > .fields > .frow:first-child { border-top: 0; }
.flist { margin-left: 24px; }
.flist ul { list-style: none; margin: 0; padding: 0; }
.fitem { display: flex; align-items: flex-start; gap: 4px; margin-top: 6px; }
.fitem > :first-child { flex: 1; min-width: 0; }
.fitem .fcontrol { margin: 0; }
.fitem .group { margin-left: 0; }

.tabs { display: flex; gap: 4px; margin-bottom: 10px; overflow-x: auto; }
.tabs button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button:hover { color: var(--text); background: var(--code-bg); }
.tabs button.active { color: var(--text); background: var(--code-bg); border-color: var(--line); font-weight: 600; }

.code { position: relative; }
.code .copy { position: absolute; top: 6px; right: 6px; background: var(--surface); border-color: var(--line); }
pre {
  margin: 0;
  padding: 12px 44px 12px 12px;
  border-radius: 6px;
  background: var(--code-bg);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  tab-size: 4;
}
#snippet-pane.stale pre { opacity: 0.45; }
main, #guide-view, #builder-view { min-width: 0; }
.stubs { margin-top: 10px; }

/* Get started */
.guide-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; margin-bottom: 16px; }
.guide-controls .tabs { margin-bottom: 0; }
.segmented { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.segmented button {
  padding: 5px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.guide-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 880px; }
.step { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 16px; }
.step .n {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  font-size: 12px;
  font-weight: 650;
}
.step p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.step figure { margin: 10px 0 0; min-width: 0; }
.step figcaption { margin-bottom: 4px; color: var(--muted); font-size: 12px; }

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

@media (max-width: 560px) {
  .pick { grid-template-columns: 1fr 1fr; }
  .pick label:last-child { grid-column: 1 / -1; }
  .step { padding: 12px; }
}
.step p, .step figcaption { overflow-wrap: anywhere; }
