/* Weight Loss Adventure — warm, rounded, low-contrast "neo-humanist wellness" theme. */
:root {
  --bg: #f4ebdf;            /* warm cream */
  --bg-2: #efe4d4;
  --card: #fffaf2;          /* soft off-white */
  --card-2: #f3e8d8;        /* sand */
  --text: #5a4f45;          /* warm soft brown (not black → low contrast) */
  --text-strong: #4a4039;
  --muted: #a99a89;
  --sage: #7ea27e;          /* primary: gentle sage green */
  --sage-deep: #5f8a64;
  --terra: #e0a17c;         /* accent: soft terracotta */
  --terra-deep: #cf855e;
  --peach: #f0cdb0;
  --honey: #e7bd72;         /* warn / "close" */
  --clay: #cd8478;          /* gentle danger */
  --line: #ece0cf;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 6px 22px rgba(150, 120, 90, 0.14);
  --shadow-sm: 0 3px 10px rgba(150, 120, 90, 0.12);
  --font: "ui-rounded", "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Quicksand",
          "Comfortaa", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.1px;
}
body { padding-bottom: env(safe-area-inset-bottom); }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.row { display: flex; gap: 10px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.full { width: 100%; }

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, #fbf3e7 0%, var(--bg) 70%);
}
.login-card {
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}
.login-logo { font-size: 3rem; }
.brand { font-size: 1.5rem; margin: 8px 0 4px; color: var(--text-strong); font-weight: 700; }
.who-buttons { display: flex; gap: 16px; margin-top: 22px; justify-content: center; }
.who {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 130px;
  padding: 24px 14px;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-strong);
  background: var(--card-2);
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, background 0.14s;
}
.who:hover { transform: translateY(-3px); border-color: var(--sage); background: #fbf4ea; }
.who-emoji { font-size: 2.2rem; }
.gate-input {
  width: 100%; margin: 16px 0 12px;
  background: var(--card-2); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; outline: none; text-align: center;
}
.gate-input:focus { border-color: var(--sage); }
.gate-error { color: var(--clay); font-size: 0.85rem; min-height: 1.1em; margin-top: 8px; }

/* ---------- App shell ---------- */
.app { max-width: 620px; margin: 0 auto; padding: 0 14px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 4px 10px;
  background: linear-gradient(var(--bg) 70%, rgba(244, 235, 223, 0));
}
.topbar-title { font-weight: 700; color: var(--text-strong); }
.topbar-title span { font-size: 0.92rem; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.streak-chip {
  background: linear-gradient(135deg, var(--honey), var(--terra));
  color: #5a3d28; font-weight: 700; font-size: 0.82rem;
  padding: 6px 11px; border-radius: 999px; box-shadow: var(--shadow-sm);
}

.ghost-btn {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 1rem; cursor: pointer; font-family: inherit;
}
.ghost-btn:hover { background: var(--card-2); }
.ghost-btn.round { width: 42px; height: 42px; padding: 0; font-size: 1.3rem; }
.ghost-btn.full { width: 100%; margin-top: 6px; }

.tabs {
  display: flex; gap: 6px;
  position: sticky; top: 52px; z-index: 4;
  background: var(--bg); padding: 2px 0 10px;
}
.tab {
  flex: 1; padding: 10px 4px;
  font-size: 0.82rem; font-weight: 600; font-family: inherit;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
  transition: all 0.15s;
}
.tab.active { color: #fff; background: var(--sage); border-color: var(--sage); box-shadow: var(--shadow-sm); }

.tabpane { display: none; animation: fade 0.22s ease; }
.tabpane.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 12px; font-size: 1.08rem; color: var(--text-strong); }
.card h3 { margin: 0 0 10px; font-size: 0.96rem; color: var(--text-strong); }
.center-card { text-align: center; }
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- Inputs ---------- */
input, select, button { font-family: inherit; font-size: 1rem; }
.date-input, .select, .addform input, .search-row input, .portion-controls input,
#manualBarcode input {
  background: var(--card-2); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; outline: none;
}
.date-input:focus, .select:focus, input:focus { border-color: var(--sage); }
.select { cursor: pointer; }
.addform { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.addform input[type="number"] { width: 110px; flex: 0 0 auto; }
.addform input[type="text"] { flex: 1; min-width: 120px; }
.addform input[type="date"] { flex: 1; min-width: 130px; }
.primary {
  background: var(--sage); color: #fff; font-weight: 700;
  border: none; border-radius: var(--radius-sm); padding: 11px 18px; cursor: pointer;
  transition: background 0.15s;
}
.primary:hover { background: var(--sage-deep); }
.icon-btn {
  background: var(--peach); border: none; border-radius: var(--radius-sm);
  padding: 0 14px; font-size: 1.3rem; cursor: pointer;
}
.icon-btn:hover { background: var(--terra); }

/* ---------- Calorie ring ---------- */
.ring-wrap { position: relative; width: 200px; height: 200px; margin: 4px auto 14px; }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-total { font-size: 2.5rem; font-weight: 800; line-height: 1; color: var(--text-strong); }
.badge {
  font-weight: 700; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--card-2); color: var(--text);
}
.badge.good { background: #e7f0e2; color: var(--sage-deep); }
.badge.over { background: #f6e2dd; color: var(--clay); }
.badge.close { background: #f7ecd6; color: #b78a3c; }

/* ---------- Food search ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input { flex: 1; }
.result-list { list-style: none; margin: 6px 0 0; padding: 0; }
.result-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; margin-bottom: 6px;
  background: var(--card-2); border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.12s;
}
.result-list li:hover { background: var(--peach); }
.result-main { display: flex; flex-direction: column; min-width: 0; }
.result-name { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sub { color: var(--muted); font-size: 0.8rem; }
.result-kcal { font-weight: 700; color: var(--terra-deep); white-space: nowrap; }

.chip-group { margin-top: 12px; }
.chip-label { font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 13px; font-size: 0.86rem; font-weight: 600; color: var(--text);
  cursor: pointer; transition: background 0.12s;
}
.chip:hover { background: var(--peach); }

.manual { margin-top: 14px; }
.manual summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; padding: 6px 0; }
.manual[open] summary { margin-bottom: 8px; }

/* ---------- Entry lists ---------- */
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.entry-list li:last-child { border-bottom: none; }
.entry-main { display: flex; flex-direction: column; min-width: 0; }
.entry-amt { font-weight: 700; color: var(--text-strong); }
.entry-note { color: var(--muted); font-size: 0.82rem; }
.del-btn {
  background: transparent; color: var(--muted); border: none;
  font-size: 1.05rem; cursor: pointer; padding: 4px 8px;
}
.del-btn:hover { color: var(--clay); }
.empty { color: var(--muted); text-align: center; padding: 16px; }

/* ---------- Charts ---------- */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--muted); font-size: 10px; }
.chart .line { fill: none; stroke: var(--terra-deep); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: rgba(224, 161, 124, 0.16); }
.chart .dot { fill: var(--terra-deep); }
.chart .target-line { stroke: var(--sage); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .goal-line { stroke: var(--honey); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .bar { fill: var(--sage); }
.chart .bar.over { fill: var(--clay); }

/* ---------- Couples ---------- */
.couples-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.couple-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 14px;
  box-shadow: var(--shadow-sm); text-align: center;
}
.couple-card.leading { outline: 2px solid var(--sage); }
.couple-emoji { font-size: 2rem; }
.couple-name { font-weight: 700; color: var(--text-strong); margin: 2px 0 8px; }
.couple-mini-ring { width: 92px; height: 92px; margin: 0 auto 8px; }
.couple-num { font-weight: 800; font-size: 1.2rem; color: var(--text-strong); }
.couple-sub { font-size: 0.8rem; color: var(--muted); }
.couple-streak { margin-top: 6px; font-size: 0.82rem; font-weight: 600; color: var(--terra-deep); }

/* ---------- App views / home menu ---------- */
.appview { display: none; animation: fade 0.22s ease; }
.appview.active { display: block; }

.hello { font-size: 1.4rem; font-weight: 700; color: var(--text-strong); margin: 6px 2px 14px; }

.widgets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.widget {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 14px 10px; cursor: pointer; text-align: center;
  font-family: inherit; transition: transform 0.12s;
}
.widget:hover { transform: translateY(-2px); }
.widget-emoji { font-size: 1.5rem; }
.widget-num { font-size: 1.6rem; font-weight: 800; color: var(--text-strong); line-height: 1.1; }
.widget-label { font-size: 0.76rem; color: var(--muted); }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px 14px; cursor: pointer; text-align: left;
  font-family: inherit; display: flex; flex-direction: column; gap: 4px;
  transition: transform 0.12s, border-color 0.12s; min-height: 116px;
}
.tile:hover { transform: translateY(-3px); border-color: var(--sage); }
.tile-emoji { font-size: 2rem; }
.tile-name { font-weight: 700; color: var(--text-strong); }
.tile-sub { font-size: 0.78rem; color: var(--muted); }

/* ---------- Shared check-lists (groceries / chores / bucket) ---------- */
.full-input {
  width: 100%; background: var(--card-2); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; outline: none; margin-bottom: 8px;
}
.full-input:focus { border-color: var(--sage); }
.chore-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.chore-opts .select, .chore-opts .date-input { flex: 1; min-width: 92px; padding: 9px 10px; }
.small-btn { padding: 6px 12px; font-size: 0.82rem; }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.check-item:last-child { border-bottom: none; }
.check-box {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 999px;
  border: 2px solid var(--sage); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; color: #fff; transition: background 0.12s;
}
.check-box.checked { background: var(--sage); }
.check-body { flex: 1; min-width: 0; }
.check-title { font-weight: 600; color: var(--text-strong); }
.check-sub { font-size: 0.78rem; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.check-item.done .check-title { text-decoration: line-through; color: var(--muted); }
.tag {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--card-2); color: var(--muted);
}
.tag.tyler { background: #e7f0e2; color: var(--sage-deep); }
.tag.hali { background: #f7ecd6; color: #b78a3c; }
.tag.either { background: var(--peach); color: var(--terra-deep); }
.tag.recur { background: #e6eef5; color: #5a7d99; }
.tag.due { background: #f6e2dd; color: var(--clay); }
.tag.due.ok { background: var(--card-2); color: var(--muted); }

/* ---------- Settings ---------- */
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: none; }
.setting-row label { font-weight: 600; color: var(--text-strong); }
.setting-row input { width: 110px; background: var(--card-2); border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; }

.spade-head { display: flex; align-items: center; gap: 14px; }
.spade-emoji { font-size: 2.6rem; }
.foot { text-align: center; padding: 16px 0; }
code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; }

/* ---------- Overlays / sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(74, 64, 57, 0.38);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade 0.18s ease;
}
.sheet {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 26px 26px 0 0; padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(120, 90, 60, 0.22);
  animation: slideUp 0.22s ease;
}
@keyframes slideUp { from { transform: translateY(40px); } to { transform: translateY(0); } }
.sheet-handle { width: 44px; height: 5px; background: var(--line); border-radius: 999px; margin: 2px auto 12px; }
.sheet h3 { margin: 0 0 4px; color: var(--text-strong); }
.portion-controls { display: flex; gap: 12px; align-items: center; margin: 16px 0 8px; }
.portion-controls input { width: 100px; font-size: 1.2rem; text-align: center; }
.unit-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.unit-opt {
  padding: 9px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card-2); cursor: pointer; font-weight: 600; font-size: 0.9rem; color: var(--text);
}
.unit-opt.active { background: var(--sage); color: #fff; border-color: var(--sage); }
.portion-kcal { font-size: 1.8rem; font-weight: 800; color: var(--terra-deep); margin: 6px 0 14px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.sheet-actions .primary { flex: 1; min-width: 130px; }
.reader { width: 100%; border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 10px; background: #000; min-height: 60px; }
#manualBarcode { margin-top: 8px; }
#manualBarcode input { flex: 1; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--text-strong); color: #fff;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow);
  z-index: 40; opacity: 1; transition: opacity 0.3s; font-weight: 600; font-size: 0.9rem;
}
.toast.fade { opacity: 0; }

@media (max-width: 360px) {
  .who { width: 120px; }
  .tab { font-size: 0.76rem; }
}
