/* ============================================================================
   MASTER CODEX FINANCIAL - CSS LAYER v2.0
   140 Micro-Interactions for High-End Financial UX
   Mobile-First | iOS/Safari Optimized | Marlowe Partners
   ============================================================================ */

/* --- FONT IMPORTS --- */
@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=Reenie+Beanie&display=swap');

/* ============================================================================
   PART 0: iOS/MOBILE-FIRST CONSTRAINTS (CRITICAL)
   ============================================================================ */

/* Global iOS tap highlight removal */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Interactive elements - iOS optimized */
.cdx-interactive,
.cdx-btn,
.cdx-btn-sm,
.cdx-btn-primary,
.cdx-toggle-switch,
.cdx-fab,
.cdx-modal-close,
.cdx-back-top,
[class*="cdx-trigger"],
button[class*="cdx-"],
a[class*="cdx-"] {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Safe area insets for iPhone notch/home bar */
.cdx-toast,
.cdx-fab,
.cdx-footer-banner,
.cdx-back-top,
.cdx-command-palette,
.cdx-modal {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Fixed bottom elements - respect home indicator */
.cdx-fixed-bottom {
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

/* iOS scroll momentum */
.cdx-scroll-container {
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}

/* Prevent iOS zoom on input focus */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
textarea,
select {
  font-size: 16px !important; /* Prevents iOS zoom */
}

/* ============================================================================
   PART 1: UTILITIES & BASE CLASSES
   ============================================================================ */

/* Hidden/Visible States */
.cdx-hidden { display: none !important; }
.cdx-visible { 
  opacity: 1 !important; 
  pointer-events: auto !important; 
  transform: translateY(0) !important; 
}
.cdx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

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

/* Button Styles */
.cdx-btn {
  background: #000;
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
  border-radius: 4px;
}

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

.cdx-btn-sm {
  background: #000;
  color: #fff;
  border: none;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
  border-radius: 4px;
}

/* 77. Primary Button */
.cdx-btn-primary {
  background: #1a1a1a;
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.cdx-btn-primary:hover {
  background: #333;
}

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

/* ============================================================================
   PART 2: POLISH LAYER - UI/UX DETAIL (51-100)
   ============================================================================ */

/* 51. Hover Lift */
.cdx-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cdx-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

/* 53. Focus Glow */
.cdx-focus-glow:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.25);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}

/* 54. Skeleton Animation */
.cdx-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: cdx-shimmer 1.5s infinite;
  border-radius: 4px;
}

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

/* Dark mode skeleton */
.dark .cdx-skeleton {
  background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
  background-size: 200% 100%;
}

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

.cdx-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

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

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

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

/* 59. Toast Pop Animation */
@keyframes cdx-toast-pop {
  0% { transform: translateY(100px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.cdx-toast {
  position: fixed;
  bottom: calc(30px + env(safe-area-inset-bottom, 0));
  right: 20px;
  left: 20px;
  background: #fff;
  border-left: 4px solid #f59e0b;
  padding: 16px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  z-index: 2147483647;
  opacity: 0;
  transform: translateY(100px);
  transition: all 0.3s ease;
  border-radius: 8px;
  max-width: 400px;
  margin-left: auto;
}

@media (min-width: 768px) {
  .cdx-toast {
    left: auto;
    right: 30px;
  }
}

.cdx-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
  animation: cdx-toast-pop 0.3s ease;
}

.cdx-toast-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
  color: #1a1a1a;
}

.cdx-toast-message {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.cdx-toast-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 4px;
  line-height: 1;
}

/* 60. Progress Bar (Scroll) */
.cdx-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #ea580c);
  z-index: 2147483647;
  width: 0%;
  transition: width 0.1s ease;
}

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

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

/* 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; }

/* 64. Contrast */
.cdx-high-contrast {
  color: #222;
  background: #fff;
}

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

/* 68. Link Style */
.cdx-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* 69. Whitespace Utilities */
.cdx-mb-1 { margin-bottom: 0.5rem; }
.cdx-mb-2 { margin-bottom: 0.75rem; }
.cdx-mb-3 { margin-bottom: 1rem; }
.cdx-mb-4 { margin-bottom: 1.5rem; }
.cdx-mb-6 { margin-bottom: 2rem; }

/* 75. Numeric Keypad */
input[inputmode="numeric"] {
  font-variant-numeric: tabular-nums;
}

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

/* 79. Label Float */
.cdx-float-label {
  position: relative;
}

.cdx-float-label label {
  position: absolute;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  transition: all 0.2s ease;
  pointer-events: none;
  color: #999;
  font-size: 14px;
}

.cdx-float-label input:focus + label,
.cdx-float-label input:not(:placeholder-shown) + label {
  top: 0;
  font-size: 11px;
  background: #fff;
  padding: 0 4px;
  color: #f59e0b;
}

/* 80. Breadcrumbs */
.cdx-breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: #666;
}

