/* =====================================================================
   Elys — Material Design 3 Expressive design system
   Dynamic color (OKLCH, driven by --h), expressive shapes, spring motion
   ===================================================================== */

:root {
  --h: 285; /* seed hue — changed by the dynamic color picker */

  /* --- Typography ------------------------------------------------- */
  --font-brand: "Roboto Flex", "Google Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-plain: "Roboto Flex", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* --- Shape scale (M3 Expressive) -------------------------------- */
  --shape-xs: 4px;
  --shape-sm: 8px;
  --shape-md: 12px;
  --shape-lg: 16px;
  --shape-lg-inc: 20px;
  --shape-xl: 28px;
  --shape-xl-inc: 32px;
  --shape-xxl: 48px;
  --shape-full: 999px;

  /* --- Motion: spring physics approximations ---------------------- */
  --spring-fast: linear(0, 0.0114, 0.0436 2.1%, 0.1773 4.6%, 0.7298 12.6%, 0.9381 16.7%,
      1.0294 19.6%, 1.0784 22.4%, 1.0985 25%, 1.1012 27.6%, 1.0908 30.4%, 1.0453 37.1%,
      1.0069 44.5%, 0.9919 50.6%, 0.9892 56.8%, 0.9969 71.4%, 1.0006 85.4%, 1);
  --spring-gentle: linear(0, 0.0036, 0.0141 1.5%, 0.0563 3.1%, 0.2337 6.6%, 0.4851 10.4%,
      0.7255 14.8%, 0.8973 19.6%, 0.9958 24.4%, 1.0371 29%, 1.0477 33.2%, 1.0412 38.5%,
      1.0121 50.1%, 0.9988 61.8%, 0.9974 74.3%, 1);
  --ease-emph: cubic-bezier(0.2, 0, 0, 1);
  --ease-emph-dec: cubic-bezier(0.05, 0.7, 0.1, 1);
  --ease-emph-acc: cubic-bezier(0.3, 0, 0.8, 0.15);
  --dur-s: 200ms;
  --dur-m: 400ms;
  --dur-l: 650ms;
}

/* --- Color schemes ------------------------------------------------ */
:root,
[data-theme="light"] {
  color-scheme: light;
  --md-primary: oklch(0.5 0.2 var(--h));
  --md-on-primary: oklch(1 0 0);
  --md-primary-container: oklch(0.9 0.075 var(--h));
  --md-on-primary-container: oklch(0.3 0.13 var(--h));
  --md-inverse-primary: oklch(0.8 0.12 var(--h));

  --md-secondary: oklch(0.5 0.06 var(--h));
  --md-on-secondary: oklch(1 0 0);
  --md-secondary-container: oklch(0.91 0.04 var(--h));
  --md-on-secondary-container: oklch(0.3 0.05 var(--h));

  --md-tertiary: oklch(0.53 0.14 calc(var(--h) + 70));
  --md-on-tertiary: oklch(1 0 0);
  --md-tertiary-container: oklch(0.9 0.08 calc(var(--h) + 70));
  --md-on-tertiary-container: oklch(0.32 0.12 calc(var(--h) + 70));

  --md-error: oklch(0.53 0.2 27);
  --md-on-error: oklch(1 0 0);
  --md-error-container: oklch(0.92 0.05 27);
  --md-on-error-container: oklch(0.35 0.13 27);

  --md-warn-container: oklch(0.93 0.07 85);
  --md-on-warn-container: oklch(0.38 0.09 70);
  --md-ok-container: oklch(0.92 0.07 150);
  --md-on-ok-container: oklch(0.34 0.09 150);

  --md-surface: oklch(0.985 0.007 var(--h));
  --md-surface-container-lowest: oklch(1 0 0);
  --md-surface-container-low: oklch(0.966 0.011 var(--h));
  --md-surface-container: oklch(0.951 0.013 var(--h));
  --md-surface-container-high: oklch(0.936 0.015 var(--h));
  --md-surface-container-highest: oklch(0.92 0.017 var(--h));
  --md-on-surface: oklch(0.22 0.018 var(--h));
  --md-on-surface-variant: oklch(0.43 0.025 var(--h));
  --md-outline: oklch(0.6 0.025 var(--h));
  --md-outline-variant: oklch(0.85 0.02 var(--h));
  --md-inverse-surface: oklch(0.3 0.02 var(--h));
  --md-inverse-on-surface: oklch(0.95 0.01 var(--h));
  --md-scrim: oklch(0 0 0 / 0.38);
  --md-shadow: oklch(0.2 0.05 var(--h) / 0.16);

  --code-bg: oklch(0.21 0.03 var(--h));
  --code-fg: oklch(0.93 0.015 var(--h));
}

