@import url("/vendor/inter/inter.css");

/* ---- The auth wall ----
   The console's HTML is public — it is static files on a CDN and there is no server here to refuse a
   request. What must not happen is a signed-out visitor SITTING IN the dashboard while an API call
   decides their fate. console.js probes the session before it mounts anything and redirects on a 401;
   this keeps the shell out of sight until it does. The <noscript> in each page shows it again, because
   a reader without JS gets no dashboard either way and a blank page explains nothing.

   THIS IS THE SECOND LOCK. The first is an inline <style> in each console page's head, because an
   external sheet can lose the race to first paint — it did, in production, and the dashboard was
   briefly readable with this rule present but not yet applied.

   SCOPED VIA data-title, which only console shells carry. The reference pages load this stylesheet
   too and set data-mounted rather than data-authed, so an unscoped body rule would hide the
   documentation permanently. */
body:not([data-authed]):has(.shell[data-title]) { visibility: hidden; }


:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --primary: #286bfe;
  --primary-fg: #ffffff;
  --sandbox: #d97706;
  --muted: #666666;
  --faint: rgba(10, 10, 10, 0.45);
  --hair: rgba(10, 10, 10, 0.08);
  --hair-2: rgba(10, 10, 10, 0.14);
  --surface: rgba(10, 10, 10, 0.03);
  --surface-2: rgba(10, 10, 10, 0.05);
  --surface-3: rgba(10, 10, 10, 0.08);
  --green: #16a34a;
  --red: #dc2626;
  --sidebar-w: 256px;
  --gutter: 40px;
  --settle: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-optical-sizing: auto;
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; }
strong, b { font-weight: 500; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--hair);
  background: var(--bg);
  z-index: 30;
}
.sb-logo { height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--hair); }
.sb-logo img { height: 24px; width: auto; }
.sb-close { display: none !important; color: var(--faint); }

.sb-app { padding: 18px 24px 12px; }
.sb-back {
  display: inline-flex; color: var(--fg); text-decoration: none;
  margin-left: -4px; transition: opacity 160ms ease;
}
.sb-back:hover { opacity: 0.6; }
.sb-back svg { width: 22px; height: 22px; }
.sb-appname-h { margin: 8px 0 0; font-size: 1.1875rem; font-weight: 500; letter-spacing: -0.04em; }

.sb-nav { flex: 1; overflow-y: auto; padding: 16px 16px 12px; }
.sb-nav > ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 16px; border-radius: 9999px;
  color: rgba(10, 10, 10, 0.6); text-decoration: none;
  font-size: 1rem; font-weight: 400; font-family: inherit; text-align: left;
  border: 0; background: transparent; cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.sb-row:hover { background: var(--surface); color: var(--fg); }
.sb-row[aria-current="page"] { background: var(--surface-2); color: var(--fg); }
.sb-ico { display: inline-flex; flex: none; }
.sb-ico svg { width: 20px; height: 20px; }
.sb-caret { margin-left: auto; display: inline-flex; color: rgba(10, 10, 10, 0.4); transition: transform 220ms var(--settle); }
.sb-caret svg { width: 16px; height: 16px; }
.sb-group[data-open="true"] .sb-caret { transform: rotate(180deg); }
.sb-sub { list-style: none; margin: 6px 0 0; padding: 0; display: none; flex-direction: column; gap: 6px; }
.sb-group[data-open="true"] .sb-sub { display: flex; }
.sb-sub a {
  display: block; padding: 10px 16px 10px 32px; border-radius: 9999px;
  color: rgba(10, 10, 10, 0.6); text-decoration: none; font-size: 1rem; font-weight: 400;
  transition: background-color 160ms ease, color 160ms ease;
}
.sidebar[data-ctx] .sb-sub a { padding-left: 48px; }
.sb-sub a:hover { background: var(--surface); color: var(--fg); }
.sb-sub a[aria-current="page"] { background: var(--surface-2); color: var(--fg); }

.sb-veil { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 29; opacity: 0; visibility: hidden; transition: opacity 360ms var(--settle), visibility 0s linear 360ms; }

