/* =====================================================
   TehGuys Modern Theme
   Cinematic, High-Contrast, Premium Design System
   Supports Light & Dark modes

   NOTE: Structural tokens (palette, radii, spacing,
   typography, transitions) live in tokens.css (SSOT).
   This file only defines theme-specific vars and
   consumes tokens — it does NOT redefine any var
   that already exists in tokens.css.
   ===================================================== */

/* =====================================================
   CSS Variables - Light Theme (Default)
   ===================================================== */
:root {
  /* >>> gen:theme-root >>> AUTO-GENERATED by scripts/gen_design_tokens.py — edit design-tokens.md */
  /* Primary Light Palette */
  --bg-primary:    #FFFFFF;
  --bg-secondary:  #FAF7EF;
  --bg-tertiary:   #DDD8CC;
  --bg-card:       #FAF7EF;
  --bg-card-hover: #F3F0E4;
  --bg-elevated:   #FAF7EF;
  --bg-input:      #FFFFFF;

  /* Surface Colors */
  --surface-dark:      #DDD8CC;
  --surface-medium:    #E5E1D6;
  --surface-light:     #EDE8DA;
  --surface-highlight: #F2EDE2;

  /* Border Colors */
  --border-dark:      #958A73;
  --border-medium:    #988C74;
  --border-light:     #B2A68B;
  --border-highlight: #C6BBA1;
  --border-strong:    #8B7F66;

  /* Text Colors */
  --text-primary:     #0E2233;
  --text-secondary:   #1A3348;
  --text-tertiary:    #4A6070;
  --text-muted:       #4C5F6E;
  --text-placeholder: #4F6170;

  /* Semantic accent vars — mapped to Craft palette */
  --accent-red:    #DA2839;
  --accent-green:  #1E8F4E;
  --accent-yellow: #ffc107;
  --accent-purple: #6f42c1;

  /* Status roles — text, fill, label on the fill (no palette override) */
  --status-danger-text:     #B91C1C;
  --status-danger-fill:     #DC2626;
  --status-danger-on-fill:  #FFFFFF;
  --status-warning-text:    #7A4B00;
  --status-warning-fill:    #BC7D14;
  --status-warning-on-fill: #0E2233;
  --status-success-text:    #166534;
  --status-success-fill:    #15803D;
  --status-success-on-fill: #FFFFFF;
  --status-info-text:       #1D4ED8;
  --status-info-fill:       #2563EB;
  --status-info-on-fill:    #FFFFFF;

  /* Gradient identity — one gradient used everywhere */
  --gradient-primary: var(--craft-gradient-accent);

  /* Accent contrast + focus role (themes.css overrides per palette) */
  --accent-contrast:   #0E2233; /* label ON a solid accent; Electric Green is light -> ink */
  --focus-ring:        #17703D; /* Deep Forest: >=3:1 on all 26 light surfaces */
  --focus-ring-offset: 2px;

  /* Toggle controls */
  --switch-track-off: var(--border-dark);
  --switch-thumb:     #DDD8CC;

  /* Marketing theme — public surfaces only, never product UI */
  --marketing-hero-gradient: linear-gradient(135deg, #3730A3 0%, #4F46E5 50%, #504ED7 100%);
  --marketing-hero-ink:      #4F46E5;
  --marketing-hero-contrast: #FFFFFF; /* label ON the hero gradient; one value on every palette */

  /* Avatar sizes */
  --avatar-sm: 36px;
  --avatar-md: 48px;
  --avatar-lg: 128px;

  /* Legacy vars for compatibility */
  --bg-color:     #FFFFFF;
  --text-color:   #0E2233;
  --card-bg:      #FAF7EF;
  --footer-bg:    #FAF7EF;
  --muted-color:  #6A7D8A;
  --link-color:   var(--craft-green-text);
  --border-color: #DDD8CC;

  /* Shadows — tinted to Craft Indigo */
  --shadow-sm:         0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md:         0 4px 12px rgba(15, 23, 42, 0.10);
  --shadow-lg:         0 10px 24px rgba(15, 23, 42, 0.12);
  --shadow-xl:         0 18px 36px rgba(15, 23, 42, 0.16);
  --shadow-glow:       none;
  --shadow-card:       0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-card-hover: 0 6px 16px rgba(15, 23, 42, 0.12);

  /* Glass Morphism (Premium) */
  --glass-border:       1px solid rgba(221, 216, 204, 0.40);
  --glass-shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.2);

  /* Tinted Shadows (Alternative Depth) */
  --shadow-tinted-sm: 0 2px 8px rgba(30, 143, 78, 0.08);
  --shadow-tinted-md: 0 4px 16px rgba(30, 143, 78, 0.12);
  --shadow-tinted-lg: 0 8px 32px rgba(30, 143, 78, 0.15);
/* <<< gen:theme-root <<< */
}