[data-theme="dark"] {
  color-scheme: dark;
  --md-primary: oklch(0.82 0.12 var(--h));
  --md-on-primary: oklch(0.3 0.13 var(--h));
  --md-primary-container: oklch(0.4 0.15 var(--h));
  --md-on-primary-container: oklch(0.92 0.06 var(--h));
  --md-inverse-primary: oklch(0.5 0.2 var(--h));

  --md-secondary: oklch(0.82 0.045 var(--h));
  --md-on-secondary: oklch(0.32 0.04 var(--h));
  --md-secondary-container: oklch(0.38 0.045 var(--h));
  --md-on-secondary-container: oklch(0.91 0.035 var(--h));

  --md-tertiary: oklch(0.83 0.1 calc(var(--h) + 70));
  --md-on-tertiary: oklch(0.32 0.1 calc(var(--h) + 70));
  --md-tertiary-container: oklch(0.42 0.11 calc(var(--h) + 70));
  --md-on-tertiary-container: oklch(0.92 0.06 calc(var(--h) + 70));

  --md-error: oklch(0.8 0.11 27);
  --md-on-error: oklch(0.32 0.12 27);
  --md-error-container: oklch(0.42 0.14 27);
  --md-on-error-container: oklch(0.92 0.04 27);

  --md-warn-container: oklch(0.38 0.07 75);
  --md-on-warn-container: oklch(0.92 0.07 85);
  --md-ok-container: oklch(0.37 0.07 150);
  --md-on-ok-container: oklch(0.92 0.07 150);

  --md-surface: oklch(0.165 0.012 var(--h));
  --md-surface-container-lowest: oklch(0.13 0.01 var(--h));
  --md-surface-container-low: oklch(0.2 0.014 var(--h));
  --md-surface-container: oklch(0.225 0.016 var(--h));
  --md-surface-container-high: oklch(0.26 0.018 var(--h));
  --md-surface-container-highest: oklch(0.3 0.02 var(--h));
  --md-on-surface: oklch(0.93 0.012 var(--h));
  --md-on-surface-variant: oklch(0.8 0.02 var(--h));
  --md-outline: oklch(0.62 0.022 var(--h));
  --md-outline-variant: oklch(0.38 0.02 var(--h));
  --md-inverse-surface: oklch(0.93 0.012 var(--h));
  --md-inverse-on-surface: oklch(0.25 0.015 var(--h));
  --md-shadow: oklch(0 0 0 / 0.5);

  --code-bg: oklch(0.12 0.015 var(--h));
  --code-fg: oklch(0.92 0.015 var(--h));
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 108px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-plain);
  font-size: 16px;
  line-height: 1.6;
  color: var(--md-on-surface);
  background: var(--md-surface);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur-m) var(--ease-emph), color var(--dur-m) var(--ease-emph);
  overflow-x: hidden;
}

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

a { color: var(--md-primary); text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2.5px; }

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

:focus-visible {
  outline: 3px solid var(--md-primary);
  outline-offset: 3px;
  border-radius: var(--shape-sm);
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 500, "GRAD" 0, "opsz" 24;
  user-select: none;
  transition: font-variation-settings var(--dur-m) var(--ease-emph);
  flex-shrink: 0;
}
.icon-fill { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }

