/* Developer portal (WS6 §4). Daylight/Afterlight tokens from app-tokens.css
 * (a copy of src/styles/app-tokens.css; the portal test checks they match).
 * Same visual system as /contribute: canvas, surface cards, text-coloured
 * selection, the accent only for actions (buttons, links, focus). */

html { background: var(--app-canvas); }
body {
  margin: 0;
  background: var(--app-canvas);
  color: var(--app-text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left));
}
main { max-width: 760px; }
main:focus { outline: none; }
main:has(.docs) { max-width: none; }

a { color: var(--app-accent); }
code, .mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .88em; }
:not(pre) > code { background: var(--app-surface); padding: 1px 5px; border-radius: 6px; overflow-wrap: anywhere; }
.card :not(pre) > code, .notice :not(pre) > code { background: var(--app-canvas); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 10;
  background: var(--app-text); color: var(--app-canvas);
  padding: 10px 14px; border-radius: 10px; text-decoration: none; font-weight: 600;
}
.skip:focus { top: 12px; }

/* Header */
.top { display: flex; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 28px; }
.brand { display: inline-flex; gap: 8px; align-items: center; min-height: 44px; font-weight: 700; color: var(--app-text); text-decoration: none; margin-right: auto; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.brand-sub { font-weight: 400; color: var(--app-secondary); }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a, .nav .ghost { color: var(--app-text); text-decoration: none; font-size: 15px; min-height: 44px; display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 10px; font-weight: 500; }
.nav a[aria-current="page"] { background: var(--app-surface); font-weight: 600; }
.nav .nav-cta { color: var(--app-accent); font-weight: 600; }
.look { display: inline-flex; background: var(--app-surface); border-radius: 999px; padding: 3px; }
.look button {
  border: 0; background: none; color: var(--app-secondary); font: inherit; font-size: 13px;
  min-height: 34px; min-width: 44px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
}
.look button[aria-pressed="true"] { background: var(--app-canvas); color: var(--app-text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); font-weight: 600; }

/* Type */
.eyebrow { font-size: 13px; font-weight: 600; color: var(--app-secondary); margin: 0; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.4px; margin: 4px 0 8px; }
.lede { color: var(--app-secondary); margin: 0 0 20px; font-size: 17px; max-width: 60ch; }
.section-title { font-size: 18px; margin: 28px 0 10px; }
.small, .meta { font-size: 13px; color: var(--app-secondary); }
.optional { font-weight: 400; color: var(--app-secondary); }
.empty { color: var(--app-secondary); background: var(--app-surface); border-radius: 14px; padding: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Hero */
.hero { padding: 8px 0 12px; }
.hero h1 { font-size: 34px; max-width: 18ch; }
.soon { background: var(--app-surface); border-radius: 16px; padding: 16px 18px; margin: 0 0 16px; border-left: 4px solid var(--app-live); }
.soon h2 { font-size: 17px; margin: 0 0 4px; }
.soon p { margin: 0 0 6px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 8px; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 14px; border: 0;
  background: var(--app-accent); color: var(--app-on-accent);
  font: inherit; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button-quiet { background: var(--app-surface); color: var(--app-text); }
.button-small { min-height: 40px; padding: 6px 14px; font-size: 14px; border-radius: 12px; }
.ghost { background: none; border: 0; color: var(--app-accent); font: inherit; font-size: 15px; font-weight: 600; min-height: 44px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.danger { color: var(--app-destructive); }
.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 2px; }
.button:focus-visible { outline: 3px solid var(--app-text); outline-offset: 3px; }

/* Cards */
.card { background: var(--app-surface); border-radius: 16px; padding: 18px 18px; margin: 0 0 12px; min-width: 0; }
.card h2 { font-size: 17px; margin: 0 0 8px; }
.cards { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin: 12px 0; }
.grid-2 .card { margin: 0; }
.pairs { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 8px; align-items: baseline; }
.pairs dt { font-weight: 700; font-variant-numeric: tabular-nums; }
.pairs dd { margin: 0; color: var(--app-secondary); }
.attribution .attr-line { font-weight: 600; font-size: 18px; background: var(--app-canvas); border-radius: 12px; padding: 10px 14px; display: inline-block; margin: 0 0 6px; }

.endpoints { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.endpoints a { display: grid; gap: 2px; background: var(--app-surface); border-radius: 14px; padding: 12px 14px; color: var(--app-text); text-decoration: none; min-height: 100%; }
.endpoints code { background: none !important; padding: 0 !important; color: var(--app-secondary); font-size: 13px; }
.endpoints .ep-name { font-weight: 600; }
.endpoints .ep-text { font-size: 14px; color: var(--app-secondary); }

/* Apps and keys */
.app-head, .key-head { display: flex; align-items: baseline; gap: 6px 10px; flex-wrap: wrap; }
.app h2, .usage h2 { margin: 0; font-size: 18px; }
.row-actions { display: flex; gap: 8px 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.keys { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 10px; }
.key { background: var(--app-surface); border-radius: 14px; padding: 14px 16px; }
.key-off { opacity: .6; }
.key-name { font-weight: 600; }
.key-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 6px 16px; margin: 10px 0 0; font-size: 14px; }
.key-meta .wide { grid-column: 1 / -1; }
.key-meta dt { font-size: 12px; color: var(--app-secondary); }
.key-meta dd { margin: 0; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--app-separator); color: var(--app-secondary); }
.badge-ok { color: var(--app-success); border-color: currentColor; }
.badge-warn { color: var(--app-live); border-color: currentColor; }
.badge-off { color: var(--app-secondary); }

.once { background: var(--app-surface); border-radius: 16px; padding: 18px; margin: 8px 0 12px; border: 2px solid var(--app-text); }
.once p { margin: 0 0 12px; }
.key-reveal { display: flex; gap: 8px; flex-wrap: wrap; }
.key-reveal .input { flex: 1 1 280px; font-size: 15px; }

/* Forms */
.form-card form { display: grid; gap: 4px; }
.form-card .button { margin-top: 12px; justify-self: start; }
.input, .textarea {
  width: 100%; min-height: 48px; background: var(--app-canvas); color: var(--app-text);
  border: 1px solid var(--app-separator); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 17px;
}
select.input { appearance: auto; }
.input-small { width: auto; min-height: 40px; padding: 6px 10px; font-size: 15px; max-width: 120px; }
.textarea { resize: vertical; min-height: 72px; }
.input::placeholder, .textarea::placeholder { color: var(--app-secondary); opacity: 1; }
.input:focus-visible, .textarea:focus-visible { outline: 2px solid var(--app-accent); outline-offset: 1px; border-color: transparent; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--app-destructive); }
.q { display: block; font-size: 14px; color: var(--app-secondary); margin: 10px 0 4px; padding: 0; }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field-err { margin: 4px 0 0; font-size: 14px; color: var(--app-destructive); }
.hint { margin: 4px 0 0; font-size: 13px; color: var(--app-secondary); }
.warn { font-size: 14px; background: var(--app-canvas); border-radius: 12px; padding: 10px 12px; border-left: 3px solid var(--app-live); margin: 8px 0 0; }
.prose .warn { background: var(--app-surface); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.radio { position: relative; }
.radio input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio span { display: inline-flex; align-items: baseline; gap: 6px; min-height: 44px; padding: 10px 16px; background: var(--app-canvas); color: var(--app-text); border: 1px solid var(--app-separator); border-radius: 999px; font-size: 15px; }
.radio small { font-size: 12px; opacity: .75; }
.radio input:checked + span { background: var(--app-text); color: var(--app-canvas); border-color: var(--app-text); }
.radio input:focus-visible + span { outline: 2px solid var(--app-accent); outline-offset: 2px; }

/* Notices */
.notice { border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; font-size: 15px; background: var(--app-surface); }
.notice-ok { border-left: 4px solid var(--app-success); }
.notice-error { border: 1.5px solid var(--app-destructive); background: var(--app-canvas); }
.notice-info { border-left: 4px solid var(--app-live); }

/* Usage charts: small multiples, one measure each, one axis each. */
.charts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); margin-top: 12px; }
.chart { margin: 0; background: var(--app-canvas); border-radius: 12px; padding: 10px 12px 8px; }
.chart figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; color: var(--app-secondary); margin-bottom: 4px; }
.chart-title { font-weight: 600; color: var(--app-text); }
.chart-total { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--app-text); font-size: 15px; }
.chart-plot { position: relative; }
.chart-plot svg { display: block; width: 100%; height: 96px; overflow: visible; }
.chart-ymax { position: absolute; right: 0; top: -2px; font-size: 11px; color: var(--app-secondary); background: var(--app-canvas); padding-left: 4px; font-variant-numeric: tabular-nums; }
.chart-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--app-secondary); margin-top: 2px; }
.chart .grid { stroke: var(--app-separator); stroke-width: 1; stroke-dasharray: 2 3; vector-effect: non-scaling-stroke; }
.chart .axis { stroke: var(--app-separator); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .bar-ink { fill: var(--app-secondary); }
.chart .bar-alert { fill: var(--app-destructive); }
.chart .hit { fill: transparent; }
.chart .col:hover .bar { fill: var(--app-text); }
.table-view { margin-top: 10px; font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--app-accent); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }

/* Tables */
.table-scroll { overflow-x: auto; margin: 8px 0 16px; border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--app-separator); }
thead th { font-size: 12px; color: var(--app-secondary); font-weight: 600; }
td { font-variant-numeric: tabular-nums; }
.stat .big { font-size: 28px; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.stat .of { font-size: 15px; font-weight: 400; color: var(--app-secondary); }

/* Docs */
.docs { display: grid; gap: 24px; }
.toc { background: var(--app-surface); border-radius: 14px; padding: 12px 16px; font-size: 14px; align-self: start; }
.toc-title { font-weight: 600; margin: 0 0 4px; }
.toc ol { margin: 0; padding-left: 18px; }
.toc ol ol { padding-left: 14px; }
.toc a { color: var(--app-text); display: inline-block; padding: 3px 0; }
.toc code { background: none !important; padding: 0 !important; }
.prose { min-width: 0; max-width: 780px; }
.prose h2 { font-size: 22px; margin: 32px 0 8px; scroll-margin-top: 16px; }
.prose h3 { font-size: 19px; margin: 32px 0 8px; padding-top: 16px; border-top: 1px solid var(--app-separator); scroll-margin-top: 16px; }
.prose h4 { font-size: 16px; margin: 20px 0 6px; scroll-margin-top: 16px; }
.prose p, .prose li { max-width: 72ch; }
.prose li { margin: 4px 0; }
.code { background: var(--app-surface); color: var(--app-text); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.card .code { background: var(--app-canvas); }
.terms li { margin: 10px 0; }
.narrow { max-width: 680px; }

.foot { margin-top: 40px; font-size: 13px; color: var(--app-secondary); display: flex; gap: 0 16px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--app-separator); padding-top: 8px; }
.foot span { flex: 1 1 100%; padding: 8px 0; }
.foot a { color: var(--app-secondary); min-height: 44px; display: inline-flex; align-items: center; }

@media (min-width: 900px) {
  .page { padding-top: 32px; }
  h1 { font-size: 34px; }
  .hero h1 { font-size: 44px; }
  .docs { grid-template-columns: 220px minmax(0, 1fr); }
  .toc { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .radio span, .look button { transition: background-color .15s, color .15s; }
}

@media (forced-colors: active) {
  .chart .bar { fill: CanvasText; }
  .chart .bar-alert { fill: Highlight; }
  .radio input:checked + span, .nav a[aria-current="page"] { outline: 2px solid CanvasText; }
}

/* Parameter / field names in the reference never break mid-word; the table scrolls instead. */
.reference td:first-child, .reference td:first-child code { white-space: nowrap; overflow-wrap: normal; }