/* =====================================================
   CSS Variables - Dark Theme Override
   ===================================================== */
body.dark-mode {
  /* >>> gen:theme-dark >>> AUTO-GENERATED by scripts/gen_design_tokens.py — edit design-tokens.md */
  /* Primary Dark Palette */
  --bg-primary:    #081628;
  --bg-secondary:  #0D1E35;
  --bg-tertiary:   #0A1825;
  --bg-card:       #0E2233;
  --bg-card-hover: #132844;
  --bg-elevated:   #163050;
  --bg-input:      #0D1E35;

  /* Surface Colors */
  --surface-dark:      #0A0D1A;
  --surface-medium:    #0A1A2E;
  --surface-light:     #102038;
  --surface-highlight: #152840;

  /* Border Colors */
  --border-dark:      #0E2233;
  --border-medium:    #58748E;
  --border-light:     #254560;
  --border-highlight: #30587A;
  --border-strong:    #6A87A1;

  /* Text Colors */
  --text-primary:     #F6F1E4;
  --text-secondary:   #C8D8E8;
  --text-tertiary:    #7A9AB5;
  --text-muted:       #8FA6B8;
  --text-placeholder: #9AAFC0;

  /* Focus role — Deep Forest is 2.18:1 on the dark activities band */
  --focus-ring: #53E867; /* Electric Green: >=3:1 on all 26 dark surfaces */

  /* Toggle controls */
  --switch-track-off: #546A80;
  --switch-thumb:     #F6F1E4;

  /* Status roles (dark) */
  --status-danger-text:     #F87171;
  --status-danger-fill:     #DC2626;
  --status-danger-on-fill:  #FFFFFF;
  --status-warning-text:    #FBBF24;
  --status-warning-fill:    #F59E0B;
  --status-warning-on-fill: #0E2233;
  --status-success-text:    #4ADE80;
  --status-success-fill:    #15803D;
  --status-success-on-fill: #FFFFFF;
  --status-info-text:       #93C5FD;
  --status-info-fill:       #2563EB;
  --status-info-on-fill:    #FFFFFF;

  /* Legacy vars for compatibility */
  --bg-color:     #081628;
  --text-color:   #F6F1E4;
  --card-bg:      #0E2233;
  --footer-bg:    #0D1E35;
  --muted-color:  #506070;
  --border-color: #1A3348;

  /* Shadows — darker for dark mode */
  --shadow-sm:         0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md:         0 4px 16px rgba(0, 0, 0, 0.6);
  --shadow-lg:         0 8px 32px rgba(0, 0, 0, 0.7);
  --shadow-xl:         0 16px 48px rgba(0, 0, 0, 0.8);
  --shadow-glow:       none;
  --shadow-card:       0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.6);
  --shadow-tinted-sm:  0 2px 8px rgba(83, 232, 103, 0.18);
  --shadow-tinted-md:  0 4px 16px rgba(83, 232, 103, 0.24);
  --shadow-tinted-lg:  0 8px 32px rgba(83, 232, 103, 0.30);
/* <<< gen:theme-dark <<< */
}

/* =====================================================
   Global Reset & Base Styles
   ===================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  /* NO overflow-x here. Per spec, `overflow-x: hidden` forces overflow-y to
     compute to `auto`, which made <body> a scroll container that never
     actually scrolls (scrollHeight === clientHeight) while <html> did the
     real scrolling. position:sticky resolves against its nearest scrolling
     ancestor, so every sticky descendant in the app silently never engaged -
     measured on activity_detail: a sticky element scrolled away to y=-261
     instead of pinning. `html` above already sets overflow-x: hidden, so
     horizontal scroll is still clipped and nothing is lost. */
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Bridge to Bootstrap variables */
  --bs-body-bg: var(--bg-primary);
  --bs-body-color: var(--text-primary);
  --bs-link-color: var(--link-color);
  --bs-border-color: var(--border-color);
}

.skip-link {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  z-index: var(--z-skip);
  padding: 0.875rem 1.125rem;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--link-color);
  border: 2px solid var(--accent-blue);
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  transform: translateY(-180%);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-color);
}

/* =====================================================
   Card Components
   ===================================================== */
.card, .list-group-item, .alert, .dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
}


/* Text utilities */
.text-muted, small, .form-text {
  color: var(--text-muted) !important;
}

/* Footer */
footer {
  background-color: var(--footer-bg);
  color: var(--text-secondary);
}

