/**
 * MASTER CODEX FINANCIAL - CSS Layer
 * Complete 140 Micro-Interactions for Marlowe Partners
 * Mobile-First (iPhone/Safari Focus) | Financial Data Handling | Strict Isolation
 * All classes namespaced with .cdx-
 */

/* ============================================
   ROOT VARIABLES & MOBILE-FIRST CONSTRAINTS
   ============================================ */

:root {
  /* Semantic Colors */
  --cdx-success: #22c55e;
  --cdx-error: #ef4444;
  --cdx-warning: #f59e0b;
  --cdx-info: #3b82f6;
  --cdx-accent: #f97316;
  
  /* Text Colors */
  --cdx-text: #e5e5e5;
  --cdx-text-muted: #888;
  --cdx-text-dark: #222;
  
  /* Background Colors */
  --cdx-bg: #0f0f0f;
  --cdx-bg-elevated: #1a1a1a;
  --cdx-bg-light: #fff;
  
  /* Borders */
  --cdx-border: rgba(255, 255, 255, 0.1);
  --cdx-border-light: rgba(0, 0, 0, 0.1);
  
  /* Skeleton */
  --cdx-skeleton-base: rgba(255, 255, 255, 0.05);
  --cdx-skeleton-shine: rgba(255, 255, 255, 0.1);
  
  /* Font Scale */
  --cdx-font-scale: 1;
  
  /* Spacing (Density) */
  --cdx-spacer: 1rem;
}

/* iOS Safe Area Support */
.cdx-safe-bottom {
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

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

/* Force cursor pointer on all interactive elements (iOS requirement) */
button, a, [role="button"], [data-cdx-clickable], .cdx-clickable {
  cursor: pointer;
}

/* Prevent double-tap zoom delay */
.cdx-fast-tap, button, a, input, select, textarea {
  touch-action: manipulation;
}

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

/* 2. Quick Actions - Floating Action Button */
.cdx-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cdx-accent);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
  z-index: 2147483640;
  transition: all 0.2s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cdx-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 8px 30px rgba(249, 115, 22, 0.5);
}

/* FAB Command Menu */
.cdx-fab-menu {
  position: fixed;
  bottom: 90px;
  left: 24px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  z-index: 2147483640;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(0.95);
  transition: all 0.2s ease;
  min-width: 200px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cdx-fab-menu.cdx-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.cdx-fab-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--cdx-text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.cdx-fab-menu-item:hover {
  background: rgba(249, 115, 22, 0.1);
}

.cdx-fab-menu-item:first-child {
  border-radius: 12px 12px 0 0;
}

.cdx-fab-menu-item:last-child {
  border-radius: 0 0 12px 12px;
}

/* 3. Command Palette (Cmd+K) */
.cdx-cmd-palette {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

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

.cdx-cmd-palette-box {
  width: 100%;
  max-width: 580px;
  margin: 0 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.95) translateY(-10px);
  transition: transform 0.2s ease;
}

.cdx-cmd-palette.cdx-visible .cdx-cmd-palette-box {
  transform: scale(1) translateY(0);
}

.cdx-cmd-input {
  width: 100%;
  padding: 18px 20px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--cdx-border);
  color: var(--cdx-text);
  font-size: 16px;
  outline: none;
}

.cdx-cmd-input::placeholder {
  color: var(--cdx-text-muted);
}

.cdx-cmd-results {
  max-height: 400px;
  overflow-y: auto;
  padding: 8px;
}

.cdx-cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.cdx-cmd-item:hover,
.cdx-cmd-item.cdx-selected {
  background: var(--cdx-accent);
}

.cdx-cmd-item-icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
}

.cdx-cmd-item-text {
  flex: 1;
  font-size: 14px;
  color: var(--cdx-text);
}

.cdx-cmd-item-shortcut {
  font-size: 11px;
  color: var(--cdx-text-muted);
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* 5. Clean Toggle */
.cdx-clean-toggle {
  position: fixed;
  bottom: 90px;
  left: 24px;
  padding: 8px 12px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 8px;
  color: var(--cdx-text);
  font-size: 12px;
  cursor: pointer;
  z-index: 2147483640;
  transition: all 0.15s ease;
}

.cdx-clean-toggle:hover {
  background: var(--cdx-accent);
  color: white;
}

/* Clean mode - hide sidebars */
.cdx-clean-mode [class*="sidebar"],
.cdx-clean-mode [class*="Sidebar"],
.cdx-clean-mode .cdx-sidebar {
  display: none !important;
}

/* 6. Theme Switcher */
.cdx-theme-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 8px;
}

