/* NutriFast v1.13.0 */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --paper: #EAF3EC;
  --paper-raised: #FFFFFF;
  --ink: #1B1F1C;
  --ink-soft: #5C6B60;
  --line: #DCE7DE;
  --forest: #1E9E4E;
  --forest-deep: #157A3B;
  --leaf: #8FC96B;
  --ochre: #F2A71B;
  --danger: #D64B3D;
  --success: #2CB562;
  --protein: #1E9E4E;
  --carbs: #F2A71B;
  --fat: #8A5A9E;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 88px; position: relative; }
.app::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('../assets/bkg-nutrifast.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.14;
  z-index: -1;
  pointer-events: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.topbar .brand { display: flex; align-items: center; }
.brand-logo { height: 30px; width: auto; }
.topbar .icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-raised); border: 1px solid var(--line);
  color: var(--ink-soft); cursor: pointer;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  background: var(--paper-raised);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 25;
}
.bottom-nav button {
  flex: 1;
  background: none; border: none;
  padding: 10px 0 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink-soft);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.bottom-nav button.active { color: var(--forest); }
.bottom-nav svg { width: 22px; height: 22px; }

.view { display: none; }
.view.active { display: block; }

#auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 28px;
  background-image: url('../assets/bkg-nutrifast.jpg');
  background-size: cover;
  background-position: center;
}
.brand-logo-lockup { height: 52px; width: auto; margin-bottom: 4px; }
#auth-screen h1 { font-family: 'Fraunces', serif; font-size: 32px; font-weight: 700; margin: 0; }
#auth-screen p.tagline { color: var(--ink-soft); margin: 10px 0 28px; font-size: 15px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-raised);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
}
.field input:focus { outline: 2px solid var(--forest); outline-offset: 1px; border-color: var(--forest); }
.field select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper-raised);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
}
.field select:focus { outline: 2px solid var(--forest); outline-offset: 1px; border-color: var(--forest); }
#auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

