/* ===== Base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: 80px 16px 16px !important;
  /* Adjusted padding for fixed navbar */
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, .08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255, 255, 255, .08) 0%, transparent 50%);
  pointer-events: none;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%
  }

  50% {
    background-position: 100% 50%
  }

  100% {
    background-position: 0% 50%
  }
}

/* ===== Navbar ===== */
.navbar {
  position: fixed;
  left: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 16px max(24px, calc(50% - 550px));
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 0 0 24px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar .brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: #333;
  /* Mobile safety: prevent pushing menu off-screen */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  margin-right: 12px;
  cursor: pointer;
}

.navbar .links {
  display: flex;
  gap: 20px;
}

.navbar .links a {
  text-decoration: none;
  color: #555;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s;
}

.navbar .links a:hover,
.navbar .links a.active {
  color: #667eea;
}

body.dark-mode .navbar {
  background: rgba(26, 26, 46, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .navbar .brand {
  color: #fff;
}

body.dark-mode .navbar .links a {
  color: #aaa;
}

body.dark-mode .navbar .links a:hover,
body.dark-mode .navbar .links a.active {
  color: #a78bfa;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: auto;
}

.calculator-card {
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .22), 0 10px 30px rgba(0, 0, 0, .12);
  border: 1px solid rgba(255, 255, 255, .28);
}

/* ===== Header / Brand ===== */
.header-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #667eea, #f093fb);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12)
}

.brand-title {
  font-weight: 800;
  letter-spacing: -.2px;
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.2;
}

.brand-sub {
  display: block;
  font-size: .75rem;
  opacity: .7;
  margin-top: -2px
}

body.dark-mode .brand-title,
body.dark-mode .brand-sub {
  color: #f5f5f5;
}

.theme-toggle {
  background: rgba(102, 126, 234, .1);
  border: 2px solid rgba(102, 126, 234, .3);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #667eea;
  font-weight: 700
}

.theme-toggle .theme-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

body.dark-mode .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.subtitle {
  text-align: center;
  color: #555;
  margin: 8px 0 14px
}

body.dark-mode .subtitle {
  color: #d0d0e6;
}

/* ===== Stepper ===== */
.stepper {
  display: flex;
  gap: 8px;
  margin: 6px 0 14px
}

.stepper li {
  list-style: none;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f3f3f7;
  font-weight: 700;
  font-size: .85rem
}

.stepper li.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff
}

/* ===== Layout: Form | Results ===== */
.calc-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.calc-form,
.calc-results {
  width: 100%;
  flex: 0 0 100%;
  min-width: 0
}

@media (min-width: 720px) {

  .calc-form,
  .calc-results {
    width: calc(50% - 12px);
    flex: 0 0 calc(50% - 12px);
  }
}

/* ===== Form ===== */
.calc-form {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  border: 1px solid rgba(102, 126, 234, .15)
}

.form-group {
  margin-bottom: 18px
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: #333;
  font-weight: 700
}

.label-icon {
  font-size: 1.1rem
}

.helper {
  display: block;
  margin-top: 6px;
  color: #888;
  font-size: .85rem
}

/* Unit Toggle Buttons */
.label-with-units {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.unit-toggle {
  display: flex;
  gap: 4px;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 3px;
}

.unit-btn {
  padding: 4px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-btn.active {
  background: #667eea;
  color: #fff;
  box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.unit-btn:hover:not(.active) {
  background: rgba(102, 126, 234, 0.1);
  color: #667eea;
}

/* Imperial Height Inputs */
.imperial-height-inputs {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.imperial-height-inputs input {
  flex: 1;
}

input[type="number"],
input[type="text"],
input[type="email"],
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  background: #fafafa;
  color: #222;
  font-weight: 500;
  transition: .25s;
  font-family: inherit;
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #667eea;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, .12)
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23667eea' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 12px 12px;
  padding-right: 40px
}

.calculate-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  background-size: 200% 200%;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(102, 126, 234, .35);
  position: relative;
  overflow: hidden
}

.calculate-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  left: -100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .25), transparent);
  transition: left .5s
}

.calculate-btn:hover::before {
  left: 100%
}

.demo-buttons {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap
}

/* ===== Results ===== */
.calc-results {
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  border: 1px solid rgba(102, 126, 234, .15)
}

.results.hidden {
  display: none
}

.results-header {
  text-align: center;
  margin-bottom: 10px
}

.results-header h2 {
  font-size: 1.4rem
}

.results-divider,
.section-divider {
  height: 3px;
  width: 60px;
  margin: 10px auto 0;
  background: linear-gradient(90deg, #667eea, #764ba2);
  border-radius: 2px
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 14px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fafafa, #f5f5f5);
  border-radius: 12px;
  border-left: 4px solid #667eea
}

.result-item.highlight {
  background: linear-gradient(135deg, rgba(102, 126, 234, .12), rgba(118, 75, 162, .12));
  border-left-color: #764ba2
}

.result-label {
  color: #555
}

.result-value {
  color: #667eea;
  font-weight: 800
}

.result-unit {
  color: #999;
  font-size: .9rem
}

/* Density + Badge */
.result-badge {
  margin: 8px auto 0;
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e6ffed;
  color: #0a7a2a;
  font-weight: 800;
  font-size: .8rem
}

.density-switch {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px
}

.density-btn {
  border: 1px solid #e0e0e0;
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer
}

.density-btn.is-active {
  border-color: #667eea
}

.results.cozy .result-item {
  padding: 18px 20px
}

.results.compact .result-item {
  padding: 12px 14px
}

/* Skeleton */
.skeleton {
  position: relative;
  overflow: hidden;
  background: #eee;
  border-radius: 12px
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  animation: sweep 1s infinite
}

@keyframes sweep {
  to {
    transform: translateX(100%)
  }
}

.result-item.skel .result-label,
.result-item.skel .result-value,
.result-item.skel .result-unit {
  opacity: 0
}

/* Macros */
.macros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px
}

.macro-card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
  border: 2px solid transparent;
  position: relative
}