.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; left: 16px; top: -80px; z-index: 1000;
  padding: 12px 20px; border-radius: var(--shape-full);
  background: var(--md-primary); color: var(--md-on-primary); font-weight: 600;
  transition: top var(--dur-m) var(--spring-fast);
}
.skip-link:focus { top: 16px; }

/* --- Type scale (Expressive: emphasized variants) ------------------ */
.display-l { font: 400 clamp(52px, 8.5vw, 112px)/0.95 var(--font-brand); letter-spacing: -0.035em; font-variation-settings: "wdth" 115, "wght" 760; }
.display-m { font: 400 clamp(40px, 5.8vw, 72px)/1 var(--font-brand); letter-spacing: -0.03em; font-variation-settings: "wdth" 112, "wght" 700; }
.display-s { font: 400 clamp(32px, 4vw, 48px)/1.08 var(--font-brand); letter-spacing: -0.02em; font-variation-settings: "wdth" 110, "wght" 680; }
.headline-l { font: 400 32px/1.2 var(--font-brand); letter-spacing: -0.01em; font-variation-settings: "wdth" 106, "wght" 640; }
.headline-m { font: 400 26px/1.25 var(--font-brand); font-variation-settings: "wdth" 104, "wght" 620; }
.title-l { font: 400 22px/1.3 var(--font-brand); font-variation-settings: "wdth" 102, "wght" 600; }
.title-m { font: 500 16px/1.45 var(--font-plain); letter-spacing: 0.01em; }
.body-l { font-size: 18px; line-height: 1.6; }
.label-l { font: 600 14px/1.4 var(--font-plain); letter-spacing: 0.01em; }
.label-m { font: 600 12px/1.3 var(--font-plain); letter-spacing: 0.04em; text-transform: uppercase; }
.muted { color: var(--md-on-surface-variant); }

/* =====================================================================
   State layers & ripple
   ===================================================================== */
.state {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}
.state::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0;
  border-radius: inherit;
  transition: opacity var(--dur-s) linear;
  pointer-events: none;
  z-index: -1;
}
.state:hover::before { opacity: 0.08; }
.state:focus-visible::before { opacity: 0.1; }
.state:active::before { opacity: 0.12; }

.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.18;
  transform: scale(0);
  pointer-events: none;
  animation: ripple 650ms var(--ease-emph-dec) forwards;
  z-index: -1;
}
@keyframes ripple {
  to { transform: scale(1); opacity: 0; }
}

/* =====================================================================
   Buttons — shape-morph on press (Expressive)
   ===================================================================== */