.cdx-breadcrumbs a {
  color: #666;
  text-decoration: none;
}

.cdx-breadcrumbs a:hover {
  color: #f59e0b;
}

.cdx-breadcrumbs span::before {
  content: '/';
  margin-right: 8px;
  color: #ccc;
}

/* 82. Visited Links */
a:visited {
  color: #6b7280;
}

/* 83. Empty State */
.cdx-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.cdx-empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* 86. Back to Top */
.cdx-back-top {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom, 0));
  right: 20px;
  width: 44px;
  height: 44px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  z-index: 1000;
}

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

.cdx-back-top:hover {
  background: #f59e0b;
}

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

.cdx-lazy.is-loaded {
  filter: blur(0);
}

/* 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;
}

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

/* 94. Tablet Media Queries */
@media (max-width: 768px) {
  .cdx-hide-mobile { display: none !important; }
  .cdx-stack-mobile { flex-direction: column !important; }
}

@media (min-width: 769px) {
  .cdx-hide-desktop { display: none !important; }
}

/* 97. External Link Icon */
a[target="_blank"]::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;
  vertical-align: middle;
  opacity: 0.5;
}

/* 100. Selection Color */
::selection {
  background: rgba(245, 158, 11, 0.3);
  color: inherit;
}

/* ============================================================================
   PART 3: RECIPROCITY FEATURES (121-123)
   ============================================================================ */

/* 122. Welcome Modal */
.cdx-welcome-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
}

.cdx-welcome-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cdx-welcome-modal-content {
  background: #0a0a0a;
  padding: 40px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  border-radius: 16px;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  color: #fff;
}

.cdx-welcome-modal.is-visible .cdx-welcome-modal-content {
  transform: scale(1);
}

.cdx-welcome-modal-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.cdx-welcome-modal-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #f59e0b;
}

.cdx-welcome-modal-subtitle {
  font-size: 14px;
  color: #888;
  margin-bottom: 8px;
}

.cdx-welcome-modal-quote {
  font-style: italic;
  color: #aaa;
  margin-bottom: 24px;
  font-size: 15px;
}

.cdx-welcome-modal-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.cdx-welcome-modal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.cdx-welcome-modal-dot:last-child {
  background: #3b82f6;
}

.cdx-welcome-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: #f97316;
  border: 3px solid #fb923c;
  border-radius: 50%;
  color: #fff;
  font-size: 32px;
  font-weight: bold;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 1;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.5);
  z-index: 10;
}

.cdx-welcome-modal-close:hover {
  background: #ea580c;
  transform: scale(1.1);
}

.cdx-welcome-modal-close:active {
  transform: scale(0.95);
}

/* 123. Exit Intent Overlay */
.cdx-exit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.cdx-exit-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cdx-exit-content {
  background: #1a1a1a;
  padding: 40px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  border-radius: 16px;
  color: #fff;
}

.cdx-exit-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #f59e0b;
}

.cdx-exit-message {
  color: #aaa;
  margin-bottom: 24px;
  line-height: 1.6;
}

.cdx-exit-cta {
  background: #f59e0b;
  color: #000;
  border: none;
  padding: 14px 28px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  min-height: 44px;
  transition: all 0.2s;
}

.cdx-exit-cta:hover {
  background: #d97706;
}

