/*
 * Occupemo Web — Design System
 * Ported from Occupemo/App/Theme.swift (exact hex values)
 *
 * Usage:
 *   - Pages must include this file AND the Inter Google Font link:
 *     <link rel="preconnect" href="https://fonts.googleapis.com">
 *     <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
 *     <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
 *   - Dark mode: add class "dark" to <html>. initTheme() in ui.js handles
 *     prefers-color-scheme detection and localStorage override.
 *   - All component classes use CSS custom properties — never hardcode hex.
 */

/* ============================================================
   0. Type — Bricolage Grotesque (display, variable) + Manrope (body).
      Both have warmth and character that Inter lacks. The variable
      axis on Bricolage gives us distinctive headlines without a
      second download.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wdth,wght@12..96,75..100,400..800&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ============================================================
   1. Color tokens — light mode (from Theme.swift)
   ============================================================ */
:root {
  /* Primary accent — electric purple */
  --color-accent:         #5840F7;
  --color-accent-light:   #7B67F9;
  --color-accent-surface: #EDE9FE;

  /* Backgrounds */
  --color-bg:             #FFFFFF;
  --color-surface:        #F1F3F9;
  --color-surface-dark:   #1C2033;

  /* Text */
  --color-text-primary:   #1D2433;
  --color-text-secondary: #828CA0;
  --color-text-muted:     #9D9EA1;
  --color-text-inactive:  #C2C2C4;

  /* Borders */
  --color-border:         #E1E6EF;
  --color-border-dark:    #3F444D;

  /* State colors (no dark variant — same across modes) */
  --color-success:        #22C55E;
  --color-warning:        #F59E0B;
  --color-error:          #EF4444;
  --color-coral:          #F43F5E;

  /* Splash gradient */
  --color-gradient-top:    #7B5CE7;
  --color-gradient-bottom: #C77DFF;

  /* Category colors (from Theme.swift:38-43) */
  --color-cat-academic:     #5840F7;
  --color-cat-sports:       #22C55E;
  --color-cat-art:          #F97316;
  --color-cat-entertainment:#F43F5E;
  --color-cat-social:       #EC4899;
  --color-cat-unknown:      #8B8FA8;

  /* ============================================================
     2. Spacing tokens (from Theme.swift:60-69)
     ============================================================ */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  12px;
  --space-lg:  16px;
  --space-xl:  24px;
  --space-xxl: 32px;
  --screen-pad: 16px;
  --card-pad:   16px;
  --card-gap:   8px;

  /* ============================================================
     3. Radius tokens (from Theme.swift:73-79)
     ============================================================ */
  --radius-xs:   6px;
  --radius-sm:   8px;
  --radius-md:   10px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-xxl:  20px;
  --radius-full: 360px;

  /* ============================================================
     4. Shadow tokens (from Theme.swift:83-95)
     ============================================================ */
  --shadow-card:    0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-tab-bar: 0 -10px 20px rgba(0, 0, 0, 0.05);
  --shadow-floating: 0 10px 30px rgba(0, 0, 0, 0.12);

  /* ============================================================
     4b. Motion tokens — shared with iOS Theme.Motion
         (BRAND_IDENTITY.md §8 — Motion language)
     ============================================================ */
  --motion-instant:    100ms;
  --motion-fast:       180ms;
  --motion-base:       240ms;
  --motion-slow:       360ms;
  --motion-cinematic:  600ms;

  /* Easings */
  --ease-out:    cubic-bezier(0.22, 0.61, 0.36, 1);   /* default — entrances */
  --ease-in:     cubic-bezier(0.55, 0, 0.68, 0.06);   /* exits */
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);      /* state changes */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);   /* Occupemo bounce */

  /* Layout */
  --sidebar-width: 240px;
  --bottom-nav-height: 60px;
  --mobile-breakpoint: 768px;

  /* Z-index scale — a documented stack so we never have to play whack-a-mole
     with magic numbers. Always reach for these tokens (not raw numbers). */
  --z-bottom-nav:  100;   /* fixed mobile nav, sticky page headers below this */
  --z-dropdown:    200;   /* tooltips, small popovers */
  --z-modal:       500;   /* modal overlay */
  --z-popover:    1050;   /* popovers anchored to modal contents */
  --z-toast:      1100;   /* always on top */
}

/* ============================================================
   4c. prefers-reduced-motion — collapse durations to instant
       (browser-level honoring; component CSS still respects this
        via @media checks for transforms it can't disable here)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  :root {
    --motion-instant:   1ms;
    --motion-fast:      1ms;
    --motion-base:      1ms;
    --motion-slow:      1ms;
    --motion-cinematic: 1ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   5. Dark mode — .dark class on <html>
      Values from Theme.swift dark variants.
      Automatically applied by initTheme() in ui.js based on
      prefers-color-scheme and localStorage.theme override.
   ============================================================ */