.btn {
  --btn-h: 48px;
  --btn-r: var(--shape-full);
  --btn-r-pressed: var(--shape-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 24px;
  border: 0;
  border-radius: var(--btn-r);
  font: 600 15px/1 var(--font-plain);
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition:
    border-radius var(--dur-m) var(--spring-fast),
    transform var(--dur-m) var(--spring-fast),
    background-color var(--dur-s) var(--ease-emph),
    box-shadow var(--dur-s) var(--ease-emph),
    color var(--dur-s) var(--ease-emph);
}
.btn:hover { text-decoration: none; }
.btn:active { border-radius: var(--btn-r-pressed); transform: scale(0.97); }
.btn .material-symbols-rounded { font-size: 20px; transition: transform var(--dur-m) var(--spring-fast); }
.btn:hover .material-symbols-rounded.slide { transform: translateX(4px); }

.btn-lg { --btn-h: 64px; padding: 0 32px; font-size: 17px; --btn-r-pressed: var(--shape-lg); }
.btn-lg .material-symbols-rounded { font-size: 24px; }
.btn-xl { --btn-h: 80px; padding: 0 44px; font-size: 20px; --btn-r-pressed: var(--shape-xl); }
.btn-xl .material-symbols-rounded { font-size: 28px; }
.btn-sm { --btn-h: 40px; padding: 0 16px; font-size: 14px; }
.btn-square { --btn-r: var(--shape-lg); --btn-r-pressed: var(--shape-sm); }
.btn-lg.btn-square { --btn-r: var(--shape-xl); --btn-r-pressed: var(--shape-lg); }

.btn-filled { background: var(--md-primary); color: var(--md-on-primary); }
.btn-filled:hover { box-shadow: 0 2px 6px var(--md-shadow), 0 8px 22px -6px var(--md-shadow); }
.btn-tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn-tertiary { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.btn-outlined { background: transparent; color: var(--md-on-surface-variant); box-shadow: inset 0 0 0 1.5px var(--md-outline-variant); }
.btn-outlined:hover { color: var(--md-on-surface); }
.btn-text { background: transparent; color: var(--md-primary); padding: 0 14px; }
.btn-elevated { background: var(--md-surface-container-low); color: var(--md-primary); box-shadow: 0 1px 3px var(--md-shadow); }

/* Icon buttons */
.icon-btn {
  --s: 48px;
  width: var(--s);
  height: var(--s);
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--shape-full);
  background: transparent;
  color: var(--md-on-surface-variant);
  cursor: pointer;
  transition: border-radius var(--dur-m) var(--spring-fast), background-color var(--dur-s), color var(--dur-s), transform var(--dur-m) var(--spring-fast);
  text-decoration: none;
}
.icon-btn:active { border-radius: var(--shape-md); transform: scale(0.94); }
.icon-btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.icon-btn.filled { background: var(--md-primary); color: var(--md-on-primary); }
.icon-btn.sm { --s: 40px; }
.icon-btn.sm .material-symbols-rounded { font-size: 20px; }
.icon-btn[aria-expanded="true"] { background: var(--md-primary); color: var(--md-on-primary); border-radius: var(--shape-md); }

/* Split button */
.split { display: inline-flex; gap: 2px; }
.split > .btn:first-child { border-radius: var(--shape-full) var(--shape-sm) var(--shape-sm) var(--shape-full); }
.split > .btn:last-child { border-radius: var(--shape-sm) var(--shape-full) var(--shape-full) var(--shape-sm); padding: 0 16px; }
.split > .btn:active { border-radius: var(--shape-md); }

/* =====================================================================
   Connected button group (segmented, morphing selection)
   ===================================================================== */
.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.btn-group > button {
  height: 44px;
  padding: 0 18px;
  border: 0;
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface-variant);
  font: 600 14px/1 var(--font-plain);
  border-radius: var(--shape-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-radius var(--dur-m) var(--spring-fast), background-color var(--dur-s), color var(--dur-s), transform var(--dur-m) var(--spring-fast), padding var(--dur-m) var(--spring-fast);
}
.btn-group > button .material-symbols-rounded { font-size: 18px; }
.btn-group > button:first-child { border-top-left-radius: var(--shape-full); border-bottom-left-radius: var(--shape-full); padding-left: 22px; }
.btn-group > button:last-child { border-top-right-radius: var(--shape-full); border-bottom-right-radius: var(--shape-full); padding-right: 22px; }
.btn-group > button:active { transform: scale(0.95); }
.btn-group > button[aria-selected="true"],
.btn-group > button[aria-pressed="true"] {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border-radius: var(--shape-full);
  padding-left: 22px;
  padding-right: 22px;
}

/* =====================================================================
   Chips & badges
   ===================================================================== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--shape-sm);
  border: 0;
  box-shadow: inset 0 0 0 1px var(--md-outline-variant);
  background: transparent;
  color: var(--md-on-surface-variant);
  font: 600 13.5px/1 var(--font-plain);
  cursor: pointer;
  text-decoration: none;
  transition: border-radius var(--dur-m) var(--spring-fast), background-color var(--dur-s), color var(--dur-s), box-shadow var(--dur-s);
  white-space: nowrap;
}
.chip .material-symbols-rounded { font-size: 18px; }
.chip[aria-pressed="true"] {
  background: var(--md-secondary-container);
  color: var(--md-on-secondary-container);
  box-shadow: none;
  border-radius: var(--shape-full);
}
.chip.static { cursor: default; }
.chip.tonal { background: var(--md-surface-container-high); box-shadow: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 6px;
  border-radius: var(--shape-full);
  background: var(--md-tertiary-container);
  color: var(--md-on-tertiary-container);
  font: 600 13px/1 var(--font-plain);
  text-decoration: none;
}
.badge .dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--md-tertiary); color: var(--md-on-tertiary);
}
.badge .dot .material-symbols-rounded { font-size: 14px; }

/* =====================================================================
   Cards
   ===================================================================== */
.card {
  position: relative;
  border-radius: var(--shape-xl);
  padding: 28px;
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  transition: border-radius var(--dur-l) var(--spring-gentle), transform var(--dur-l) var(--spring-gentle), background-color var(--dur-m) var(--ease-emph), box-shadow var(--dur-m) var(--ease-emph);
}
.card.outlined { background: var(--md-surface); box-shadow: inset 0 0 0 1px var(--md-outline-variant); }
.card.elevated { background: var(--md-surface-container-low); box-shadow: 0 1px 2px var(--md-shadow), 0 2px 8px -2px var(--md-shadow); }
.card.primary { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.card.secondary { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.card.tertiary { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.card.inverse { background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); }
.card.hero-primary { background: var(--md-primary); color: var(--md-on-primary); }
a.card { text-decoration: none; display: block; }
.card.interactive { cursor: pointer; }
.card.interactive:hover { border-radius: var(--shape-xxl); transform: translateY(-4px); }
.card.interactive:active { border-radius: var(--shape-lg); transform: scale(0.985); }

/* =====================================================================
   Expressive shapes (mask generated in JS from polar functions)
   ===================================================================== */
.shape {
  --size: 56px;
  --bg: var(--md-primary-container);
  --fg: var(--md-on-primary-container);
  position: relative;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  color: var(--fg);
  flex-shrink: 0;
}
.shape::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  -webkit-mask: var(--mask, none) center / 100% 100% no-repeat;
  mask: var(--mask, none) center / 100% 100% no-repeat;
  border-radius: 30%;
  transition: transform 900ms var(--spring-gentle);
}
.shape[data-shape]::before { border-radius: 0; }
.shape > * { position: relative; }
.shape .material-symbols-rounded { font-size: calc(var(--size) * 0.44); }
:hover > .shape.spin-hover::before,
.shape.spin-hover:hover::before { transform: rotate(72deg) scale(1.07); }
.shape.spin::before { animation: spin 16s linear infinite; }
.shape.primary { --bg: var(--md-primary); --fg: var(--md-on-primary); }
.shape.secondary { --bg: var(--md-secondary-container); --fg: var(--md-on-secondary-container); }
.shape.tertiary { --bg: var(--md-tertiary-container); --fg: var(--md-on-tertiary-container); }
.shape.tertiary-strong { --bg: var(--md-tertiary); --fg: var(--md-on-tertiary); }
.shape.surface { --bg: var(--md-surface-container-highest); --fg: var(--md-on-surface); }

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

/* Morphing blob (SVG path animated by JS) */
.morph svg { width: 100%; height: 100%; overflow: visible; }
.morph path { fill: var(--morph-fill, var(--md-primary-container)); transition: fill var(--dur-m); }

/* Loading indicator — M3 Expressive */
.loading-indicator {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--md-primary-container);
}
.loading-indicator .morph { width: 30px; height: 30px; --morph-fill: var(--md-primary); }

/* =====================================================================
   Floating toolbar / top bar
   ===================================================================== */
.topbar {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  margin: 0 auto;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  width: min(1180px, calc(100% - 24px));
  padding: 8px 8px 8px 8px;
  border-radius: var(--shape-full);
  background: color-mix(in oklch, var(--md-surface-container) 80%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  backdrop-filter: blur(18px) saturate(1.6);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--md-outline-variant) 55%, transparent) inset, 0 10px 30px -14px var(--md-shadow);
  transition: transform var(--dur-l) var(--spring-gentle), width var(--dur-l) var(--spring-gentle), background-color var(--dur-m);
}
.topbar.scrolled { width: min(1060px, calc(100% - 24px)); }
.topbar.hidden { transform: translateY(-140%); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 0;
  border-radius: var(--shape-full);
  text-decoration: none;
  color: var(--md-on-surface);
  font: 400 21px/1 var(--font-brand);
  font-variation-settings: "wdth" 118, "wght" 760;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand .shape { --size: 44px; --bg: var(--md-primary); --fg: var(--md-on-primary); }
.brand .ver { font: 600 11px/1 var(--font-mono); padding: 4px 7px; border-radius: var(--shape-full); background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); letter-spacing: 0; }