.cdx-exit-dismiss {
  background: none;
  border: none;
  color: #666;
  margin-top: 16px;
  cursor: pointer;
  font-size: 13px;
}

/* ============================================================================
   PART 4: COMMITMENT FEATURES (124-127)
   ============================================================================ */

/* 124. Identity Toggle - Long Duration View */
.cdx-identity-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.8);
  padding: 8px 16px;
  border-radius: 20px;
  z-index: 1000;
  font-size: 12px;
  color: #fff;
}

.cdx-toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
  background: #333;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.cdx-toggle-switch.is-active {
  background: #f59e0b;
}

.cdx-toggle-switch.is-active::after {
  transform: translateX(18px);
}

/* Noise blur when long-duration mode active */
body.cdx-mode-longterm .cdx-noise {
  opacity: 0.15;
  filter: blur(3px);
  transition: all 0.3s ease;
}

/* 125. Manifesto Gate */
.cdx-manifesto-gate {
  background: #f5f5f5;
  padding: 20px;
  border-radius: 8px;
  margin: 20px 0;
}

.cdx-manifesto-checkbox {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.cdx-manifesto-checkbox input {
  width: 20px;
  height: 20px;
  accent-color: #f59e0b;
}

.cdx-gated-content {
  filter: blur(5px);
  opacity: 0.5;
  pointer-events: none;
  transition: all 0.3s ease;
}

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

/* ============================================================================
   PART 5: SOCIAL PROOF FEATURES (128-130)
   ============================================================================ */

/* 128. Silent Badge */
.cdx-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cdx-badge-highlight {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #000;
}

/* 129. Peer Notes - Handwritten annotations */
.cdx-note {
  font-family: 'Reenie Beanie', cursive;
  font-size: 18px;
  color: #dc2626;
  position: absolute;
  right: -120px;
  transform: rotate(-3deg);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.cdx-show-notes .cdx-note {
  opacity: 1;
}

@media (max-width: 1200px) {
  .cdx-note {
    position: relative;
    right: auto;
    display: block;
    margin: 8px 0;
  }
}

/* 130. Empty Chair */
.cdx-empty-chair {
  font-size: 12px;
  color: #666;
  font-style: italic;
}

/* ============================================================================
   PART 6: SCARCITY FEATURES (131-133)
   ============================================================================ */

/* 131. Quiet Room */
.cdx-quiet-overlay {
  position: fixed;
  inset: 0;
  background: #fdfbf7;
  z-index: 2147483647;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 60px 20px;
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
}

.cdx-quiet-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cdx-quiet-content {
  max-width: 650px;
  margin: 0 auto;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 20px;
  line-height: 1.8;
  color: #333;
}

.cdx-quiet-close {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #333;
  color: #fff;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  z-index: 2147483648;
}

/* 132. Disqualify Warning */
.cdx-disqualify {
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
  color: #991b1b;
}

/* 133. Dated Window */
.cdx-dated-window {
  background: #f3f4f6;
  padding: 20px;
  text-align: center;
  border-radius: 8px;
}

.cdx-dated-window.is-closed {
  opacity: 0.6;
}

.cdx-dated-window.is-closed::after {
  content: 'Window Closed';
  display: block;
  color: #dc2626;
  font-weight: 600;
  margin-top: 12px;
}

/* ============================================================================
   PART 7: AUTHORITY FEATURES (134-136)
   ============================================================================ */

/* 134. Underwriting Mode - Financial Data Focus */
.cdx-underwriting {
  filter: grayscale(100%) contrast(1.2);
  font-family: 'Courier New', Consolas, monospace !important;
}

/* Target financial elements specifically */
body.cdx-mode-underwriting table,
body.cdx-mode-underwriting .highcharts-container,
body.cdx-mode-underwriting .recharts-wrapper,
body.cdx-mode-underwriting svg:not(.cdx-icon),
body.cdx-mode-underwriting [class*="chart"],
body.cdx-mode-underwriting [class*="Chart"] {
  filter: grayscale(100%) contrast(1.2);
}

body.cdx-mode-underwriting table {
  font-family: 'Courier New', Consolas, monospace !important;
}

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

/* 136. Header Swap - handled in JS */

/* ============================================================================
   PART 8: AFFIRMATION FEATURES (137-140)
   ============================================================================ */

/* 137. Privacy Banner */
.cdx-footer-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 20px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  text-align: center;
  font-size: 12px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cdx-footer-banner-icon {
  color: #f59e0b;
}

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

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

/* 140. Patient Tag */
.cdx-patient-tag {
  display: inline-block;
  font-size: 11px;
  color: #666;
  font-style: italic;
  margin-top: 20px;
}

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

/* 101. Velocity Type */
body.cdx-fast-scroll h1,
body.cdx-fast-scroll h2,
body.cdx-fast-scroll h3 {
  font-weight: 800;
  transition: font-weight 0.2s ease;
}

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

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

/* 106. Circadian Background - Dark Theme Compatible */
body.cdx-circadian-morning {
  --cdx-bg-tint: rgba(251, 191, 36, 0.03);
  background-image: linear-gradient(var(--cdx-bg-tint), var(--cdx-bg-tint));
}

body.cdx-circadian-day {
  --cdx-bg-tint: transparent;
}

body.cdx-circadian-evening {
  --cdx-bg-tint: rgba(245, 158, 11, 0.04);
  background-image: linear-gradient(var(--cdx-bg-tint), var(--cdx-bg-tint));
}

body.cdx-circadian-night {
  --cdx-bg-tint: rgba(234, 88, 12, 0.05);
  background-image: linear-gradient(var(--cdx-bg-tint), var(--cdx-bg-tint));
  filter: saturate(0.95) brightness(0.98);
}

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

/* 108. Rage Click Help */
.cdx-rage-help {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0));
  right: 20px;
  background: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  z-index: 2147483647;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  max-width: 280px;
}

