/* Gully developer hub. Gully Labs kit colours: navy #0E1C38, blue #3754A0, light blue #6F8DDF, ground #F1F3F8.
   Light / Dark / System: theme.js sets data-mode="light|dark" on <html> before first paint. */
:root {
  --ground: #f1f3f8; --surface: #ffffff; --ink: #0e1c38; --muted: #4a5878; --line: #d5dbe8; --accent: #3754a0; --on-accent: #ffffff;
  --code-bg: #0e1c38; --code-ink: #f1f3f8; --chip: #e3e8f4; --test: #7a4b00; --test-bg: #fdf0d5; --live: #1d5f3a; --live-bg: #dcf3e5; --try: #2b3f86; --try-bg: #dfe6fb;
  --radius: 10px; --tap: 36px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
html[data-mode="dark"] {
  --ground: #0b1529; --surface: #0e1c38; --ink: #f1f3f8; --muted: #aab6d3; --line: #26375f; --accent: #8fa8ee; --on-accent: #0b1529;
  --code-bg: #081021; --code-ink: #f1f3f8; --chip: #1b2c52; --test: #ffd993; --test-bg: #3d2c08; --live: #9fe3bb; --live-bg: #123523; --try: #c6d3fb; --try-bg: #1f2f63;
}
@media (max-width: 640px) { :root { --tap: 44px; } }
* { box-sizing: border-box; }
html { color-scheme: light; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
html[data-mode="dark"] { color-scheme: dark; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 16px/1.55 var(--font); overflow-x: hidden; }
a { color: var(--accent); text-underline-offset: 2px; }
code, pre { font-family: var(--mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 12px 16px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
.muted { color: var(--muted); }
.ic { width: 22px; height: 22px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; color: var(--ink); flex: none; }
.brand img { display: block; height: 32px; width: auto; }
.brand-tag { font-weight: 650; font-size: 0.95rem; padding-left: 10px; border-left: 1px solid var(--line); }
.brand-dark { display: none !important; }
html[data-mode="dark"] .brand-dark { display: block !important; }
html[data-mode="dark"] .brand-light { display: none !important; }
.nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.nav-link { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 10px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 0.92rem; }
.nav-link:hover, .nav-link.is-active { color: var(--ink); background: var(--chip); }
.top-tools { display: flex; gap: 8px; flex: none; margin-left: auto; }
.btn, .icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.icon-btn { padding: 0; min-width: 44px; min-height: 44px; }
.btn:hover, .icon-btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-quiet { background: transparent; }
.icon-btn.nav-toggle { display: none; }
@media (max-width: 900px) {
  .icon-btn.nav-toggle { display: inline-flex; order: 3; }
  .top { flex-wrap: wrap; padding: 8px 12px; }
  .top-tools { order: 2; }
  .nav { order: 4; flex-basis: 100%; display: none; flex-direction: column; overflow: visible; padding-bottom: 8px; }
  .nav.is-open { display: flex; }
  .nav-link { min-height: 44px; font-size: 1rem; }
  .brand-tag { display: none; }
}

/* layout */
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 48px; }
main > section { margin: 0 0 36px; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); line-height: 1.15; margin: 8px 0 10px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; margin: 0 0 16px; }
.eyebrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.hero { padding: 20px 0 4px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.chip { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 999px; background: var(--chip); color: var(--ink); font-size: 0.78rem; font-weight: 650; white-space: nowrap; }
.chip-test { background: var(--test-bg); color: var(--test); }
.chip-live { background: var(--live-bg); color: var(--live); }
.chip-try { background: var(--try-bg); color: var(--try); }
.chip-soon { background: var(--chip); color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { display: flex; flex-direction: column; gap: 8px; padding: 16px; min-height: 168px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card-top { display: flex; flex-wrap: wrap; gap: 6px; }
.card-title { font-size: 1.1rem; }
.card-text { color: var(--muted); font-size: 0.95rem; flex: 1; }
.card-meta { font-size: 0.82rem; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 10px 14px; border-bottom: 1px solid var(--line); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tbody th { font-weight: 600; white-space: nowrap; }
td code { word-break: break-word; }
td a, tbody th a, .files a, .tool a, .facts a, .foot a { display: inline-block; padding: 4px 0; }
@media (max-width: 640px) { td a, tbody th a, .files a, .tool a, .facts a, .foot a { padding: 11px 0; } }
.tools, .files { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.tools { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tool { display: flex; flex-direction: column; gap: 6px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tool span { color: var(--muted); font-size: 0.93rem; }
.tool code { align-self: flex-start; background: var(--chip); padding: 3px 8px; border-radius: 6px; }

/* API page */
.api-head { padding-top: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 0; }
.facts div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.facts dt { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.facts dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel p { margin: 0 0 12px; }
.panel p:last-child { margin-bottom: 0; }
.panel .table-wrap { border-radius: 8px; }
.code { position: relative; }
.code pre, .try-out pre { margin: 0 0 12px; padding: 14px; background: var(--code-bg); color: var(--code-ink); border-radius: 8px; overflow-x: auto; white-space: pre; max-height: 420px; }
.code .copy { position: absolute; top: 6px; right: 6px; background: var(--surface); }
.code pre { padding-right: 92px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; min-width: 0; }
.field span { font-weight: 600; }
.field small { color: var(--muted); }
.field input, .field select, .search-input { min-height: 44px; width: 100%; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--ground); color: var(--ink); font: inherit; }
.try-form { display: grid; gap: 12px; }
.try-params { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.try-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.try-actions .btn { min-height: 44px; }
.try-url { overflow-wrap: anywhere; color: var(--muted); min-width: 0; }
.try-out { margin-top: 14px; }
.try-status { font-weight: 600; }
.ref { margin-left: -20px !important; margin-right: -20px !important; }
.ref-title { padding: 0 20px; }
.ref-wait { padding: 0 20px; }
#redoc { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); min-height: 240px; }
html[data-mode="dark"] #redoc { background: #0b1529; }
/* Redoc inside the hub: readable in dark mode and big enough to tap on phones */
html[data-mode="dark"] #redoc .redoc-wrap, html[data-mode="dark"] #redoc .api-content { background: #0b1529; color: var(--ink); }
html[data-mode="dark"] #redoc table, html[data-mode="dark"] #redoc td, html[data-mode="dark"] #redoc th { border-color: var(--line); }
html[data-mode="dark"] #redoc h1, html[data-mode="dark"] #redoc h2, html[data-mode="dark"] #redoc h3, html[data-mode="dark"] #redoc h5 { color: var(--ink); }
html[data-mode="dark"] #redoc button { color: inherit; }
#redoc .menu-content label[role="menuitem"] { min-height: 40px; align-items: center; }
#redoc table { overflow-wrap: anywhere; }
@media (max-width: 800px) {
  #redoc button, #redoc [role="button"], #redoc [role="tab"], #redoc .menu-content label[role="menuitem"], #redoc select { min-height: 44px; }
  #redoc a { display: inline-block; padding-top: 12px; padding-bottom: 12px; min-height: 44px; }
  #redoc h1 a, #redoc h2 a, #redoc h3 a, #redoc h5 a { padding: 0; min-width: 44px; min-height: 44px; }
}

/* search */
.search { width: min(720px, calc(100vw - 24px)); max-height: min(80vh, 640px); margin-top: 8vh; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); }
.search::backdrop { background: rgba(8, 16, 33, 0.55); }
.search-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.search-head .btn { min-height: 44px; }
.search-results { list-style: none; margin: 0; padding: 6px; }
.search-results a { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; min-height: 48px; padding: 6px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.search-results a:hover, .search-results a:focus-visible { background: var(--chip); }
.search-results code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-sum { grid-column: 2 / 4; color: var(--muted); font-size: 0.88rem; }
.search-api { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.search-empty { padding: 16px; margin: 0; color: var(--muted); }
.verb { font: 700 0.72rem var(--mono); padding: 3px 6px; border-radius: 5px; text-align: center; background: var(--chip); }
.verb-get { background: var(--live-bg); color: var(--live); }
.verb-post, .verb-put, .verb-patch { background: var(--try-bg); color: var(--try); }
.verb-delete { background: var(--test-bg); color: var(--test); }

.foot { max-width: 1180px; margin: 0 auto; padding: 8px 20px 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color: var(--muted); font-size: 0.88rem; }
.foot img { display: block; height: 36px; width: auto; }
.foot p { margin: 0; flex: 1; min-width: 240px; }
@media (prefers-reduced-motion: no-preference) { .card, .btn, .nav-link { transition: border-color 0.15s, background-color 0.15s; } }
html[data-mode="dark"] #redoc [role="tab"][aria-selected="true"] { color: #0e1c38; }
html[data-mode="dark"] #redoc h5 span, html[data-mode="dark"] #redoc h3 span { color: var(--muted); }