button.primary {
  width: 100%;
  padding: 15px;
  background: var(--forest);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
button.primary:active { background: var(--forest-deep); }
button.primary:disabled { opacity: 0.5; }

button.link {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 0;
}

.ring-wrap { display: flex; justify-content: center; padding: 8px 20px 4px; }
.ring-center-text { font-family: 'Fraunces', serif; }
.ring-kcal { font-size: 34px; font-weight: 700; }
.ring-goal { font-size: 14px; color: var(--ink-soft); font-family: 'Inter', sans-serif; }
.ring-remaining { font-size: 13px; color: var(--ink-soft); margin-top: 2px; font-family: 'Inter', sans-serif; }

.macro-pills { display: flex; gap: 10px; justify-content: center; padding: 14px 20px 6px; flex-wrap: wrap; }
.macro-pill {
  border: 1.5px solid;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
}
.macro-pill.p { border-color: var(--protein); color: var(--forest-deep); }
.macro-pill.c { border-color: var(--carbs); color: #8a6212; }
.macro-pill.f { border-color: var(--fat); color: #6c3f80; }
.macro-pill.over-goal { border-color: var(--danger); color: var(--danger); background: rgba(214, 75, 61, 0.08); }

.section-label {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--ink-soft); text-transform: uppercase;
  padding: 20px 20px 8px;
}

.feed-list { padding: 0 20px 90px; display: flex; flex-direction: column; gap: 10px; }
.feed-item-wrapper { position: relative; border-radius: var(--radius); overflow: hidden; }
.feed-item-edit-bg {
  position: absolute; top: 0; left: 0; bottom: 0; width: 84px;
  background: var(--forest); display: flex; align-items: center; justify-content: center;
}
.feed-edit-btn { background: none; border: none; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; padding: 10px; }
.feed-item-delete-bg {
  position: absolute; top: 0; right: 0; bottom: 0; width: 84px;
  background: var(--danger); display: flex; align-items: center; justify-content: center;
}
.feed-delete-btn { background: none; border: none; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; padding: 10px; }
.feed-item {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 1;
  touch-action: pan-y;
}
.feed-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.feed-thumb-placeholder {
  width: 52px; height: 52px; border-radius: 10px; background: var(--paper);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.feed-item-info { flex: 1; min-width: 0; }
.feed-item-info .meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 2px; }
.feed-item-info .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-item .kcal { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px; white-space: nowrap; flex-shrink: 0; }

.fab-row {
  position: fixed;
  bottom: 78px;
  left: 20px;
  right: 20px;
  display: flex;
  gap: 12px;
  z-index: 20;
}
.scan-fab, .search-fab {
  flex: 1;
  border: none;
  border-radius: 30px;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  background: var(--forest);
  color: #fff;
  box-shadow: 0 6px 18px rgba(30, 158, 78, 0.35);
}
.scan-fab svg, .search-fab svg { width: 18px; height: 18px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  padding: 40px 30px;
  color: var(--ink-soft);
  font-size: 14px;
}

.week-card {
  margin: 4px 20px 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.week-card .week-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.week-card .week-header .label { font-weight: 700; font-size: 14px; }
.week-card .week-nav { display: flex; gap: 6px; }
.week-card .week-nav button {
  border: none; background: var(--paper); border-radius: 8px;
  width: 28px; height: 28px; cursor: pointer; color: var(--ink-soft);
}
.week-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px; }
.week-grid .day-name { font-size: 11px; color: var(--ink-soft); margin-bottom: 4px; }
.week-grid .day-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; margin: 0 auto 6px;
}
.week-grid .day-num.today { background: var(--ink); color: #fff; font-weight: 700; }
.week-grid .status-dot { width: 7px; height: 7px; border-radius: 50%; margin: 0 auto; }
.status-dot.under { background: var(--success); }
.status-dot.over { background: var(--danger); }
.status-dot.none { background: var(--line); }

.avg-card {
  margin: 14px 20px 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avg-card strong { font-family: 'Fraunces', serif; font-size: 16px; }

.journal-list { padding: 0 20px; display: flex; flex-direction: column; gap: 8px; }
.journal-row {
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.journal-row .day-label { flex: 1; font-size: 14px; font-weight: 500; }
.journal-row .day-kcal { font-family: 'Fraunces', serif; font-weight: 600; font-size: 15px; }

.profile-card {
  margin: 8px 20px 0;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
}
.profile-card h2 { font-family: 'Fraunces', serif; font-size: 17px; margin: 0 0 14px; }
.profile-save-msg { font-size: 12px; color: var(--success); min-height: 16px; margin-top: 6px; }
.logout-btn {
  margin: 20px 20px 0;
  width: calc(100% - 40px);
  padding: 13px;
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--danger);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.sheet-overlay {
  position: fixed; inset: 0; background: rgba(27, 31, 28, 0.5);
  display: flex; align-items: flex-end; z-index: 30;
}
.sheet {
  background: var(--paper);
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 20px 28px;
}
.sheet { position: relative; }
.sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-header h2 { margin: 0; }
.sheet-close-x {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--forest);
  background: none;
  color: var(--forest);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  padding: 0;
}
.sheet-close-x svg { width: 16px; height: 16px; }
.sheet h2 { font-family: 'Fraunces', serif; font-size: 20px; margin: 0 0 14px; }
.sheet img.preview { width: 100%; border-radius: 12px; margin-bottom: 14px; object-fit: cover; max-height: 220px; }
.sheet .status-line { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.entry-items { margin-top: 12px; }
.entry-item-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 6px 0; font-size: 13px;
}
.entry-item-row .item-name { flex: 1; }
.entry-item-row .item-name-edit {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
}
.entry-item-row .grams-edit {
  width: 60px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 6px;
  font-family: inherit;
  font-size: 13px;
  text-align: right;
}
.entry-item-row .item-kcal { width: 64px; text-align: right; color: var(--ink-soft); flex-shrink: 0; }
.confidence-flag {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: rgba(242, 167, 27, 0.16); color: #8a6212; margin-top: 8px;
}
