/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; }
img, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ── Brand tokens (overridable per org via Branding.apply()) ────────────── */
:root {
  --color-primary:       #00FF88;
  --color-secondary:     #4488FF;
  --color-work:          #00FF88;
  --color-rest:          #FF4444;
  --color-move:          #FFAA00;
  --color-warning:       #FFAA00;
  --color-complete:      #FFFFFF;
  --color-idle:          #FFFFFF;

  --color-btn-primary-bg:   var(--color-primary);
  --color-btn-primary-text: #0f0f0f;
  --color-btn-secondary-bg: #242424;

  --color-page-bg:    #0f0f0f;
  --color-popup-bg:   #242424;
  --color-overlay:    #000000;

  --color-banner-bg:  var(--surface-card);
  --color-drawer-bg:  var(--surface-card);
}

/* ── Surface & text tokens (not overridable) ────────────────────────────── */
:root {
  --surface-bg:       #0f0f0f;
  --surface-card:     #1a1a1a;
  --surface-raised:   #242424;
  --surface-border:   #2e2e2e;
  --surface-hover:    #2a2a2a;

  --text-primary:     #f0f0f0;
  --text-secondary:   #a0a0a0;
  --text-muted:       #606060;
  --text-inverse:     #0f0f0f;
  --text-on-primary:  #0f0f0f;

  --color-success:    #00FF88;
  --color-danger:     #FF4444;
  --color-info:       #4488FF;
  --color-warning-ui: #FFAA00;

  --display-bg:       #1a1a1a;
  --display-text:     #ffffff;
}

/* ── Spacing ────────────────────────────────────────────────────────────── */
:root {
  --space-1:   4px;  --space-2:   8px;  --space-3:  12px;
  --space-4:  16px;  --space-5:  20px;  --space-6:  24px;
  --space-8:  32px;  --space-10: 40px;  --space-12: 48px;
  --space-16: 64px;  --space-20: 80px;  --space-24: 96px;
}

/* ── Radii ──────────────────────────────────────────────────────────────── */
:root {
  --radius-sm:   6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-full: 9999px;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
:root {
  --font-family: system-ui, -apple-system, "Segoe UI", sans-serif;

  --text-xs:   12px;  --text-sm:   14px;  --text-base: 16px;
  --text-lg:   18px;  --text-xl:   22px;  --text-2xl:  28px;

  --weight-normal:   400;  --weight-medium:  500;
  --weight-semibold: 600;  --weight-bold:    700;  --weight-black: 900;

  --line-height-tight:  1.2;
  --line-height-normal: 1.5;
  --line-height-loose:  1.75;
}

/* ── Transitions ────────────────────────────────────────────────────────── */
:root {
  --transition-fast:  100ms ease;
  --transition-base:  200ms ease;
  --transition-slow:  400ms ease;
  --transition-phase: 600ms ease;
}

/* ── Z-index ────────────────────────────────────────────────────────────── */
:root {
  --z-base:    1;  --z-sticky:  10;  --z-drawer:  100;
  --z-modal:  200; --z-overlay: 300; --z-toast:   400;
}

/* ── Base styles ────────────────────────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--color-page-bg);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: var(--text-base);
  line-height: var(--line-height-normal);
}

/* ── Focus ──────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
  }
}

/* ── Typography utilities ───────────────────────────────────────────────── */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-danger    { color: var(--color-danger); }
.text-success   { color: var(--color-success); }

.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }

.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.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;
}
.hidden { display: none !important; }
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mb-4  { margin-bottom: var(--space-4); }