.cdx-theme-btn {
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--cdx-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-theme-btn.cdx-active {
  background: var(--cdx-accent);
  color: white;
}

/* Light theme overrides */
.cdx-theme-light {
  --cdx-text: #222;
  --cdx-text-muted: #666;
  --cdx-bg: #fff;
  --cdx-bg-elevated: #f5f5f5;
  --cdx-border: rgba(0, 0, 0, 0.1);
  --cdx-skeleton-base: rgba(0, 0, 0, 0.05);
  --cdx-skeleton-shine: rgba(0, 0, 0, 0.1);
}

/* 7. Facet Converter - Select as List Groups */
.cdx-facet-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0;
}

.cdx-facet-item {
  padding: 8px 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 20px;
  color: var(--cdx-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-facet-item:hover,
.cdx-facet-item.cdx-active {
  background: var(--cdx-accent);
  border-color: var(--cdx-accent);
  color: white;
}

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

.cdx-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  color: var(--cdx-text);
  font-size: 14px;
  pointer-events: auto;
  transform: translateX(120%);
  animation: cdx-toast-in 0.3s ease forwards;
}

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

@keyframes cdx-toast-in {
  to { transform: translateX(0); }
}

@keyframes cdx-toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

.cdx-toast-success { border-left: 3px solid var(--cdx-success); }
.cdx-toast-error { border-left: 3px solid var(--cdx-error); }
.cdx-toast-warning { border-left: 3px solid var(--cdx-warning); }
.cdx-toast-info { border-left: 3px solid var(--cdx-info); }

/* 12. Greeter */
.cdx-greeter {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--cdx-text);
}

/* 17. Recent View Widget */
.cdx-recent-view {
  padding: 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
}

.cdx-recent-view-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--cdx-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.cdx-recent-view-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  color: var(--cdx-text);
  font-size: 14px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.cdx-recent-view-item:hover {
  color: var(--cdx-accent);
}

/* 18. Onboarding Checklist */
.cdx-checklist {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 320px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  z-index: 2147483640;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cdx-checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--cdx-border);
}

.cdx-checklist-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--cdx-text);
}

.cdx-checklist-close {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--cdx-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.cdx-checklist-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cdx-text);
}

.cdx-checklist-items {
  padding: 12px;
}

.cdx-checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.cdx-checklist-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.cdx-checklist-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--cdx-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cdx-checklist-item.cdx-completed .cdx-checklist-check {
  background: var(--cdx-success);
  border-color: var(--cdx-success);
}

.cdx-checklist-item.cdx-completed .cdx-checklist-check::after {
  content: '✓';
  color: white;
  font-size: 12px;
}

.cdx-checklist-text {
  flex: 1;
  font-size: 13px;
  color: var(--cdx-text);
}

.cdx-checklist-item.cdx-completed .cdx-checklist-text {
  text-decoration: line-through;
  opacity: 0.6;
}

/* 19. Notification Settings Modal */
.cdx-notify-modal {
  width: 400px;
  max-width: 90vw;
  padding: 24px;
}

.cdx-notify-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--cdx-border);
}

.cdx-notify-option:last-child {
  border-bottom: none;
}

.cdx-notify-label {
  font-size: 14px;
  color: var(--cdx-text);
}

.cdx-notify-desc {
  font-size: 12px;
  color: var(--cdx-text-muted);
  margin-top: 4px;
}

/* 22. Zen Mode */
.cdx-zen-mode [class*="sidebar"],
.cdx-zen-mode [class*="Sidebar"],
.cdx-zen-mode header,
.cdx-zen-mode footer,
.cdx-zen-mode nav {
  display: none !important;
}

.cdx-zen-mode main,
.cdx-zen-mode article,
.cdx-zen-mode [class*="content"],
.cdx-zen-mode [class*="Content"] {
  max-width: 75ch !important;
  margin: 0 auto !important;
  padding: 48px 24px !important;
}

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

