/**
 * ============================================================================
 * MASTER CODEX FINANCIAL - CSS LAYER
 * Version: 2.0.0 (iOS/Safari Optimized)
 * 140 Micro-Interactions for Marlowe Partners
 * ============================================================================
 * 
 * Mobile-First (iPhone/Safari Focus):
 * - Uses -webkit-tap-highlight-color: transparent
 * - Uses cursor: pointer on all interactive elements
 * - Respects env(safe-area-inset-bottom) for fixed elements
 * - Uses touch-action: manipulation for fast taps
 * 
 * Namespace: All classes prefixed with .cdx-
 * ============================================================================
 */

/* ============================================================================
 * PART 0: GLOBAL RESETS & iOS OPTIMIZATIONS
 * ============================================================================ */

:root {
  /* Core Colors */
  --cdx-primary: #1a1a2e;
  --cdx-secondary: #16213e;
  --cdx-accent: #f97316;
  --cdx-success: #22c55e;
  --cdx-warning: #f59e0b;
  --cdx-error: #ef4444;
  --cdx-info: #3b82f6;
  
  /* Text Colors */
  --cdx-text: #222;
  --cdx-text-muted: #666;
  --cdx-text-inverse: #fff;
  --cdx-bg: #fff;
  --cdx-bg-secondary: #f8f9fa;
  
  /* Spacing */
  --cdx-spacer: 1rem;
  
  /* Typography */
  --cdx-font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  --cdx-font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
  --cdx-font-serif: 'Crimson Text', Georgia, 'Times New Roman', serif;
  
  /* Transitions */
  --cdx-transition-fast: 0.15s ease;
  --cdx-transition-base: 0.2s ease;
  --cdx-transition-slow: 0.3s ease;
  
  /* Shadows */
  --cdx-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --cdx-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --cdx-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --cdx-shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
  
  /* Circadian (updated by JS) */
  --cdx-circadian-warmth: 0;
}

/* Remove grey tap boxes on iOS */
.cdx-interactive,
.cdx-btn,
.cdx-link,
.cdx-card,
.cdx-fab,
button,
a,
[role="button"],
[onclick] {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
}

/* Safe area insets for fixed elements (iPhone notch/home bar) */
.cdx-fixed-bottom {
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-bottom: max(env(safe-area-inset-bottom), 16px);
}

.cdx-fixed-top {
  padding-top: env(safe-area-inset-top, 0);
}

/* Prevent double-tap zoom delay */
* {
  touch-action: manipulation;
}

/* ============================================================================
 * PART 1: EFFICIENCY LAYER (Features 1-50)
 * ============================================================================ */