/* Nav tabs/pills */
.nav-tabs .nav-link, .nav-pills .nav-link {
  color: var(--text-tertiary);
  border: none;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.nav-tabs .nav-link:hover, .nav-pills .nav-link:hover {
  color: var(--text-primary);
  background: var(--surface-light);
}

.nav-tabs .nav-link.active, .nav-pills .nav-link.active {
  background: var(--craft-indigo);
  color: var(--accent-contrast, #0E2233);
}

/* Dropdown items */
.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-sm);
}

.dropdown-menu .dropdown-item {
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.dropdown-menu .dropdown-item:hover, .dropdown-menu .dropdown-item:focus {
  background: var(--surface-light);
  color: var(--text-primary);
}

/* Forms */
.form-control,
.form-select,
.input-group-text,
textarea,
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="time"] {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-medium) !important;
  border-radius: var(--radius-md) !important;
  padding: var(--space-md) !important;
  transition: all var(--transition-fast) !important;
}

/* No resizable components anywhere in the app - a user-draggable resize
   handle on a textarea can be stretched to overlap surrounding layout
   (buttons, page title) with nothing constraining it. */
textarea {
  resize: none !important;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus {
  border-color: var(--craft-indigo) !important;
  box-shadow: 0 0 0 3px var(--craft-indigo-tint) !important;
}

.form-control:focus-visible,
.form-select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E) !important;
  outline-offset: var(--focus-ring-offset, 2px);
}

.form-control::placeholder,
textarea::placeholder {
  color: var(--text-placeholder) !important;
}

.form-label {
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-sm);
}

.form-check-label {
  color: var(--text-secondary);
}

.form-check-input {
  background-color: var(--bg-input);
  border-color: var(--border-medium);
}

.form-check-input:checked {
  background-color: var(--craft-indigo);
  border-color: var(--craft-indigo);
}

/* Background utilities */
.bg-light {
  background-color: var(--surface-light) !important;
  color: var(--text-primary) !important;
}

.bg-white {
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

.text-dark {
  color: var(--text-primary) !important;
}

a.text-dark {
  color: var(--text-primary) !important;
}

/* Utils */
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }

/* =====================================================
   Modern Layout Structure - Right Sidebar
   ===================================================== */

/* Right Sidebar */
/* The docked rail's width is --dock-w, set once on <body> in shell-desktop.css
   (--sidebar-width at every screen size). The outer boxes and the content
   offsets that read it stay here; the rail's insides are shell-desktop.css. */

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  width: var(--dock-w);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-dark);
  border-left: none;
  display: flex;
  flex-direction: column;
  z-index: var(--z-dock);
  transition: transform var(--transition-base);
}

.app-sidebar-left {
  left: 0;
  right: auto;
  border-right: 1px solid var(--border-dark);
  border-left: none;
}

.app-sidebar-right {
  left: auto;
  right: 0;
  border-left: 1px solid var(--border-dark);
  border-right: none;
  /* Sit above page content so the dock arrows + width toggle at the bottom are
     never obscured by a sticky widget (e.g. the home calendar) in the column
     beside it. */
  z-index: var(--z-dock);
}

/* Docking animates in so switching positions feels smooth, not a hard cut.
   The global prefers-reduced-motion rule neutralises this for those users. */
.app-sidebar-left,
.app-sidebar-right {
  animation: dock-in var(--transition-base) ease;
}

@keyframes dock-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Content offset follows the dock side. #sidebar-root is the element
   immediately before .app-content. */
.app-sidebar-right + .app-content {
  margin-left: 0;
  margin-right: var(--dock-w);
}

.app-sidebar-right.minimized + .app-content {
  margin-left: 0;
  margin-right: var(--sidebar-collapsed);
}


/* Minimized Sidebar State */
  .app-sidebar.minimized {
    width: var(--sidebar-collapsed);
    min-width: 0;
  }

/* Left dock only — a right-docked minimized sidebar must NOT get a left margin
   (that left an empty strip beside the header). Right has its own rule. */
.app-sidebar-left.minimized + .app-content {
  margin-left: var(--sidebar-collapsed);
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}

/* Main Content Area */
.app-content {
  margin-left: var(--dock-w);
  margin-right: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  --topbar-min-height: 72px;
}

/* Top Bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  min-height: var(--topbar-min-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-dark);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.top-nav-controls {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  flex: 0 0 auto;
}

/* Search Container */
.search-container {
  flex: 1;
  max-width: 100%;
}

.search-form {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-full);
  overflow: hidden;
  transition: all var(--transition-fast);
}

