:root {
  /* Colors */
  --primary: #00704A; /* Starbucks Green */
  --primary-dark: #005c3d;
  --accent: #d4e9e2;
  --bg-body: #f7f9fa;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --focus-ring: 0 0 0 3px rgba(0, 112, 74, 0.3);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Georgia', serif; 
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --accent: #004d33;
  }
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 80px; /* Space for bottom sheet or footer */
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  display: block;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: var(--space-md) 0;
}

.nav-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

nav ul {
  display: flex;
  gap: var(--space-md);
  list-style: none;
}

nav a {
  color: var(--text-main);
  font-weight: 500;
  font-size: 0.95rem;
}

nav a:hover, nav a.active {
  color: var(--primary);
}

/* Hero & Sections */
.hero {
  text-align: center;
  padding: var(--space-xl) 0;
}
.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: var(--space-sm);
  letter-spacing: -0.025em;
}
.hero p {
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
  font-size: 1.1rem;
}

/* Controls */
.controls {
  margin: var(--space-lg) 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: center;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  background: var(--bg-card);
  color: var(--text-main);
}
.search-input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--primary);
}

.category-select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 1rem;
  cursor: pointer;
}

/* Grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card h3 {
  font-size: 1.1rem;
  margin-bottom: var(--space-xs);
  color: var(--text-main);
}
.card .category {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}
.card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
  flex-grow: 1;
}
.card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-color);
}
.badge {
  background: var(--accent);
  color: var(--primary-dark);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Calculator Modal / Bottom Sheet */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: flex-end; /* Bottom sheet on mobile */
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-overlay.open {
  display: flex;
}
.modal-content {
  background: var(--bg-card);
  width: 100%;
  max-width: 600px; /* Desktop max width */
  max-height: 90vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: var(--space-lg);
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-content {
    border-radius: var(--radius-lg);
    height: auto;
    max-height: 85vh;
  }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: var(--space-md);
}
.close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
}

/* Calculator Inputs */
.calc-section {
  margin-bottom: var(--space-lg);
}
.calc-section h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  font-weight: 600;
}
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}
.option-btn {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-main);
  transition: all 0.2s;
}
.option-btn:hover {
  border-color: var(--primary);
}
.option-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.counter-control {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.counter-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.counter-btn:hover {
  background: var(--bg-body);
}
.counter-val {
  font-weight: 600;
  width: 24px;
  text-align: center;
}

/* Result Box */
.result-box {
  background: var(--accent);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
  margin-top: var(--space-lg);
  color: var(--primary-dark);
}
.total-cals {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}
.total-label {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-md);
}
.btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: none;
  cursor: pointer;
  flex: 1;
  text-align: center;
  transition: background 0.2s;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  border-color: var(--text-main);
}

/* FAQ & Text Content */
.content-section {
  max-width: 800px;
  margin: var(--space-xl) auto;
  line-height: 1.7;
}
.content-section h2 {
  font-size: 1.75rem;
  margin-bottom: var(--space-md);
  color: var(--text-main);
}
.content-section h3 {
  font-size: 1.25rem;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}
.faq-item {
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-md) 0;
}
.faq-question {
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}
.faq-answer {
  color: var(--text-muted);
  margin-top: var(--space-sm);
  display: none;
}
.faq-item.open .faq-answer {
  display: block;
}

footer {
  text-align: center;
  padding: var(--space-xl) 0;
  margin-top: var(--space-xl);
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.9rem;
}
footer a {
  color: var(--text-main);
  margin: 0 var(--space-sm);
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.text-center { text-align: center; }
.mb-4 { margin-bottom: 1rem; }