.macro-card.protein {
  border-color: #e74c3c;
  background: linear-gradient(135deg, rgba(231, 76, 60, .08), rgba(231, 76, 60, .15))
}

.macro-card.carbs {
  border-color: #3498db;
  background: linear-gradient(135deg, rgba(52, 152, 219, .08), rgba(52, 152, 219, .15))
}

.macro-card.fats {
  border-color: #f39c12;
  background: linear-gradient(135deg, rgba(243, 156, 18, .08), rgba(243, 156, 18, .15))
}

.macro-value {
  font-size: 2.1rem;
  font-weight: 800;
  margin: 8px 0
}

.macro-help {
  position: absolute;
  top: 10px;
  right: 10px;
  border: none;
  background: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  cursor: pointer
}

.macro-pop {
  display: none;
  position: absolute;
  right: 12px;
  top: 38px;
  background: #111;
  color: #fff;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .85rem;
  max-width: 240px;
  text-align: left
}

.macro-card.open .macro-pop,
.stat-card.open .macro-pop {
  display: block;
  z-index: 10;
}

/* Disclaimer */
.disclaimer-box {
  margin-top: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-left: 4px solid #6c757d;
  border-radius: 12px;
  border-top: 2px solid #e0e0e0
}

body.dark-mode .disclaimer-box {
  background: linear-gradient(135deg, #2a2a3e, #252535);
  border-left-color: #a78bfa;
  border-top-color: #3a3a4e;
  color: #cfcfe6;
}

/* ===== Dark Mode ===== */
body.dark-mode {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  animation: gradientShift 15s ease infinite;
  color: #e0e0e0;
}

body.dark-mode .calculator-card {
  background: rgba(26, 26, 46, .95);
  border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 25px 80px rgba(0, 0, 0, .5)
}

body.dark-mode label {
  color: #e0e0e0
}

body.dark-mode .calc-form,
body.dark-mode .calc-results {
  background: #2a2a3e;
  border-color: #3a3a4e
}

body.dark-mode input[type="number"],
body.dark-mode select {
  background: #2a2a3e;
  border-color: #3a3a4e;
  color: #e0e0e0
}

body.dark-mode .result-item {
  background: linear-gradient(135deg, #2a2a3e, #252535);
  border-left-color: #a78bfa
}

body.dark-mode .result-item.highlight {
  background: linear-gradient(135deg, rgba(167, 139, 250, .15), rgba(192, 132, 252, .15))
}

body.dark-mode .result-value {
  color: #a78bfa
}

body.dark-mode .macro-card {
  background: #2a2a3e;
  border-color: #3a3a4e
}

body.dark-mode .macro-pop {
  background: #000
}

body.dark-mode .results-header h2,
body.dark-mode .section-header h3 {
  color: #e9e9ff
}

body.dark-mode .brand-mark {
  background: linear-gradient(135deg, #a78bfa, #e879f9)
}

body.dark-mode .stepper li {
  background: #2a2a3e;
  color: #cfcfe6
}

body.dark-mode .stepper li.active {
  background: linear-gradient(135deg, #a78bfa, #c084fc);
  color: #121224
}

/* Fix select arrow duplication in dark */
body.dark-mode select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23a78bfa' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat !important;
  background-position: right 15px center !important;
  background-size: 12px 12px !important;
}

/* Dark mode unit toggles */
body.dark-mode .unit-toggle {
  background: #1a1a2e;
}

body.dark-mode .unit-btn {
  color: #9aa;
}

body.dark-mode .unit-btn.active {
  background: #a78bfa;
  color: #121224;
}

body.dark-mode .unit-btn:hover:not(.active) {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

/* ===== Mobile polish ===== */
@media (max-width:768px) {
  body {
    padding: 85px 12px 20px !important;
    animation: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    background-attachment: fixed
  }

  .calculator-card {
    padding: 16px
  }

  .blog-wrap {
    margin: 20px auto 40px !important;
    padding: 0;
  }

  .blog-content {
    padding: 24px 16px;
  }

  .prose h1 {
    font-size: 1.75rem;
    /* Better fit for mobile */
  }
}

/* === Dynamic 2-column rule: form is full-width until results appear === */
.calc-form {
  width: 100% !important;
  flex: 0 0 100% !important;
}

.calc-results {
  width: 100% !important;
  flex: 0 0 100% !important;
}

@media (min-width: 720px) {

  body.results-shown .calc-form,
  body.results-shown .calc-results {
    width: calc(50% - 12px) !important;
    flex: 0 0 calc(50% - 12px) !important;
  }
}

/* === Centered single-column before results === */
body:not(.results-shown) .calc-layout {
  justify-content: center !important;
}

body:not(.results-shown) .calc-form {
  max-width: 720px !important;
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* === Typography & Font Refinements === */
:root {
  --radius: 18px;
  --shadow-1: 0 6px 20px rgba(0, 0, 0, .08);
  --shadow-2: 0 16px 50px rgba(0, 0, 0, .12);
}

body {
  line-height: 1.6;
  letter-spacing: .2px;
}

.stat-value,
.result-value,
.macro-value {
  font-variant-numeric: tabular-nums lining-nums;
}

/* === Results: Stat Grid Cards === */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin: 6px 0 8px;
}

.stat-card {
  position: relative;
  background: white;
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-1);
  border: 1px solid rgba(102, 126, 234, .16);
  /* overflow: hidden; Removed to allow popups */
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(102, 126, 234, .25), rgba(240, 147, 251, .25));
  opacity: .08;
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
}

.stat-label {
  color: #555;
  font-weight: 700;
  font-size: .9rem;
}

.stat-value {
  color: #111;
  font-weight: 900;
  font-size: 1.9rem;
  line-height: 1.15;
  margin-top: 6px;
}

.stat-unit {
  color: #777;
  font-weight: 600;
  font-size: .85rem;
  margin-top: 2px;
}

body.dark-mode .stat-card {
  background: #2a2a3e;
  border-color: #3a3a4e;
}

body.dark-mode .stat-label {
  color: #d0d0e6;
}

body.dark-mode .stat-value {
  color: #e9e9ff;
}

body.dark-mode .stat-unit {
  color: #9aa;
}

/* Hide changeTargetItem by default until JS reveals */
#changeTargetItem {
  display: none;
}

/* === Macro Progress Bars === */
.progress {
  width: 100%;
  height: 10px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .05);
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width .6s ease;
}