.dark {
  --color-accent:         #7B67F9;
  --color-accent-light:   #9B8BFB;
  --color-accent-surface: #2A2347;

  --color-bg:             #0F1120;
  --color-surface:        #1C2033;
  --color-surface-dark:   #252A40;

  --color-text-primary:   #F1F3F9;
  --color-text-secondary: #A8B2C5;
  --color-text-muted:     #7A8090;
  --color-text-inactive:  #5A5F6E;

  --color-border:         #2D3344;
  --color-border-dark:    #5A6070;

  --shadow-card:    0 2px 8px rgba(0, 0, 0, 0.18);
  --shadow-tab-bar: 0 -10px 20px rgba(0, 0, 0, 0.18);
}

/* ============================================================
   6. Respect prefers-color-scheme as default (JS overrides via
      .dark class on <html> when localStorage.theme is set)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --color-accent:         #7B67F9;
    --color-accent-light:   #9B8BFB;
    --color-accent-surface: #2A2347;

    --color-bg:             #0F1120;
    --color-surface:        #1C2033;
    --color-surface-dark:   #252A40;

    --color-text-primary:   #F1F3F9;
    --color-text-secondary: #A8B2C5;
    --color-text-muted:     #7A8090;
    --color-text-inactive:  #5A5F6E;

    --color-border:         #2D3344;
    --color-border-dark:    #5A6070;

    --shadow-card:    0 2px 8px rgba(0, 0, 0, 0.18);
    --shadow-tab-bar: 0 -10px 20px rgba(0, 0, 0, 0.18);
  }
}

/* ============================================================
   7. Base reset + body
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15.5px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  letter-spacing: -0.005em;
  transition: background-color 0.2s ease, color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Display type — used on h1/h2/page titles via .page-title and friends */
h1, h2, h3, .page-title, .text-hero, .text-h1, .text-h2 {
  font-family: 'Bricolage Grotesque', 'Manrope', sans-serif;
  font-variation-settings: 'wdth' 92, 'opsz' 32;
  letter-spacing: -0.022em;
  font-weight: 700;
}

/* Sweep the .text-h1/h2 size down a touch so Bricolage's optical weight
   reads at parity with what Inter looked like. */
.text-hero { font-size: 38px; line-height: 1.05; }
.text-h1   { font-size: 30px; line-height: 1.1;  }
.text-h2   { font-size: 22px; line-height: 1.2;  }

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ============================================================
   8. Typography scale (from Theme.swift:47-56 + WEBSITE_SPEC §4.2)
   ============================================================ */
.text-hero {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.text-h1 {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.text-h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
}

.text-h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.text-body {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.text-body-med {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}

.text-caption {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.2px;
}

.text-small {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.1px;
}

/* Utility color helpers */
.text-primary   { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted     { color: var(--color-text-muted); }
.text-inactive  { color: var(--color-text-inactive); }
.text-accent    { color: var(--color-accent); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-error     { color: var(--color-error); }

/* ============================================================
   9. Layout — App chrome
   App pages use a sidebar on desktop, bottom nav on mobile.
   Structure:
     <div class="app-layout">
       <nav id="sidebar-root" class="sidebar"></nav>
       <main class="app-main">...</main>
     </div>
     <nav id="bottom-nav-root" class="bottom-nav"></nav>
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-xl);
  overflow-y: auto;
}

/* ============================================================
   10. Sidebar (desktop — shown >= 768px)
   --------------------------------------------------------------
   Mechanics mirror the mockup the user shared:
     • Top: bordered "logo frame" — large lockup expanded,
       small mark when collapsed.
     • Middle: nav list. Active item gets a tinted pill with a
       full border + accent-tinted icon + accent label.
     • Bottom: Plus badge, theme + sign-out icon utils, and the
       collapse toggle (rounded rect with a chevron pointing
       inward when expanded, outward when collapsed).
   ============================================================ */
.sidebar {
  --sidebar-pad-x: 14px;
  width: var(--sidebar-width);
  min-height: 100vh;
  background-color: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--sidebar-pad-x);
  position: sticky;
  top: 0;
  flex-shrink: 0;
  gap: var(--space-md);
  transition: width 0.22s cubic-bezier(0.2, 0.8, 0.2, 1),
              padding 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.sidebar.collapsed {
  width: 76px;
  --sidebar-pad-x: 10px;
}

/* ─── Logo (top) ──────────────────────────────────────────────── */
/* No frame, no border. Wordmark+clock expanded; clock-only collapsed. */
.sidebar-logo-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 6px;
  text-decoration: none;
  min-height: 40px;
  transition: opacity 0.15s ease;
}

.sidebar-logo-link:hover {
  text-decoration: none;
  opacity: 0.85;
}

.sidebar-logo {
  display: block;
  width: auto;
  max-width: 100%;
}

.sidebar-logo--large { height: 26px; }
.sidebar-logo--small { display: none; height: 32px; }

.sidebar.collapsed .sidebar-logo-link {
  justify-content: center;
  padding: 4px 0;
}

.sidebar.collapsed .sidebar-logo--large { display: none; }
.sidebar.collapsed .sidebar-logo--small { display: block; }

/* ─── Nav list ────────────────────────────────────────────────── */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  margin-top: var(--space-xs);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--color-text-primary);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  background: transparent;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.sidebar-nav-item:hover {
  background-color: var(--color-bg);
  text-decoration: none;
}

.sidebar-nav-item.is-active {
  /* Tinted pill with a full accent border — the brand purple equivalent
     of the green active state from the mockup. */
  background-color: var(--color-accent-surface);
  border-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
  color: var(--color-accent);
  font-weight: 600;
}

.sidebar-nav-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: color 0.18s ease;
}

.sidebar-nav-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}