/* ---------- Main ---------- */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--hair);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--gutter);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.topbar .crumb { font-size: 0.875rem; color: var(--faint); display: flex; align-items: center; gap: 8px; }
.topbar .crumb b { color: var(--fg); font-weight: 500; }
.topbar .crumb .sep { opacity: 0.4; }
.topbar .spacer { flex: 1; }
.searchpill {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 16px;
  border-radius: 9999px; background: transparent; border: 1px solid rgba(10, 10, 10, 0.15); cursor: pointer;
  color: rgba(10, 10, 10, 0.4); font-family: inherit; font-size: 0.875rem;
  width: 100%; max-width: 320px; transition: background-color 160ms ease;
}
.searchpill:hover { background: var(--surface); }
.searchpill svg { width: 16px; height: 16px; color: currentColor; flex: none; }
.topnav { display: flex; align-items: center; gap: 28px; }
.topnav a { font-size: 0.875rem; font-weight: 500; color: var(--fg); text-decoration: none; transition: opacity 160ms ease; }
.topnav a:hover { opacity: 0.6; }
.topnav-item { position: relative; display: flex; align-items: center; }
.topnav-trigger { border: 0; background: transparent; cursor: pointer; font-family: inherit; font-size: 0.875rem; font-weight: 500; color: var(--fg); padding: 0; transition: opacity 160ms ease; }
.topnav-trigger:hover { opacity: 0.6; }
.topnav-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  background: #fff; border: 1px solid var(--hair); border-radius: 12px;
  box-shadow: 0 12px 32px -10px rgba(0, 0, 0, 0.24); padding: 6px; min-width: 168px;
  display: flex; flex-direction: column; gap: 2px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms; z-index: 40;
}
.topnav-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; }
.topnav-item:hover .topnav-menu, .topnav-item:focus-within .topnav-menu {
  opacity: 1; visibility: visible; transform: none; transition: opacity 160ms ease, transform 160ms ease;
}
.topnav-menu a, .topnav-menu button {
  text-align: left; border: 0; background: transparent; cursor: pointer;
  font-family: inherit; font-size: 0.875rem; font-weight: 500; color: var(--fg);
  padding: 9px 12px; border-radius: 8px; text-decoration: none; transition: background-color 140ms ease;
}
.topnav-menu a:hover, .topnav-menu button:hover { background: var(--surface); }
.env-label { font-weight: 500; }

.content { padding: var(--gutter) var(--gutter) 96px; max-width: 940px; transition: opacity 160ms ease; }
/* Only when a soft navigation is slow enough to be felt. A fast swap never reaches this. */
.content[data-nav="out"] { opacity: 0.5; }
.page-toggle { display: flex; justify-content: center; margin-bottom: 24px; }
.page-title { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 500; letter-spacing: -0.04em; margin: 0 0 18px; }
.page-title-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.page-title-row .page-title { margin: 0; }
.page-title-row .spacer { flex: 1; }
.page-title-row .title-actions { display: flex; gap: 10px; }
hr.rule { border: 0; height: 1px; background: var(--hair); margin: 0 0 32px; }

.page-sub { margin: 0 0 32px; color: var(--muted); font-size: 0.9375rem; line-height: 1.6; }
.section-h { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.04em; margin: 52px 0 16px; }
.section-h:first-child { margin-top: 0; }
.section-row { display: flex; align-items: center; gap: 16px; margin: 52px 0 16px; }
.section-row .section-h { margin: 0; }
.section-row .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border-radius: 9999px;
  font-size: 0.9375rem;
  font-weight: 400;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 220ms ease, color 220ms ease, opacity 220ms ease;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--fg); }