.search-form:focus-within {
  border-color: var(--craft-indigo);
  box-shadow: 0 0 0 3px var(--craft-indigo-tint);
}

.search-input {
  flex: 1;
  padding: var(--space-md) var(--space-lg) !important;
  padding-left: 88px !important;
  background: transparent !important;
  border: none !important;
  -webkit-appearance: none;
  appearance: none;
  color: var(--text-primary) !important;
  font-size: var(--font-size-sm);
  border-radius: 0 !important;
  min-width: 0;
}

.search-input::placeholder {
  color: var(--text-placeholder) !important;
}

.search-input:focus {
  /* Same 1.4.11 problem as the global :focus-visible rule below — the brand
     accent is 1.60:1 on white for the default palette. Use --focus-ring. */
  outline: 2px solid var(--focus-ring, #17703D) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

.search-icon {
  position: absolute;
  top: 50%;
  left: var(--space-lg);
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 1;
}

[dir="rtl"] .search-input {
  padding-left: var(--space-lg) !important;
  padding-right: 88px !important;
}

[dir="rtl"] .search-icon {
  left: auto;
  right: var(--space-lg);
}

/* Remove native search field decorations that overlap the custom icon */
.search-input::-webkit-search-decoration,
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-results-button,
.search-input::-webkit-search-results-decoration {
  display: none;
}

.search-btn {
  padding: var(--space-md) var(--space-xl);
  background: var(--craft-indigo);
  color: var(--accent-contrast, #0E2233);
  border: none;
  font-weight: 600;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.search-btn:hover {
  background: var(--craft-indigo-hover);
}

.search-advanced-btn {
  padding: var(--space-md) var(--space-xl);
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border-left: 1px solid var(--border-medium);
  flex-shrink: 0;
  border-top-right-radius: var(--radius-full);
  border-bottom-right-radius: var(--radius-full);
}

.search-advanced-btn:hover {
  background: var(--surface-highlight);
  color: var(--link-color);
}

/* Hide old top elements */
.top-logo-bar,
.search-bar-container {
  display: none !important;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

/* Full-bleed pages (auth two-column layout, profile cover banner) need to reach
   the content edges. The centered max-width column + padding above would
   otherwise leave the page background showing as cream bands on each side — a
   child's negative margin can cancel the padding but never the auto-centering
   margins. Release both here; the profile re-caps its body inside .prof-content. */
.main-content:has(.auth-wrapper),
.main-content:has(.prof-page) {
  max-width: none;
  padding: 0;
}

/* Auth pages fill the space between the header and footer via flex (NOT a magic
   100vh-Npx min-height, which drifts from the real chrome heights and leaves a
   page-background gap). The auth-wrapper flexes to fill; the global
   footer{margin-top:3rem} is zeroed here so no cream band shows above it. */
.main-content:has(.auth-wrapper) {
  display: flex;
  flex-direction: column;
}
/* body:has(...), not .main-content + .app-footer: some auth pages (e.g.
   password-reset) render an extra unnamed wrapper div between
   .main-content and .app-footer, which silently broke the adjacent-
   sibling selector on those pages only (2026-09-02 fix/find, while fixing
   the rule below -- verified via elementFromPoint DOM-walk that
   .app-footer was NOT matched there before this change). :has() doesn't
   care about the exact sibling structure, so it covers every auth page. */
body:has(.auth-wrapper) .app-footer {
  margin-top: 0;
  /* .app-footer's own background:var(--bg-secondary) below is an opaque
     fill -- NoiseBackground owns the page backdrop everywhere else
     (shell-bg-guard enforces it), and this is the one spot that still
     painted over it, leaving a flat, textureless band between the auth
     card and the footer links (2026-09-02, user-reported). Scoped to
     auth pages only -- the footer's opaque background elsewhere may be
     intentional and wasn't touched. */
  background: transparent;
}

/* Page Title */
.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

/* Footer */
.app-footer {
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-dark);
  background: var(--bg-secondary);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Footer links read as a comma-separated list: "About Us, Privacy & Cookies".
   Each link is underlined; the comma separators stay plain. */
.app-footer__links {
  margin-bottom: var(--space-sm);
}

.app-footer__links a,
.app-footer__link-button {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-footer__links a:hover,
.app-footer__link-button:hover {
  color: var(--link-color);
  text-decoration-thickness: 2px;
}

.app-footer__links > *:not(:last-child)::after {
  content: ", ";
  text-decoration: none;
}

/* Hide old navbar elements */
nav.navbar,
.search-bar-wrap,
.top-navbar,
.navbar,
.navbar-expand-lg,
.navbar-dark,
.navbar-collapse,
.navbar-nav,
.navbar-toggler,
.navbar-brand {
  display: none !important;
}

.mobile-search-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-height: 100dvh;
  padding: calc(60px + var(--space-md)) max(var(--space-md), env(safe-area-inset-left)) calc(var(--space-lg) + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 255, 255, 0.30), transparent 26%),
    linear-gradient(180deg, rgba(246, 241, 228, 0.78), rgba(246, 241, 228, 0.52));
  backdrop-filter: blur(22px) saturate(1.45);
  -webkit-backdrop-filter: blur(22px) saturate(1.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 22px 60px rgba(8, 22, 40, 0.22);
  z-index: var(--z-dropdown);
  overflow-y: auto;
}

.mobile-search-overlay.show {
  display: block;
}

/* NoiseBackground island (#bg-noise-root): a fixed -z-10 layer (brand midnight
   #081628 + electric-green light source + film grain). Body paints the same
   token beneath the fixed island so long pages never reveal the browser canvas;
   the island supplies the backdrop texture and colour. */
body {
  background: var(--bg-primary);
}

/* Fixed visual backdrop, on the island's own mount point. The element remains
   fixed so NoiseBackground can layer its radial light, grid, and film grain
   across the viewport. Body paints the same resolved token underneath it for
   document regions below the fixed viewport; no palette value is duplicated.
   This element is inside body so --bg-primary resolves against body.dark-mode
   in both themes. */
#bg-noise-root {
  position: fixed;
  inset: 0;
  z-index: var(--z-canvas);
  background: var(--bg-primary);
}

/* The app content column normally paints var(--bg-primary) across the whole
   viewport, which hid the fixed background on logged-in pages. Make it
   transparent so the island shows through there too. Cards/widgets keep their
   own surfaces. */
.app-content {
  background: transparent;
}

/* All chrome (top-bar, footer, mobile) keeps its native token-driven surfaces —
   opaque and theme-correct; the animated background shows through the
   transparent .app-content gaps. No glass hacks, no hardcoded hex, no token
   re-definitions. */

/* Dock/sidebar: brand "cream daytime section" in light, midnight in dark — via
   the theme token, so its text stays readable in both. The cream now lives in
   --bg-secondary (the page canvas is white), which is what the base
   .app-sidebar rule already uses, so no override is needed here. */

.mobile-search-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  max-width: 640px;
  margin: 0 auto var(--space-lg);
}

.mobile-search-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  line-height: 1;
}

.mobile-search-title svg {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.mobile-search-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.26);
  border: 1px solid rgba(14, 34, 51, 0.12);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: var(--glass-inset), 0 8px 22px rgba(8, 22, 40, 0.12);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.mobile-search-close:hover {
  background: rgba(255, 255, 255, 0.42);
}

.mobile-search-overlay .search-form {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.40);
  border: 1px solid rgba(255, 255, 255, 0.56);
  border-radius: 28px;
  overflow: visible;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.58),
    inset 0 -18px 34px rgba(255, 255, 255, 0.16),
    0 18px 44px rgba(8, 22, 40, 0.16);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
}

