:root {
  --surface-0: #0b1120;
  --surface-1: #111c2f;
  --surface-2: #152238;
  --surface-3: rgba(21, 34, 56, 0.85);
  --surface-overlay: rgba(15, 23, 42, 0.55);
  --dark-bg: var(--surface-2);
  --border-subtle: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.24);
  --shadow-soft: 0 18px 40px rgba(7, 11, 25, 0.35);
  --shadow-subtle: 0 1px 0 rgba(148, 163, 184, 0.08);

  --primary-gradient: linear-gradient(180deg, #0b1120 0%, #111c2f 100%);
  --secondary-gradient: linear-gradient(180deg, #111c2f 0%, #1e293b 100%);
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --success-gradient: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --accent-500: #3b82f6;
  --accent-600: #2563eb;
  --success-color: #22c55e;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;

  --text-primary: #e2e8f0;
  --text-secondary: rgba(203, 213, 225, 0.85);
  --text-muted: rgba(148, 163, 184, 0.75);

  --glass-bg: rgba(17, 28, 47, 0.92);
  --glass-border: rgba(148, 163, 184, 0.16);

  --page-background-light: linear-gradient(180deg, var(--surface-0) 0%, var(--surface-1) 100%);
  --page-background-dark: linear-gradient(180deg, #050b16 0%, #0f1b2f 100%);

  --lovelace-header-height: 96px;
  --lovelace-header-offset: calc(var(--lovelace-header-height, 96px) + 24px);
  --section-gap: clamp(1.5rem, 3vw, 2rem);
  --section-max-width: 1200px;
  --section-padding-x: clamp(1.5rem, 3vw, 2rem);
  --section-padding-y: clamp(2rem, 3vw, 2.5rem);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--page-background-light);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

html {
  overflow-x: hidden;
}

body.light-theme {
  background: var(--page-background-light);
}

body.dark-theme {
  background: var(--page-background-dark);
}

body.landing-page {
  --page-background-light: linear-gradient(180deg, var(--surface-0) 0%, var(--surface-1) 100%);
}

body.landing-page.dark-theme {
  --page-background-dark: linear-gradient(180deg, #050b16 0%, #0f1b2f 100%);
}

html.dark-theme,
body.dark-theme {
  --surface-0: #050b16;
  --surface-1: #09101f;
  --surface-2: #0f1b2f;
  --surface-3: rgba(12, 22, 38, 0.85);
  --surface-overlay: rgba(9, 17, 31, 0.6);
  --border-subtle: rgba(71, 85, 105, 0.35);
  --border-strong: rgba(94, 117, 148, 0.48);
  --primary-gradient: linear-gradient(180deg, #050b16 0%, #0f1b2f 100%);
  --secondary-gradient: linear-gradient(180deg, #0f1b2f 0%, #1b2a41 100%);
  --glass-bg: rgba(12, 22, 38, 0.92);
  --glass-border: rgba(94, 117, 148, 0.32);
  --dark-bg: var(--surface-2);
  --text-primary: #f1f5f9;
  --text-secondary: rgba(226, 232, 240, 0.85);
  --text-muted: rgba(148, 163, 184, 0.7);
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--lovelace-header-height, 96px) + 1rem) clamp(1.5rem, 3vw, 2.5rem) clamp(3rem, 4vw, 4rem);
  box-sizing: border-box;
  display: block;
}

.page-section {
  width: min(100%, var(--section-max-width));
  margin: 0 auto var(--section-gap);
  padding: var(--section-padding-y) var(--section-padding-x);
  box-sizing: border-box;
}

.page-section:last-of-type {
  margin-bottom: 0;
}

.section-stack {
  display: block;
}

.section-stack > * + * {
  margin-top: var(--section-gap);
}

.gradient-page-title {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  font-weight: 800;
  line-height: 1.05;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, #ffffff 0%, #4facfe 50%, #00f2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
  text-shadow: 0 0 18px rgba(79, 172, 254, 0.175);
}

.page-shell--fluid {
  max-width: none;
  width: 100%;
  padding-left: clamp(1.5rem, 4vw, 3rem);
  padding-right: clamp(1.5rem, 4vw, 3rem);
}

.page-section--fluid {
  --section-max-width: 1440px;
}

.page-section--compact {
  --section-padding-y: clamp(1.75rem, 4vw, 3rem);
}

body.trade-page {
  --section-max-width: 100%;
  --section-padding-x: clamp(1.5rem, 3vw, 2.5rem);
  --section-padding-y: clamp(2rem, 4vw, 3rem);
  --section-gap: clamp(2.5rem, 4vw, 3.5rem);
}

[data-reduce-only-row][aria-disabled="true"] {
  opacity: 0.6;
}

[data-reduce-only-row][aria-disabled="true"] .reduce-only-title {
  color: rgba(226, 232, 240, 0.7);
}

[data-reduce-only-row][aria-disabled="true"] input {
  pointer-events: none;
}

body.trade-page .trade-shell {
  margin: 0 auto;
  width: 100%;
  max-width: 1680px;
}

body.liquidity-page {
  --section-max-width: 1280px;
  --section-gap: clamp(2.75rem, 4.5vw, 3.75rem);
}

.section-lead {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary, rgba(255, 255, 255, 0.8));
  margin-bottom: clamp(1.75rem, 3vw, 2.5rem);
  max-width: 48rem;
}

.hero-block {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: calc(var(--lovelace-header-height, 96px) + clamp(6rem, 12vw, 8rem)) 2rem clamp(3rem, 6vw, 4rem);
  box-sizing: border-box;
}

#shared-header:empty {
  display: block;
  min-height: var(--lovelace-header-height, 96px);
  width: 100%;
  background: rgba(6, 11, 20, 0.85);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
  .page-shell {
    padding: calc(var(--lovelace-header-height, 96px) + 1rem) clamp(1rem, 5vw, 1.5rem) clamp(2rem, 6vw, 3rem);
  }
  .hero-block {
    padding: calc(var(--lovelace-header-height, 96px) + 4rem) 1.5rem clamp(2rem, 6vw, 3rem);
  }
}

/* Logo styles handled by shared-header.js component */

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


/* Footer disabled link styling */
.footer-link-disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
  position: relative;
}