.protein .progress-fill {
  background: #e74c3c;
}

.carbs .progress-fill {
  background: #3498db;
}

.fats .progress-fill {
  background: #f39c12;
}

/* ===== Trends / Chart ===== */
.chart-container {
  position: relative;
  margin: auto;
  height: 400px;
  width: 100%;
}

@media (max-width: 600px) {
  .chart-container {
    height: 300px;
  }
}

/* History Tags */
.h-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
}

.h-tag.loss {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
}

.h-tag.gain {
  background: rgba(46, 204, 113, 0.1);
  color: #2ecc71;
}

.h-tag.maintenance {
  background: rgba(241, 196, 15, 0.1);
  color: #f1c40f;
}

.icon-btn:hover {
  opacity: 1 !important;
  transform: scale(1.1);
}

/* Contact Form Styles */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-form textarea {
  width: 100%;
  padding: 12px;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-primary);
  resize: vertical;
  font-family: inherit;
  min-height: 120px;
}

.contact-form textarea:focus {
  outline: none;
}

/* Stepper Cursor */
.stepper li {
  cursor: pointer;
  transition: all 0.2s ease;
}

.stepper li:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* === Results reveal animation === */
#results {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
}

#results.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Alignment polish for results === */
.stat-grid {
  gap: 18px !important;
}

.stat-card {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  min-height: 130px !important;
  padding: 18px 18px 16px !important;
}

.stat-label {
  margin-bottom: 6px !important;
}

.stat-value {
  line-height: 1.1 !important;
  margin-top: 2px !important;
}

.stat-unit {
  margin-top: 6px !important;
}

/* Macro card polish */
.macro-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.macro-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.macro-name {
  font-weight: 800;
}

.macro-calories {
  opacity: .9
}

.progress {
  height: 8px !important;
  margin-top: 8px !important;
}

.macro-card .macro-help {
  top: 8px !important;
  right: 8px !important;
}

/* Section headings alignment */
.results-header h2,
.section-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.section-header h3::before {
  content: '📊';
  font-size: 1rem;
  transform: translateY(1px);
}

/* Info/warning box spacing */
.info-box {
  margin-top: 14px !important;
}

.info-box p {
  margin: 0 0 6px 0 !important;
}

/* === Density modes (Cozy/Compact) for results === */
.results.cozy .stat-card {
  padding: 18px 18px 16px;
  min-height: 130px;
}

.results.cozy .stat-value {
  font-size: 1.9rem;
}

.results.cozy .macros-grid {
  gap: 14px;
}

.results.cozy .macro-card {
  padding: 18px;
}

.results.cozy .macro-value {
  font-size: 2.1rem;
}

.results.cozy .progress {
  height: 8px;
}

.results.compact .stat-card {
  padding: 12px 12px 10px;
  min-height: 110px;
}

.results.compact .stat-value {
  font-size: 1.6rem;
}

.results.compact .stat-label {
  font-size: .85rem;
}

.results.compact .stat-unit {
  font-size: .8rem;
}

.results.compact .stat-grid {
  gap: 12px;
}

.results.compact .macros-grid {
  gap: 10px;
}

.results.compact .macro-card {
  padding: 12px;
}

.results.compact .macro-value {
  font-size: 1.8rem;
}

.results.compact .progress {
  height: 6px;
}

/* === Visual effects to differentiate Cozy vs Compact === */

/* Smooth transitions when density changes */
#results,
#results .stat-card,
#results .macro-card,
#results .progress,
#results .stat-value,
#results .macro-value {
  transition: all .25s ease;
}

/* Cozy: soft, elevated, rounded, subtle gradient */
.results.cozy .stat-card {
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(102, 126, 234, .18), 0 6px 18px rgba(102, 126, 234, .12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
  border-color: rgba(102, 126, 234, .18);
}

.results.cozy .stat-card:hover {
  transform: translateY(-3px);
}

.results.cozy .macro-card {
  border-radius: 18px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .10);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
  border-color: rgba(0, 0, 0, .06);
}

.results.cozy .progress {
  height: 10px;
  border-radius: 999px;
}

.results.cozy .macro-name {
  letter-spacing: .2px;
}

.results.cozy .stat-label {
  letter-spacing: .2px;
}

.results.cozy .result-badge {
  background: #d1fae5;
  color: #065f46;
}

/* Compact: flat, tighter radius, subtle borders, reduced shadows */
.results.compact .stat-card,
.results.compact .macro-card {
  border-radius: 12px;
  box-shadow: none;
  background: #ffffff;
  border-color: #e5e7eb;
}

.results.compact .stat-label {
  text-transform: uppercase;
  letter-spacing: .4px;
  opacity: .8;
}

.results.compact .macro-name {
  text-transform: uppercase;
  letter-spacing: .4px;
  opacity: .85;
}

.results.compact .progress {
  height: 6px;
  border-radius: 6px;
}

.results.compact .macro-card:hover,
.results.compact .stat-card:hover {
  transform: none;
}

