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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-16);
}

/* ---- Neumorphic Color Tokens ---- */
:root {
  --nm-base: #e0e5ec;
  --nm-shadow: #a3b1c6;
  --nm-highlight: #ffffff;
  --nm-accent: #6366f1;
  --nm-accent-hover: #4f52e0;
  --nm-text-heading: #2d3436;
  --nm-text-body: #44475a;
  --nm-text-faint: #8a97ab;
  --nm-flat: 6px 6px 12px var(--nm-shadow), -6px -6px 12px var(--nm-highlight);
  --nm-inset: inset 4px 4px 8px var(--nm-shadow), inset -4px -4px 8px var(--nm-highlight);
  --nm-flat-sm: 3px 3px 6px var(--nm-shadow), -3px -3px 6px var(--nm-highlight);
  --nm-inset-sm: inset 2px 2px 4px var(--nm-shadow), inset -2px -2px 4px var(--nm-highlight);
  --nm-transition: cubic-bezier(0.4, 0, 0.2, 1);

  /* Semantic aliases for compatibility */
  --color-bg: var(--nm-base);
  --color-surface: var(--nm-base);
  --color-surface-2: #d8dde6;
  --color-surface-offset: #d5dae3;
  --color-surface-offset-2: #cdd2db;
  --color-divider: #c8cfd9;
  --color-border: #bcc4d0;
  --color-text: var(--nm-text-body);
  --color-text-muted: #636e82;
  --color-text-faint: var(--nm-text-faint);
  --color-text-inverse: #ffffff;
  --color-primary: var(--nm-accent);
  --color-primary-hover: var(--nm-accent-hover);
  --color-primary-active: #3b3dc8;
  --color-primary-highlight: rgba(99, 102, 241, 0.1);
  --color-success: #27ae60;
  --color-success-hover: #229954;
  --color-success-highlight: rgba(39, 174, 96, 0.1);
  --color-warning: #f39c12;
  --color-warning-hover: #d68910;
  --color-warning-highlight: rgba(243, 156, 18, 0.1);
  --color-error: #e74c3c;
  --color-error-hover: #c0392b;
  --color-error-highlight: rgba(231, 76, 60, 0.1);
  --color-blue: #2980b9;
  --color-purple: #8e44ad;
  --color-orange: #e67e22;
  --shadow-sm: var(--nm-flat-sm);
  --shadow-md: var(--nm-flat);
  --shadow-lg: 8px 8px 20px var(--nm-shadow), -8px -8px 20px var(--nm-highlight);
  --transition-interactive: 0.35s var(--nm-transition);
}

[data-theme="dark"] {
  --nm-base: #2d3436;
  --nm-shadow: #1d2426;
  --nm-highlight: #3d4447;
  --nm-accent: #6366f1;
  --nm-accent-hover: #7b7ef5;
  --nm-text-heading: #ffffff;
  --nm-text-body: #e0e5ec;
  --nm-text-faint: #8b949e;
  --nm-flat: 6px 6px 12px var(--nm-shadow), -6px -6px 12px var(--nm-highlight);
  --nm-inset: inset 4px 4px 8px var(--nm-shadow), inset -4px -4px 8px var(--nm-highlight);
  --nm-flat-sm: 3px 3px 6px var(--nm-shadow), -3px -3px 6px var(--nm-highlight);
  --nm-inset-sm: inset 2px 2px 4px var(--nm-shadow), inset -2px -2px 4px var(--nm-highlight);

  --color-bg: var(--nm-base);
  --color-surface: var(--nm-base);
  --color-surface-2: #353b3d;
  --color-surface-offset: #383e41;
  --color-surface-offset-2: #3e4447;
  --color-divider: #454c4f;
  --color-border: #505859;
  --color-text: var(--nm-text-body);
  --color-text-muted: #a0abb8;
  --color-text-faint: var(--nm-text-faint);
  --color-text-inverse: #1a1f20;
  --color-primary: var(--nm-accent);
  --color-primary-hover: var(--nm-accent-hover);
  --color-primary-active: #5254d8;
  --color-primary-highlight: rgba(99, 102, 241, 0.15);
  --color-success: #3fb950;
  --color-success-hover: #56d364;
  --color-success-highlight: rgba(63, 185, 80, 0.12);
  --color-warning: #e3b341;
  --color-warning-hover: #d29922;
  --color-warning-highlight: rgba(210, 153, 34, 0.12);
  --color-error: #f85149;
  --color-error-hover: #ff7b72;
  --color-error-highlight: rgba(248, 81, 73, 0.12);
  --color-blue: #58a6ff;
  --color-purple: #bc8cff;
  --color-orange: #f0883e;
  --shadow-sm: var(--nm-flat-sm);
  --shadow-md: var(--nm-flat);
  --shadow-lg: 8px 8px 20px var(--nm-shadow), -8px -8px 20px var(--nm-highlight);
  --transition-interactive: 0.35s var(--nm-transition);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --nm-base: #2d3436;
    --nm-shadow: #1d2426;
    --nm-highlight: #3d4447;
    --nm-accent: #6366f1;
    --nm-accent-hover: #7b7ef5;
    --nm-text-heading: #ffffff;
    --nm-text-body: #e0e5ec;
    --nm-text-faint: #8b949e;
    --color-bg: var(--nm-base);
    --color-surface: var(--nm-base);
    --color-surface-2: #353b3d;
    --color-surface-offset: #383e41;
    --color-surface-offset-2: #3e4447;
    --color-divider: #454c4f;
    --color-border: #505859;
    --color-text: var(--nm-text-body);
    --color-text-muted: #a0abb8;
    --color-text-faint: var(--nm-text-faint);
    --color-text-inverse: #1a1f20;
    --color-primary: var(--nm-accent);
    --color-primary-hover: var(--nm-accent-hover);
    --color-primary-active: #5254d8;
    --color-primary-highlight: rgba(99, 102, 241, 0.15);
    --color-success: #3fb950;
    --color-success-hover: #56d364;
    --color-success-highlight: rgba(63, 185, 80, 0.12);
    --color-warning: #e3b341;
    --color-warning-hover: #d29922;
    --color-warning-highlight: rgba(210, 153, 34, 0.12);
    --color-error: #f85149;
    --color-error-hover: #ff7b72;
    --color-error-highlight: rgba(248, 81, 73, 0.12);
    --color-blue: #58a6ff;
    --color-purple: #bc8cff;
    --color-orange: #f0883e;
    --shadow-sm: var(--nm-flat-sm);
    --shadow-md: var(--nm-flat);
    --shadow-lg: 8px 8px 20px var(--nm-shadow), -8px -8px 20px var(--nm-highlight);
    --transition-interactive: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body, sans-serif);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
ul[role="list"], ol[role="list"] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; color: var(--nm-text-heading); }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }

::selection {
  background: rgba(99, 102, 241, 0.25);
  color: var(--color-text);
}

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

@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;
  }
}

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

a, button, [role="button"], [role="link"], input, textarea, select {
  transition: color var(--transition-interactive),
              background var(--transition-interactive),
              border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}

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