/* 24. Copy Code Button */
.cdx-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 6px;
  color: var(--cdx-text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-copy-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--cdx-text);
}

.cdx-copy-btn.cdx-copied {
  background: var(--cdx-success);
  color: white;
}

/* 31. Night Shift - warm colors after 8 PM */
.cdx-night-shift {
  filter: sepia(0.1) saturate(0.9);
}

/* 32. Pulse Loader Animation */
@keyframes cdx-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.cdx-pulse {
  animation: cdx-pulse 2s ease-in-out infinite;
}

/* 33. Skeleton UI */
.cdx-skeleton {
  background: linear-gradient(
    90deg,
    var(--cdx-skeleton-base) 25%,
    var(--cdx-skeleton-shine) 50%,
    var(--cdx-skeleton-base) 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; }
}

/* 42. Print Styles */
@media print {
  .cdx-no-print,
  .cdx-fab,
  .cdx-toast-container,
  .cdx-back-to-top,
  .cdx-checklist,
  nav,
  footer,
  .cdx-scroll-progress {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
  }
  
  a {
    text-decoration: underline;
  }
  
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}

/* 44. Feedback Widget */
.cdx-feedback {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 20px;
}

.cdx-feedback-label {
  font-size: 13px;
  color: var(--cdx-text-muted);
}

.cdx-feedback-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--cdx-border);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-feedback-btn:hover {
  background: var(--cdx-accent);
  border-color: var(--cdx-accent);
}

.cdx-feedback-btn.cdx-selected {
  background: var(--cdx-accent);
  border-color: var(--cdx-accent);
}

/* 49. Permission UI - Disabled Buttons */
.cdx-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.cdx-disabled-tooltip {
  position: relative;
}

.cdx-disabled-tooltip::after {
  content: attr(data-cdx-reason);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--cdx-text);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.cdx-disabled-tooltip:hover::after {
  opacity: 1;
}

/* 50. Digest Widget */
.cdx-digest {
  padding: 20px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
}

.cdx-digest-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--cdx-text);
  margin-bottom: 12px;
}

.cdx-digest-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--cdx-text-muted);
}

/* ============================================
   PART 2: POLISH LAYER (50 Features)
   ============================================ */

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

.cdx-lift {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* 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, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.25);
}

/* 54. Skeleton Animation */
.cdx-skeleton-anim {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 0%,
    rgba(255, 255, 255, 0.08) 50%,
    rgba(255, 255, 255, 0.03) 100%
  );
  background-size: 200% 100%;
  animation: cdx-skeleton-shimmer 1.5s infinite;
}

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

.cdx-menu-slide.cdx-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 56. Cursor Hand */
.cdx-cursor-hand {
  cursor: pointer;
}

/* 57. Link Fade */
.cdx-link-fade {
  transition: color 0.2s ease, opacity 0.2s ease;
}

.cdx-link-fade:hover {
  opacity: 0.8;
}

/* 58. Sticky Header */
.cdx-sticky {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

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

.cdx-toast-pop {
  animation: cdx-toast-pop 0.3s ease forwards;
}

/* 60. Progress Bar (Scroll Indicator) */
.cdx-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--cdx-accent);
  z-index: 2147483647;
  transition: width 0.1s ease;
}

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

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

/* 63. Typography Hierarchy */
.cdx-h1 { font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; }
.cdx-h2 { font-size: 2rem; font-weight: 600; letter-spacing: -0.02em; }
.cdx-h3 { font-size: 1.75rem; font-weight: 600; }
.cdx-h4 { font-size: 1.25rem; font-weight: 500; }
.cdx-h5 { font-size: 1rem; font-weight: 500; }
.cdx-h6 { font-size: 0.875rem; font-weight: 500; }

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

.cdx-contrast-light {
  color: #e5e5e5;
  background: #0f0f0f;
}

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

/* 67. Hanging Punctuation */
.cdx-hanging-punct {
  list-style-position: outside;
  padding-left: 1.5em;
}

/* 68. Link Style */
.cdx-link {
  text-decoration: underline;
  text-decoration-color: rgba(249, 115, 22, 0.4);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s ease;
}