/* Small animation pulse when switching density */
@keyframes densityPop {
  0% {
    transform: scale(.98);
    opacity: .8;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.results.density-animate .stat-card,
.results.density-animate .macro-card {
  animation: densityPop .22s ease;
}

.results.density-animate .stat-card:nth-child(1) {
  animation-delay: 0s;
}

.results.density-animate .stat-card:nth-child(2) {
  animation-delay: .02s;
}

.results.density-animate .stat-card:nth-child(3) {
  animation-delay: .04s;
}

.results.density-animate .stat-card:nth-child(4) {
  animation-delay: .06s;
}

/* === Dark-mode fixes for Cozy/Compact cards (contrast + gradients) === */
body.dark-mode .results.cozy .stat-card {
  background: linear-gradient(180deg, rgba(42, 42, 62, 0.98), rgba(37, 37, 53, 0.96));
  border-color: rgba(167, 139, 250, 0.22);
  box-shadow: 0 18px 45px rgba(0, 0, 0, .55), 0 6px 18px rgba(0, 0, 0, .35);
}

body.dark-mode .results.cozy .macro-card {
  background: linear-gradient(180deg, rgba(42, 42, 62, 0.98), rgba(37, 37, 53, 0.96));
  border-color: rgba(167, 139, 250, 0.15);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
}

body.dark-mode .results.compact .stat-card,
body.dark-mode .results.compact .macro-card {
  background: #2a2a3e;
  border-color: #3a3a4e;
  box-shadow: none;
}

body.dark-mode .stat-label {
  color: #c8c8ee !important;
  opacity: 0.95;
}

body.dark-mode .stat-value {
  color: #f0f0ff !important;
}

body.dark-mode .stat-unit {
  color: #a4a8c2 !important;
}

body.dark-mode .progress {
  background: #1f1f30 !important;
}

body.dark-mode .result-badge {
  background: #113d2c;
  color: #92f8c8;
}

/* Macro card light tints in dark */
body.dark-mode .macro-card.protein {
  border-color: #e74c3c;
  background: linear-gradient(135deg, rgba(231, 76, 60, 0.12), rgba(231, 76, 60, 0.20));
}

body.dark-mode .macro-card.carbs {
  border-color: #3498db;
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.12), rgba(52, 152, 219, 0.20));
}

body.dark-mode .macro-card.fats {
  border-color: #f39c12;
  background: linear-gradient(135deg, rgba(243, 156, 18, 0.12), rgba(243, 156, 18, 0.20));
}

/* === Macro card readability & contrast (both themes) === */
.macro-card .macro-name {
  color: #1f2937;
}

/* deep gray for light mode */
.macro-card .macro-value {
  color: #0b1220;
}

/* headline number */
.macro-card .macro-unit,
.macro-card .macro-calories,
.macro-card .macro-percentage {
  color: #4b5563;
}

/* supportive text */

/* Progress track contrast in light mode */
.macro-card .progress {
  background: #e5e7eb;
}

.macro-card .progress-fill {
  filter: saturate(1.1);
}

/* --- DARK MODE: High-contrast, legible macros --- */
body.dark-mode .macro-card {
  color: #e9ecf8;
}

body.dark-mode .macro-card .macro-name {
  color: #cfd6ff;
  font-weight: 800;
}

body.dark-mode .macro-card .macro-value {
  color: #f5f7ff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

body.dark-mode .macro-card .macro-unit,
body.dark-mode .macro-card .macro-calories,
body.dark-mode .macro-card .macro-percentage {
  color: #aeb6d6;
}

/* Stronger track + brighter fills in dark mode */
body.dark-mode .macro-card .progress {
  background: #1f2235;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .35);
}

body.dark-mode .protein .progress-fill {
  background: #ff6b5f;
  box-shadow: 0 0 10px rgba(255, 107, 95, .25);
}

body.dark-mode .carbs .progress-fill {
  background: #53b6ff;
  box-shadow: 0 0 10px rgba(83, 182, 255, .25);
}

body.dark-mode .fats .progress-fill {
  background: #ffbf3d;
  box-shadow: 0 0 10px rgba(255, 191, 61, .25);
}

/* Card surface & edge contrast for dark Cozy/Compact variants */
body.dark-mode .results.cozy .macro-card {
  background: linear-gradient(180deg, rgba(42, 42, 62, 0.98), rgba(35, 36, 53, 0.96));
  border: 1px solid rgba(175, 148, 255, .18);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .45);
}

body.dark-mode .results.compact .macro-card {
  background: #2a2a3e;
  border: 1px solid #3a3a4e;
  box-shadow: none;
}

/* Hover feedback only in Cozy to keep Compact minimal */
.results.cozy .macro-card:hover {
  transform: translateY(-2px);
}

.results.compact .macro-card:hover {
  transform: none;
}

/* === Reset Button === */
.reset-btn {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff5f6d, #ffc371);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 95, 109, 0.35);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.reset-btn:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

body.dark-mode .reset-btn {
  background: linear-gradient(135deg, #ff6b81, #ffa94d);
  box-shadow: 0 6px 20px rgba(255, 150, 120, 0.35);
}

/* === Form validation states (appended) === */
input.is-invalid,
select.is-invalid {
  border-color: #dc3545 !important;
  background: #fff5f5 !important;
  box-shadow: 0 0 0 4px rgba(220, 53, 69, .12) !important;
}

.error-text {
  display: block;
  margin-top: 6px;
  color: #b00020;
  font-size: .85rem;
  font-weight: 600;
  min-height: 1em;
  /* reserve space to reduce layout shift */
}

body.dark-mode input.is-invalid,
body.dark-mode select.is-invalid {
  background: #3a2230 !important;
  border-color: #ff6b6b !important;
  box-shadow: 0 0 0 4px rgba(255, 107, 107, .18) !important;
}

body.dark-mode .error-text {
  color: #ffb3b3;
}


/* === Global Navbar (fixed & theme-aware) === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 9999;
  background: #ffffff;
  border-bottom: 1px solid rgba(0, 0, 0, .08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

body.dark-mode .navbar {
  background: #1e1f24;
  border-bottom-color: rgba(255, 255, 255, .12);
}

body.dark-mode .navbar .brand {
  color: #f5f5f5;
}

/* .navbar .links .theme-toggle style moved to flex gap logic */

.navbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
}

.navbar .links {
  display: flex;
  align-items: center;
  gap: 20px;
  /* Consistent spacing */
}

.navbar .links a {
  text-decoration: none;
  color: #222;
  font-weight: 500;
  /* margin-left: 20px; removed in favor of gap */
}

body.dark-mode .navbar .links a {
  color: #f5f5f5;
}

.navbar .links a:hover {
  opacity: .85;
}

/* Keep content below navbar */
body {
  padding-top: 70px;
}

/* ===== Hamburger Menu Styles ===== */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #333;
  padding: 5px;
  flex-shrink: 0;
  /* Critical: never shrink */
}

body.dark-mode .menu-toggle {
  color: #fff;
}