.sidebar-nav-item:hover .sidebar-nav-icon {
  color: var(--color-text-primary);
}

.sidebar-nav-item.is-active .sidebar-nav-icon {
  color: var(--color-accent);
}

/* Collapsed nav — icon-only, centered, active state becomes a tinted square */
.sidebar.collapsed .sidebar-nav-item {
  justify-content: center;
  padding: 10px;
  gap: 0;
}

.sidebar.collapsed .sidebar-nav-item.is-active {
  background-color: var(--color-accent-surface);
  border-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
}

.sidebar.collapsed .sidebar-nav-label {
  display: none;
}

/* ─── Bottom stack: badge, utilities, collapse toggle ────────── */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.sidebar-utilities {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

/* Util buttons inherit .sidebar-nav-item from the cascade. This modifier
   gives them a slightly muted resting color so they don't compete with
   the primary nav for attention. */
.sidebar-nav-item--util {
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 13.5px;
}

.sidebar-nav-item--util .sidebar-nav-icon {
  color: var(--color-text-muted);
}

.sidebar-nav-item--util:hover {
  color: var(--color-text-primary);
}

/* ─── Collapse toggle (always visible, bottom-most) ──────────── */
.sidebar-collapse-toggle {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-collapse-toggle:hover {
  background: var(--color-accent-surface);
  border-color: color-mix(in srgb, var(--color-accent) 25%, var(--color-border));
  color: var(--color-accent);
}

/* Plus badge in collapsed mode: hide (no icon-only fallback yet) */
.sidebar.collapsed .plus-badge {
  display: none;
}

/* Hide sidebar on mobile */
@media (max-width: 767px) {
  .sidebar {
    display: none;
  }
  .app-main {
    /* Safe-area-aware padding so notches in landscape don't clip content.
       env() falls back to 0 on devices/browsers that don't expose it. */
    padding: var(--space-lg);
    padding-left:   calc(var(--space-lg) + env(safe-area-inset-left, 0px));
    padding-right:  calc(var(--space-lg) + env(safe-area-inset-right, 0px));
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-lg) + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================================
   11. Bottom nav (mobile — shown < 768px)
   ============================================================ */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  /* Add safe-area padding via min-height so the bar still measures correctly
     on notched devices in landscape (env() values fall back to 0 on others). */
  min-height: var(--bottom-nav-height);
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-tab-bar);
  z-index: var(--z-bottom-nav);
  padding: 0 var(--space-sm);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: var(--bottom-nav-height);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--color-text-inactive);
  font-size: 10.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s ease;
  /* Minimum 44pt iOS / 48dp Material touch target. */
  min-height: 44px;
  padding: var(--space-sm) var(--space-xs);
  border-radius: var(--radius-sm);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.bottom-nav-item:active {
  background-color: var(--color-accent-surface);
}

.bottom-nav-item.active {
  color: var(--color-accent);
}

.bottom-nav-item .nav-icon {
  width: 24px;
  height: 24px;
}

@media (max-width: 767px) {
  .bottom-nav {
    display: flex;
  }
}

/* ============================================================
   12. Card component
   ============================================================ */
.card {
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, var(--shadow-card);
  border: 1px solid var(--color-border);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

/* ============================================================
   Category chip selector — shared by Tasks, Goals, AddTask modal.
   Was previously only loaded with tasks.css; promoted to global so
   every modal/picker gets the same chip aesthetic.
   ============================================================ */
.category-selector {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
}

.category-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.category-option:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.category-option.selected {
  border-color: var(--accent-cat-color, var(--color-accent));
  background-color: color-mix(in srgb, var(--accent-cat-color, var(--color-accent)) 12%, transparent);
  color: var(--accent-cat-color, var(--color-accent));
}

.category-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}

.card:hover {
  border-color: var(--color-border-dark, var(--color-border));
}

/* Accent card — 4px left color strip (mirrors AccentCard.swift) */
.accent-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--card-pad);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
  padding-left: calc(var(--card-pad) + 6px);
}