.btn-primary:hover:not(:disabled), .btn-secondary:hover:not(:disabled) { background: #000; color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-icon { width: 48px; padding: 0; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 0.875rem; }
.btn-sm svg { width: 16px; height: 16px; }
.linkbtn { background: transparent; border: 0; color: var(--primary); font-family: inherit; font-size: 0.875rem; font-weight: 400; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.iconbtn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 9999px;
  background: transparent; border: 0; color: var(--muted); cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.iconbtn:hover { background: var(--surface); color: var(--fg); }
.iconbtn.danger-icon { color: var(--red); }
.iconbtn.danger-icon:hover { background: rgba(220, 38, 38, 0.09); color: var(--red); }
.iconbtn svg { width: 18px; height: 18px; }

/* ---------- Environment segmented (sliding) ---------- */
.env {
  position: relative;
  display: inline-flex;
  padding: 5px;
  border-radius: 9999px;
  background: var(--surface-2);
}
.env .thumb {
  position: absolute; top: 5px; left: 5px; bottom: 5px;
  width: calc(50% - 5px);
  border-radius: 9999px; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  transition: transform 320ms var(--settle);
}
.env[data-env="production"] .thumb { transform: translateX(100%); }
.env button {
  position: relative; z-index: 1;
  border: 0; background: transparent; cursor: pointer;
  min-width: 112px; padding: 12px 24px; border-radius: 9999px;
  font-size: 0.9375rem; font-weight: 500; color: var(--muted);
  transition: color 200ms ease;
}
.env[data-env="sandbox"] button[data-env="sandbox"] { color: var(--sandbox); }
.env[data-env="production"] button[data-env="production"] { color: var(--primary); }

/* ---------- Fields (divider-separated, no container) ---------- */
.card { }
.field {
  display: flex; align-items: center; gap: 24px;
  padding: 22px 0; border-bottom: 1px solid var(--hair);
}
.field:last-child { border-bottom: 0; }
.field .fmeta { min-width: 0; flex: 1; }
.field .flabel { font-size: 0.9375rem; font-weight: 500; letter-spacing: -0.01em; }
.field .flabel .tag { color: var(--faint); font-weight: 400; font-size: 0.8125rem; }
.field .fhelp { font-size: 0.8125rem; color: var(--faint); margin-top: 5px; line-height: 1.55; max-width: 460px; }
.field .fval { display: flex; align-items: center; gap: 8px; flex: none; }
.mono { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.875rem; color: var(--fg); }
.mono.dim { color: var(--faint); letter-spacing: 1px; }
.secret-val { display: inline-block; min-width: 240px; text-align: right; }

/* A client id or a secret is too long to sit at the end of a row, so it gets three lines of its
   own: label, help, then the value across the full column. */
.field.field-stack { flex-direction: column; align-items: stretch; gap: 13px; }
.field-stack .fmeta { flex: none; }
.field-stack .fhelp { max-width: none; }
.field-stack .fval {
  flex: 1 1 auto; width: 100%; align-items: center; gap: 10px;
  background: var(--surface); border-radius: 12px; padding: 11px 11px 11px 15px;
}
.field-stack .fval > .mono { flex: 1 1 auto; min-width: 0; text-align: left; }
.field-stack .fval-actions { display: flex; align-items: center; gap: 4px; flex: none; margin-left: auto; }
.mono-long { word-break: break-all; overflow-wrap: anywhere; line-height: 1.5; }
.fnote { margin: 0; font-size: 0.8125rem; color: var(--faint); line-height: 1.55; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 13px; border-radius: 9999px; background: var(--surface-2); font-size: 0.8125rem; font-weight: 500; }

/* ---------- Status ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 0.875rem; }
.dot { width: 8px; height: 8px; border-radius: 9999px; flex: none; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--sandbox); }
.dot.blue { background: var(--primary); }
.dot.grey { background: var(--faint); }
.status.green { color: var(--green); }
.status.red { color: var(--red); }
.status.amber { color: var(--sandbox); }
.status.blue { color: var(--primary); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 0.8125rem; font-weight: 500; color: var(--faint);
  padding: 14px 20px; border-bottom: 1px solid var(--hair); white-space: nowrap;
}
tbody td { padding: 16px 20px; border-bottom: 1px solid var(--hair); font-size: 0.9375rem; vertical-align: middle; }
thead th:first-child, tbody td:first-child { padding-left: 0; }
thead th:last-child, tbody td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background-color 140ms ease; }
tbody tr.clickable:hover { background: var(--surface); cursor: pointer; }
td .sub { color: var(--faint); font-size: 0.8125rem; }
td .name { font-weight: 500; }
.tnum { font-variant-numeric: tabular-nums; }
.trunc { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tright { text-align: right; }
tr[hidden] { display: none; }

/* ---------- Applications grid ---------- */
.app-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.app-card {
  display: flex; flex-direction: column; align-items: flex-start;
  border: 1px solid var(--hair); border-radius: 16px; padding: 24px 26px;
}
.app-card h3 { margin: 0 0 6px; font-size: 1.0625rem; font-weight: 500; letter-spacing: -0.04em; }
.app-card .app-id { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; color: var(--faint); align-self: stretch; word-break: break-all; overflow-wrap: anywhere; }
.app-card .btn { margin-top: 22px; }

/* ---------- Toolbar (logs) ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.fchip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 9999px; background: var(--surface-2); border: 0; font-family: inherit; font-size: 0.875rem; color: var(--fg); cursor: pointer; transition: background-color 220ms ease, color 220ms ease; }
.fchip:hover, .fchip[data-active="true"] { background: #000; color: #fff; }
.fchip svg { width: 15px; height: 15px; color: currentColor; opacity: 0.6; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--hair-2); flex: 1; min-width: 220px; }
.search svg { width: 16px; height: 16px; color: var(--faint); }
.search input { border: 0; outline: 0; flex: 1; font-family: inherit; font-size: 0.875rem; background: transparent; }
.toolbar-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 0.8125rem; color: var(--faint); }

/* ---------- Empty ---------- */
.empty { border: 1px dashed var(--hair-2); border-radius: 16px; padding: 56px 24px; text-align: center; }
.empty p { color: var(--faint); margin: 0 0 20px; }
.empty p:last-child { margin-bottom: 0; }
.empty .btn { margin: 0 5px; }

/* ---------- Spinner (same ring as the auth pages) ---------- */
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent; border-top-color: color-mix(in srgb, currentColor 25%, transparent);
  animation: console-spin 0.8s linear infinite; vertical-align: middle;
}
.spinner-lg { width: 26px; height: 26px; border-width: 2.5px; color: var(--fg); }
.spinner-region { display: grid; place-items: center; padding: 64px 0; color: var(--fg); }
@keyframes console-spin { to { transform: rotate(360deg); } }

/* ---------- Inline errors ---------- */
.form-err { font-size: 0.8125rem; color: var(--red); margin: 8px 0 0; padding: 0 2px; }
.form-field .form-err { margin-top: 8px; }
.cover-err { font-size: 0.875rem; color: var(--red); margin: 0 0 20px; }

/* ---------- Secret shown once ---------- */
.once { border: 1px solid rgba(217, 119, 6, 0.34); background: rgba(217, 119, 6, 0.06); border-radius: 14px; padding: 16px 18px; margin: 0 0 22px; }
.once p { margin: 0; font-size: 0.875rem; line-height: 1.55; color: var(--fg); }
.once .once-h { font-weight: 500; margin-bottom: 4px; }
.secret-once { display: block; word-break: break-all; text-align: left; min-width: 0; }

/* ---------- Modal (full-screen cover) ---------- */
.cover {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
  opacity: 0; visibility: hidden;
  transition: opacity 260ms ease-in-out, visibility 0s linear 260ms;
}
.cover[data-open="true"] { opacity: 1; visibility: visible; transition: opacity 260ms ease-in-out; }
.cover:not(.drawer) .cover-col { transform: translateY(8px); transition: transform 260ms var(--settle); }
.cover[data-open="true"]:not(.drawer) .cover-col { transform: none; }
.cover-bar { display: flex; align-items: center; justify-content: space-between; padding: 18px var(--gutter); }
.cover:not(.drawer) .cover-bar { width: 100%; max-width: calc(576px + 2 * var(--gutter)); margin: 0 auto; }
.cover-bar > .iconbtn:first-child { width: 40px; height: 40px; margin-left: -8px; color: rgba(10, 10, 10, 0.6); }
.cover-bar > .iconbtn:first-child svg { width: 20px; height: 20px; }
.cover-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 72px; }
.cover-col { max-width: 576px; margin: 0 auto; }
.cover h2 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 500; letter-spacing: -0.04em; margin: 16px 0 28px; }

