/* dark's studio design system: tokens and primitives shared by every page and subdomain.
   Layout language: dark field, ember accent used sparingly, Mona Sans for words, Martian Mono only for data. */

/* ---------- Tokens ---------- */
:root {
  --bg: #111111;
  --panel: rgba(25, 25, 25, .86);
  --panel-solid: #191919;
  --tile: #1F1F1F;
  --raise: #242424;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --fg: #F5F5F4;
  --soft: #D6D3D1;
  --muted: #A8A29E;
  --dim: #8A847F;
  --a1: #FFB07A;
  --a2: #FF5A1F;
  --a-rgb: 255, 120, 60;
  --on-accent: #1F0A00;
  --live: #86EFAC;
  --warn: #FCD34D;
  --bad: #F87171;
  --bad-rgb: 248, 113, 113;
  --display: "Mona Sans", ui-sans-serif, sans-serif;
  --sans: "Mona Sans", ui-sans-serif, sans-serif;
  --mono: "Martian Mono", ui-monospace, Menlo, monospace;
  --r-lg: 18px; --r-md: 12px; --r-sm: 8px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --gutter: 16px;
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 15px/1.6 var(--sans); padding-inline: var(--gutter); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--a1); outline-offset: 3px; border-radius: 6px; }
img, svg, video { max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--a2); color: var(--on-accent); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2A2A2A; border-radius: 4px; transition: background .2s ease; }
::-webkit-scrollbar-thumb:hover { background: var(--a2); }
h1, h2, h3 { margin: 0; font-family: var(--display); letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(30px, 4.4vw, 48px); font-weight: 700; }
h2 { font-size: clamp(22px, 2.6vw, 30px); font-weight: 650; }
h3 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
.w { max-width: 1160px; margin-inline: auto; }
.w-narrow { max-width: 720px; margin-inline: auto; }
.mono { font-family: var(--mono); font-size: .86em; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.tnum { font-variant-numeric: tabular-nums; }
.sr { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, 12px); }
.spread { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.lede { font-size: 17px; color: var(--soft); max-width: 60ch; }
.label { font: 500 11px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.skip { position: absolute; left: 16px; top: -60px; z-index: 60; padding: 10px 14px; border-radius: 10px; background: var(--a2); color: var(--on-accent); font-weight: 600; }
.skip:focus { top: 12px; }

/* ---------- Site header (subpages: always visible) ---------- */
.site-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 40; margin-inline: calc(-1 * var(--gutter)); padding: 10px var(--gutter); background: rgba(17, 17, 17, .82); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); border-bottom: 1px solid var(--line); }
.site-head .in { max-width: 1160px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; margin-right: auto; }
/* The mark: a geometric d with an ember satellite, drawn in CSS so no CSP can block it. Same geometry as favicon.svg
   (32-unit grid). Set --mark to resize; any text inside is hidden. */
.brand-mark, .ds-mark {
  --u: calc(var(--mark, 30px) / 32); position: relative; display: inline-block; flex: none; overflow: hidden;
  width: var(--mark, 30px); height: var(--mark, 30px); border-radius: calc(var(--u) * 8); font-size: 0; color: transparent; user-select: none;
  background: radial-gradient(circle at calc(var(--u) * 10.6) calc(var(--u) * 10), var(--a2) 0 calc(var(--u) * 2.6), transparent calc(var(--u) * 2.6 + .6px)) #161616;
}
.brand-mark::before, .ds-mark::before {
  content: ""; position: absolute; left: calc(var(--u) * 10); top: calc(var(--u) * 13); width: calc(var(--u) * 13); height: calc(var(--u) * 13);
  box-sizing: border-box; border: calc(var(--u) * 3) solid var(--a1); border-radius: 50%;
}
.brand-mark::after, .ds-mark::after {
  content: ""; position: absolute; left: calc(var(--u) * 20); top: calc(var(--u) * 7.5); width: calc(var(--u) * 3); height: calc(var(--u) * 17);
  border-radius: calc(var(--u) * 1.5); background: var(--a1);
}
.brand small { color: var(--dim); font-weight: 500; }
.nav { display: flex; gap: 2px; }
.nav a { font-size: 14px; color: var(--muted); padding: 8px 11px; border-radius: 8px; }
.nav a:hover { color: var(--fg); }
.nav a[aria-current="page"] { color: var(--a1); background: rgba(var(--a-rgb), .1); }
@media (max-width: 720px) {
  .site-head .in { flex-wrap: wrap; row-gap: 6px; }
  .site-head .nav { order: 3; width: 100%; overflow-x: auto; margin-inline: -6px; padding-bottom: 2px; }
  .site-head .nav a { flex: none; padding: 7px 9px; font-size: 13.5px; }
}