.cdx-rage-help.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.cdx-rage-help strong {
  display: block;
  margin-bottom: 8px;
  color: #dc2626;
}

/* 110. Density Mode */
body.cdx-compact {
  --cdx-spacer: 0.5rem;
}

body.cdx-compact .cdx-mb-4 {
  margin-bottom: var(--cdx-spacer, 0.5rem);
}

/* 111. Patina Effect */
.cdx-patina-1 { background-color: rgba(0,0,0,0.02); }
.cdx-patina-2 { background-color: rgba(0,0,0,0.04); }
.cdx-patina-3 { background-color: rgba(0,0,0,0.06); }
.cdx-patina-4 { background-color: rgba(0,0,0,0.08); }
.cdx-patina-5 { background-color: rgba(0,0,0,0.10); }

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

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

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

/* 2. Floating Action Button (FAB) */
.cdx-fab {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  left: 20px;
  width: 56px;
  height: 56px;
  background: #f59e0b;
  color: #000;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
  z-index: 1000;
  transition: all 0.2s ease;
}

.cdx-fab:hover {
  transform: scale(1.1);
}

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

/* 3. Command Palette */
.cdx-command-palette {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.cdx-command-palette.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cdx-command-box {
  background: #1a1a1a;
  width: 100%;
  max-width: 560px;
  border-radius: 12px;
  overflow: hidden;
  margin: 0 20px;
  transform: translateY(-20px);
  transition: transform 0.2s ease;
}

.cdx-command-palette.is-visible .cdx-command-box {
  transform: translateY(0);
}

.cdx-command-input {
  width: 100%;
  padding: 20px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 18px;
  outline: none;
}

.cdx-command-input::placeholder {
  color: #666;
}

.cdx-command-results {
  border-top: 1px solid #333;
  max-height: 400px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cdx-command-item {
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ccc;
  transition: background 0.1s;
}

.cdx-command-item:hover,
.cdx-command-item.is-selected {
  background: #333;
  color: #fff;
}

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

.cdx-command-shortcut {
  margin-left: auto;
  font-size: 11px;
  color: #666;
  background: #2a2a2a;
  padding: 2px 6px;
  border-radius: 4px;
}

/* 12. Greeter */
.cdx-greeter {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
}

/* 17. Recent Views Widget */
.cdx-recent-views {
  background: #f5f5f5;
  padding: 16px;
  border-radius: 8px;
  margin: 20px 0;
}

.cdx-recent-views-title {
  font-size: 12px;
  font-weight: 600;
  color: #666;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cdx-recent-views-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cdx-recent-views-item {
  font-size: 14px;
  color: #333;
  text-decoration: none;
  padding: 8px;
  background: #fff;
  border-radius: 4px;
  transition: background 0.2s;
}

.cdx-recent-views-item:hover {
  background: #f59e0b;
  color: #000;
}

/* 18. Onboarding Checklist */
.cdx-onboarding {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0));
  right: 20px;
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  max-width: 300px;
  z-index: 1000;
}