/* ---------- Drawer: a .cover that enters from the right instead of covering the page ----------
   Reuses every cover mechanism (open/close, reparent-on-nav, close-all) by staying a .cover; the
   modifier only restyles it into a right-hand panel over a dim backdrop. */
.cover.drawer { background: rgba(10, 10, 10, 0.4); flex-direction: row; justify-content: flex-end; }
.cover.drawer .drawer-panel {
  display: flex; flex-direction: column; width: 100%; max-width: 520px; height: 100%;
  background: var(--bg); box-shadow: -24px 0 60px -20px rgba(0, 0, 0, 0.28);
  transform: translateX(24px); transition: transform 260ms var(--settle);
}
.cover.drawer[data-open="true"] .drawer-panel { transform: none; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px var(--gutter) 16px; border-bottom: 1px solid var(--hair);
}
.drawer-titles { min-width: 0; }
.drawer-head h2 { font-size: 1.375rem; font-weight: 500; letter-spacing: -0.04em; margin: 0; }
.drawer-sub { margin: 4px 0 0; font-size: 0.875rem; color: var(--faint); word-break: break-word; }
.drawer-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px var(--gutter) 24px; }
.drawer-body .form-field:first-child { margin-top: 0; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 16px var(--gutter); border-top: 1px solid var(--hair); }
.drawer-foot .spacer { flex: 1 1 auto; }
@media (max-width: 560px) { .cover.drawer .drawer-panel { max-width: 100%; } }
@media (prefers-reduced-motion: reduce) { .cover.drawer .drawer-panel { transition: none; transform: none; } }
.form-field { margin-bottom: 22px; }
.form-field label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 8px; }
.form-field input, .form-field select {
  width: 100%; height: 48px; padding: 0 15px; border-radius: 12px;
  border: 1px solid var(--hair-2); font-family: inherit; font-size: 1rem; outline: 0; background: #fff;
  transition: border-color 160ms ease;
}
.form-field textarea {
  width: 100%; padding: 12px 15px; border-radius: 12px; resize: vertical; min-height: 96px;
  border: 1px solid var(--hair-2); font-family: inherit; font-size: 1rem; outline: 0; background: #fff;
  transition: border-color 160ms ease;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--fg); }