.accent-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--color-accent);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
}

/* Category-colored strip — set --accent-strip-color inline */
.accent-card[style*="--accent-strip-color"]::before {
  background-color: var(--accent-strip-color);
}

/* ============================================================
   13. Button components
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition:
    opacity var(--motion-fast) var(--ease-out),
    transform var(--motion-fast) var(--ease-out),
    background-color var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
  will-change: transform;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Branded focus ring — meets WCAG AA, doesn't fight the design */
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn-primary {
  background-color: var(--color-accent);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(88, 64, 247, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-accent-light);
  color: #FFFFFF;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(88, 64, 247, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(88, 64, 247, 0.2);
}

.btn-secondary {
  background-color: var(--color-accent-surface);
  color: var(--color-accent);
}

.btn-secondary:hover:not(:disabled) {
  opacity: 0.85;
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--color-surface);
  color: var(--color-text-primary);
  text-decoration: none;
}

.btn-sm {
  padding: 6px var(--space-md);
  font-size: 14px;
  border-radius: var(--radius-md);
}

.btn-danger {
  background-color: var(--color-error);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.85;
  text-decoration: none;
}

/* ============================================================
   14. Input component
   ============================================================ */
.input {
  width: 100%;
  padding: 10px var(--space-md);
  background-color: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-primary);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--color-text-inactive);
}

.input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-surface);
}

.input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-error {
  border-color: var(--color-error);
}

.input-error:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-xs);
}

.input-hint {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.input-error-msg {
  font-size: 12px;
  color: var(--color-error);
  margin-top: var(--space-xs);
  /* Apply role="alert" on the HTML element itself so screen readers announce. */
}

/* ============================================================
   15. Pill / PillPicker (segmented capsule selector)
   ============================================================ */
.pill-group {
  display: inline-flex;
  gap: var(--space-xs);
  background-color: var(--color-surface);
  border-radius: var(--radius-full);
  padding: 3px;
}

.pill {
  padding: 6px var(--space-md);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  border: none;
  background: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.pill:hover {
  color: var(--color-text-primary);
}

.pill-selected {
  background-color: var(--color-bg);
  color: var(--color-accent);
  box-shadow: var(--shadow-card);
}

/* ============================================================
   16. Category badge (colored dot + label — mirrors CategoryBadge.swift)
   ============================================================ */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  background-color: var(--color-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.category-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Category-specific badge colors */
.category-badge[data-category="academic"]      { color: var(--color-cat-academic); border-color: var(--color-cat-academic); background-color: rgba(88, 64, 247, 0.08); }
.category-badge[data-category="sports"]        { color: var(--color-cat-sports); border-color: var(--color-cat-sports); background-color: rgba(34, 197, 94, 0.08); }
.category-badge[data-category="art"]           { color: var(--color-cat-art); border-color: var(--color-cat-art); background-color: rgba(249, 115, 22, 0.08); }
.category-badge[data-category="entertainment"] { color: var(--color-cat-entertainment); border-color: var(--color-cat-entertainment); background-color: rgba(244, 63, 94, 0.08); }
.category-badge[data-category="social"]        { color: var(--color-cat-social); border-color: var(--color-cat-social); background-color: rgba(236, 72, 153, 0.08); }
.category-badge[data-category="unknown"]       { color: var(--color-cat-unknown); border-color: var(--color-cat-unknown); background-color: rgba(139, 143, 168, 0.08); }

/* ============================================================
   17. Chip (filter chip — smaller, dismissible variant)
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 5px var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.chip-active {
  background-color: var(--color-accent-surface);
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ============================================================
   18. Toast notification
   ============================================================ */
.toast-container {
  position: fixed;
  /* Keep toasts clear of the bottom nav AND the bottom safe-area on iPhones. */
  bottom: calc(var(--bottom-nav-height) + var(--space-lg) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: center;
  pointer-events: none;
}

@media (min-width: 768px) {
  .toast-container {
    bottom: var(--space-xl);
    left: auto;
    right: var(--space-xl);
    transform: none;
    align-items: flex-end;
  }
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  border-radius: var(--radius-xl);
  font-size: 14px;
  font-weight: 600;
  /* Inverted surface — uses --color-bg as the foreground so the toast
     reads correctly in both light and dark modes (was hardcoded #FFFFFF,
     which became invisible on the near-white dark-mode text color). */
  color: var(--color-bg);
  background-color: var(--color-text-primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  max-width: 320px;
  text-align: center;
}

/* Status-colored toasts keep white text — these backgrounds are saturated
   enough that white stays readable in both themes. */
.toast-success { background-color: var(--color-success); color: #FFFFFF; }
.toast-error   { background-color: var(--color-error);   color: #FFFFFF; }
.toast-warning { background-color: var(--color-warning); color: #FFFFFF; }

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

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

.toast-hiding {
  animation: toast-out 0.2s ease forwards;
}

/* ============================================================
   19. Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: overlay-in 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background-color: var(--color-bg);
  border-radius: var(--radius-xxl);
  padding: var(--space-xl);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  position: relative;
  animation: modal-in 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow-y: auto;
  /* iOS Safari: avoid the rubber-band scroll from leaking to the body. */
  overscroll-behavior: contain;
}

@media (max-width: 767px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: var(--radius-xxl) var(--radius-xxl) 0 0;
    max-width: 100%;
    /* On phones use nearly the full viewport so big modals (Add Task,
       Theme Studio) don't get cropped behind a soft keyboard. The 4vh
       gap keeps a sliver of dimmed background visible so the user knows
       this is a sheet, not a full page. */
    max-height: calc(100vh - 4vh);
    padding-bottom: calc(var(--space-xl) + env(safe-area-inset-bottom, 0px));
    animation: modal-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  }
}

.modal-close {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--color-surface);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 16px;
  font-weight: 700;
  transition: background-color 0.15s ease;
}

.modal-close:hover {
  background-color: var(--color-border);
}

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes modal-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ============================================================
   20. Progress bar (mirrors ProgressBarView.swift)
   ============================================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--color-accent);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.progress-bar-fill.success { background-color: var(--color-success); }
.progress-bar-fill.warning { background-color: var(--color-warning); }
.progress-bar-fill.error   { background-color: var(--color-error); }

/* ─── Live block progress bar (replaces the old Tools stopwatch) ──────────
   Rendered inside the "current" block on the dashboard timetable AND on
   the schedule active page. JS ticks at 1 Hz, updating fill width and the
   "12:34 left" / "+0:42 over" inline text. Designed so the visual sits
   naturally inside the card layout without restructuring it.

   --block-progress-tint is set inline to the block's category color hex
   (or stays as the brand accent fallback) so the bar feels like part of
   that specific task, not a generic widget. */
.block-progress {
  --block-progress-tint: var(--color-accent);
  margin-top: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.block-progress-bar {
  flex: 1;
  height: 6px;
  background-color: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.block-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--block-progress-tint) 78%, white 22%),
    var(--block-progress-tint)
  );
  border-radius: var(--radius-full);
  transition: width 0.45s linear;
  box-shadow: 0 0 8px -2px color-mix(in srgb, var(--block-progress-tint) 70%, transparent);
}

.block-progress-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--block-progress-tint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: 0.1px;
  min-width: 74px;
  text-align: right;
}

/* Overrun state — block ran past its scheduled end without being marked
   complete. Switches the visual to the warning color so users notice. */
.block-progress.is-overrun {
  --block-progress-tint: var(--color-warning);
}

.block-progress.is-overrun .block-progress-fill {
  background: var(--color-warning);
  animation: block-progress-overrun-pulse 1.6s ease-in-out infinite;
}

@keyframes block-progress-overrun-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .block-progress-fill {
    transition: none;
  }
  .block-progress.is-overrun .block-progress-fill {
    animation: none;
  }
}

