:root {
  --bg: #FAFAF7;
  --bg-card: #FFFFFF;
  --bg-input: #F4F3EF;
  --bg-hover: #EEEDEA;
  --text-1: #1A1A18;
  --text-2: #6B6A65;
  --text-3: #9C9B96;
  --border: rgba(0,0,0,0.08);
  --border-focus: rgba(0,0,0,0.2);
  --accent: #2E6B3E;
  --accent-light: #E8F3EB;
  --accent-text: #1B4025;
  --blue: #2B6CB0;
  --blue-light: #E6F0FA;
  --amber: #B7791F;
  --amber-light: #FEF5E7;
  --coral: #C53D2F;
  --coral-light: #FEECEB;
  --teal: #1A7A6D;
  --teal-light: #E6F5F3;
  --purple: #A855F7;
  --purple-light: #F3E8FF;
  --font-display: 'Fraunces', serif;
  --font-body: 'DM Sans', sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not(.light-mode) {
    --bg: #141413;
    --bg-card: #1E1E1C;
    --bg-input: #282825;
    --bg-hover: #32322F;
    --text-1: #EAEAE6;
    --text-2: #9C9B96;
    --text-3: #6B6A65;
    --border: rgba(255,255,255,0.08);
    --border-focus: rgba(255,255,255,0.2);
    --accent: #5CB176;
    --accent-light: #1C2E22;
    --accent-text: #A8DCAD;
    --blue: #63A4E8;
    --blue-light: #1A2840;
    --amber: #E8A93E;
    --amber-light: #2E2410;
    --coral: #E86B5E;
    --coral-light: #2E1614;
    --teal: #52C4B2;
    --teal-light: #122A27;
    --purple: #C084FC;
    --purple-light: #2D1A4E;
  }
}
:root.dark-mode {
  --bg: #141413;
  --bg-card: #1E1E1C;
  --bg-input: #282825;
  --bg-hover: #32322F;
  --text-1: #EAEAE6;
  --text-2: #9C9B96;
  --text-3: #6B6A65;
  --border: rgba(255,255,255,0.08);
  --border-focus: rgba(255,255,255,0.2);
  --accent: #5CB176;
  --accent-light: #1C2E22;
  --accent-text: #A8DCAD;
  --blue: #63A4E8;
  --blue-light: #1A2840;
  --amber: #E8A93E;
  --amber-light: #2E2410;
  --coral: #E86B5E;
  --coral-light: #2E1614;
  --teal: #52C4B2;
  --teal-light: #122A27;
  --purple: #C084FC;
  --purple-light: #2D1A4E;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 20px 100px;
}

.logo-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 28px;
}
.logo {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-1);
  letter-spacing: -0.03em;
}
.logo span { color: var(--accent); }
.status-pill {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
}
.status-pill .dot.ok { background: var(--accent); }

.settings-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}
.settings-btn:hover { background: var(--bg-hover); color: var(--text-1); }
.settings-btn.has-key { border-color: var(--accent); color: var(--accent); }

.setup-card.hidden { display: none; }

/* Setup card */
.setup-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.setup-card label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 6px;
}
.setup-card input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
  transition: border-color 0.2s;
}
.setup-card input:focus { border-color: var(--border-focus); }
.setup-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--text-2);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* Meal input */
.meal-textarea {
  width: 100%;
  min-height: 90px;
  padding: 14px;
  font-size: 15px;
  font-family: var(--font-body);
  line-height: 1.6;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-1);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
.meal-textarea:focus { border-color: var(--border-focus); }
.meal-textarea::placeholder { color: var(--text-3); }

.meal-pills {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}
.meal-pill {
  flex: 1;
  padding: 8px 4px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-2);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.meal-pill:hover { border-color: var(--text-3); }