/* ---------- Usage meters ---------- */
/* One per environment. The fill and the accent take the environment's colour: sandbox amber, live blue,
   the same pairing the env switch uses, so the meter reads as "this is your sandbox pool" at a glance. */
.usage-card { padding: 26px 0; border-bottom: 1px solid var(--hair); }
.usage-card:last-child { border-bottom: 0; }
.usage-head { display: flex; align-items: baseline; gap: 12px; }
.usage-head h2 { margin: 0; font-size: 1.0625rem; font-weight: 500; letter-spacing: -0.04em; }
.usage-head .usage-count { margin-left: auto; font-size: 0.875rem; color: var(--muted); }
.usage-head .usage-count b { color: var(--fg); font-weight: 400; }
.usage-sub { margin: 6px 0 0; font-size: 0.8125rem; color: var(--faint); line-height: 1.55; }
.meter { margin: 16px 0 4px; }
.meter-track { height: 10px; border-radius: 9999px; background: var(--surface-3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 9999px; transition: width 420ms var(--settle); }
.usage-card[data-env="sandbox"] .meter-fill { background: var(--sandbox); }
.usage-card[data-env="live"] .meter-fill { background: var(--primary); }
.meter-fill[data-full="true"] { background: var(--red) !important; }
.usage-stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 20px; }
.usage-stat { min-width: 92px; }
.usage-stat .us-label { font-size: 0.8125rem; font-weight: 500; color: var(--faint); }
.usage-stat .us-val { font-size: 1.375rem; font-weight: 500; letter-spacing: -0.04em; margin-top: 4px; }
.usage-stat .us-val .tnum { font-variant-numeric: tabular-nums; }
.usage-actions { margin-top: 22px; }
.usage-note { margin: 18px 0 0; }
.form-field select {
  -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 15px center;
}
.form-field .fhelp { font-size: 0.8125rem; color: var(--faint); margin-top: 8px; }
.input-prefixed { display: flex; align-items: center; height: 48px; border: 1px solid var(--hair-2); border-radius: 12px; background: #fff; transition: border-color 160ms ease; }
.input-prefixed:focus-within { border-color: var(--fg); }
.input-prefixed .prefix { padding: 0 1px 0 15px; color: var(--faint); font-size: 1rem; }
.input-prefixed input { flex: 1; min-width: 0; border: 0; height: 100%; padding: 0 15px 0 1px; background: transparent; font-family: inherit; font-size: 1rem; outline: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.input-prefixed.tel .prefix { padding-right: 7px; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; margin: 28px 0 10px; }
/* ---------- File picker ---------- */
.filedrop {
  display: flex; align-items: center; gap: 18px;
  border: 1px dashed var(--hair-2); border-radius: 16px; padding: 18px 20px;
  transition: border-color 160ms ease, background-color 160ms ease;
}
.filedrop[data-drag="true"] { border-color: var(--primary); background: rgba(40, 107, 254, 0.06); }
.filedrop-preview {
  width: 72px; height: 72px; border-radius: 16px; border: 1px dashed var(--hair-2);
  display: grid; place-items: center; color: var(--faint); flex: none; cursor: pointer; overflow: hidden;
  transition: border-color 160ms ease;
}
.filedrop-preview:hover { border-color: var(--fg); }
.filedrop-preview svg { width: 24px; height: 24px; }
.filedrop-preview img { width: 100%; height: 100%; object-fit: contain; }
.filedrop-preview[data-filled="true"] { border-style: solid; border-color: var(--hair); }
.filedrop-body { flex: 1; min-width: 0; }
.filedrop-actions { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.filedrop .fhelp { font-size: 0.8125rem; color: var(--faint); line-height: 1.55; }

/* ---------- A refresh that failed, over content we still trust ---------- */
.warnbar {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid rgba(217, 119, 6, 0.34); background: rgba(217, 119, 6, 0.06);
  border-radius: 14px; padding: 13px 14px 13px 16px; margin: 0 0 24px;
  font-size: 0.875rem; line-height: 1.55;
}
.warnbar svg { width: 18px; height: 18px; color: var(--sandbox); flex: none; }
.warnbar .spacer { flex: 1; }

.app-logo-sm { width: 36px; height: 36px; border-radius: 9px; background: var(--fg); color: #fff; display: grid; place-items: center; font-size: 0.875rem; font-weight: 500; }
.logo-empty { width: 44px; height: 44px; border-radius: 11px; border: 1px dashed var(--hair-2); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.logo-empty svg { width: 20px; height: 20px; }
.logo-empty.has-logo { border-style: solid; border-color: var(--hair); }
.logo-empty img { width: 100%; height: 100%; object-fit: contain; }
.backlink { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; font-weight: 500; color: var(--faint); text-decoration: none; margin-bottom: 14px; transition: color 160ms ease; }
.backlink:hover { color: var(--fg); }
.backlink svg { width: 15px; height: 15px; }
.code { background: var(--surface); border-radius: 12px; padding: 16px 18px; font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.65; overflow-x: auto; white-space: pre; color: var(--fg); margin: 0; }
.events-list { }
.event-row { display: flex; align-items: flex-start; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--hair); }
.event-row:last-child { border-bottom: 0; }
.event-row .emeta { flex: 1; }
.event-row code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 0.875rem; font-weight: 500; }
.event-row p { margin: 5px 0 0; font-size: 0.8125rem; color: var(--faint); line-height: 1.5; }
.check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--hair-2); display: grid; place-items: center; cursor: pointer; flex: none; margin-top: 1px; transition: background-color 140ms ease, border-color 140ms ease; }
.check[data-on="true"] { background: var(--primary); border-color: var(--primary); }
.check svg { display: block; width: 13px; height: 13px; color: #fff; opacity: 0; }
.check[data-on="true"] svg { opacity: 1; }

/* danger */
.danger-zone { border-top: 1px solid var(--hair); padding: 22px 0; display: flex; align-items: center; gap: 28px; }
.danger-zone .fmeta { flex: 1; }
.danger-zone .flabel { color: var(--red); font-size: 0.9375rem; font-weight: 500; }
.danger-zone .fhelp { font-size: 0.8125rem; color: var(--faint); margin-top: 5px; line-height: 1.55; max-width: 520px; }

/* ---------- Dialog (centered pop-up card) ---------- */
.dialog {
  position: fixed; inset: 0; z-index: 65; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(10, 10, 10, 0.4);
  opacity: 0; visibility: hidden; transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.dialog[data-open="true"] { opacity: 1; visibility: visible; transition: opacity 200ms ease; }
.dialog-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 28px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.32);
  transform: translateY(8px) scale(0.98); transition: transform 220ms var(--settle);
}
.dialog[data-open="true"] .dialog-card { transform: none; }
.dialog-card h2 { margin: 0 0 10px; font-size: 1.25rem; font-weight: 500; letter-spacing: -0.04em; }
.dialog-card p { margin: 0 0 24px; color: var(--muted); font-size: 0.9375rem; line-height: 1.55; }
.dialog-card p:has(+ p) { margin-bottom: 12px; }
.dialog-card .row { display: flex; gap: 10px; justify-content: flex-end; }
/* The confirm-to-delete field inside a dialog: the generic .form-field input styling does not reach a
   bare label.field here, so scope it — a properly bordered, full-width input and tight, intentional
   spacing instead of a default browser box under an oversized section margin. */
.dialog-card .field { display: block; margin: 0 0 20px; }
.dialog-card .field.field-stack { padding: 0; border: 0; margin: 0 0 14px; }
.dialog-card .field-stack .flabel { margin-bottom: 8px; }
.dialog-card .field .form-label { margin: 0 0 8px; }
.dialog-card .field input[type="text"] {
  width: 100%; height: 48px; padding: 0 15px; border-radius: 12px;
  border: 1px solid var(--hair-2); font-family: inherit; font-size: 1rem; outline: 0; background: #fff;
  transition: border-color 160ms ease;
}
.dialog-card .field input[type="text"]:focus { border-color: var(--fg); }

.confirm-card { max-width: 440px; margin: 40px auto 0; text-align: left; }
.confirm-card h2 { margin: 0 0 12px; font-size: 1.375rem; font-weight: 500; letter-spacing: -0.04em; }
.confirm-card p { margin: 0 0 24px; color: var(--muted); font-size: 0.9375rem; line-height: 1.55; }
.confirm-card .row { display: flex; gap: 10px; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-14px);
  background: var(--fg); color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 0.875rem; font-weight: 500; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  opacity: 0; visibility: hidden; transition: opacity 200ms ease, transform 200ms ease, visibility 0s linear 200ms; z-index: 80;
}
.toast[data-show="true"] { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0); transition: opacity 200ms ease, transform 200ms ease; }