.footer-link-disabled::after {
  content: " 🔒";
  font-size: 0.8em;
  opacity: 0.7;
}

/* Discord icon styling for disabled state */
.social-icon.discord-icon {
  opacity: 0.6;
  cursor: not-allowed;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  transition: all 0.3s ease;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
}

.social-icon.discord-icon:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

.social-icon.discord-icon::after {
  content: "Coming Soon";
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.social-icon.discord-icon:hover::after {
  opacity: 1;
}

/* ================================================================
   GLASS MORPHISM COMPONENTS - September 2025 Premium Standards
   Single source of truth for all glass effects
   Added: 2025-10-02 for DRY implementation
   ================================================================ */

.glass-panel,
.api-section,
.stat-card,
.chart-card,
.control-panel,
.trading-panel,
.positions-section,
.my-positions-section,
.pools-section,
.chart-section,
.metric-card,
.price-card,
.feature-card,
.pool-row,
.endpoint,
.step-card,
.price-feed-status {
  background: linear-gradient(135deg, rgba(15, 15, 20, 0.6), rgba(10, 10, 15, 0.4));
  backdrop-filter: blur(30px) saturate(150%);
  -webkit-backdrop-filter: blur(30px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(79, 172, 254, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-panel:hover,
.api-section:hover,
.stat-card:hover,
.chart-card:hover,
.control-panel:hover,
.trading-panel:hover,
.positions-section:hover,
.my-positions-section:hover,
.pools-section:hover,
.chart-section:hover,
.metric-card:hover,
.price-card:hover,
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.5),
    0 0 100px rgba(79, 172, 254, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  border-color: rgba(79, 172, 254, 0.15);
}

/* Shimmer effect for glass panels */
.glass-panel::before,
.api-section::before,
.stat-card::before,
.chart-card::before,
.control-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(79, 172, 254, 0.15), transparent);
}

/* ================================================================
   BUTTON STYLES - September 2025 Premium Standards
   Single source of truth for all button effects
   Added: 2025-10-02 for DRY implementation
   ================================================================ */

/* Primary Button with Magnetic Hover */
.btn-primary {
  background: var(--accent-gradient);
  color: white;
  padding: 1rem 2rem;
  border-radius: 50px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow:
    0 4px 20px rgba(79, 172, 254, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-primary:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow:
    0 25px 50px rgba(79, 172, 254, 0.15),
    0 0 40px rgba(79, 172, 254, 0.15);
}

.btn-primary:hover::before {
  width: 300px;
  height: 300px;
}

.btn-primary:active {
  transform: translateY(-3px) scale(1.03);
}

/* Secondary Button */
.btn-secondary {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), transparent);
  color: var(--text-primary);
  padding: 1rem 2rem;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  backdrop-filter: blur(10px) saturate(150%);
  -webkit-backdrop-filter: blur(10px) saturate(150%);
  box-shadow:
    0 4px 15px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transform-style: preserve-3d;
  will-change: transform;
}

.btn-secondary::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.btn-secondary:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 15px 35px rgba(0, 0, 0, 0.2),
    0 5px 15px rgba(79, 172, 254, 0.15);
}

.btn-secondary:hover::before {
  opacity: 1;
}

