:root {
  /* Dark Mode (Default) */
  --bg-primary: #1e1b4b;
  --bg-secondary: rgba(30, 41, 59, 0.6);
  --text-primary: #fef3c7;
  --text-secondary: #cbd5e1;
  --accent-health: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.2);
  --card-border: rgba(254, 243, 199, 0.1);
  --font-main: 'Outfit', sans-serif;
}

/* Light Mode */
body.light-mode {
  --bg-primary: #fffbeb;
  --bg-secondary: #ffffff;
  --text-primary: #1e1b4b;
  --text-secondary: #475569;
  --accent-health: #059669;
  --accent-glow: rgba(5, 150, 105, 0.15);
  --card-border: rgba(30, 27, 75, 0.15);
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

html {
  background-color: var(--bg-primary);
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 2rem;
  background-color: var(--bg-primary);
}

/* Typography */
h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-weight: 600;
  line-height: 1.1;
}

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

a:hover {
  opacity: 0.8;
}

/* Header */
header.container {
  padding: 4rem 1rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1rem;
  position: relative;
}

header h1 .name {
  color: var(--accent-health);
  text-shadow: 0 0 20px var(--accent-glow);
}

header p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
}

/* Theme Toggle */
.theme-toggle-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 2rem;
}

.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  padding: 0.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.theme-toggle button {
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  color: var(--text-secondary);
  font-size: 1.2rem;
}

.theme-toggle button.active {
  background: var(--accent-health);
  color: white;
  box-shadow: 0 0 15px var(--accent-glow);
}

.theme-toggle button:hover:not(.active) {
  background: var(--card-border);
}

/* Settings Toggle */
.settings-toggle {
  margin: 0 auto 2rem;
  max-width: 600px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

body.light-mode .settings-toggle {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.settings-toggle summary {
  padding: 1rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  list-style: none;
  text-align: center;
  user-select: none;
}

.settings-toggle summary::-webkit-details-marker {
  display: none;
}

.settings-toggle[open] summary {
  border-bottom: 1px solid var(--card-border);
}

/* Controls */
.controls {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.ctrl {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ctrl span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ctrl input {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  padding: 0.75rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
}

body.light-mode .ctrl input {
  background: rgba(255, 255, 255, 0.8);
}

.ctrl input:focus {
  outline: none;
  border-color: var(--accent-health);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ctrl.buttons {
  grid-column: 1 / -1;
  flex-direction: row;
  justify-content: flex-end;
  margin-top: 1rem;
}

.ctrl button {
  background: var(--accent-health);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}

.ctrl button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

#reset-button {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

body.light-mode .card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-health);
  box-shadow: 0 0 20px var(--accent-glow);
}

.progress {
  flex-direction: column;
  gap: 1rem;
}

.progress .left {
  width: 60px;
  height: 60px;
}

.progress .right h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.progress .right h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Hide savings card by default */
.card.savings {
  display: none;
}

/* SVG Progress */
svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

svg circle {
  fill: none;
  stroke-width: 8px;
  stroke-linecap: round;
}

svg circle.bg {
  stroke: var(--card-border);
}

svg circle.prog {
  stroke: var(--accent-health);
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

/* Timeline */
.wellness-header {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 3rem 0 2rem;
  position: relative;
}

.wellness-header::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background: linear-gradient(to right, var(--accent-health), transparent);
  margin: 1rem auto 0;
  border-radius: 2px;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0 4rem;
}

.milestone {
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--accent-health);
  padding: 1.5rem;
  border-radius: 12px;
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

body.light-mode .milestone {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.milestone:hover {
  transform: translateX(4px);
  box-shadow: 0 0 20px var(--accent-glow);
}

.milestone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.milestone h3 {
  color: var(--accent-health);
  margin-bottom: 0.75rem;
  font-size: 1.3rem;
  font-weight: 700;
}

.milestone p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0.5rem 0;
}

.milestone p strong {
  color: var(--text-primary);
  font-weight: 600;
}

.milestone .source {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--accent-health);
  opacity: 0.7;
  text-decoration: none;
  transition: opacity 0.2s;
}

.milestone .source:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Footer */
.site-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--card-border);
  color: var(--text-secondary);
}

.site-footer .disclaimer {
  max-width: 700px;
  margin: 0 auto 1.5rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--card-border);
}

.site-footer .disclaimer small {
  line-height: 1.5;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-health);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast[hidden] {
  opacity: 0;
  transform: translate(-50%, 20px);
  pointer-events: none;
  display: block;
}

/* Invalid input */
input.invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Responsive Typography */
@media (min-width: 768px) {
  header h1 {
    font-size: 5rem;
  }
}