.cdx-link:hover {
  text-decoration-color: var(--cdx-accent);
}

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

/* 74. Password Eye Toggle */
.cdx-pass-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--cdx-text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s ease;
}

.cdx-pass-toggle:hover {
  color: var(--cdx-text);
}

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

/* 77. Button Primary */
.cdx-btn-primary {
  background: var(--cdx-accent);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.cdx-btn-secondary {
  background: transparent;
  color: var(--cdx-text);
  border: 1px solid var(--cdx-border);
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.cdx-btn-ghost {
  background: transparent;
  color: var(--cdx-text-muted);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-btn-ghost:hover {
  color: var(--cdx-text);
  background: rgba(255, 255, 255, 0.05);
}

/* 78. Touch Target (iOS 44px minimum) */
.cdx-touch-target {
  min-height: 44px;
  min-width: 44px;
}

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

.cdx-float-label input {
  padding-top: 20px;
}

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

.cdx-float-label input:focus + label,
.cdx-float-label input:not(:placeholder-shown) + label {
  top: 8px;
  font-size: 11px;
  color: var(--cdx-accent);
}

/* 80. Breadcrumbs */
.cdx-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--cdx-text-muted);
}

.cdx-breadcrumbs a {
  color: var(--cdx-text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.cdx-breadcrumbs a:hover {
  color: var(--cdx-accent);
}

.cdx-breadcrumbs-sep {
  opacity: 0.5;
}

.cdx-breadcrumbs-current {
  color: var(--cdx-text);
}

/* 82. Visited Links */
.cdx-visited:visited {
  color: var(--cdx-text-muted);
}

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

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

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

.cdx-empty-state-desc {
  font-size: 14px;
  color: var(--cdx-text-muted);
  max-width: 300px;
}

/* 84. Custom 404 */
.cdx-404 {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--cdx-bg);
  z-index: 2147483647;
}

.cdx-404-code {
  font-size: 120px;
  font-weight: 700;
  color: var(--cdx-accent);
  line-height: 1;
}

.cdx-404-text {
  font-size: 24px;
  color: var(--cdx-text);
  margin-top: 16px;
}

/* 86. Back to Top */
.cdx-back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 50%;
  color: var(--cdx-text);
  cursor: pointer;
  z-index: 2147483640;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.cdx-back-to-top.cdx-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.cdx-back-to-top:hover {
  background: var(--cdx-accent);
  border-color: var(--cdx-accent);
}

/* 89. Modal Close */
.cdx-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2147483646;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

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

.cdx-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

.cdx-modal.cdx-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.cdx-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--cdx-text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.cdx-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cdx-text);
}

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

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

/* 92. Image Aspect Ratio */
.cdx-aspect-square { aspect-ratio: 1 / 1; }
.cdx-aspect-video { aspect-ratio: 16 / 9; }
.cdx-aspect-portrait { aspect-ratio: 3 / 4; }

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

/* 94. Tablet Media Queries */
@media (max-width: 768px) {
  .cdx-hide-mobile { display: none !important; }
  
  .cdx-modal {
    width: 95vw;
    max-height: 85vh;
  }
  
  .cdx-checklist {
    width: calc(100% - 48px);
    left: 24px;
  }
}

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

/* 97. External Link Icon */
a[target="_blank"]::after {
  content: " ↗";
  font-size: 0.8em;
  opacity: 0.7;
}

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

/* ============================================
   PART 3: ANTICIPATORY LAYER (20 Features)
   ============================================ */

/* 101. Velocity Type - increased weight on fast scroll */
.cdx-velocity-headers h1,
.cdx-velocity-headers h2,
.cdx-velocity-headers h3 {
  transition: font-weight 0.3s ease;
}

.cdx-fast-scroll .cdx-velocity-headers h1,
.cdx-fast-scroll .cdx-velocity-headers h2,
.cdx-fast-scroll .cdx-velocity-headers h3 {
  font-weight: 800;
}

/* 102. Trajectory Glow */
.cdx-trajectory-glow {
  transition: box-shadow 0.2s ease;
}

.cdx-trajectory-glow.cdx-glow {
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.5);
}

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

/* 106. Circadian Background */
.cdx-circadian-morning {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.cdx-circadian-day {
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
}

.cdx-circadian-evening {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b3d 100%);
}

