/* ==========================================================================
   CAFFEINE CALCULATOR BY WEIGHT & AGE - MASTER DESIGN SYSTEM
   Ultra-Modern Glassmorphism & High-Contrast SEO Typography
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* Color Tokens - Deep Cosmic Dark Mode */
  --bg-primary: #080c16;
  --bg-secondary: #0d1424;
  --bg-gradient: radial-gradient(circle at 15% 20%, rgba(14, 165, 233, 0.12) 0%, transparent 45%),
                 radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.12) 0%, transparent 45%);
  
  --card-bg: rgba(18, 28, 48, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-hover-border: rgba(14, 165, 233, 0.35);
  --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Neon Accents */
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.25);
  --accent-purple: #8b5cf6;

  /* Typography & Layout */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --max-width: 1240px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #e2e8f0;
  --bg-gradient: radial-gradient(circle at 15% 20%, rgba(14, 165, 233, 0.08) 0%, transparent 45%),
                 radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.08) 0%, transparent 45%);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(15, 23, 42, 0.1);
  --card-hover-border: rgba(14, 165, 233, 0.5);
  --glass-shadow: 0 12px 35px rgba(15, 23, 42, 0.08);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}

a {
  color: var(--accent-cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-emerald);
  text-decoration: underline;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(8, 12, 22, 0.75);
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 0;
  transition: background 0.3s ease;
}

[data-theme="light"] header {
  background: rgba(240, 244, 248, 0.85);
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-emerald));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 0 20px var(--accent-cyan-glow);
  color: #fff;
  font-weight: bold;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, var(--text-main), var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 0.75rem;
  color: var(--accent-emerald);
  display: block;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 2rem;
  align-items: center;
}

nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

nav a:hover {
  color: var(--text-main);
  text-decoration: none;
}

.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero {
  text-align: center;
  padding: 3.5rem 1.5rem 2rem;
  max-width: 900px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1rem;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 99px;
  color: var(--accent-emerald);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.hero h1 span.highlight {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-emerald) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero p {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto 2rem;
  line-height: 1.65;
}

/* ==========================================================================
   INTERACTIVE CALCULATOR CONTAINER & TABS
   ========================================================================== */
.app-container {
  max-width: var(--max-width);
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
  box-sizing: border-box;
  width: 100%;
}

.calculator-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
  position: relative;
  width: 100%;
  box-sizing: border-box;
}

/* Glow Border Effect */
.calculator-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), var(--accent-emerald), transparent);
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--card-border);
  padding: 0.5rem;
  gap: 0.5rem;
}

[data-theme="light"] .tab-nav {
  background: rgba(226, 232, 240, 0.5);
}

.tab-btn {
  flex: 1;
  min-width: 200px;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--accent-cyan);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-hover-border);
}

.tab-content {
  display: none;
  padding: 2.5rem;
  animation: fadeIn 0.35s ease forwards;
}

.tab-content.active {
  display: block;
}

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

/* ==========================================================================
   GRID LAYOUT FOR CALCULATOR PANELS
   ========================================================================== */
.panel-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2.5rem;
  align-items: start;
}

@media (max-width: 960px) {
  .panel-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.form-panel {
  background: rgba(255, 255, 255, 0.02);
  padding: 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
}

.results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text-main);
}

/* ==========================================================================
   FORM CONTROLS & SLIDERS
   ========================================================================== */
.form-group {
  margin-bottom: 1.6rem;
}

.form-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}

.form-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.input-val-display {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.12);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.input-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.unit-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
}

.unit-btn {
  background: transparent;
  border: none;
  padding: 0.3rem 0.6rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.unit-btn.active {
  background: var(--accent-cyan);
  color: #fff;
}

/* Custom Sliders */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  outline: none;
  transition: background 0.3s;
}

[data-theme="light"] input[type="range"] {
  background: rgba(0, 0, 0, 0.12);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  border: 2px solid #fff;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* Number & Text Inputs */
.custom-input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: all 0.2s ease;
}

[data-theme="light"] .custom-input {
  background: #fff;
}

.custom-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan-glow);
  outline: none;
}

/* Select & Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

@media (max-width: 550px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

.option-card {
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.option-card:hover {
  border-color: rgba(14, 165, 233, 0.4);
  color: var(--text-main);
}

.option-card.selected {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  font-weight: 600;
  box-shadow: 0 0 10px var(--accent-cyan-glow);
}

/* Factors Toggle Chips */
.factors-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.factor-chip {
  padding: 0.5rem 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.factor-chip.active {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  font-weight: 600;
}

/* ==========================================================================
   RESULTS CARDS & METRIC DISPLAYS
   ========================================================================== */
.result-card {
  background: rgba(13, 20, 36, 0.85);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s ease, border-color 0.3s ease;
}

[data-theme="light"] .result-card {
  background: #fff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.05);
}

.result-card.highlight-card {
  border-color: var(--accent-emerald);
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.1) 0%, rgba(13, 20, 36, 0.85) 100%);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.15);
}