.mobile-search-overlay .search-form:focus-within {
  border-color: var(--craft-indigo);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.64),
    inset 0 -18px 34px rgba(255, 255, 255, 0.16),
    0 0 0 3px var(--craft-indigo-tint),
    0 22px 54px rgba(8, 22, 40, 0.18);
}

.mobile-search-overlay .search-icon {
  top: calc(var(--space-md) + 27px);
  left: calc(var(--space-md) + var(--space-md));
  color: var(--text-muted);
}

.mobile-search-overlay .search-input {
  width: 100%;
  min-height: 54px;
  padding: 0 var(--space-md) 0 3.25rem !important;
  background: rgba(255, 255, 255, 0.48) !important;
  border: 1px solid rgba(14, 34, 51, 0.13) !important;
  border-radius: 18px !important;
  font-size: 1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.mobile-search-overlay .search-input:focus {
  border-color: var(--craft-indigo) !important;
  box-shadow: 0 0 0 3px var(--craft-indigo-tint) !important;
}

.mobile-search-overlay .search-input:focus-visible {
  outline: 2px solid var(--focus-ring, #1E8F4E) !important;
  outline-offset: var(--focus-ring-offset, 2px);
}

.mobile-search-overlay .search-btn,
.mobile-search-overlay .search-advanced-btn {
  min-height: 52px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  font-size: 1rem;
  font-weight: 800;
  border: 1px solid transparent;
}

.mobile-search-overlay .search-btn {
  background: linear-gradient(135deg, var(--craft-indigo), var(--craft-indigo-hover));
  box-shadow: var(--glass-inset), var(--shadow-tinted-lg);
}

.mobile-search-overlay .search-advanced-btn {
  background: rgba(255, 255, 255, 0.30);
  color: var(--text-primary);
  border-color: rgba(14, 34, 51, 0.12);
  box-shadow: var(--glass-inset);
}

body.no-scroll {
  overflow: hidden;
}

@media (max-width: 575.98px) {
  .mobile-search-overlay .search-form {
    border-radius: 24px;
  }
}

[dir="rtl"] .mobile-search-overlay .search-icon {
  left: auto;
  right: calc(var(--space-md) + var(--space-md));
}

[dir="rtl"] .mobile-search-overlay .search-input {
  padding-left: var(--space-md) !important;
  padding-right: 3.25rem !important;
}

[data-theme="dark"] .mobile-search-overlay,
body.dark-mode .mobile-search-overlay {
  background:
    radial-gradient(circle at 18% 8%, var(--accent-blue-glow), transparent 30%),
    linear-gradient(180deg, rgba(8, 22, 40, 0.84), rgba(8, 22, 40, 0.68));
  border-bottom-color: rgba(255, 255, 255, 0.14);
}

[data-theme="dark"] .mobile-search-overlay .search-form,
body.dark-mode .mobile-search-overlay .search-form {
  background: rgba(8, 22, 40, 0.52);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -18px 34px rgba(0, 0, 0, 0.14),
    0 22px 54px rgba(0, 0, 0, 0.34);
}

[data-theme="dark"] .mobile-search-overlay .search-input,
body.dark-mode .mobile-search-overlay .search-input {
  background: rgba(255, 255, 255, 0.10) !important;
  border-color: rgba(255, 255, 255, 0.16) !important;
}

[data-theme="dark"] .mobile-search-close,
body.dark-mode .mobile-search-close,
[data-theme="dark"] .mobile-search-overlay .search-advanced-btn,
body.dark-mode .mobile-search-overlay .search-advanced-btn {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.18);
}

@media (min-width: 1024px) {
  .mobile-search-overlay {
    display: none !important;
  }
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 1023.98px) {
  .main-content {
    padding: var(--space-md);
  }
}

@media (max-width: 767px) {
  .mobile-search-close {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 575.98px) {
  .main-content {
    padding: var(--space-sm);
  }

  /* Tighter cards on small screens for consistent sizing */
  .card {
    border-radius: 12px;
    margin-bottom: var(--space-sm);
  }

  .card > .card-body {
    padding: var(--space-md);
  }

  .card > .card-header,
  .card > .card-footer {
    padding: var(--space-sm) var(--space-md);
  }
}

/* =====================================================
   Animation Utilities
   ===================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
  animation: slideUp 0.4s ease-out;
}

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

/* The brand accent is not a legal focus indicator. --craft-indigo is 1.60:1 on
   white and 1.42:1 on Cream for the default palette (also 1.83 sunbeam, 2.74
   terracotta), all under the 3:1 SC 1.4.11 floor. --focus-ring is the token that
   exists for exactly this and is measured against all 52 surfaces, so use it here
   as the [data-btn] and .ds-disclosure rules already do. */
:focus-visible {
  outline: 2px solid var(--focus-ring, #17703D);
  outline-offset: var(--focus-ring-offset, 2px);
}

/* =====================================================
   Perpetual Micro-Interactions (Premium Motion)
   ===================================================== */
@keyframes float-gentle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

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

@keyframes glow-pulse {
  0%, 100% {
    box-shadow: none;
  }
  50% {
    box-shadow: none;
  }
}

@keyframes parallax-bg {
  0% { background-position: center 0; }
  100% { background-position: center 100%; }
}

/* =====================================================
   Advanced Motion Features (Magnetic Hover, Pulse, Parallax)
   ===================================================== */

/* Magnetic Hover: Smooth transition for button movement */
.btn-primary, .btn-success, .action-btn.action-primary, .action-btn.action-success, .notif-btn-primary {
  transition: transform 120ms cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary, .btn-success, .action-btn.action-primary, .action-btn.action-success, .notif-btn-primary {
    will-change: auto;
    transform: none !important;
  }
}

/* Scroll-triggered Parallax Hero Background */
.hero-section, .hero, [data-parallax="hero"] {
  background-attachment: fixed;
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  transition: background-position 0.15s linear;
}

@media (prefers-reduced-motion: reduce) {
  .hero-section, .hero, [data-parallax="hero"] {
    background-attachment: scroll;
  }
}

/* Shared Element Transitions (Smooth state changes) */
.shared-transition {
  transition: all 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.shared-transition.entering {
  opacity: 0;
  transform: scale(0.95);
}

.shared-transition.active {
  opacity: 1;
  transform: scale(1);
}

.shared-transition.exiting {
  opacity: 0;
  transform: scale(0.95);
}

/* =====================================================
   Scrollbar Styling
   ===================================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* =====================================================
   Section Heading Styles (server-rendered pages)
   Consumes type-scale vars from tokens.css (SSOT).
   ===================================================== */
.section-heading {
  font-family: var(--font-display);
  font-size: var(--text-scale-display-size);
  font-weight: var(--text-scale-display-weight);
  line-height: var(--text-scale-display-leading);
  letter-spacing: var(--text-scale-display-tracking);
  color: var(--text-primary);
  margin-top: 0;
}


.meta-caption {
  font-family: var(--font-body);
  font-size: var(--text-scale-caption-size);
  font-weight: var(--text-scale-caption-weight);
  line-height: var(--text-scale-caption-leading);
  color: var(--text-muted);
}

/* =====================================================
   Liquid-glass button tokens (hand-authored, theme-aware)
   Consumed by [data-btn][data-variant="glass"] (components.css)
   and the React GlassButton. Light theme uses SATURATED fills so white
   labels keep WCAG contrast (the dark theme's frosted, low-
   alpha tints turn pastel on a white card and fail). Dark
   theme keeps the translucent glass that reads over the dark
   surface. Outside the gen markers — safe from `make design`.
   ===================================================== */
:root {
  --glass-primary-bg: linear-gradient(135deg, var(--craft-indigo) 0%, var(--craft-indigo-hover) 100%);
  --glass-primary-text: var(--accent-contrast, #0E2233);
  --glass-primary-border: rgba(255,255,255,0.5);
  --glass-primary-shadow: var(--shadow-tinted-md);
  --glass-primary-shadow-hover: var(--shadow-tinted-lg);
  --glass-neutral-bg: rgba(14,34,51,0.05);
  --glass-neutral-border: rgba(14,34,51,0.16);
  --glass-neutral-text: var(--text-primary);
  --glass-neutral-shadow: 0 6px 18px rgba(14,34,51,0.12);
  --glass-neutral-shadow-hover: 0 10px 24px rgba(14,34,51,0.18);
  /* First stop was rgba(220,53,69,0.95): white on it measured 4.28:1 on the
     cream card, under AA. This shade holds the hue and clears 4.67:1. */
  --glass-danger-bg: linear-gradient(135deg, rgba(210,48,62,0.95) 0%, rgba(190,40,55,0.9) 100%);
  --glass-danger-shadow: 0 6px 18px rgba(220,53,69,0.30);
  --glass-danger-shadow-hover: 0 10px 26px rgba(220,53,69,0.42);
  --glass-outline-bg: rgba(14,34,51,0.03);
  --glass-outline-border: rgba(14,34,51,0.20);
  --glass-inset: inset 0 1px 0 rgba(255,255,255,0.55), inset 0 -2px 6px rgba(0,0,0,0.08);
}

body.dark-mode {
  --glass-primary-bg: linear-gradient(135deg, var(--craft-indigo) 0%, var(--craft-indigo-hover) 100%);
  --glass-primary-text: var(--accent-contrast, #0E2233);
  --glass-primary-border: rgba(255,255,255,0.28);
  --glass-primary-shadow: var(--shadow-tinted-md);
  --glass-primary-shadow-hover: var(--shadow-tinted-lg);
  --glass-neutral-bg: rgba(255,255,255,0.10);
  --glass-neutral-border: rgba(255,255,255,0.22);
  --glass-neutral-text: var(--text-primary);
  --glass-neutral-shadow: 0 6px 18px rgba(0,0,0,0.18);
  --glass-neutral-shadow-hover: 0 10px 24px rgba(0,0,0,0.22);
  --glass-danger-bg: linear-gradient(135deg, rgba(220,53,69,0.55) 0%, rgba(220,53,69,0.4) 100%);
  --glass-danger-shadow: 0 6px 18px rgba(220,53,69,0.35);
  --glass-danger-shadow-hover: 0 10px 26px rgba(220,53,69,0.45);
  --glass-outline-bg: rgba(255,255,255,0.06);
  --glass-outline-border: rgba(255,255,255,0.30);
  --glass-inset: inset 0 1px 0 rgba(255,255,255,0.4), inset 0 -2px 6px rgba(0,0,0,0.15);
}

/* ─────────────────────────────────────────────────────────────────────────
   Type roles that are not a family: numerals and Persian (wave C1-B).

   Numeric role (L7-019): dates, counts and capacity are tabular figures of the
   body face, not a fourth font. --numeric-variant is generated from
   design-tokens.md (typography.numeric); <time> takes it everywhere, and a
   count, a date or a capacity in a component opts in with data-numeric.

   Persian (L7-020, L3-015): Vazirmatn comes from the font stacks in tokens.css
   and is fetched only when a page paints Arabic-script text. What a stack
   cannot say lives here: letter-spacing and uppercase are Latin typography,
   and a tracked or capitalised run breaks the joins of a connected script. 75
   rules across the stylesheets, templates and islands ask for tracking, so the
   reset is !important and covers every descendant of a Persian element. This
   block sits outside the gen: markers, so `make design` never rewrites it.
   ───────────────────────────────────────────────────────────────────────── */
time,
[data-numeric] {
  font-variant-numeric: var(--numeric-variant);
}

:lang(fa),
:lang(fa) * {
  letter-spacing: 0 !important;
  text-transform: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────
   Accent aliases and semantic status, resolved LAST.

   The accent existed in two forms: --craft-* which every palette in themes.css
   overrides, and a set of aliases (--accent-green, --accent-blue, --focus-ring)
   that no palette ever touched. Anything painted through an alias therefore
   stayed green no matter which colour the user picked - the "Online" label in
   the menu, the focus ring, the settings toggles. The comment beside
   --focus-ring above even says "themes.css overrides per palette"; it never
   did.

   These are defined here, at the end of the last stylesheet base.html loads,
   because the generated :root and body.dark-mode blocks earlier in this file
   would otherwise win on source order. They point at --craft-* rather than at
   a literal, so a palette only has to define its own accent once and every
   alias follows, in both themes.

   Do not move these into the gen: blocks above - scripts/gen_design_tokens.py
   rewrites those from design-tokens.md and would drop them.
   ───────────────────────────────────────────────────────────────────────── */
:root,
body.dark-mode {
  --accent-green: var(--craft-green-text);
  --accent-blue: var(--craft-indigo);
  --focus-ring: var(--craft-green-text);

  /* Presence and success stay green in every palette: a green dot means
     "online" the world over, and recolouring it to the brand accent would make
     it read as decoration. It was previously UNDEFINED, so each caller fell
     back to its own literal - the same "online" dot rendered #22c55e on the
     home feed and #1E8F4E in the menu. One token, one colour. */
  --color-success: #1E8F4E;
}

body.dark-mode {
  /* #1E8F4E is 2.6:1 on the dark surfaces; the lighter green clears AA there. */
  --color-success: #4DD97A;
}

/* ─────────────────────────────────────────────────────────────────────────
   Dark mode was ignoring the chosen palette, and this is why.

   The generated dark token block is scoped to `body.dark-mode`. A palette
   sets its dark accent on the ROOT element
   (:root[data-palette="x"][data-theme="dark"]). Custom properties inherit
   DOWNWARD, so a declaration on <body> shadows the root value for <body> and
   everything inside it - which is the entire page. Measured with the purple
   palette in dark mode: :root resolved --craft-green-text to #C084FC while
   body and every descendant resolved it to #4DD97A, the default green.
   Specificity never entered into it; the two declarations are on different
   elements.

   --craft-green-text is the only token declared in both places, so the repair
   is narrow: publish the dark default on the root, where palettes can out-
   specify it, then stop body from shadowing whatever the root resolved.

   `inherit` on a custom property takes the parent's computed value, so body
   simply adopts the root's - palette value when a palette supplies one, the
   default below when it does not (1 of the 8 palettes has no dark block).
   ───────────────────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  /* Same value the generated body.dark-mode block uses - #17703D is 2.64:1 on
     Ink, so dark needs the lightened Forest. Kept in step with design-tokens.md
     (color.dark_overrides.craft-green-text). */
  --craft-green-text: #4DD97A;
}

/* `html body.dark-mode` (0,1,2), not `body.dark-mode` (0,1,1): the island
   bundle ships its own copy of the dark token block (frontend/src/styles/
   tokens.css) and its stylesheet loads after this one, so an equal-specificity
   rule here would lose on source order. The extra element beats it outright,
   whatever the load order ends up being. */
html body.dark-mode {
  --craft-green-text: inherit;
}

/* Keep keyboard focus visible when the browser increases contrast or replaces
   the product palette with a forced-colors system palette. This block is at
   the end so it wins over component-level focus declarations. */
@media (forced-colors: active), (prefers-contrast: more) {
  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid CanvasText !important;
    outline-offset: 2px;
  }

  .ds-btn,
  [data-btn],
  .ds-modal__close,
  .ds-dialog__close {
    forced-color-adjust: auto;
  }
}