/* ============================================================
   21. Empty state (mirrors EmptyStateView.swift)
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xxl) var(--space-xl);
  text-align: center;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  background-color: var(--color-accent-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-sm);
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.empty-state-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  max-width: 260px;
  line-height: 1.5;
}

/* ============================================================
   22. Plus badge (sidebar bottom — upgrade prompt)
   ============================================================ */
.plus-badge {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  border-radius: var(--radius-lg);
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.plus-badge:hover {
  opacity: 0.9;
  text-decoration: none;
}

.plus-badge-label {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
}

.plus-badge-sub {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
}

/* Active Plus state — same gradient with a sparkle and a subtle glow ring */
.plus-badge--active {
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18) inset,
              0 6px 18px -8px rgba(88, 64, 247, 0.55);
}

.plus-badge-spark {
  font-size: 18px;
  color: #FFFFFF;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

/* ─── Celebration sheet ─────────────────────────────────────────────────── */
.celebration-sheet {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
  max-width: 460px;
}

.celebration-spark {
  font-size: 56px;
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 18px rgba(123, 92, 231, 0.45));
  margin-bottom: var(--space-md);
  animation: spark-spin 1.6s ease-in-out 1;
}

@keyframes spark-spin {
  0%   { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60%  { transform: scale(1.18) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.celebration-headline {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0 0 var(--space-sm);
  letter-spacing: -0.4px;
}

.celebration-body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xl);
}

.celebration-actions {
  display: flex;
  justify-content: center;
}

/* ─── Add Task modal (iOS AddTaskSheet parity) ──────────────────────────── */
.add-task-modal {
  max-width: 540px;
  width: 100%;
  padding: var(--space-md) var(--space-sm);
}

.add-task-modal-title {
  font-family: 'Bricolage Grotesque', 'Manrope', sans-serif;
  font-variation-settings: 'wdth' 92, 'opsz' 28;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
  color: var(--color-text-primary);
}

.add-task-modal-nl {
  font-size: 16px; /* ≥16px keeps iOS Safari from zooming on focus */
  padding: 12px 14px;
}

.add-task-modal-nl-hint {
  margin: 6px 2px 0;
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.add-task-modal-nl-hint em {
  font-style: normal;
  color: var(--color-text-secondary);
  font-weight: 600;
}

.add-task-modal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-sm) 0 var(--space-lg);
}