.cdx-circadian-night {
  background: linear-gradient(135deg, #0a0a0f 0%, #0f0f1a 100%);
}

/* 107. Focus Tunnel */
.cdx-focus-tunnel::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2147483640;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cdx-focus-tunnel.cdx-active::before {
  opacity: 1;
}

.cdx-focus-tunnel.cdx-active input:focus,
.cdx-focus-tunnel.cdx-active textarea:focus {
  position: relative;
  z-index: 2147483641;
}

/* 108. Rage Click Help */
.cdx-rage-help {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--cdx-warning);
  border-radius: 10px;
  color: #000;
  font-size: 14px;
  font-weight: 500;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

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

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

.cdx-compact .cdx-p-md { padding: 8px; }
.cdx-compact .cdx-gap-md { gap: 8px; }
.cdx-compact .cdx-mb-4 { margin-bottom: 0.75rem; }

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

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

.cdx-loading * {
  cursor: progress;
}

/* 116. Link Peek Preview */
.cdx-link-peek {
  position: absolute;
  width: 320px;
  height: 200px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s ease;
}

.cdx-link-peek.cdx-visible {
  opacity: 1;
  transform: translateY(0);
}

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

/* 117. Changelog "New" Badge */
.cdx-new-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  background: var(--cdx-accent);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cdx-changelog {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 320px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  z-index: 2147483640;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.cdx-changelog.cdx-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.cdx-changelog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--cdx-border);
}

.cdx-changelog-badge {
  padding: 2px 8px;
  background: var(--cdx-accent);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

/* ============================================
   PART 4: PSYCHOLOGICAL CODEX (20 Features)
   ============================================ */

/* 121. Reverse Download Modal */
.cdx-download-modal {
  padding: 32px;
  text-align: center;
}

.cdx-download-progress {
  width: 100%;
  height: 4px;
  background: var(--cdx-border);
  border-radius: 2px;
  margin: 20px 0;
  overflow: hidden;
}

.cdx-download-progress-bar {
  height: 100%;
  background: var(--cdx-accent);
  width: 0%;
  transition: width 0.3s ease;
}

/* 122. Welcome Prime Modal */
.cdx-welcome-modal {
  padding: 32px;
  text-align: center;
  max-width: 400px;
}

.cdx-welcome-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: rgba(249, 115, 22, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.cdx-welcome-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--cdx-text);
  margin-bottom: 12px;
}

.cdx-welcome-desc {
  font-size: 14px;
  color: var(--cdx-text-muted);
  margin-bottom: 24px;
}

/* 123. Exit Intent Overlay */
.cdx-exit-intent {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.cdx-exit-intent-content {
  max-width: 500px;
  padding: 48px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 20px;
  text-align: center;
}

/* 124. Identity Toggle */
.cdx-identity-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-identity-toggle:hover {
  border-color: var(--cdx-accent);
}

.cdx-identity-toggle.cdx-active {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--cdx-accent);
}

/* Blur noise elements when Long-Duration View is active */
.cdx-long-duration .cdx-noise {
  filter: blur(4px);
  opacity: 0.5;
}

/* 125. Manifesto Gate */
.cdx-manifesto-gate {
  padding: 24px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
  margin-bottom: 24px;
}

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

.cdx-manifesto-checkbox input {
  width: 20px;
  height: 20px;
  accent-color: var(--cdx-accent);
}

.cdx-manifesto-text {
  font-size: 14px;
  color: var(--cdx-text);
  font-style: italic;
}

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

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

/* 126. First Move Input */
.cdx-first-move {
  padding: 24px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
}

.cdx-first-move-label {
  font-size: 14px;
  color: var(--cdx-text);
  margin-bottom: 8px;
}

.cdx-first-move-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--cdx-bg);
  border: 1px solid var(--cdx-border);
  border-radius: 8px;
  color: var(--cdx-text);
  font-size: 16px;
}

.cdx-first-move-analysis {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}

.cdx-first-move-analysis.cdx-visible {
  max-height: 500px;
}

/* 127. Future Self Email */
.cdx-future-self {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 10px;
}

.cdx-future-self-icon {
  font-size: 24px;
}