.meal-pill.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}
.estimate-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.estimate-btn {
  margin-left: auto;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.estimate-btn:hover { opacity: 0.9; }
.estimate-btn:active { transform: scale(0.98); }
.estimate-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.status-line {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 10px;
  display: none;
}
.status-line.show { display: block; }
.error-line {
  font-size: 13px;
  color: var(--coral);
  margin-top: 10px;
  display: none;
}
.error-line.show { display: block; }

/* Preview */
.preview-card {
  margin-top: 16px;
  background: var(--accent-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: none;
}
.preview-card.show { display: block; animation: slideUp 0.25s ease; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.preview-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 12px;
}
.multi-preview {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.multi-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.multi-name { color: var(--text-1); }
.multi-cal { color: var(--text-3); font-size: 12px; }
.macro-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.macro-cell {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
}
.macro-num {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-1);
}
.macro-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}
.preview-note {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 10px;
  font-style: italic;
}

/* Calibration note inline */
.cal-toggle {
  background: none;
  border: none;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-body);
}
.cal-toggle:hover { color: var(--text-1); }
.cal-inline { margin-top: 8px; display: none; }
.cal-inline.show { display: block; }
.cal-inline textarea {
  width: 100%;
  padding: 10px;
  font-size: 13px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  resize: none;
  outline: none;
  line-height: 1.5;
}
.cal-inline-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.confirm-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
}
.confirm-btn:hover { opacity: 0.9; }
.cancel-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.cancel-btn:hover { background: var(--bg-hover); }
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.date-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-1);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 500;
}
.date-btn:hover { background: var(--bg-hover); }
.cal-remaining-bar {
  margin-bottom: 16px;
}
.cal-remaining-track {
  height: 28px;
  border-radius: 14px;
  background: var(--bg-input);
  overflow: hidden;
  position: relative;
}
.cal-remaining-fill {
  height: 100%;
  border-radius: 14px;
  transition: width 0.4s ease, background 0.4s ease;
}
.cal-remaining-text {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-1);
  pointer-events: none;
}
.date-label {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-1);
  min-width: 120px;
  text-align: center;
}
.btn-secondary {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-primary {
  flex: 1;
  padding: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
}
.btn-primary:hover { opacity: 0.9; }

/* Today panel */
.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.date-row button {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.date-row button:hover { background: var(--bg-hover); }
.date-label {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
}

.totals-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.total-cell {
  text-align: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 14px 4px;
}
.total-num {
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-1);
}
.total-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.progress-name {
  font-size: 12px;
  color: var(--text-2);
  width: 56px;
  flex-shrink: 0;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-pct {
  font-size: 12px;
  color: var(--text-2);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.meal-list { list-style: none; }
.meal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.meal-item:last-child { border-bottom: none; }
.meal-item-left { flex: 1; min-width: 0; }
.meal-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meal-item-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.meal-item-tag {
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg-input);
  border-radius: 4px;
  padding: 3px 8px;
  white-space: nowrap;
}
.meal-item-cal {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-1);
  white-space: nowrap;
}
.del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.del-btn:hover { color: var(--coral); background: var(--coral-light); }
.edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 1;
}
.edit-btn:hover { color: var(--blue); background: rgba(43,108,176,0.08); }
.meal-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.meal-group-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin: 12px 0 2px;
}
.meal-group-header:first-child { margin-top: 0; }
.meal-group-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.meal-group-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-1);
}
.meal-group-btns {
  display: flex;
  gap: 6px;
  align-items: center;
}
.meal-group-subtotal {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}
.pull-indicator {
  text-align: center;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s, padding 0.2s;
  font-size: 13px;
  color: var(--text-3);
}
.pull-indicator.show {
  max-height: 40px;
  padding: 10px 0;
}
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty-state-icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.empty-state-hint {
  font-size: 13px;
  line-height: 1.5;
}
.meal-item-name[contenteditable] {
  outline: none;
  border-bottom: 1.5px dashed var(--accent);
  cursor: text;
  min-width: 40px;
}
.edit-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.edit-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.edit-modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 14px;
}
.edit-modal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.edit-modal-label {
  font-size: 12px;
  color: var(--text-3);
  width: 60px;
  flex-shrink: 0;
}
.edit-modal-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
}
.edit-modal-input:focus { border-color: var(--border-focus); }
.edit-modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}
.edit-modal-cancel {
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.edit-modal-save {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
}
.date-banner {
  background: var(--amber);
  color: #1A1A1A;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.date-banner-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #1A1A1A;
  padding: 0 4px;
  line-height: 1;
}
.log-today-btn {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.compare-toggle {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.compare-row {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 4px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.compare-row:last-child { border-bottom: none; }
.compare-label { color: var(--text-3); }
.compare-val { text-align: center; font-weight: 500; color: var(--text-1); }
.compare-delta { font-size: 11px; font-weight: 500; }
.compare-delta.up { color: var(--coral); }
.compare-delta.down { color: var(--accent); }
.compare-header {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 4px;
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.undo-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-1);
  color: var(--bg-card);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
  z-index: 100;
}
.undo-toast.show { transform: translateX(-50%) translateY(0); }
.undo-toast button {
  background: none;
  border: none;
  color: var(--accent-light, #68D391);
  font-weight: 600;
  font-size: 14px;
  font-family: var(--font-body);
  cursor: pointer;
  padding: 0;
}
.quick-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.25s ease;
  z-index: 100;
}
.quick-toast.show { transform: translateX(-50%) translateY(0); }
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3);
  font-size: 14px;
}

/* Calibrations */
.cal-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cal-input-field {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
}
.cal-input-field:focus { border-color: var(--border-focus); }
.cal-note-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.cal-note-item:last-child { border-bottom: none; }
.cal-note-text {
  flex: 1;
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.4;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.cal-note-text:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input);
}
.cal-note-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  padding-top: 2px;
}
.save-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.save-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  cursor: pointer;
}
.save-btn:hover { background: var(--bg-hover); }
.flash {
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}
.flash.show { opacity: 1; }