.add-task-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.add-task-chip:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.add-task-chip--override {
  border-color: var(--color-accent);
  background-color: var(--color-accent-surface);
  color: var(--color-accent);
}

.add-task-modal-field {
  margin-top: var(--space-md);
}

.add-task-modal-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.add-task-modal-more-toggle {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: var(--space-md) 0 var(--space-xs);
  text-align: left;
}

.add-task-modal-more-toggle:hover {
  color: var(--color-accent);
}

.add-task-modal-more.is-hidden {
  display: none;
}

.add-task-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

/* ─── Popover (chip pickers) ─────────────────────────────────────────────── */
.add-task-popover {
  position: absolute;
  z-index: var(--z-popover);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 38px -10px rgba(0, 0, 0, 0.22);
  padding: 6px;
  min-width: 200px;
  max-width: 320px;
  max-height: 320px;
  overflow-y: auto;
}

.add-task-popover-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
}

.add-task-popover-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.add-task-popover-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.add-task-popover-option:hover {
  background: var(--color-accent-surface);
}

.add-task-popover-option.is-active {
  background: var(--color-accent-surface);
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
}

.add-task-popover-date {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
}

.add-task-popover-clear {
  background: transparent;
  border: none;
  color: var(--color-error);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  text-align: left;
}

/* ─── Onboarding flow ──────────────────────────────────────────────────── */
.onboarding-sheet {
  max-width: 560px;
  width: 100%;
  padding: var(--space-md);
  text-align: left;
}

.onboarding-step-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.onboarding-spark {
  font-size: 36px;
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: var(--space-md);
  display: inline-block;
}

.onboarding-title {
  font-family: 'Bricolage Grotesque', 'Manrope', sans-serif;
  font-variation-settings: 'wdth' 92, 'opsz' 32;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--color-text-primary);
  margin: 0 0 var(--space-sm);
}

.onboarding-title--gradient {
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.onboarding-body {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-md);
}

.onboarding-body--small {
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.onboarding-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

@media (max-width: 520px) {
  .onboarding-grid { grid-template-columns: 1fr; }
}

.onboarding-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--color-text-primary);
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.12s ease;
}

.onboarding-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-1px);
}

.onboarding-card.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-surface);
  color: var(--color-accent);
}

.onboarding-card-icon {
  width: 28px;
  height: 28px;
  color: var(--color-accent);
}

.onboarding-card-label {
  font-size: 15px;
  font-weight: 700;
}

.onboarding-card-blurb {
  font-size: 12px;
  color: var(--color-text-muted);
}

.onboarding-card.is-selected .onboarding-card-blurb { color: var(--color-accent); opacity: 0.75; }

.onboarding-q {
  margin-bottom: var(--space-lg);
}

.onboarding-q-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: 8px;
}

.onboarding-q-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.onboarding-q-option {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-bg);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.onboarding-q-option:hover {
  border-color: var(--color-accent);
}

.onboarding-q-option.is-selected {
  border-color: var(--color-accent);
  background: var(--color-accent-surface);
  color: var(--color-accent);
}

.onboarding-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.onboarding-skip-link {
  order: -1;                 /* sits to the left of the primary CTA */
  margin-right: auto;        /* pushes the CTA to the right */
  background: none;
  border: none;
  padding: 8px 4px;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.onboarding-skip-link:hover {
  color: var(--color-text-primary);
  text-decoration-color: currentColor;
}

.onboarding-skip-link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Calibration animation */
.onboarding-calibration {
  text-align: center;
  padding: var(--space-xl) var(--space-md);
}

.onboarding-calibration-spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: var(--space-lg);
}

.onboarding-calibration-orb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  animation: onboarding-orb-bounce 1s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.onboarding-calibration-orb:nth-child(2) { animation-delay: 0.15s; }
.onboarding-calibration-orb:nth-child(3) { animation-delay: 0.30s; }

@keyframes onboarding-orb-bounce {
  0%, 100% { transform: translateY(0) scale(0.9); opacity: 0.65; }
  50%      { transform: translateY(-12px) scale(1.0); opacity: 1; }
}

.onboarding-status {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: opacity 0.3s ease;
}

/* ─── Reflection sheet ──────────────────────────────────────────────────── */
.reflection-sheet {
  max-width: 500px;
  width: 100%;
  padding: var(--space-md);
}

.reflection-sheet-title {
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px;
  color: var(--color-text-primary);
}