/* Submit/Save Button */
.btn-submit,
.save-btn {
  width: 100%;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 4px 15px rgba(16, 185, 129, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-submit::before,
.save-btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn-submit:hover,
.save-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 8px 25px rgba(16, 185, 129, 0.4),
    0 0 40px rgba(16, 185, 129, 0.2);
}

.btn-submit:hover::before,
.save-btn:hover::before {
  width: 300px;
  height: 300px;
}

.save-btn:active {
  transform: translateY(-1px) scale(0.98);
}

.save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Emergency Button */
.emergency-btn {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  border: none;
  padding: 1.2rem 2.2rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  box-shadow:
    0 6px 20px rgba(239, 68, 68, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: pulse-danger 2s infinite;
}

.emergency-btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow:
    0 12px 35px rgba(239, 68, 68, 0.5),
    0 0 60px rgba(239, 68, 68, 0.3);
  animation: none;
}

.emergency-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.emergency-btn.active {
  background: linear-gradient(45deg, #dc2626, #b91c1c);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* ================================================================
   ANIMATION KEYFRAMES - September 2025 Standards
   Single source of truth for all animations
   Added: 2025-10-02 for DRY implementation
   ================================================================ */

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 20px rgba(79, 172, 254, 0.15); }
  50% { box-shadow: 0 0 40px rgba(79, 172, 254, 0.15); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(67, 233, 123, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(67, 233, 123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67, 233, 123, 0); }
}

@keyframes pulse-danger {
  0%, 100% {
    box-shadow:
      0 6px 20px rgba(239, 68, 68, 0.4),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow:
      0 6px 30px rgba(239, 68, 68, 0.6),
      0 0 40px rgba(239, 68, 68, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

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

@keyframes slideOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-10px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes magnetic-hover {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.05) rotate(1deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes pulse-success {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* ================================================================
   RESPONSIVE LAYOUTS - September 2025 Standards
   Single source of truth for all breakpoints
   Added: 2025-10-02 for DRY implementation
   ================================================================ */

/* Mobile header height adjustments */
@media (max-width: 768px) {
  :root {
    --lovelace-header-height: 120px;
  }
}

@media (max-width: 430px) {
  :root {
    --lovelace-header-height: 140px;
  }
}

@media (max-width: 320px) {
  :root {
    --lovelace-header-height: 160px;
  }
}

/* Small Mobile (320px-390px) */
@media (max-width: 390px) {
  .container,
  .main-container,
  .dashboard-container,
  .api-container {
    width: 100vw !important;
    margin: 0 !important;
    padding: 0.5rem !important;
    padding-top: calc(var(--lovelace-header-height, 96px) + 1rem) !important;
    box-sizing: border-box;
  }

  .dashboard-grid,
  .stats-grid,
  .features-grid,
  .pools-grid,
  .charts-grid,
  .price-cards,
  .performance-grid,
  .api-health-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .hero {
    padding-top: calc(var(--lovelace-header-height, 96px) + 1rem) !important;
  }
}

/* Large Mobile (391px-430px) */
@media (min-width: 391px) and (max-width: 430px) {
  .container,
  .main-container,
  .dashboard-container,
  .api-container {
    width: 100vw !important;
    margin: 0 !important;
    padding: 0.75rem !important;
    padding-top: calc(var(--lovelace-header-height, 96px) + 1.5rem) !important;
    box-sizing: border-box;
  }

  .dashboard-grid,
  .stats-grid,
  .features-grid,
  .pools-grid,
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem;
  }

  .hero {
    padding-top: calc(var(--lovelace-header-height, 96px) + 1.5rem) !important;
  }
}

/* Mobile & Small Tablets (431px-768px) */
@media (min-width: 431px) and (max-width: 768px) {
  .container,
  .main-container,
  .dashboard-container,
  .api-container {
    width: 100vw !important;
    margin: 0 !important;
    padding: clamp(0.75rem, 2vw, 1rem) !important;
    padding-top: calc(var(--lovelace-header-height, 96px) + 2rem) !important;
    box-sizing: border-box;
  }

  .dashboard-grid,
  .stats-grid,
  .features-grid,
  .pools-grid,
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }

  .hero {
    padding-top: calc(var(--lovelace-header-height, 96px) + 2rem) !important;
  }

  /* Enhanced text readability */
  .hero h1,
  .feature-card h3,
  .step-card h3,
  .stat-card h3 {
    word-break: break-word;
    hyphens: auto;
    line-height: 1.4;
  }
}

/* Tablets (769px-1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .container,
  .main-container,
  .dashboard-container,
  .api-container {
    width: 100vw !important;
    margin: 0 !important;
    padding: 2rem !important;
    padding-top: calc(var(--lovelace-header-height, 96px) + 2rem) !important;
    box-sizing: border-box;
  }

  .stats-grid,
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Large Tablets & Small Laptops (1025px-1199px) */
@media (min-width: 1025px) and (max-width: 1199px) {
  .stats-grid,
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .charts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Performance optimizations for mobile */
@media (max-width: 768px) {
  .container,
  .main-container,
  .dashboard-container {
    contain: layout style paint;
  }

  /* Reduce animation duration on mobile */
  @media (prefers-reduced-motion: no-preference) {
    * {
      animation-duration: 0.2s !important;
      transition-duration: 0.2s !important;
    }
  }
}