/* ---------- Footer ---------- */
.site-foot { max-width: 1160px; margin: clamp(64px, 9vw, 120px) auto 0; padding: 22px 0 calc(28px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px 24px; justify-content: space-between; font: 500 12.5px/1.4 var(--mono); color: var(--dim); }
.site-foot nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.site-foot a:hover { color: var(--a1); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); color: var(--fg); font: 600 14px/1 var(--sans); cursor: pointer; white-space: nowrap; transition: background-color .15s, border-color .15s, transform .15s var(--ease); }
.btn:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.24); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--a2); border-color: transparent; color: var(--on-accent); }
.btn-primary:hover { background: #FF6E38; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--soft); }
.btn-ghost:hover { background: rgba(255,255,255,.06); border-color: transparent; }
.btn-danger { background: rgba(var(--bad-rgb), .1); border-color: rgba(var(--bad-rgb), .35); color: var(--bad); }
.btn-danger:hover { background: rgba(var(--bad-rgb), .18); border-color: rgba(var(--bad-rgb), .5); }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 0 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--soft); cursor: pointer; }
.icon-btn:hover { color: var(--a1); border-color: rgba(var(--a-rgb), .45); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Form fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label, .field > .field-label { font-size: 13.5px; font-weight: 500; color: var(--soft); }
.input, .select, .textarea { width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line-2); background: #151515; color: var(--fg); font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23A8A29E' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.input::placeholder, .textarea::placeholder { color: var(--dim); }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(255,255,255,.24); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgba(var(--a-rgb), .7); box-shadow: 0 0 0 3px rgba(var(--a-rgb), .18); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: rgba(var(--bad-rgb), .6); }
.help { font-size: 12.5px; color: var(--dim); }
.error { font-size: 12.5px; color: var(--bad); }
.input-group { display: flex; min-width: 0; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; font-family: var(--mono); font-size: 13px; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 0; min-height: 44px; }

/* Toggle (input type=checkbox role=switch) */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: #2a2a2a; border: 1px solid var(--line-2); position: relative; cursor: pointer; transition: background-color .2s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--soft); transition: transform .2s var(--ease), background-color .2s; }
.switch input:checked { background: var(--a2); border-color: transparent; }
.switch input:checked::after { transform: translateX(16px); background: #fff; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { appearance: none; width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--line-2); background: #151515; display: grid; place-items: center; margin: 0; cursor: pointer; flex: none; }
.check input:checked { background: var(--a2); border-color: transparent; }
.check input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--on-accent); border-bottom: 2px solid var(--on-accent); transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a { flex: none; padding: 10px 14px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover, .tabs a:hover { color: var(--fg); }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--fg); border-bottom-color: var(--a2); }
.seg { display: inline-flex; align-self: flex-start; padding: 3px; border-radius: 10px; border: 1px solid var(--line); background: #151515; }
.seg button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--raise); color: var(--fg); }

/* ---------- Badges, pills, status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line-2); font: 500 11px/1 var(--mono); color: var(--muted); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.live { color: var(--live); border-color: rgba(134,239,172,.3); }
.badge.build { color: var(--warn); border-color: rgba(252,211,77,.3); }
.badge.bad { color: var(--bad); border-color: rgba(var(--bad-rgb), .35); }
.badge.accent { color: var(--a1); border-color: rgba(var(--a-rgb), .4); }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--tile); font-size: 13px; color: var(--soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.dot.live { background: var(--live); box-shadow: 0 0 0 3px rgba(134,239,172,.15); }
.dot.build { background: var(--warn); }
.dot.bad { background: var(--bad); }

/* ---------- Surfaces ---------- */
.panel { background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(18px, 2.4vw, 24px); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.panel-head p { color: var(--muted); font-size: 14px; }
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat strong { font: 600 26px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
/* App window frame (from the homepage project windows) */
.win { background: var(--tile); border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; box-shadow: 0 24px 50px -24px rgba(0,0,0,.9); }
.win-bar { display: flex; align-items: center; gap: 12px; height: 34px; padding: 0 12px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.03); font: 500 11.5px/1 var(--mono); color: var(--muted); }
.win-bar i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.16); }
.win-bar i + i { margin-left: -6px; }
.win-body { padding: 14px; }