.reflection-sheet-sub {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-lg);
}

.reflection-moods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.reflection-mood {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-sm);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
}

.reflection-mood:hover {
  border-color: var(--color-accent);
}

.reflection-mood.selected {
  border-color: var(--color-accent);
  background: var(--color-accent-surface);
  transform: translateY(-2px);
}

.reflection-mood-emoji {
  font-size: 32px;
}

.reflection-mood-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-top: 4px;
}

.reflection-mood-sub {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.reflection-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

/* ============================================================
   22a. Empty state — canonical component (was duplicated in tasks.css)
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xxl) var(--space-xl);
  text-align: center;
  gap: var(--space-md);
  /* Subtle entrance — not a scroll reveal since empty states appear in-place */
  animation: empty-state-in var(--motion-slow) var(--ease-out) both;
}

@keyframes empty-state-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .empty-state { animation: none; }
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.empty-state-icon svg {
  width: 28px;
  height: 28px;
}

/* Modifier — error variant (red bg, white symbol).
   Use when the empty state represents a failure rather than an absence. */
.empty-state-icon--error {
  background: var(--color-error);
}

.empty-state-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.empty-state-body,
.empty-state-subtitle {
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text-secondary);
  max-width: 320px;
  margin: 0;
}

.empty-state .btn {
  margin-top: var(--space-sm);
}

/* ============================================================
   22b. Loading skeleton — canonical (was duplicated in dashboard.css + schedule.css)
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-border) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

.skeleton-line {
  height: 14px;
  margin-bottom: var(--space-sm);
}
.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short  { width: 45%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.full   { width: 100%; }

.skeleton-block {
  height: 72px;
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-sm);
}

/* Reduce motion → freeze the shimmer */
@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
    background: var(--color-surface);
  }
}

/* ============================================================
   22c. Global focus-visible — branded ring for all interactive elements
        (browsers' default ring is faint; this matches the accent)
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* .btn, .input, .chip, .pill have their own focus rules at the component
   level — global :focus-visible above falls back for everything else. */

/* ============================================================
   22c. Scroll-reveal — marketing page entrance animations
        Add data-reveal to any element to fade+lift it into view as
        it enters the viewport. JS toggles the class via IntersectionObserver.
        Honors prefers-reduced-motion (no animation, instant final state).
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--motion-slow) var(--ease-out),
    transform var(--motion-slow) var(--ease-out);
  will-change: opacity, transform;
}

[data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children: add data-reveal-stagger to a parent, and each
   direct [data-reveal] child gets a 60ms cumulative delay. */
[data-reveal-stagger] [data-reveal]:nth-child(1) { transition-delay: 0ms; }
[data-reveal-stagger] [data-reveal]:nth-child(2) { transition-delay: 60ms; }
[data-reveal-stagger] [data-reveal]:nth-child(3) { transition-delay: 120ms; }
[data-reveal-stagger] [data-reveal]:nth-child(4) { transition-delay: 180ms; }
[data-reveal-stagger] [data-reveal]:nth-child(5) { transition-delay: 240ms; }
[data-reveal-stagger] [data-reveal]:nth-child(6) { transition-delay: 300ms; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ============================================================
   23. Utility classes
   ============================================================ */
.hidden   { display: none !important; }
.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;
}

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.flex-1      { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs  { gap: var(--space-xs); }
.gap-sm  { gap: var(--space-sm); }
.gap-md  { gap: var(--space-md); }
.gap-lg  { gap: var(--space-lg); }
.gap-xl  { gap: var(--space-xl); }
.p-md    { padding: var(--space-md); }
.p-lg    { padding: var(--space-lg); }
.p-xl    { padding: var(--space-xl); }
.mt-sm   { margin-top: var(--space-sm); }
.mt-md   { margin-top: var(--space-md); }
.mt-lg   { margin-top: var(--space-lg); }
.mt-xl   { margin-top: var(--space-xl); }
.mb-sm   { margin-bottom: var(--space-sm); }
.mb-md   { margin-bottom: var(--space-md); }
.mb-lg   { margin-bottom: var(--space-lg); }
.mb-xl   { margin-bottom: var(--space-xl); }
.w-full  { width: 100%; }

/* Gradient text (for the Occupemo wordmark) */
.gradient-text {
  background: linear-gradient(135deg, var(--color-gradient-top), var(--color-gradient-bottom));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   24. Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Theme Studio — inlined here so it can't fail to load.
   ============================================================ */
/* ─── Theme Studio — Occupemo's Arc-flavor color picker ───────────────── */

/* The modal-box from ui.js wraps us. Tighten the chrome around the studio. */
.modal-box:has(.ts) {
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.55);
  max-width: 560px;
  width: calc(100vw - 32px);
}

.ts {
  background: #14141a;
  color: rgba(255, 255, 255, 0.92);
  font-family: 'Manrope', sans-serif;
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ─── Top bar ─────────────────────────────────────────────────────────── */
.ts-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 16px 6px;
}

.ts-mode {
  display: inline-flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 12px;
}

.ts-mode-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.55);
  width: 36px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.18s ease, color 0.18s ease;
  padding: 0;
}