/* Goals */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.goal-cell { display: flex; flex-direction: column; gap: 4px; }
.goal-label { font-size: 11px; color: var(--text-3); }
.goal-pct {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 2px;
  display: block;
}
.goal-input {
  width: 100%;
  padding: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
}
.goal-input:focus { border-color: var(--border-focus); }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-1);
  cursor: pointer;
}
.export-btn:hover { background: var(--bg-hover); }

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--coral);
  cursor: pointer;
  margin-left: 8px;
}
.reset-btn:hover { background: var(--coral-light); }

.info-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* Favorites */
.fav-list { display: flex; flex-direction: column; gap: 6px; }
.fav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.fav-item:hover { background: var(--bg-hover); }
.fav-item-left { flex: 1; min-width: 0; }
.fav-item-name { font-size: 14px; font-weight: 500; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-item-macros { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.fav-item-cal { font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.fav-item-actions { display: flex; gap: 4px; }
.fav-relog { font-size: 12px; font-weight: 500; color: var(--accent); background: var(--accent-light); border: none; border-radius: 4px; padding: 4px 10px; cursor: pointer; white-space: nowrap; }
.fav-relog:hover { opacity: 0.8; }
.fav-remove { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 14px; padding: 4px; }
.fav-remove:hover { color: var(--coral); }

/* Suggest */
.suggest-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  cursor: pointer;
}
.suggest-btn:hover { opacity: 0.85; }
.suggest-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.suggest-result {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-1);
  line-height: 1.7;
  display: none;
}
.suggest-result.show { display: block; animation: slideUp 0.25s ease; }
.suggest-card {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.suggest-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-1);
  margin-bottom: 8px;
}
.suggest-card-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 12px;
}
.suggest-macros {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.suggest-macro-cell { text-align: center; }
.suggest-macro-val {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--text-1);
}
.suggest-macro-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.suggest-macro-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 4px;
  overflow: hidden;
}
.suggest-macro-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.summary-cell {
  text-align: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px 4px;
}
.summary-num {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--text-1);
}
.summary-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.streak-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.streak-pill {
  flex: 1;
  text-align: center;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
}
.streak-num {
  font-size: 18px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--accent);
}
.streak-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}
.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 8px 0;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-legend-pct {
  font-weight: 600;
  color: var(--text-1);
  margin-left: auto;
  min-width: 36px;
  text-align: right;
}
.deficit-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-2);
}
.deficit-val {
  font-weight: 600;
  font-family: var(--font-display);
  font-size: 16px;
}
.deficit-val.surplus { color: var(--coral); }
.deficit-val.deficit { color: var(--accent); }

/* Weight */
.weight-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.weight-text-field {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
}
.weight-text-field:focus { border-color: var(--border-focus); }

/* Theme toggle */
.theme-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.theme-opt {
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: all 0.15s;
}
.theme-opt.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Exercise */
.exercise-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.exercise-text-field {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
}
.exercise-text-field:focus { border-color: var(--border-focus); }
.exercise-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.exercise-item:last-child { border-bottom: none; }
.exercise-name { color: var(--text-1); flex: 1; }
.exercise-cal { color: #22C55E; font-weight: 600; margin: 0 10px; white-space: nowrap; }

/* Recipes */
.recipe-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recipe-item:last-child { border-bottom: none; }
.recipe-item-left { flex: 1; min-width: 0; }
.recipe-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
}
.recipe-item-macros {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.recipe-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}
.recipe-use {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.range-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: 6px;
  padding: 2px;
}
.range-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: 4px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.2s;
}
.range-btn.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Mobile responsive */
@media (max-width: 480px) {
  .container { padding: 16px 14px 100px; }
  .logo { font-size: 22px; }
  .macro-row, .totals-row { grid-template-columns: repeat(2, 1fr); }
  .goals-grid { grid-template-columns: repeat(2, 1fr); }
  .tab-btn { font-size: 12px; padding: 9px 4px; }
  .meal-item { gap: 8px; }
  .meal-item-tag { display: none; }
  .estimate-btn { width: 100%; margin-left: 0; }
  .action-row { flex-direction: column; }
}

/* Animate cards in */
.card { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Auth */
.auth-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 20px;
}
.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.auth-logo {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-1);
  text-align: center;
  margin-bottom: 24px;
}
.auth-logo span { color: var(--accent); }
.auth-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-1);
  outline: none;
  margin-bottom: 10px;
}
.auth-input:focus { border-color: var(--border-focus); }
.auth-btn {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
  margin-top: 4px;
}
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
}
.auth-toggle a {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
.auth-error {
  color: var(--coral);
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
  display: none;
}
.auth-error.show { display: block; }
.auth-signout {
  font-size: 12px;
  color: var(--text-3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
}
.auth-signout:hover { color: var(--coral); }