/* Feature 2: Quick Actions FAB */
.cdx-fab {
  position: fixed;
  bottom: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2147483640;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cdx-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.cdx-fab:active {
  transform: scale(0.95);
}

.cdx-fab-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Feature 3: Command Palette */
.cdx-command-palette {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 2147483647;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.cdx-command-palette.cdx-active {
  opacity: 1;
  visibility: visible;
}

.cdx-command-modal {
  width: 90%;
  max-width: 600px;
  background: #1a1a2e;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: translateY(-20px) scale(0.95);
  transition: transform 0.2s ease;
}

.cdx-command-palette.cdx-active .cdx-command-modal {
  transform: translateY(0) scale(1);
}

.cdx-command-input {
  width: 100%;
  padding: 20px 24px;
  font-size: 18px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  outline: none;
}

.cdx-command-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.cdx-command-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px 0;
}

.cdx-command-item {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-command-item:hover,
.cdx-command-item.cdx-selected {
  background: rgba(255, 255, 255, 0.1);
}

.cdx-command-item-icon {
  width: 20px;
  height: 20px;
  opacity: 0.6;
}

.cdx-command-item-label {
  flex: 1;
  color: #fff;
}

.cdx-command-item-shortcut {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
}

.cdx-command-category {
  padding: 8px 24px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
}

/* Feature 6: Theme Switcher */
.cdx-theme-switcher {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px;
  border-radius: 8px;
}

.cdx-theme-btn {
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

.cdx-theme-btn.cdx-active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Feature 10: Toast System */
.cdx-toast-container {
  position: fixed;
  bottom: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0));
  right: 24px;
  z-index: 2147483646;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.cdx-toast {
  background: #1a1a2e;
  color: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  animation: cdx-toast-slide-in 0.3s ease;
  border-left: 4px solid #f97316;
}

.cdx-toast.cdx-toast-success { border-left-color: #22c55e; }
.cdx-toast.cdx-toast-error { border-left-color: #ef4444; }
.cdx-toast.cdx-toast-info { border-left-color: #3b82f6; }
.cdx-toast.cdx-toast-warning { border-left-color: #f59e0b; }

.cdx-toast-exit {
  animation: cdx-toast-slide-out 0.3s ease forwards;
}

@keyframes cdx-toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes cdx-toast-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* Feature 17: Recent View Widget */
.cdx-recent-widget {
  position: fixed;
  bottom: 100px;
  bottom: calc(100px + env(safe-area-inset-bottom, 0));
  left: 24px;
  background: #1a1a2e;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 2147483639;
  max-width: 280px;
  display: none;
}

.cdx-recent-widget.cdx-active {
  display: block;
  animation: cdx-fade-in 0.2s ease;
}

.cdx-recent-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 12px;
}

.cdx-recent-item {
  padding: 8px 12px;
  border-radius: 6px;
  color: #fff;
  text-decoration: none;
  display: block;
  transition: background 0.15s ease;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-tap-highlight-color: transparent;
}

.cdx-recent-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Feature 22: Zen Mode */
.cdx-zen-mode header,
.cdx-zen-mode footer,
.cdx-zen-mode nav,
.cdx-zen-mode aside,
.cdx-zen-mode .sidebar,
.cdx-zen-mode .cdx-fab,
.cdx-zen-mode .cdx-toast-container {
  display: none !important;
}

.cdx-zen-mode main,
.cdx-zen-mode article {
  max-width: 75ch;
  margin: 0 auto;
  padding: 40px 24px;
}

/* Feature 23: Read Time */
.cdx-read-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
}

/* Feature 24: Copy Code Button */
.cdx-code-wrapper {
  position: relative;
}

.cdx-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-code-wrapper:hover .cdx-copy-btn {
  opacity: 1;
}

.cdx-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Feature 30: Break Timer */
.cdx-break-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cdx-break-overlay.cdx-active {
  opacity: 1;
  visibility: visible;
}

.cdx-break-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  opacity: 0.6;
}

.cdx-break-title {
  font-size: 28px;
  color: #fff;
  margin-bottom: 12px;
}

.cdx-break-text {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 32px;
}

.cdx-break-btn {
  padding: 16px 32px;
  background: #f97316;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-break-btn:hover {
  background: #ea580c;
}

.cdx-break-btn:active {
  transform: scale(0.98);
}

/* Feature 31: Night Shift */
.cdx-night-shift {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 180, 100, 0.08);
  pointer-events: none;
  z-index: 2147483630;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.cdx-night-shift.cdx-active {
  opacity: 1;
}

/* Feature 32: Pulse Loader */
.cdx-pulse {
  animation: cdx-pulse 1.5s ease-in-out infinite;
}

@keyframes cdx-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Feature 33: Skeleton UI */
.cdx-skeleton {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.05) 25%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: cdx-skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes cdx-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.cdx-skeleton-text { height: 1em; margin-bottom: 0.5em; }
.cdx-skeleton-text:last-child { width: 70%; }
.cdx-skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; }
.cdx-skeleton-card { height: 200px; border-radius: 12px; }

/* Feature 42: Print Styles */
@media print {
  .cdx-fab,
  .cdx-toast-container,
  .cdx-command-palette,
  .cdx-recent-widget,
  .cdx-break-overlay,
  .cdx-night-shift,
  header, footer, nav, aside, .sidebar, .no-print {
    display: none !important;
  }
  
  body { background: #fff !important; color: #000 !important; }
  a { text-decoration: underline; }
  a[href]:after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* Feature 44: Feedback Widget */
.cdx-feedback {
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 24px;
}

.cdx-feedback-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-feedback-btn:hover { background: rgba(255, 255, 255, 0.2); }
.cdx-feedback-btn.cdx-active-up { background: #22c55e; color: #fff; }
.cdx-feedback-btn.cdx-active-down { background: #ef4444; color: #fff; }

/* Feature 45: Confetti Canvas */
.cdx-confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2147483645;
}

/* ============================================================================
 * PART 2: POLISH LAYER (Features 51-100)
 * ============================================================================ */

/* Feature 51: Hover Lift */
.cdx-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cdx-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Feature 52: Active Press */
.cdx-press:active {
  transform: scale(0.98);
}

/* Feature 53: Focus Glow */
.cdx-focus-glow:focus,
input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.25);
}

/* Feature 55: Menu Slide */
.cdx-dropdown {
  opacity: 0;
  transform: translateY(-10px);
  visibility: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.cdx-dropdown.cdx-active {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

/* Feature 56: Cursor Hand */
button, [role="button"], .cdx-clickable {
  cursor: pointer;
}

/* Feature 57: Link Fade */
a {
  transition: color 0.2s ease, opacity 0.2s ease;
}

/* Feature 58: Sticky Head */
.cdx-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  background: inherit;
}

/* Feature 60: Progress Bar */
.cdx-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #f97316, #fb923c);
  z-index: 2147483647;
  transition: width 0.1s ease;
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.5);
}

/* Feature 61: Line Height */
.cdx-readable { line-height: 1.6; }

/* Feature 62: Line Width */
.cdx-prose { max-width: 75ch; }

/* Feature 63: Typography Hierarchy */
.cdx-h1 { font-size: 2.5rem; font-weight: 700; line-height: 1.2; }
.cdx-h2 { font-size: 2rem; font-weight: 600; line-height: 1.3; }
.cdx-h3 { font-size: 1.75rem; font-weight: 600; line-height: 1.4; }
.cdx-h4 { font-size: 1.5rem; font-weight: 500; line-height: 1.4; }
.cdx-h5 { font-size: 1.25rem; font-weight: 500; line-height: 1.5; }
.cdx-h6 { font-size: 1rem; font-weight: 500; line-height: 1.5; }

/* Feature 64: Contrast */
.cdx-light { --cdx-text: #222; --cdx-bg: #fff; --cdx-muted: #666; }
.cdx-dark { --cdx-text: #fff; --cdx-bg: #1a1a2e; --cdx-muted: rgba(255, 255, 255, 0.6); }

/* Feature 65: System Fonts */
.cdx-system-font {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Feature 68: Link Style */
.cdx-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  -webkit-tap-highlight-color: transparent;
}

.cdx-link:hover { text-decoration-thickness: 2px; }

/* Feature 69: Whitespace Utilities */
.cdx-mb-1 { margin-bottom: 0.25rem; }
.cdx-mb-2 { margin-bottom: 0.5rem; }
.cdx-mb-3 { margin-bottom: 1rem; }
.cdx-mb-4 { margin-bottom: 1.5rem; }
.cdx-mb-5 { margin-bottom: 2rem; }
.cdx-mb-6 { margin-bottom: 3rem; }
.cdx-mt-1 { margin-top: 0.25rem; }
.cdx-mt-2 { margin-top: 0.5rem; }
.cdx-mt-3 { margin-top: 1rem; }
.cdx-mt-4 { margin-top: 1.5rem; }
.cdx-mt-5 { margin-top: 2rem; }
.cdx-mt-6 { margin-top: 3rem; }

/* Feature 74: Password Eye Toggle */
.cdx-password-wrapper { position: relative; }

.cdx-password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-password-toggle:hover { opacity: 1; }

/* Feature 76: Error Text */
.cdx-error-text {
  color: #ef4444;
  font-size: 12px;
  margin-top: 4px;
}

/* Feature 77: Button Primary */
.cdx-btn-primary {
  background: #1a1a2e;
  color: #fff;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cdx-btn-primary:hover { background: #16213e; }
.cdx-btn-primary:active { transform: scale(0.98); }

/* Feature 78: Touch Target (iOS Standard 44px) */
.cdx-touch-target {
  min-height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Feature 79: Floating Label */
.cdx-float-label { position: relative; }
.cdx-float-label input, .cdx-float-label textarea { padding-top: 24px; }

.cdx-float-label label {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  transition: all 0.2s ease;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.4);
}

.cdx-float-label input:focus + label,
.cdx-float-label input:not(:placeholder-shown) + label,
.cdx-float-label textarea:focus + label,
.cdx-float-label textarea:not(:placeholder-shown) + label {
  top: 8px;
  font-size: 11px;
  transform: translateY(0);
}

/* Feature 80: Breadcrumbs */
.cdx-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.cdx-breadcrumb-item {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.cdx-breadcrumb-item:hover { color: #fff; }
.cdx-breadcrumb-separator { opacity: 0.4; }
.cdx-breadcrumb-current { color: #fff; }

/* Feature 82: Visited Links */
a:visited { opacity: 0.85; }

/* Feature 83: Empty State */
.cdx-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.cdx-empty-icon { width: 120px; height: 120px; margin-bottom: 24px; opacity: 0.3; }
.cdx-empty-title { font-size: 20px; color: #fff; margin-bottom: 8px; }
.cdx-empty-text { font-size: 14px; color: rgba(255, 255, 255, 0.6); max-width: 300px; }

/* Feature 86: Back to Top */
.cdx-back-top {
  position: fixed;
  bottom: 100px;
  bottom: calc(100px + env(safe-area-inset-bottom, 0));
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 2147483638;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cdx-back-top.cdx-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.cdx-back-top:hover { background: rgba(255, 255, 255, 0.2); }

/* Feature 91: Lazy Load Blur-up */
.cdx-lazy { filter: blur(10px); transition: filter 0.3s ease; }
.cdx-lazy.cdx-loaded { filter: blur(0); }

/* Feature 92: Image Aspect Ratio */
.cdx-aspect-16-9 { aspect-ratio: 16 / 9; object-fit: cover; }
.cdx-aspect-4-3 { aspect-ratio: 4 / 3; object-fit: cover; }
.cdx-aspect-1-1 { aspect-ratio: 1 / 1; object-fit: cover; }
.cdx-aspect-9-16 { aspect-ratio: 9 / 16; object-fit: cover; }

/* Feature 93: Alt Warning (Dev Mode) */
.cdx-dev-mode img:not([alt]),
.cdx-dev-mode img[alt=""] {
  outline: 3px solid #ef4444 !important;
  outline-offset: 2px;
}

/* Feature 94: Tablet Media Queries */
@media (max-width: 768px) {
  .cdx-hide-tablet { display: none !important; }
  .cdx-command-modal { width: 95%; margin-top: 10vh; }
  .cdx-fab { bottom: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0)); left: 16px; }
  .cdx-toast-container { left: 16px; right: 16px; bottom: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0)); }
  .cdx-toast { min-width: auto; width: 100%; }
}

/* Feature 97: External Link Icon */
a[target="_blank"]:not(.cdx-no-icon)::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  vertical-align: middle;
  opacity: 0.5;
}

/* Feature 100: Selection Color */
::selection { background: rgba(249, 115, 22, 0.3); color: inherit; }
::-moz-selection { background: rgba(249, 115, 22, 0.3); color: inherit; }

/* ============================================================================
 * PART 3: ANTICIPATORY LAYER (Features 101-120)
 * ============================================================================ */

/* Feature 101: Velocity Type */
.cdx-velocity-active h1,
.cdx-velocity-active h2,
.cdx-velocity-active h3 {
  font-weight: 800;
  transition: font-weight 0.3s ease;
}

/* Feature 102: Trajectory Glow */
.cdx-trajectory-glow {
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.4);
  transition: box-shadow 0.2s ease;
}

/* Feature 103: Magnet Cursor */
.cdx-magnet {
  transition: transform 0.15s ease;
}

/* Feature 106: Circadian Background */
.cdx-circadian {
  transition: background-color 0.5s ease, filter 0.5s ease;
}

/* Feature 107: Focus Tunnel */
.cdx-focus-tunnel *:not(:focus):not(:focus-within) {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.cdx-focus-tunnel *:focus,
.cdx-focus-tunnel *:focus-within { opacity: 1; }

/* Feature 108: Rage Click Indicator */
.cdx-rage-indicator {
  animation: cdx-shake 0.5s ease;
}

@keyframes cdx-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Feature 110: Density Mode */
.cdx-compact { --cdx-spacer: 0.5rem; }
.cdx-compact .cdx-mb-4 { margin-bottom: var(--cdx-spacer, 1.5rem); }

/* Feature 111: Patina Effect */
.cdx-patina-1 { background-color: rgba(249, 115, 22, 0.05); }
.cdx-patina-2 { background-color: rgba(249, 115, 22, 0.1); }
.cdx-patina-3 { background-color: rgba(249, 115, 22, 0.15); }
.cdx-patina-4 { background-color: rgba(249, 115, 22, 0.2); }
.cdx-patina-5 { background-color: rgba(249, 115, 22, 0.25); }

/* Feature 113: Wait Cursor */
.cdx-loading { cursor: progress !important; }
.cdx-loading * { cursor: progress !important; }

/* Feature 116: Link Peek */
.cdx-link-peek {
  position: absolute;
  width: 400px;
  height: 300px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  z-index: 2147483644;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.cdx-link-peek.cdx-active { opacity: 1; visibility: visible; }

.cdx-link-peek iframe {
  width: 100%;
  height: 100%;
  border: none;
  transform: scale(0.5);
  transform-origin: top left;
  width: 200%;
  height: 200%;
}

/* Feature 117: Changelog Badge */
.cdx-new-badge { position: relative; }

.cdx-new-badge::after {
  content: 'NEW';
  position: absolute;
  top: -8px;
  right: -8px;
  background: #f97316;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

/* ============================================================================
 * PART 4: PSYCHOLOGICAL CODEX (Features 121-140)
 * ============================================================================ */

/* Feature 121-123: Reciprocity Modals */
.cdx-reciprocity-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cdx-reciprocity-modal.cdx-active { opacity: 1; visibility: visible; }

.cdx-reciprocity-content {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 40px;
  max-width: 480px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.cdx-reciprocity-modal.cdx-active .cdx-reciprocity-content { transform: scale(1); }

.cdx-reciprocity-icon { width: 64px; height: 64px; margin: 0 auto 24px; opacity: 0.8; }
.cdx-reciprocity-title { font-size: 24px; color: #fff; margin-bottom: 12px; }
.cdx-reciprocity-text { font-size: 16px; color: rgba(255, 255, 255, 0.6); margin-bottom: 24px; line-height: 1.6; }

/* Feature 124: Identity Toggle */
.cdx-identity-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cdx-identity-toggle input { display: none; }

.cdx-identity-switch {
  width: 48px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  position: relative;
  transition: background 0.2s ease;
}

.cdx-identity-switch::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
}

.cdx-identity-toggle input:checked + .cdx-identity-switch { background: #f97316; }
.cdx-identity-toggle input:checked + .cdx-identity-switch::after { transform: translateX(20px); }

.cdx-noise { transition: filter 0.3s ease, opacity 0.3s ease; }
.cdx-long-duration .cdx-noise { filter: blur(4px); opacity: 0.5; }

/* Feature 125: Manifesto Gate */
.cdx-manifesto-gate {
  padding: 24px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 12px;
  margin-bottom: 24px;
}

.cdx-manifesto-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cdx-manifesto-checkbox input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: #f97316;
}

.cdx-manifesto-text { font-size: 16px; color: #fff; line-height: 1.5; }

.cdx-gated-content {
  filter: blur(8px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.cdx-gated-content.cdx-unlocked {
  filter: blur(0);
  opacity: 1;
  pointer-events: auto;
  user-select: auto;
}

/* Feature 128: Silent Badge (Social Proof) */
.cdx-social-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 20px;
  font-size: 12px;
  color: #f97316;
}

.cdx-social-badge-icon { width: 14px; height: 14px; }

/* Feature 129: Peer Notes */
.cdx-peer-notes {
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: rgba(249, 115, 22, 0.8);
  transform: rotate(-2deg);
  margin-left: 20px;
  position: relative;
}

.cdx-peer-notes::before {
  content: '"';
  font-size: 24px;
  position: absolute;
  left: -12px;
  top: -4px;
}

/* Feature 131: Quiet Room */
.cdx-quiet-room {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.cdx-quiet-room.cdx-active { opacity: 1; visibility: visible; }

.cdx-quiet-content { max-width: 600px; padding: 40px; text-align: center; }

.cdx-quiet-text {
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 24px;
  line-height: 1.8;
  color: #333;
}

.cdx-quiet-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.cdx-quiet-close:hover { opacity: 1; }

/* Feature 132: Disqualify Warning */
.cdx-disqualify {
  padding: 20px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  margin-bottom: 24px;
}

.cdx-disqualify-title { font-size: 14px; font-weight: 600; color: #ef4444; margin-bottom: 8px; }
.cdx-disqualify-text { font-size: 14px; color: rgba(255, 255, 255, 0.7); line-height: 1.5; }

/* Feature 133: Dated Window */
.cdx-window-closed {
  padding: 40px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  text-align: center;
}

.cdx-window-closed-title { font-size: 20px; color: rgba(255, 255, 255, 0.4); margin-bottom: 8px; }
.cdx-window-closed-date { font-size: 14px; color: rgba(255, 255, 255, 0.3); }

/* Feature 134: Underwriting Mode */
.cdx-underwriting table,
.cdx-underwriting .highcharts-container,
.cdx-underwriting .recharts-wrapper,
.cdx-underwriting svg:not(.cdx-icon) {
  filter: grayscale(1);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace !important;
}

.cdx-underwriting table { border-collapse: collapse; }
.cdx-underwriting table td,
.cdx-underwriting table th { border: 1px solid rgba(255, 255, 255, 0.2); padding: 8px 12px; }

/* Feature 135: Legacy Font */
.cdx-legacy-font {
  font-family: 'Crimson Text', Georgia, 'Times New Roman', serif;
}

/* Feature 137: Privacy Banner */
.cdx-privacy-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 24px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  background: #1a1a2e;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 2147483635;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

.cdx-privacy-icon { width: 20px; height: 20px; opacity: 0.6; }

/* Feature 138: Pacing Tooltip */
.cdx-pacing-tooltip {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(26, 26, 46, 0.95);
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 16px;
  color: #fff;
  z-index: 2147483643;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  pointer-events: none;
}

.cdx-pacing-tooltip.cdx-active { opacity: 1; visibility: visible; }

/* Feature 139: Smart 404 */
.cdx-smart-404 { text-align: center; padding: 80px 24px; }
.cdx-smart-404-title { font-size: 48px; color: rgba(255, 255, 255, 0.2); margin-bottom: 16px; }
.cdx-smart-404-text { font-size: 18px; color: rgba(255, 255, 255, 0.6); margin-bottom: 8px; }
.cdx-smart-404-apology { font-size: 14px; color: rgba(255, 255, 255, 0.4); font-style: italic; }

/* Feature 140: Patient Tag */
.cdx-patient-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.05em;
}

/* ============================================================================
 * UTILITY ANIMATIONS
 * ============================================================================ */

@keyframes cdx-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cdx-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes cdx-slide-up { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes cdx-slide-down { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes cdx-scale-in { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.cdx-animate-fade-in { animation: cdx-fade-in 0.3s ease; }
.cdx-animate-slide-up { animation: cdx-slide-up 0.3s ease; }
.cdx-animate-slide-down { animation: cdx-slide-down 0.3s ease; }
.cdx-animate-scale-in { animation: cdx-scale-in 0.3s ease; }

/* ============================================================================
 * RESPONSIVE UTILITIES
 * ============================================================================ */

@media (max-width: 640px) { .cdx-hide-mobile { display: none !important; } }
@media (min-width: 641px) and (max-width: 1024px) { .cdx-hide-tablet { display: none !important; } }
@media (min-width: 1025px) { .cdx-hide-desktop { display: none !important; } }

/* ============================================================================
 * DARK/LIGHT MODE SUPPORT
 * ============================================================================ */

@media (prefers-color-scheme: light) {
  .cdx-auto-theme { --cdx-bg: #fff; --cdx-text: #222; --cdx-muted: #666; }
}

@media (prefers-color-scheme: dark) {
  .cdx-auto-theme { --cdx-bg: #1a1a2e; --cdx-text: #fff; --cdx-muted: rgba(255, 255, 255, 0.6); }
}