.ts-mode-btn:hover {
  color: rgba(255, 255, 255, 0.92);
  background: rgba(255, 255, 255, 0.05);
}

.ts-mode-btn.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.ts-mode-btn svg { width: 16px; height: 16px; }

/* ─── Canvas card ─────────────────────────────────────────────────────── */
.ts-canvas {
  position: relative;
  margin: 6px 16px 14px;
  height: 320px;
  border-radius: 18px;
  background: #0d0d12;
  overflow: hidden;
  isolation: isolate;
}

/* Color field — hue across X, lightness top→bottom. */
.ts-canvas-field {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom,
      rgba(255, 255, 255, 0.55) 0%,
      rgba(255, 255, 255, 0)    50%,
      rgba(0, 0, 0, 0.55)       100%),
    linear-gradient(to right,
      hsl(0,   80%, 60%) 0%,
      hsl(45,  80%, 60%) 12.5%,
      hsl(90,  80%, 60%) 25%,
      hsl(135, 80%, 60%) 37.5%,
      hsl(180, 80%, 60%) 50%,
      hsl(225, 80%, 60%) 62.5%,
      hsl(270, 80%, 60%) 75%,
      hsl(315, 80%, 60%) 87.5%,
      hsl(360, 80%, 60%) 100%);
  opacity: 0.9;
  pointer-events: none;
}

/* Subtle dotted texture overlay. */
.ts-canvas-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 14px 14px;
  pointer-events: none;
  mix-blend-mode: overlay;
}

/* Balls. */
.ts-ball {
  position: absolute;
  width: 58px;
  height: 58px;
  padding: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid #ffffff;
  background-clip: padding-box;
  box-shadow:
    0 6px 22px -3px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: grab;
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1),
              box-shadow 0.18s ease;
  touch-action: none;
}

.ts-ball:hover { transform: translate(-50%, -50%) scale(1.06); }

.ts-ball.is-active,
.ts-ball:active {
  cursor: grabbing;
  box-shadow:
    0 6px 22px -3px rgba(0, 0, 0, 0.55),
    0 0 0 4px rgba(255, 255, 255, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.ts-ball.is-primary   { width: 62px; height: 62px; }
.ts-ball.is-secondary { width: 50px; height: 50px; }

/* +/- counter at bottom-center of the canvas. */
.ts-counter {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 3px;
}

.ts-counter-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.ts-counter-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

.ts-counter-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.ts-counter-btn svg { width: 14px; height: 14px; }

/* ─── Preset row ─────────────────────────────────────────────────────── */
.ts-presets {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  margin-bottom: 12px;
}

.ts-arrow {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.65);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ts-arrow:hover {
  background: rgba(255, 255, 255, 0.10);
  color: #ffffff;
}

.ts-arrow svg { width: 14px; height: 14px; }

.ts-preset-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 2px 0;
}

.ts-preset-strip::-webkit-scrollbar { display: none; }

.ts-preset {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.ts-preset:hover {
  transform: scale(1.12);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.45);
}

/* ─── Sliders row: hue + knob ────────────────────────────────────────── */
.ts-sliders {
  display: grid;
  grid-template-columns: 1fr 76px;
  align-items: center;
  gap: 14px;
  padding: 6px 16px 14px;
}

/* Hue slider — full-width track with decorative sine inside. */
.ts-hue {
  position: relative;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  touch-action: none;
  overflow: hidden;
}

.ts-hue-wave {
  position: absolute;
  inset: 6px 12px;
  width: calc(100% - 24px);
  height: calc(100% - 12px);
  color: rgba(255, 255, 255, 0.32);
  pointer-events: none;
}

.ts-hue-thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 34px;
  background: #ffffff;
  border-radius: 14px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 3px 10px -2px rgba(0, 0, 0, 0.5);
}

/* Saturation knob. */
.ts-knob {
  position: relative;
  width: 60px;
  height: 60px;
  cursor: grab;
  touch-action: none;
}

.ts-knob:active { cursor: grabbing; }

.ts-knob-ring {
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px dotted rgba(255, 255, 255, 0.22);
}

.ts-knob-dot {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ─── Actions row ────────────────────────────────────────────────────── */
.ts-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  gap: 10px;
}

.ts-action {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  border: 1px solid transparent;
}

.ts-action--ghost {
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  border-color: rgba(255, 255, 255, 0.10);
}

.ts-action--ghost:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.ts-action--primary {
  background: var(--color-accent, #5840F7);
  color: #ffffff;
  border: none;
}

.ts-action--primary:hover {
  filter: brightness(1.08);
}
