/* ==========================================================================
   Base — reset, typography, layout primitives
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(80vmax 55vmax at -10% -12%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 68%),
    radial-gradient(65vmax 45vmax at 108% -5%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 70%, #ffffff) 0%, var(--bg) 34%, var(--bg) 100%);
  background-attachment: fixed;
  font: 400 var(--fs-base)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(80vmax 55vmax at -10% -12%, rgba(16, 185, 129, 0.08), transparent 68%),
    radial-gradient(65vmax 45vmax at 108% -5%, rgba(99, 102, 241, 0.06), transparent 70%),
    linear-gradient(180deg, #0a110e 0%, var(--bg) 38%, var(--bg) 100%);
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--text);
  letter-spacing: -0.025em;
  line-height: 1.12;
}

h1 { font-size: var(--fs-4xl); font-weight: 750; }
h2 { font-size: var(--fs-3xl); font-weight: 720; }
h3 { font-size: var(--fs-xl); font-weight: 700; }
h4 { font-size: var(--fs-lg); font-weight: 700; }

p { color: var(--text-2); }

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

img, svg, video, canvas {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

::selection {
  color: var(--on-primary);
  background: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 38%, transparent) transparent;
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 34%, transparent);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); background-clip: padding-box; }

/* Icons */
.ico {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ico--sm { width: 15px; height: 15px; }
.ico--lg { width: 22px; height: 22px; }
.ico--xl { width: 28px; height: 28px; }

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 999;
  padding: 10px 16px;
  border-radius: var(--r-full);
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 16px; }

.tabular-numbers,
.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -0.015em;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.text-2 { color: var(--text-2); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.full { width: 100%; }
.hidden { display: none !important; }

.stack { display: grid; gap: var(--sp-4); }
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.row--sm { gap: var(--sp-2); }
.row--lg { gap: var(--sp-5); }
.row--top { align-items: flex-start; }
.row--wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); }

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.section-title h2,
.section-title h3 { font-size: var(--fs-xl); }
.section-title p { font-size: var(--fs-sm); color: var(--muted); }

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pulse-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}
.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--good);
  opacity: 0.5;
  animation: pulse-ring 2s var(--ease) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.7); opacity: 0.6; }
  70% { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -480px 0; }
  100% { background-position: 480px 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Native dialog defaults */
dialog {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--raised);
  padding: 0;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
}
dialog::backdrop {
  background: rgba(7, 18, 13, 0.4);
  backdrop-filter: blur(5px) saturate(1.1);
  -webkit-backdrop-filter: blur(5px) saturate(1.1);
}
:root[data-theme="dark"] dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 999;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  background: var(--bad);
  color: #fff;
  font-weight: 700;
  text-align: center;
}

/* Boot */
.boot-screen {
  min-height: 58vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  color: var(--muted);
}
.boot-screen .brand__mark {
  width: 56px;
  height: 56px;
  color: var(--primary);
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  animation: pulse-soft 1.6s ease-in-out infinite;
}
.boot-screen svg { width: 34px; height: 34px; }
.boot-screen p { font-size: var(--fs-md); }

@keyframes pulse-soft {
  0%, 100% { opacity: 0.65; transform: scale(0.98); }
  50% { opacity: 1; transform: scale(1.02); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: var(--fs-3xl); }
  h2 { font-size: var(--fs-2xl); }
}