.nav-pills {
  position: relative;
  display: flex;
  gap: 2px;
  margin: 0 auto;
  padding: 4px;
  border-radius: var(--shape-full);
  background: color-mix(in oklch, var(--md-surface-container-highest) 75%, transparent);
}
.nav-pills a {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--shape-full);
  color: var(--md-on-surface-variant);
  font: 600 14.5px/1 var(--font-plain);
  text-decoration: none;
  transition: color var(--dur-m) var(--ease-emph);
}
.nav-pills a:hover { color: var(--md-on-surface); }
.nav-pills a .material-symbols-rounded { font-size: 20px; }
.nav-pills a[aria-current="page"] { color: var(--md-on-primary); }
.nav-pills a[aria-current="page"] .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 600, "GRAD" 0, "opsz" 24; }
.nav-pills .indicator {
  position: absolute;
  z-index: 0;
  top: 4px;
  left: 4px;
  width: 0;
  height: 40px;
  border-radius: var(--shape-full);
  background: var(--md-primary);
  transition: left var(--dur-l) var(--spring-fast), width var(--dur-l) var(--spring-fast);
}
.topbar-actions { position: relative; display: flex; align-items: center; gap: 4px; }

/* Theme menu */
.menu {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  width: 312px;
  padding: 20px;
  border-radius: var(--shape-xl);
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
  box-shadow: 0 12px 40px -10px var(--md-shadow), 0 2px 6px var(--md-shadow);
  transform-origin: top right;
  transform: scale(0.5);
  opacity: 0;
  visibility: hidden;
  transition: transform var(--dur-l) var(--spring-fast), opacity var(--dur-s) var(--ease-emph), visibility 0s linear var(--dur-l);
}
.menu.open { transform: none; opacity: 1; visibility: visible; transition: transform var(--dur-l) var(--spring-fast), opacity var(--dur-s) var(--ease-emph); }
.menu h4 { margin: 0 0 12px; }
.menu h4 + .btn-group { width: 100%; }
.menu .btn-group > button { flex: 1; justify-content: center; }
.menu .sep { height: 18px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1;
  border: 0;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  background: conic-gradient(from 200deg, oklch(0.5 0.2 var(--sh)) 0 50%, oklch(0.9 0.075 var(--sh)) 50% 75%, oklch(0.6 0.14 calc(var(--sh) + 70)) 75%);
  transition: border-radius var(--dur-m) var(--spring-fast), transform var(--dur-m) var(--spring-fast), box-shadow var(--dur-s);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked="true"] { border-radius: 32%; box-shadow: 0 0 0 3px var(--md-surface-container-high), 0 0 0 5px var(--md-primary); }