/* info note (money disclosure) */
.note { display: flex; gap: 10px; align-items: flex-start; font-size: 0.875rem; line-height: 1.55; color: var(--muted); }
.note svg { width: 18px; height: 18px; color: var(--faint); flex: none; margin-top: 1px; }

/* ---------- CLI sign-in ---------- */
.cli-form { max-width: 360px; }
.form-field .cli-input { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
#cli-cover .cover-col { text-align: center; }
.cli-code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: clamp(2rem, 6vw, 2.75rem); font-weight: 500; letter-spacing: 0.08em; margin: 0 0 16px; padding: 22px 16px; background: var(--surface); border: 1px solid var(--hair); border-radius: 16px; }
.cli-line { margin: 0 0 14px; font-size: 1rem; line-height: 1.55; color: var(--fg); }
.cli-line.cli-from { color: var(--faint); }
#cli-cover .cover-err { margin: 14px 0 0; }
.cover-foot { border-top: 1px solid var(--hair); padding: 16px var(--gutter) calc(16px + env(safe-area-inset-bottom, 0px)); }
.cover-foot .cover-col { display: flex; flex-direction: column; gap: 10px; }
.cover-foot .btn { width: 100%; height: 48px; justify-content: center; }
.cli-result { margin: 0; padding: 22px 0; border-bottom: 1px solid var(--hair); font-size: 1.0625rem; }
@media (max-width: 640px) {
  .cli-form { max-width: none; }
  .cli-form .btn { width: 100%; }
}