.cdx-future-self-text {
  flex: 1;
  font-size: 14px;
  color: var(--cdx-text);
}

.cdx-future-self-btn {
  padding: 8px 16px;
  background: var(--cdx-accent);
  border: none;
  border-radius: 6px;
  color: white;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-future-self-btn:hover {
  filter: brightness(1.1);
}

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

/* 129. Peer Notes */
.cdx-peer-notes {
  font-family: 'Caveat', 'Comic Sans MS', cursive;
  color: var(--cdx-accent);
  font-size: 14px;
  transform: rotate(-2deg);
  margin-left: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cdx-peer-notes.cdx-visible {
  opacity: 1;
}

/* 130. Empty Chair Footer */
.cdx-empty-chair {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--cdx-text-muted);
  font-style: italic;
}

/* 131. Quiet Room */
.cdx-quiet-room {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f5f0e8;
  z-index: 2147483646;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.cdx-quiet-room-content {
  max-width: 700px;
  padding: 48px;
  text-align: center;
  color: #333;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 18px;
  line-height: 1.8;
}

.cdx-quiet-room-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 50%;
  color: #666;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.cdx-quiet-room-close:hover {
  background: #333;
  border-color: #333;
  color: white;
}

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

.cdx-disqualify-text {
  font-size: 14px;
  color: var(--cdx-error);
  font-style: italic;
}

/* 133. Dated Window */
.cdx-dated-window {
  padding: 24px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 12px;
  text-align: center;
}

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

.cdx-dated-window-text {
  font-size: 16px;
  color: var(--cdx-text-muted);
  font-style: italic;
}

/* 134. Underwriting Mode (Authority) */
.cdx-underwriting table,
.cdx-underwriting .highcharts-container,
.cdx-underwriting .recharts-wrapper,
.cdx-underwriting svg:not(.cdx-icon) {
  filter: grayscale(1);
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
}

.cdx-underwriting table {
  border-collapse: collapse;
}

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

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

/* 136. Header Swap */
.cdx-header-swap [data-cdx-swap="contact"] {
  visibility: hidden;
  position: relative;
}

.cdx-header-swap [data-cdx-swap="contact"]::after {
  content: "Alignment Check";
  visibility: visible;
  position: absolute;
  left: 0;
  top: 0;
}

/* 137. Privacy Banner (Affirmation) */
.cdx-privacy-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--cdx-success);
}

.cdx-privacy-banner-icon {
  width: 16px;
  height: 16px;
}

/* 138. Pacing Tooltip */
.cdx-pace-tooltip {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 10px 16px;
  background: var(--cdx-bg-elevated);
  border: 1px solid var(--cdx-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--cdx-text);
  z-index: 2147483647;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.cdx-pace-tooltip.cdx-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 139. Smart 404 */
.cdx-smart-404 {
  text-align: center;
  padding: 48px;
}

.cdx-smart-404-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--cdx-text);
  margin-bottom: 12px;
}

.cdx-smart-404-text {
  font-size: 16px;
  color: var(--cdx-text-muted);
  font-style: italic;
}

/* 140. Patient Tag Footer */
.cdx-patient-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  font-size: 12px;
  color: var(--cdx-text-muted);
  border-top: 1px solid var(--cdx-border);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.cdx-hidden { display: none !important; }
.cdx-visible { display: block !important; }
.cdx-flex { display: flex !important; }
.cdx-grid { display: grid !important; }
.cdx-center { align-items: center; justify-content: center; }
.cdx-between { justify-content: space-between; }
.cdx-gap-sm { gap: 8px; }
.cdx-gap-md { gap: 16px; }
.cdx-gap-lg { gap: 24px; }
.cdx-p-sm { padding: 8px; }
.cdx-p-md { padding: 16px; }
.cdx-p-lg { padding: 24px; }
.cdx-m-sm { margin: 8px; }
.cdx-m-md { margin: 16px; }
.cdx-m-lg { margin: 24px; }
.cdx-rounded { border-radius: 8px; }
.cdx-rounded-lg { border-radius: 16px; }
.cdx-rounded-full { border-radius: 9999px; }
.cdx-shadow { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
.cdx-shadow-lg { box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); }
.cdx-transition { transition: all 0.2s ease; }
.cdx-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdx-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