.hue-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  margin: 16px 0 0;
  border-radius: var(--shape-full);
  background: linear-gradient(90deg, oklch(0.65 0.17 0), oklch(0.65 0.17 60), oklch(0.65 0.17 120), oklch(0.65 0.17 180), oklch(0.65 0.17 240), oklch(0.65 0.17 300), oklch(0.65 0.17 360));
}
.hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px; height: 40px; border-radius: 4px;
  background: var(--md-on-surface);
  box-shadow: 0 0 0 4px var(--md-surface-container-high);
  cursor: grab;
}
.hue-slider::-moz-range-thumb { width: 8px; height: 40px; border: 0; border-radius: 4px; background: var(--md-on-surface); box-shadow: 0 0 0 4px var(--md-surface-container-high); }

/* =====================================================================
   Wavy scroll progress (M3 Expressive wavy indicator)
   ===================================================================== */
.wavy-progress {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: 8px;
  z-index: 70;
  pointer-events: none;
}
.wavy-progress svg { width: 100%; height: 100%; display: block; }
.wavy-progress .wave { stroke: var(--md-primary); fill: none; stroke-width: 3; stroke-linecap: round; }

/* =====================================================================
   FAB
   ===================================================================== */
.fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  height: 64px;
  min-width: 64px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: var(--shape-lg-inc);
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font: 600 16px/1 var(--font-plain);
  box-shadow: 0 6px 18px -6px var(--md-shadow), 0 2px 4px var(--md-shadow);
  cursor: pointer;
  transform: scale(0) rotate(-90deg);
  transition: transform var(--dur-l) var(--spring-fast), border-radius var(--dur-m) var(--spring-fast);
}
.fab.show { transform: none; }
.fab:active { border-radius: var(--shape-md); }