/* ---------- Tables ---------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--dim); padding: 12px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ---------- App shell: sidebar + main ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; margin-inline: calc(-1 * var(--gutter)); }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; border-right: 1px solid var(--line); background: #131313; }
.side-group { display: flex; flex-direction: column; gap: 2px; }
.side-group .label { padding: 6px 10px; }
.side a, .side button.side-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 9px; border: 0; background: none; color: var(--muted); font-size: 14px; text-align: left; cursor: pointer; }
.side a:hover, .side button.side-link:hover { color: var(--fg); background: rgba(255,255,255,.04); }
.side a[aria-current="page"], .side .active { color: var(--fg); background: rgba(var(--a-rgb), .1); box-shadow: inset 2px 0 0 var(--a2); }
.side svg { width: 17px; height: 17px; flex: none; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.main { min-width: 0; padding: 0 clamp(16px, 3vw, 36px) 48px; }
.main-head { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; margin-bottom: 22px; background: rgba(17,17,17,.88); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side-group { flex-direction: row; flex-wrap: wrap; }
  .side-group .label, .side-foot { display: none; }
  .side a, .side button.side-link { width: auto; }
}

/* ---------- Progress / meter ---------- */
.meter { height: 8px; border-radius: 999px; background: #262626; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--a2); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }

/* ---------- Overlays ---------- */
.modal { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel-solid); color: var(--fg); box-shadow: 0 40px 90px -30px rgba(0,0,0,.95); }
.modal::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: #1d1d1d; box-shadow: 0 20px 40px -20px rgba(0,0,0,.9); font-size: 14px; max-width: 420px; }
.toast.ok { border-color: rgba(134,239,172,.35); }
.toast.err { border-color: rgba(var(--bad-rgb), .4); }
.menu { min-width: 200px; padding: 6px; border-radius: 12px; border: 1px solid var(--line-2); background: #1b1b1b; box-shadow: 0 24px 50px -20px rgba(0,0,0,.9); display: flex; flex-direction: column; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 0; background: none; text-align: left; font-size: 14px; color: var(--soft); cursor: pointer; }
.menu button:hover, .menu a:hover { background: rgba(255,255,255,.06); color: var(--fg); }
.menu .danger { color: var(--bad); }
.menu hr { border: 0; height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- States ---------- */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, #1c1c1c 0%, #262626 50%, #1c1c1c 100%); background-size: 200% 100%; animation: ds-shimmer 1.4s linear infinite; min-height: 14px; }
@keyframes ds-shimmer { to { background-position: -200% 0; } }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 48px 20px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); color: var(--muted); }
.empty h3 { color: var(--fg); }
.empty svg { width: 34px; height: 34px; color: var(--dim); }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 200px; padding: 28px; border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: rgba(255,255,255,.015); text-align: center; color: var(--muted); transition: border-color .2s, background-color .2s; }
.dropzone.dragover, .dropzone:hover { border-color: rgba(var(--a-rgb), .6); background: rgba(var(--a-rgb), .05); }

/* ---------- Code ---------- */
code { font-family: var(--mono); font-size: .86em; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.06); color: var(--soft); }
pre { margin: 0; overflow-x: auto; padding: 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: #141414; font: 400 12.5px/1.7 var(--mono); color: var(--soft); }
pre code { padding: 0; background: none; font-size: inherit; }
.k { color: var(--a1); } .s { color: #A7D8A0; } .c { color: #6f6a66; } .n { color: #F0C27B; }
kbd { font: 500 11px/1 var(--mono); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; color: var(--soft); background: #1a1a1a; }

/* ---------- Prose (legal, docs, changelog bodies) ---------- */
.prose { max-width: 68ch; color: var(--soft); font-size: 16px; line-height: 1.7; }
.prose > * + * { margin-top: 1em; }
.prose h2 { margin-top: 2em; color: var(--fg); }
.prose h3 { margin-top: 1.6em; color: var(--fg); }
.prose a { color: var(--a1); text-decoration: underline; text-decoration-color: rgba(var(--a-rgb), .4); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li + li { margin-top: .4em; }

/* ---------- Pixel field (optional page background) ---------- */
.px-bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Error pages (404, 500): one app-window frame holding the code, a line of copy and the way out ---------- */
.nf { min-height: calc(100vh - 150px); display: flex; align-items: center; padding-block: clamp(40px, 8vw, 96px); }
.nf-stage, .nf-win { width: min(680px, 100%); margin-inline: auto; }
.nf-win { box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .95); }
.nf-body { display: flex; flex-direction: column; gap: 18px; padding: clamp(28px, 6vw, 56px); }
.nf-code { font: 700 clamp(88px, 22vw, 200px)/.85 var(--display); letter-spacing: -.05em; color: var(--fg); font-variant-numeric: tabular-nums; }
.nf-code::after { content: ""; display: block; width: 14px; height: 14px; margin-top: 18px; border-radius: 3px; background: var(--a2); }
.nf-copy { max-width: 44ch; }
.nf-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.nf-links .btn { min-height: 44px; }
@media (max-width: 480px) { .nf-links .btn { flex: 1 1 100%; } }

/* ---------- Touch: every control reaches 44px on coarse pointers ---------- */
@media (pointer: coarse) {
  .btn-sm, .seg button, .nav a, .site-foot a, .tabs button, .tabs a { min-height: 44px; display: inline-flex; align-items: center; }
}