/* ---------- Search cover ---------- */
.search.search-lg { height: 56px; border-radius: 14px; border: 1px solid var(--hair-2); padding: 0 18px; gap: 12px; margin-top: 6px; }
.search.search-lg svg { width: 20px; height: 20px; }
.search.search-lg input { font-size: 1.0625rem; }
.search-results { margin-top: 22px; }
.sresult { display: block; padding: 16px 0; border-bottom: 1px solid var(--hair); text-decoration: none; color: inherit; }
.sresult:last-child { border-bottom: 0; }
.sresult-t { font-size: 0.9375rem; font-weight: 500; letter-spacing: -0.01em; transition: color 140ms ease; }
a.sresult:hover .sresult-t { color: var(--primary); }
.sresult-s { font-size: 0.8125rem; color: var(--faint); margin-top: 4px; line-height: 1.5; }
.sempty { padding: 26px 0; color: var(--faint); font-size: 0.9375rem; }
/* Robust-search result rendering, shared behaviour with the reference docs (search-core.js): a result
   names its page and section before itself, highlights show why it matched, and the active row (arrow
   keys) is tinted. */
.sgroup { font-size: 0.875rem; font-weight: 500; color: var(--faint); padding: 4px 2px 10px; }
.sresult-crumb { font-size: 0.8125rem; color: var(--faint); margin-bottom: 5px; }
.sresult-crumb .sep { opacity: 0.5; padding: 0 2px; }
.sresult mark { background: rgba(40, 107, 254, 0.14); color: inherit; border-radius: 3px; padding: 0 2px; }
.sresult[data-active="true"] { background: var(--surface-2); }
.sresult[data-active="true"] .sresult-t { color: var(--primary); }
.sempty span { display: block; margin-top: 8px; font-size: 0.875rem; color: var(--faint); }
.sempty code { font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.searchpill-kbd { margin-left: auto; font-family: inherit; font-size: 0.8125rem; color: var(--faint); border: 1px solid var(--hair); border-radius: 5px; padding: 2px 6px; line-height: 1; }
@media (max-width: 640px) { .searchpill-kbd { display: none; } }

/* ---------- Skeleton shimmer ---------- */
.skeleton { position: relative; overflow: hidden; background: rgba(10, 10, 10, 0.06); border-radius: 5px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-in { animation: skelIn 260ms ease both; }
@keyframes skelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.menu-toggle { display: none; }

@media (max-width: 900px) {
  :root { --gutter: 20px; }
  .sidebar { transform: translateX(-100%); transition: transform 360ms var(--settle); box-shadow: 0 0 0 100vmax rgba(0,0,0,0); }
  .sidebar[data-open="true"] { transform: translateX(0); box-shadow: 0 24px 60px -20px rgba(0,0,0,0.3); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-grid !important; }
  .sb-close { display: inline-grid !important; }
  .sb-back { display: inline-flex !important; }
  .topnav { gap: 20px; }
  .sb-veil[data-open="true"] { opacity: 1; visibility: visible; transition: opacity 360ms var(--settle); }
  .app-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .field { flex-direction: column; align-items: flex-start; gap: 8px; }
  .field .fval { flex: none; }
  .field.field-stack { gap: 12px; }
  .field-stack .fval { flex: 1 1 auto; align-items: flex-start; }
  .field-stack .fval-actions { flex-wrap: wrap; justify-content: flex-end; }
  .filedrop { flex-wrap: wrap; }
  .warnbar { flex-wrap: wrap; }
  .warnbar .spacer { display: none; }
  .secret-val { min-width: 0; text-align: left; }
  .hide-sm { display: none !important; }
  .search input { font-size: 16px; }
  .searchpill span { display: none; }
  .searchpill { width: auto; max-width: none; padding: 0 12px; }
  .page-title-row { flex-wrap: wrap; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .cover .cover-col { transform: none !important; } }