@media (max-width: 768px) {
  .navbar {
    padding: 12px 16px;
    /* Optimized padding for mobile */
    align-items: center;
  }

  .menu-toggle {
    display: block;
  }

  .navbar .links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    flex-direction: column;
    background: white;
    /* Fallback */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    padding: 10px 0;
    gap: 0;
    border-radius: 0 0 16px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
  }

  body.dark-mode .navbar .links {
    background: rgba(30, 31, 36, 0.98);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }

  .navbar .links.active {
    display: flex;
  }

  .navbar .links a {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin: 0;
    font-size: 1rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  }

  body.dark-mode .navbar .links a {
    border-bottom-color: rgba(255, 255, 255, 0.03);
  }

  /* Improve Brand Display on Mobile: Wrap text, smaller font, reserved space */
  .navbar .brand {
    font-size: 1rem;
    line-height: 1.25;
    white-space: normal;
    /* Force wrap */
    margin-right: 12px;
    flex: 1;
    min-width: 0;
    /* Allow shrinking */
  }

  /* Mobile Button Style for Theme Toggle */
  .navbar .links .theme-toggle {
    display: flex;
    align-items: center;
    width: fit-content;
    /* Shrink to fit */
    margin: 0;
    padding: 6px 20px;
    /* Highly Reduced Padding */
    border-radius: 20px;
    /* Make it pill-shaped for better fit visuals */
    font-size: 0.95rem;
    /* Smaller Font */
    font-weight: 400;
    color: #444;
    /* Softer Text */
    border-bottom: none;
    background: transparent;
    outline: none;
    min-height: auto;
    /* Remove height constraint */
    border: 1px solid rgba(0, 0, 0, 0.1);
    /* Subtle border to define it */
    margin-top: 10px;
    /* Separate from links */
    margin-bottom: 10px;
    margin-left: 24px;
    /* Align with link text */
  }

  .navbar .links .theme-toggle:focus {
    background: rgba(0, 0, 0, 0.02);
  }

  body.dark-mode .navbar .links .theme-toggle:focus {
    background: rgba(255, 255, 255, 0.03);
  }

  .navbar .links .theme-toggle .theme-icon {
    line-height: 1;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Show "Dark Mode" text on mobile */
  .navbar .links .theme-toggle .theme-text {
    display: inline-block !important;
    margin-left: 8px;
    line-height: 1;
    position: relative;
    top: 1px;
    font-size: 0.9rem;
    /* Smaller label */
  }

  body.dark-mode .navbar .links .theme-toggle {
    color: #bbb;
    /* Softer dark mode text */
    border-color: rgba(255, 255, 255, 0.1);
  }
}




/* === Blog Index (hero + cards) === */
.blog-section {
  display: flex;
  flex-direction: column;
  align-items: center
}

.blog-hero {
  text-align: center;
  margin: 100px auto 30px;
  padding: 0 20px;
  max-width: 800px
}

.blog-hero h1 {
  font-size: 2rem;
  margin: 0 0 8px
}

.blog-hero p {
  max-width: 680px;
  margin: 0 auto;
  color: #555
}

body.dark-mode .blog-hero h1 {
  color: #ffffff;
}

body.dark-mode .blog-hero p {
  color: #cfcfd6
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  justify-content: center;
  align-items: start;
  max-width: 1000px;
  margin: 0 auto 100px;
  padding: 0 20px
}

.post-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, .1);
  border-color: rgba(0, 0, 0, .12)
}

body.dark-mode .post-card {
  background: #1b1d20;
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color: #e0e0e0 !important;
}

body.dark-mode .post-card .post-title {
  color: #ffffff !important;
}

.post-card .post-title {
  font-weight: 700;
  margin: 2px 0 8px;
  line-height: 1.35
}

.post-card .post-excerpt {
  color: #666;
  margin: 6px 0 12px;
  font-size: .95rem
}

body.dark-mode .post-card .post-excerpt {
  color: #bfc3c8 !important;
}

.post-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: .85rem;
  color: #6b7280
}

body.dark-mode .post-meta {
  color: #9aa1a8 !important;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid rgba(0, 0, 0, .08);
  font-size: .8rem
}

body.dark-mode .badge {
  background: #23262a;
  border-color: rgba(255, 255, 255, .12);
  color: #d0d0e6 !important;
}

.post-card,
.post-card * {
  text-decoration: none;
  color: inherit
}



/* === Blog Post (card + prose) === */
.blog-wrap {
  max-width: 920px;
  margin: 96px auto 60px;
  padding: 0 16px
}

.blog-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .06);
  overflow: hidden
}

body.dark-mode .blog-card {
  background: #1b1d20;
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35)
}

.blog-content {
  padding: 28px 24px
}

.prose {
  line-height: 1.75;
  color: #222
}

body.dark-mode .prose {
  color: #f2f2f2
}

.prose h1 {
  font-size: 2rem;
  line-height: 1.25;
  margin: 0 0 12px;
}

body.dark-mode .prose h1 {
  color: #ffffff;
}

.prose h2 {
  font-size: 1.35rem;
  margin: 22px 0 8px;
}

body.dark-mode .prose h2 {
  color: #f0f0f0;
}

.prose p {
  margin: 10px 0;
  color: #333
}

body.dark-mode .prose p {
  color: #ddd
}

.prose a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600
}

.prose a:hover {
  text-decoration: underline
}

.prose ul,
.prose ol {
  padding-left: 1.2em;
  margin: 8px 0;
}

body.dark-mode .prose ul,
body.dark-mode .prose ol {
  color: #ddd;
}

.prose li {
  margin: 6px 0
}

.blog-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(0, 0, 0, .08)
}

body.dark-mode .blog-footer {
  border-top-color: rgba(255, 255, 255, .14)
}

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid rgba(0, 0, 0, .08);
  font-size: .85rem;
  color: #111;
  text-decoration: none
}

body.dark-mode .pill {
  background: #23262a;
  border-color: rgba(255, 255, 255, .14);
  color: #f2f2f2
}