/* =====================================================================
   Snackbar
   ===================================================================== */
.snackbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px 14px 16px;
  border-radius: var(--shape-lg);
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  font-weight: 500;
  box-shadow: 0 10px 30px -10px var(--md-shadow);
  transform: translate(-50%, 160%) scale(0.9);
  transition: transform var(--dur-l) var(--spring-fast);
}
.snackbar.show { transform: translate(-50%, 0); }
.snackbar .material-symbols-rounded { color: var(--md-inverse-primary); }

/* =====================================================================
   Code
   ===================================================================== */
code, kbd, pre { font-family: var(--font-mono); }
:not(pre) > code {
  padding: 2px 7px;
  border-radius: var(--shape-sm);
  background: var(--md-surface-container-highest);
  color: var(--md-on-surface);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: var(--shape-sm);
  background: var(--md-surface-container-lowest);
  box-shadow: inset 0 -2px 0 var(--md-outline-variant), inset 0 0 0 1px var(--md-outline-variant);
  font-size: 0.8em;
  text-align: center;
  color: var(--md-on-surface);
}
.code {
  position: relative;
  margin: 20px 0;
  border-radius: var(--shape-xl);
  background: var(--code-bg);
  color: var(--code-fg);
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 0 20px;
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in oklch, var(--code-fg) 60%, transparent);
}
.code-head .dots { display: flex; gap: 6px; margin-right: 6px; }
.code-head .dots i { width: 11px; height: 11px; border-radius: 50%; }
.code-head .dots i:nth-child(1) { background: oklch(0.7 0.17 25); }
.code-head .dots i:nth-child(2) { background: oklch(0.82 0.15 85); }
.code-head .dots i:nth-child(3) { background: oklch(0.75 0.16 150); }
.code-head .copy { margin-left: auto; color: var(--code-fg); --s: 38px; }
.code-head .copy.done { background: oklch(0.75 0.16 150); color: oklch(0.2 0.05 150); border-radius: var(--shape-md); }
.code pre {
  margin: 0;
  padding: 14px 22px 22px;
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.7;
  tab-size: 4;
}
.code pre::-webkit-scrollbar { height: 8px; }
.code pre::-webkit-scrollbar-thumb { background: color-mix(in oklch, var(--code-fg) 20%, transparent); border-radius: 8px; }
.tok-k { color: oklch(0.78 0.14 calc(var(--h) + 20)); font-weight: 600; }
.tok-s { color: oklch(0.82 0.13 145); }
.tok-c { color: color-mix(in oklch, var(--code-fg) 48%, transparent); font-style: italic; }
.tok-d { color: oklch(0.84 0.13 85); }
.tok-n { color: oklch(0.8 0.12 30); }
.tok-f { color: oklch(0.82 0.11 230); }
.tok-b { color: oklch(0.8 0.1 calc(var(--h) + 70)); }
.tok-p { color: oklch(0.8 0.14 var(--h)); font-weight: 600; }