.cdx-onboarding-title {
  font-weight: 700;
  margin-bottom: 16px;
}

.cdx-onboarding-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  font-size: 14px;
}

.cdx-onboarding-item.is-complete {
  color: #22c55e;
  text-decoration: line-through;
}

.cdx-onboarding-dismiss {
  margin-top: 16px;
  font-size: 12px;
  color: #666;
  cursor: pointer;
  text-align: center;
}

/* 22. Zen Mode */
body.cdx-zen-mode > *:not(article):not(main):not(.cdx-zen-exempt) {
  display: none !important;
}

body.cdx-zen-mode article,
body.cdx-zen-mode main {
  max-width: 700px;
  margin: 40px auto;
  padding: 20px;
}

/* 23. Read Time */
.cdx-read-time {
  font-size: 13px;
  color: #666;
  margin-bottom: 20px;
}

/* 24. Copy Code Button */
.cdx-copy-code {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #333;
  color: #fff;
  border: none;
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.cdx-copy-code.is-copied {
  background: #22c55e;
}

/* 31. Night Shift */
body.cdx-night-shift {
  filter: sepia(20%) brightness(0.95);
}

/* 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; }
}

/* 33. Skeleton UI */
.cdx-skeleton-text {
  height: 1em;
  background: #e5e5e5;
  border-radius: 4px;
  margin-bottom: 8px;
}

.cdx-skeleton-text:last-child {
  width: 60%;
}

/* 42. Print Styles */
@media print {
  .cdx-no-print,
  nav,
  footer,
  .cdx-fab,
  .cdx-back-top,
  .cdx-toast {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
}

/* 44. Feedback Widget */
.cdx-feedback {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.cdx-feedback-btn {
  background: #f5f5f5;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  min-height: 44px;
}

.cdx-feedback-btn:hover {
  background: #e5e5e5;
}

.cdx-feedback-btn.is-selected {
  background: #f59e0b;
}

/* 45. Confetti Canvas */
.cdx-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483647;
}

/* 74. Password Eye Toggle */
.cdx-pass-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 8px;
}

/* ============================================================================
   PART 11: KEYBOARD SHORTCUTS GUIDE
   ============================================================================ */

.cdx-shortcuts-btn {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  z-index: 999;
  transition: all 0.2s ease;
}

.cdx-shortcuts-btn:hover {
  background: #f59e0b;
  color: #000;
}

.cdx-shortcuts-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.cdx-shortcuts-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.cdx-shortcuts-content {
  background: #1a1a1a;
  padding: 32px;
  max-width: 500px;
  width: 100%;
  border-radius: 16px;
  color: #fff;
  max-height: 80vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.cdx-shortcuts-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #f59e0b;
}

.cdx-shortcuts-section {
  margin-bottom: 24px;
}

.cdx-shortcuts-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.cdx-shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #333;
}

.cdx-shortcut-row:last-child {
  border-bottom: none;
}

.cdx-shortcut-desc {
  color: #ccc;
  font-size: 14px;
}

.cdx-shortcut-keys {
  display: flex;
  gap: 4px;
}

.cdx-shortcut-key {
  background: #333;
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  min-width: 28px;
  text-align: center;
}

.cdx-shortcuts-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
}

.cdx-shortcuts-close:hover {
  color: #fff;
}

/* ============================================================================
   END OF MASTER CODEX FINANCIAL CSS
   ============================================================================ */