/* === Footer === */
.site-footer {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
  padding: 24px 0 8px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
  margin-top: auto;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.site-footer a {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  opacity: 0.8;
  transition: opacity 0.2s, transform 0.2s;
}

.site-footer a:hover {
  opacity: 1;
  text-decoration: underline;
  transform: translateY(-1px);
}

@media (min-width: 600px) {
  .footer-content {
    flex-direction: row;
    justify-content: space-between;
    padding: 0 10px;
  }
}

body.dark-mode .site-footer {
  color: rgba(255, 255, 255, 0.6);
}

/* ===== Dynamic Tips Section ===== */
.tips-section {
  margin-top: 24px;
  animation: fadeIn 0.5s ease-out;
}

.tips-header {
  text-align: center;
  margin-bottom: 16px;
}

.tips-header h3 {
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 8px;
}

.tips-divider {
  height: 3px;
  width: 50px;
  margin: 0 auto;
  background: linear-gradient(90deg, #f093fb, #f5576c);
  border-radius: 2px;
}

.tip-card {
  background: linear-gradient(135deg, #fff, #f9f9ff);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(102, 126, 234, 0.1);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.tip-card::before {
  content: '"';
  position: absolute;
  top: -10px;
  left: 10px;
  font-size: 4rem;
  color: rgba(102, 126, 234, 0.1);
  font-family: serif;
  line-height: 1;
}

.tip-text {
  font-size: 1.05rem;
  color: #555;
  font-weight: 500;
  line-height: 1.5;
  margin: 0;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.tip-text.show {
  opacity: 1;
  transform: translateY(0);
}

/* Dark Mode for Tips */
body.dark-mode .tips-header h3 {
  color: #e9e9ff;
}

body.dark-mode .tip-card {
  background: linear-gradient(135deg, #2a2a3e, #252535);
  border-color: #3a3a4e;
}

body.dark-mode .tip-text {
  color: #d0d0e6;
}

body.dark-mode .tip-card::before {
  color: rgba(167, 139, 250, 0.1);
}

/* ===== Mobile & Tablet Polish (UX Improvements) ===== */

/* Tablet & Mobile: Better Grid Sizing */
@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .macros-grid {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }
}

/* Mobile Specific (max-width: 600px) */
@media (max-width: 600px) {

  /* Navbar: Compact & Sticky */
  .navbar {
    padding: 10px 16px;
  }

  .navbar .brand {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }

  .navbar .links a {
    margin-left: 12px;
    font-size: 0.9rem;
    padding: 6px 0;
  }

  /* Typography: Scaled down */
  .brand-title {
    font-size: 1.1rem;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  /* Spacing: Tighter but comfortable */
  .calculator-card {
    padding: 16px 14px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  /* Inputs: Ensure full width and easy tap (prevent iOS zoom) */
  input[type="number"],
  select {
    padding: 12px 14px;
    font-size: 16px !important;
  }

  /* Unit Toggles: Larger touch targets */
  .unit-btn {
    padding: 6px 14px;
  }

  /* Results: Compact grids */
  .stat-grid {
    gap: 12px !important;
  }

  .macros-grid {
    gap: 10px;
  }

  /* Tips: Compact */
  .tip-card {
    padding: 16px;
    min-height: auto;
  }

  .tip-text {
    font-size: 0.95rem;
  }

  .tip-card::before {
    font-size: 3rem;
    top: -5px;
    left: 5px;
  }

  /* Footer: Stacked */
  .footer-content {
    flex-direction: column;
    gap: 10px;
  }

  .footer-links {
    gap: 16px;
  }

  /* Force single column for blog index */
  .post-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 16px;
  }
}

/* Small Mobile (iPhone SE, Foldables) */
@media (max-width: 360px) {
  .macros-grid {
    grid-template-columns: 1fr;
    /* Stack macros on very small screens */
  }

  .navbar .brand {
    font-size: 0.9rem;
  }
}

/* ===== History Section ===== */
.history-section {
  margin-top: 24px;
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  border: 1px solid rgba(102, 126, 234, .15);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.history-header h3 {
  font-size: 1.1rem;
  color: #333;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.clear-history-btn {
  background: none;
  border: none;
  color: #888;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.clear-history-btn:hover {
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.1);
  text-decoration: none;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.history-item:hover {
  background: #fff;
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  transform: translateY(-1px);
}

.h-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.h-date {
  font-size: 0.75rem;
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.h-details {
  font-size: 0.9rem;
  font-weight: 600;
  color: #444;
}

.h-tags {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.h-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
}

.h-tag.loss {
  background: #fff5f5;
  color: #c53030;
}

.h-tag.gain {
  background: #f0fff4;
  color: #2f855a;
}

.h-tag.maintenance {
  background: #ebf8ff;
  color: #2b6cb0;
}

.h-result {
  text-align: right;
}

.h-cals {
  font-size: 1.1rem;
  font-weight: 800;
  color: #667eea;
}

.h-unit {
  font-size: 0.75rem;
  color: #999;
}

.empty-history {
  text-align: center;
  padding: 20px;
  color: #888;
  font-style: italic;
}

/* Dark Mode for History */
body.dark-mode .history-section {
  background: #2a2a3e;
  border-color: #3a3a4e;
}

body.dark-mode .history-header {
  border-bottom-color: #3a3a4e;
}

body.dark-mode .history-header h3 {
  color: #e0e0e0;
}

body.dark-mode .history-item {
  background: #252535;
}

body.dark-mode .history-item:hover {
  background: #2a2a3e;
  border-color: #a78bfa;
}

body.dark-mode .h-details {
  color: #d0d0e6;
}

body.dark-mode .h-date {
  color: #9aa;
}

body.dark-mode .h-cals {
  color: #a78bfa;
}

/* ===== Download Button ===== */
.download-btn {
  background: #f0f0f0;
  border-color: #e0e0e0;
  font-size: 1.1rem;
  padding: 4px 10px;
  line-height: 1;
}

.download-btn:hover {
  background: #e2e8f0;
  border-color: #cbd5e0;
}

/* Capturing State (Clean up for image export) */
.results.capturing {
  border-radius: 0;
  box-shadow: none;
  border: none;
  background: #fff;
  /* Force white background */
  padding: 30px;
  /* Add some padding for the image */
  width: 800px;
  /* Fixed width for consistent output */
  max-width: none;
}

/* Ensure dark mode capture looks good too */

/* Input Summary (for Screenshot) */
.result-input-summary {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
  line-height: 1.4;
}

body.dark-mode .result-input-summary {
  color: #aaa;
}

body.dark-mode .h-tag.loss {
  background: rgba(197, 48, 48, 0.2);
  color: #fc8181;
}

body.dark-mode .h-tag.gain {
  background: rgba(47, 133, 90, 0.2);
  color: #68d391;
}

body.dark-mode .h-tag.maintenance {
  background: rgba(43, 108, 176, 0.2);
  color: #63b3ed;
}

/* ===== BMI Calculator Page ===== */
.bmi-value-display {
  text-align: center;
  margin-bottom: 20px;
}

.bmi-number {
  font-size: 2.5rem;
  font-weight: 900;
  color: #333;
  line-height: 1;
}

.bmi-text-category {
  font-size: 1.2rem;
  font-weight: 700;
  color: #2ecc71;
  margin-left: 10px;
}

/* Gauge Container */
.gauge-svg-container {
  width: 100%;
  max-width: 350px;
  margin: 0 auto 20px;
  position: relative;
}

.gauge-needle {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 4px;
  height: 45%;
  background: #333;
  transform-origin: bottom center;
  transform: rotate(-90deg);
  transition: transform 1s cubic-bezier(0.4, 0.0, 0.2, 1);
  border-radius: 4px;
  z-index: 10;
}

.gauge-needle::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: -6px;
  width: 16px;
  height: 16px;
  background: #333;
  border-radius: 50%;
}

.gauge-value-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-weight: 800;
  font-size: 1.5rem;
  color: #333;
}

.bmi-stats-list {
  list-style: none;
  padding: 0;
  margin-top: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 15px;
  border: 1px solid #e0e0e0;
}

.bmi-stat-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

.bmi-stat-item:last-child {
  border-bottom: none;
}

.bmi-stat-label {
  color: #555;
  font-weight: 600;
}

.bmi-stat-val {
  color: #333;
  font-weight: 800;
}

/* Dark Mode Overrides for BMI */
body.dark-mode .bmi-number {
  color: #fff;
}

body.dark-mode .bmi-stats-list {
  background: #2a2a3e;
  border-color: #3a3a4e;
}

body.dark-mode .bmi-stat-item {
  border-bottom-color: #3a3a4e;
}

body.dark-mode .bmi-stat-label {
  color: #b0b0c0;
}

body.dark-mode .bmi-stat-val {
  color: #fff;
}

body.dark-mode .gauge-value-overlay {
  color: #fff;
}

body.dark-mode .gauge-needle {
  background: #fff;
}

body.dark-mode .gauge-needle::after {
  background: #fff;
}

/* =========================================
   FITNESS RESOURCES APP STYLES
   ========================================= */

/* Resource App Specific Styles */
.resource-container {
  max-width: 1200px;
  margin: 0 auto;
  padding-bottom: 80px;
}

/* Navigation Tabs */
.resource-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.nav-tab {
  padding: 12px 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(102, 126, 234, 0.2);
  color: #555;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tab:hover {
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.nav-tab.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

body.dark-mode .nav-tab {
  background: rgba(42, 42, 62, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
  color: #aaa;
}

body.dark-mode .nav-tab.active {
  color: #fff;
  background: linear-gradient(135deg, #a78bfa, #c084fc);
}

/* Page Sections */
.page-section {
  display: none;
  animation: fadeIn 0.4s ease;
}

.page-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Controls Bar (Search, Filter) */
.controls-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: #fff;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
  align-items: center;
}

body.dark-mode .controls-bar {
  background: #2a2a3e;
}

.search-box {
  flex: 1;
  position: relative;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  padding-left: 40px;
  border: 1px solid #ddd;
  border-radius: 8px;
  height: 40px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
}

.filter-select {
  min-width: 150px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #ddd;
  padding: 0 12px;
}

/* Data Tables */
.table-card {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(102, 126, 234, 0.15);
}

body.dark-mode .table-card {
  background: #2a2a3e;
  border-color: #3a3a4e;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th,
td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

body.dark-mode th,
body.dark-mode td {
  border-bottom-color: #3a3a4e;
  color: #e0e0e0;
}

th {
  background: #f8f9fa;
  font-weight: 700;
  color: #555;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover {
  background: #f0f0f0;
}

body.dark-mode th {
  background: #1a1a2e;
  color: #aaa;
}

body.dark-mode th:hover {
  background: #252535;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(102, 126, 234, 0.05);
}

body.dark-mode tr:hover td {
  background: rgba(167, 139, 250, 0.05);
}

/* Badges */
.badge {
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  display: inline-block;
}

.badge-high {
  background: #ffebee;
  color: #c62828;
}

.badge-mod {
  background: #fff3e0;
  color: #ef6c00;
}

.badge-low {
  background: #e8f5e9;
  color: #2e7d32;
}

body.dark-mode .badge-high {
  background: rgba(198, 40, 40, 0.2);
  color: #ff8a80;
}

body.dark-mode .badge-mod {
  background: rgba(239, 108, 0, 0.2);
  color: #ffcc80;
}

body.dark-mode .badge-low {
  background: rgba(46, 125, 50, 0.2);
  color: #a5d6a7;
}

/* Comparison Floating Bar */
.comparison-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: #fff;
  padding: 16px 24px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 1px solid #e0e0e0;
  width: 90%;
  max-width: 600px;
}

.comparison-bar.visible {
  transform: translateX(-50%) translateY(0);
}

body.dark-mode .comparison-bar {
  background: #2a2a3e;
  border-color: #444;
  color: #fff;
}

.compare-count {
  font-weight: 700;
  color: #667eea;
}

.compare-btn {
  margin-left: auto;
  background: #667eea;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

/* Checkbox custom */
.check-cell {
  width: 40px;
}

.custom-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* Modal for Comparison */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s;
}

.modal-overlay.open {
  display: grid;
  opacity: 1;
}

.modal-content {
  background: #fff;
  padding: 24px;
  border-radius: 24px;
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

body.dark-mode .modal-content {
  background: #1a1a2e;
  color: #fff;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
}

/* Contact Form Styles */
.contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contact-form textarea {
  min-height: 120px;
  resize: vertical;
}

/* ===== Unit Guide ===== */
.unit-guide {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #666;
  border-top: 1px solid #eee;
  padding-top: 1rem;
}

.unit-guide summary {
  cursor: pointer;
  margin-bottom: 0.5rem;
  font-weight: 500;
  list-style: none;
}

.unit-guide summary::-webkit-details-marker {
  display: none;
}

.unit-guide summary::after {
  content: " ▼";
  font-size: 0.8em;
  color: #999;
}

.unit-guide[open] summary::after {
  content: " ▲";
}

.unit-content {
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  line-height: 1.6;
}

.unit-group {
  margin-bottom: 0.8rem;
}

.unit-group:last-child {
  margin-bottom: 0;
}

.unit-label {
  display: inline-block;
  width: 30px;
  font-weight: 600;
  color: #555;
}

/* Dark Mode for Unit Guide */
body.dark-mode .unit-guide {
  color: #aaa;
  border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .unit-content {
  background: #1a1a2e;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.dark-mode .unit-label {
  color: #ccc;
}

/* Dark Mode for Info Box (Privacy/Terms) */
body.dark-mode .info-box h2 {
  color: #e9e9ff;
}

body.dark-mode .info-box p,
body.dark-mode .info-box li {
  color: #d0d0e6;
}

/* === CTA Box in Blog Posts === */
.cta-box {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 16px;
  padding: 24px;
  margin: 32px 0;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.cta-box h3 {
  margin-top: 0;
  color: #333;
}

.cta-box p {
  color: #555;
  margin-bottom: 16px;
}

.btn-primary {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  color: #fff;
  opacity: 0.95;
}

/* Dark Mode for CTA Box */
body.dark-mode .cta-box {
  background: linear-gradient(135deg, #2a2a3e, #252535);
  border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .cta-box h3 {
  color: #fff;
}

body.dark-mode .cta-box p {
  color: #ccc;
}

/* Dark Mode Prose Links */
body.dark-mode .prose a {
  color: #60a5fa;
}

body.dark-mode .prose a:hover {
  color: #93c5fd;
}

/* Site Footer Dark Mode */
body.dark-mode .site-footer {
  background: #1a1a2e;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .site-footer p {
  color: #aaa;
}

body.dark-mode .footer-links a {
  color: #ccc;
}

body.dark-mode .footer-links a:hover {
  color: #fff;
}

/* Comprehensive Prose Headings Dark Mode */
body.dark-mode .prose h3,
body.dark-mode .prose h4,
body.dark-mode .prose h5,
body.dark-mode .prose h6 {
  color: #f0f0f0;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

/* Ensure list items in prose are visible */
body.dark-mode .prose li {
  color: #ddd;
}

/* Ensure strong/bold text is visible */
body.dark-mode .prose strong,
body.dark-mode .prose b {
  color: #fff;
}

/* ===== PLATEAU BREAKER FEATURES ===== */

.plateau-container {
  margin-top: 30px;
  border-top: 2px dashed #e2e8f0;
  padding-top: 24px;
  display: none;
  /* Hidden by default until results shown */
}

/* Show when results are visible */
body.results-shown .plateau-container {
  display: block;
  animation: fadeIn 0.8s ease forwards;
}

.plateau-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
  border: 1px solid rgba(102, 126, 234, .15);
  transition: transform 0.2s;
  margin-bottom: 20px;
}

.plateau-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}

/* 1. Educational Section */
.edu-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: #2d3748;
}

.edu-icon {
  font-size: 1.5rem;
  background: #e6fffa;
  color: #38b2ac;
  padding: 8px;
  border-radius: 12px;
}

.edu-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.edu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.edu-list li {
  position: relative;
  padding-left: 24px;
  color: #4a5568;
  line-height: 1.5;
  font-size: 0.95rem;
}

.edu-list li::before {
  content: "•";
  color: #38b2ac;
  font-weight: bold;
  position: absolute;
  left: 6px;
}

/* 2. Plateau Breaker Tool */
.tool-header {
  text-align: center;
  margin-bottom: 20px;
}

.goal-select-wrapper {
  position: relative;
  max-width: 300px;
  margin: 0 auto 20px;
}

.plateau-select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 1rem;
  color: #4a5568;
  background: #f7fafc;
  cursor: pointer;
}

.advice-box {
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  border-radius: 12px;
  padding: 20px;
  border-left: 4px solid #667eea;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 500;
  color: #2d3748;
  transition: all 0.3s ease;
}

.advice-box.animate {
  animation: fadeIn 0.5s ease;
}

/* 3. Motivational Tips */
.quote-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-align: center;
  border: none;
}

.quote-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 20px;
  font-style: italic;
  opacity: 0.9;
  min-height: 60px;
  /* Prevent jump */
  display: flex;
  align-items: center;
  justify-content: center;
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  padding: 8px 16px;
  border-radius: 99px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.refresh-icon {
  transition: transform 0.5s ease;
}

.refresh-btn:hover .refresh-icon {
  transform: rotate(180deg);
}

/* Dark Mode Overrides */
body.dark-mode .plateau-container {
  border-top-color: #3a3a4e;
}

body.dark-mode .plateau-card {
  background: #2a2a3e;
  border-color: #3a3a4e;
}

body.dark-mode .edu-header {
  color: #e2e8f0;
}

body.dark-mode .edu-icon {
  background: rgba(56, 178, 172, 0.2);
}

body.dark-mode .edu-list li {
  color: #cbd5e0;
}

body.dark-mode .advice-box {
  background: #1a202c;
  color: #e2e8f0;
  border-left-color: #a78bfa;
}

body.dark-mode .plateau-select {
  background: #1a202c;
  border-color: #4a5568;
  color: #e2e8f0;
}