/* =====================================================================
   Reveal on scroll
   ===================================================================== */
.js .reveal {
  opacity: 0;
  transform: translateY(36px) scale(0.98);
  transition: opacity 600ms var(--ease-emph), transform 900ms var(--spring-gentle);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.js .reveal.in { opacity: 1; transform: none; }

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

/* =====================================================================
   Accordion (expressive: corners morph when expanded)
   ===================================================================== */
.acc {
  border-radius: var(--shape-md);
  background: var(--md-surface-container-low);
  interpolate-size: allow-keywords;
  transition: border-radius var(--dur-l) var(--spring-gentle), background-color var(--dur-m);
}
.acc:first-child { border-top-left-radius: var(--shape-xl); border-top-right-radius: var(--shape-xl); }
.acc:last-child { border-bottom-left-radius: var(--shape-xl); border-bottom-right-radius: var(--shape-xl); }
.acc[open] { border-radius: var(--shape-xl); background: var(--md-surface-container-high); margin: 6px 0; }
.acc summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px 18px 24px;
  cursor: pointer;
  font: 600 16.5px/1.4 var(--font-plain);
  border-radius: inherit;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary .chev {
  margin-left: auto;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--md-surface-container-highest);
  transition: transform var(--dur-l) var(--spring-fast), background-color var(--dur-s), border-radius var(--dur-m) var(--spring-fast);
}
.acc[open] summary .chev { transform: rotate(180deg); background: var(--md-primary); color: var(--md-on-primary); border-radius: var(--shape-md); }
.acc::details-content {
  block-size: 0;
  overflow: clip;
  transition: block-size var(--dur-l) var(--spring-gentle), content-visibility var(--dur-l) allow-discrete;
}
.acc[open]::details-content { block-size: auto; }
.acc .acc-body { padding: 0 24px 22px; color: var(--md-on-surface-variant); }
.acc .acc-body > :first-child { margin-top: 0; }
.acc .acc-body > :last-child { margin-bottom: 0; }

/* =====================================================================
   Cross-document view transitions
   ===================================================================== */
@view-transition { navigation: auto; }
.topbar { view-transition-name: topbar; }
::view-transition-old(root) { animation: 260ms var(--ease-emph-acc) both vt-out; }
::view-transition-new(root) { animation: 520ms var(--ease-emph-dec) both vt-in; }
@keyframes vt-out { to { opacity: 0; transform: scale(0.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(18px); } }

/* =====================================================================
   Footer
   ===================================================================== */
.footer {
  margin: 96px 12px 12px;
  padding: 56px clamp(24px, 5vw, 64px) 32px;
  border-radius: var(--shape-xxl);
  background: var(--md-surface-container-low);
  position: relative;
  overflow: hidden;
}
.footer-grid {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: 32px;
}
.footer h5 { margin: 0 0 14px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.footer ul a { color: var(--md-on-surface-variant); text-decoration: none; font-weight: 500; }
.footer ul a:hover { color: var(--md-primary); }
.footer .big {
  max-width: 1180px;
  margin: 48px auto 0;
  font: 400 clamp(72px, 19vw, 250px)/0.8 var(--font-brand);
  font-variation-settings: "wdth" 125, "wght" 900;
  letter-spacing: -0.05em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--md-outline-variant);
  user-select: none;
  white-space: nowrap;
}
.footer .legal {
  max-width: 1180px;
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  color: var(--md-on-surface-variant);
  font-size: 14px;
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .nav-pills a .label { display: none; }
  .nav-pills a { padding: 0 14px; }
  .brand .ver { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .topbar { top: 8px; padding: 6px; }
  .brand .name { display: none; }
  .brand { padding-right: 0; }
  .footer-grid { grid-template-columns: 1fr; }
  .menu { width: calc(100vw - 28px); right: -6px; }
}