.result-card.cyan-card {
  border-color: var(--accent-cyan);
  background: linear-gradient(145deg, rgba(6, 182, 212, 0.1) 0%, rgba(13, 20, 36, 0.85) 100%);
}

.metric-header {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.metric-big {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.metric-big.emerald { color: var(--accent-emerald); }
.metric-big.cyan { color: var(--accent-cyan); }
.metric-big.amber { color: var(--accent-amber); }
.metric-big.rose { color: var(--accent-rose); }

.metric-sub {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.badge-status {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.badge-status.safe { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); border: 1px solid var(--accent-emerald); }
.badge-status.caution { background: rgba(245, 158, 11, 0.2); color: var(--accent-amber); border: 1px solid var(--accent-amber); }
.badge-status.danger { background: rgba(244, 63, 94, 0.2); color: var(--accent-rose); border: 1px solid var(--accent-rose); }

/* Cup Equivalents Bar */
.cup-equiv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--card-border);
}

.cup-item {
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
}

.cup-icon {
  font-size: 1.3rem;
  margin-bottom: 0.2rem;
}

.cup-num {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.cup-name {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   INTERACTIVE HALF-LIFE CANVAS CHART
   ========================================================================== */
.chart-container {
  background: rgba(10, 15, 26, 0.9);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1rem;
  position: relative;
}

[data-theme="light"] .chart-container {
  background: #fff;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chart-legend {
  display: flex;
  gap: 1.2rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.caffeine { background: var(--accent-cyan); box-shadow: 0 0 8px var(--accent-cyan-glow); }
.legend-dot.sleep-limit { background: var(--accent-emerald); }

canvas#decayChart {
  width: 100% !important;
  height: 280px !important;
  display: block;
}

/* ==========================================================================
   BEVERAGE LIBRARY STACKER
   ========================================================================== */
.search-filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-input-wrapper input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.category-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.cat-btn {
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cat-btn.active, .cat-btn:hover {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

.beverages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.2rem;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.bev-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  cursor: pointer;
}

.bev-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(6, 182, 212, 0.12);
}

.bev-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.8rem;
}

.bev-name {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-main);
}

.bev-volume {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bev-mg-badge {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.bev-btn {
  width: 100%;
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.bev-card:hover .bev-btn {
  background: var(--accent-cyan);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Daily Stack Tracker */
.stack-tracker {
  background: rgba(13, 20, 36, 0.9);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.15);
}

.stack-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.stack-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 1.2rem;
}

.stack-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.remove-btn {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: none;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}

/* ==========================================================================
   ON-PAGE SEO EDUCATIONAL CONTENT SECTION (BELOW THE FOLD)
   ========================================================================== */
.seo-content-section {
  max-width: var(--max-width);
  margin: 0 auto 5rem;
  padding: 0 1.5rem;
  box-sizing: border-box;
  width: 100%;
}

.seo-article {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: clamp(2rem, 5vw, 4rem);
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.math-formula-box {
  background: rgba(6, 182, 212, 0.1);
  border-left: 4px solid var(--accent-cyan);
  padding: 1.2rem 1.5rem;
  margin: 1.5rem 0;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.seo-article h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2.5rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--card-border);
}

.seo-article h2:first-of-type {
  margin-top: 0;
}

.seo-article h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  font-weight: 700;
  color: var(--accent-cyan);
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
}

.seo-article p {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.4rem;
  line-height: 1.8;
}

.seo-article ul, .seo-article ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
}

.seo-article li {
  margin-bottom: 0.6rem;
  line-height: 1.7;
}

.seo-article strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Responsive SEO Table */
.table-wrapper {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .table-wrapper {
  background: #fff;
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.seo-table th {
  background: rgba(14, 165, 233, 0.15);
  color: var(--text-main);
  font-weight: 700;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
}

.seo-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
}

.seo-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

/* FAQ Accordion */
.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.faq-item {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  transition: border-color 0.2s;
}

.faq-item:hover {
  border-color: rgba(14, 165, 233, 0.4);
}

.faq-question {
  width: 100%;
  padding: 1.25rem 1.5rem;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.faq-icon {
  font-size: 1.3rem;
  color: var(--accent-cyan);
  transition: transform 0.3s ease;
}

.faq-item.open .faq-icon {
  transform: rotate(45deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 1.5rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.faq-item.open .faq-answer {
  max-height: 500px;
  padding: 0 1.5rem 1.25rem;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
footer {
  background: rgba(5, 8, 16, 0.95);
  border-top: 1px solid var(--card-border);
  padding: 3.5rem 1.5rem 2rem;
  margin-top: auto;
}

[data-theme="light"] footer {
  background: #cbd5e1;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
  .footer-container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.footer-col h4 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.2rem;
}

.footer-col p {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 380px;
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.footer-links a {
  color: var(--text-muted);
  font-size: 0.92rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

.footer-bottom {
  max-width: var(--max-width);
  margin: 0 auto;
  padding-top: 2rem;
  border-top: 1px solid var(--card-border);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Utility Animations */
.pulse-glow {
  animation: pulseGlow 2.5s infinite alternate;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 15px var(--accent-emerald-glow); }
  100% { box-shadow: 0 0 28px rgba(16, 185, 129, 0.5); }
}

/* ==========================================================================
   SIMPLE TERMS & QUICK GLOSSARY BAR
   ========================================================================== */
.simple-terms-guide {
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  margin: 1.5rem 1.5rem 0.5rem;
  padding: 1rem 1.25rem;
  transition: all 0.3s ease;
}

[data-theme="light"] .simple-terms-guide {
  background: rgba(6, 182, 212, 0.08);
}

.simple-terms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent-cyan);
  font-size: 1.02rem;
}

.simple-terms-header span.toggle-arrow {
  transition: transform 0.3s ease;
  font-size: 1.2rem;
}

.simple-terms-guide.open .toggle-arrow {
  transform: rotate(180deg);
}

.simple-terms-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.3s ease;
}

.simple-terms-guide.open .simple-terms-content {
  max-height: 800px;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(6, 182, 212, 0.25);
}

.terms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.term-box {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.term-title {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.term-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Plain English Subtitle Helpers inside Results Cards */
.metric-plain-explanation {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: -0.25rem;
  margin-bottom: 0.75rem;
  display: block;
}

/* ==========================================================================
   ADSENSE ADS PLACEMENT CONTAINERS (100% COMPATIBLE & CLS PROTECTED)
   ========================================================================== */
.ad-slot-container {
  width: 100%;
  max-width: 100%;
  margin: 2.5rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--card-border);
  padding: 0.75rem;
  transition: all 0.3s ease;
}

[data-theme="light"] .ad-slot-container {
  background: rgba(226, 232, 240, 0.4);
}

/* Prevent Cumulative Layout Shift (CLS) */
.ad-slot-container.ad-top-banner {
  min-height: 110px;
  max-width: 970px;
}

.ad-slot-container.ad-inline {
  min-height: 250px;
  margin: 1.5rem 0 0;
}

.ad-slot-container.ad-mid-banner {
  min-height: 260px;
  max-width: 970px;
}

.ad-slot-container.ad-footer-banner {
  min-height: 110px;
  max-width: 970px;
}

.ad-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Visual Placeholder for Testing / Pre-load State */
.ad-placeholder-box {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.ad-placeholder-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.ad-placeholder-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
  max-width: 420px;
}

/* Ensure Google AdSense iframe or ins fills and centers cleanly */
.ad-slot-container ins.adsbygoogle {
  display: block !important;
  max-width: 100% !important;
  margin: 0 auto !important;
  text-align: center !important;
}

/* ==========================================================================
   ADSENSE SLOT 5: CLOSABLE POPUP MODAL STYLES (WITH TOP-RIGHT CLOSE BUTTON)
   ========================================================================== */
.ad-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.ad-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.ad-modal-content {
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 30px rgba(6, 182, 212, 0.25);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ad-modal-backdrop.active .ad-modal-content {
  transform: translateY(0) scale(1);
}

.ad-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(6, 182, 212, 0.08);
}

.ad-modal-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* TOP-RIGHT CLOSABLE 'X' BUTTON (High-Visibility & Policy Safe) */
.ad-modal-close-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
  line-height: 1;
}

.ad-modal-close-btn:hover,
.ad-modal-close-btn:focus {
  background: rgba(239, 68, 68, 0.9);
  color: #ffffff;
  transform: rotate(90deg) scale(1.08);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

.ad-modal-body {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-popup-slot {
  margin: 0 !important;
  min-height: 250px;
  width: 100%;
}

.ad-modal-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.2);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}

[data-theme="light"] .ad-modal-content {
  background: #ffffff;
  border-color: rgba(14, 165, 233, 0.4);
}

[data-theme="light"] .ad-modal-header {
  background: rgba(14, 165, 233, 0.08);
}

/* ==========================================================================
   COMPREHENSIVE MOBILE VIEW OPTIMIZATIONS (RESPONSIVE FLUID LAYOUT)
   ========================================================================== */
@media (max-width: 768px) {
  /* Header & Navigation on Mobile */
  header {
    padding: 0.75rem 0;
  }

  .header-container {
    flex-direction: column;
    gap: 0.8rem;
    padding: 0 1rem;
  }

  .logo-wrapper {
    width: 100%;
    justify-content: space-between;
  }

  nav {
    width: 100%;
  }

  nav ul {
    width: 100%;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
  }

  nav a {
    font-size: 0.86rem;
  }

  .theme-toggle {
    padding: 0.4rem 0.65rem;
    font-size: 0.9rem;
  }

  /* Hero adjustments */
  .hero {
    padding: 2.2rem 1rem 1.5rem;
  }

  .hero h1 {
    font-size: 1.85rem;
  }

  .hero p {
    font-size: 0.98rem;
    margin-bottom: 1.5rem;
  }

  /* Calculator & SEO Containers on Mobile - EXACT MATCHING WIDTH */
  .app-container,
  .seo-content-section,
  .ad-slot-container.ad-top-banner,
  .ad-slot-container.ad-mid-banner,
  .ad-slot-container.ad-footer-banner {
    padding: 0 0.75rem !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .simple-terms-guide {
    margin: 1rem 1rem 0.5rem;
    padding: 0.85rem 1rem;
  }

  .tab-nav {
    padding: 0.4rem;
    gap: 0.4rem;
  }

  .tab-btn {
    min-width: calc(50% - 0.4rem);
    flex: 1 1 calc(50% - 0.4rem);
    padding: 0.8rem 0.5rem;
    font-size: 0.84rem;
    gap: 0.35rem;
  }

  .tab-content {
    padding: 1.5rem 1rem;
  }

  .panel-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .form-panel {
    padding: 1.25rem 1rem;
  }

  .result-card {
    padding: 1.25rem 1rem;
  }

  .metric-big {
    font-size: 2.2rem;
  }

  /* Sliders & Inputs Touch Optimization */
  input[type="range"] {
    height: 10px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }

  .custom-input, input[type="time"], input[type="text"] {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
    padding: 0.75rem 0.9rem;
  }

  /* Grid layouts inside tabs */
  .cup-equiv-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .cup-item {
    padding: 0.5rem 0.3rem;
  }

  .cup-num {
    font-size: 1rem;
  }

  .options-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .input-row {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  /* Beverage library & stacker on mobile */
  .search-filter-bar {
    flex-direction: column;
    gap: 0.75rem;
  }

  .category-chips {
    overflow-x: auto;
    padding-bottom: 0.4rem;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .cat-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
  }

  .beverages-grid {
    grid-template-columns: 1fr;
    max-height: 440px;
  }

  /* Ad slots adjustments on mobile */
  .ad-slot-container.ad-top-banner {
    min-height: 100px;
    margin: 1.5rem auto;
  }

  .ad-slot-container.ad-mid-banner {
    min-height: 250px;
  }

  /* SEO Guide & FAQ mobile */
  .seo-article {
    padding: 1.5rem 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden;
  }

  .calculator-card {
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .math-formula-box {
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
  }

  .seo-article h2 {
    font-size: 1.45rem;
  }

  .seo-table th, .seo-table td {
    padding: 0.75rem 0.6rem;
    font-size: 0.85rem;
  }

  .faq-question {
    padding: 1rem;
    font-size: 0.98rem;
  }

  .faq-answer {
    padding: 0 1rem;
  }

  .faq-item.open .faq-answer {
    padding: 0 1rem 1rem;
  }
}

@media (max-width: 480px) {
  /* Extra compact for narrow phones */
  .app-container,
  .seo-content-section,
  .ad-slot-container.ad-top-banner,
  .ad-slot-container.ad-mid-banner,
  .ad-slot-container.ad-footer-banner {
    padding: 0 0.5rem !important;
  }

  .tab-btn {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .cup-equiv-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .cup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
    padding: 0.65rem 1rem;
  }

  .cup-item .cup-icon {
    margin-bottom: 0;
    font-size: 1.4rem;
  }

  .unit-toggle {
    width: 100%;
    margin-top: 0.4rem;
    justify-content: center;
  }
}

