/* Life Tracker — quiet personal-dashboard styling.
   One accent color, generous whitespace, system fonts, borders over shadows. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-2: #f4f2ee;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e7e3dc;
  --accent: #3f7d6a;
  --accent-weak: #e8f1ee;
  --accent-text: #295445;
  --danger: #b4593f;
  --radius: 14px;
  --radius-sm: 9px;
  --maxw: 1200px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1c2027;
    --surface-2: #232833;
    --text: #e8eaee;
    --muted: #9aa2af;
    --border: #2c313c;
    --accent: #5cb39c;
    --accent-weak: #17322b;
    --accent-text: #8fd3c1;
    --danger: #e08f76;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: 6px;
}

/* ---------- Header / tabs ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px;
  background: var(--accent);
  position: relative; flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0;
  background: no-repeat center/62%
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M4 [...]
}
.brand-name { font-weight: 680; letter-spacing: -0.02em; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 550;
  font-size: 0.94rem;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.tabs a:hover { color: var(--text); background: var(--surface-2); }
.tabs a.active {
  color: var(--accent-text);
  background: var(--accent-weak);
  border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

/* ---------- Layout scaffolding ---------- */
main.container { padding-top: 28px; padding-bottom: 40px; min-height: 60vh; }
.loading { color: var(--muted); }
.view { animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 20px; }
.view-head h2 { font-size: 1.5rem; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 0.95rem; }

.app-footer { padding-bottom: 40px; }
.app-footer p { color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--border); padding-top: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ---------- This Week ---------- */
.day-nav {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.day-nav-label { font-weight: 620; }
.day-nav button {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}
.day-nav button:disabled { opacity: 0.35; cursor: default; }

.week-scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px 6px; }
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(148px, 1fr));
  gap: 12px;
}
.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.day-card.is-today { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.day-card-head { display: flex; align-items: baseline; gap: 8px; }
.day-card-head .dow { font-weight: 680; }
.day-card-head .dom { color: var(--muted); font-size: 0.85rem; }
.day-card-head .today-tag {
  margin-left: auto; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent-text); background: var(--accent-weak);
  padding: 2px 7px; border-radius: 999px;
}
.meals { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.meal { display: flex; flex-direction: column; gap: 2px; }
.meal .slot {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600;
}
.meal .meal-name { font-size: 0.9rem; }
.meal .meal-name-link {
  font-size: 0.9rem;
  color: var(--accent-text);
  cursor: pointer;
  transition: color 0.15s, text-decoration 0.15s;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent);
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}
.meal .meal-name-link:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}
.meal .chip {
  align-self: flex-start;
  margin-top: 3px;
  font-size: 0.72rem;
  color: var(--accent-text);
  background: var(--accent-weak);
  border-radius: 6px;
  padding: 1px 7px;
}
.day-totals {
  margin-top: auto;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  font-size: 0.8rem;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.day-totals strong { font-weight: 650; }
.day-caveat { font-size: 0.68rem; color: var(--muted); }

/* Grocery */
.grocery { margin-top: 26px; }
.grocery-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.grocery-head h3 { font-size: 1.15rem; }
.phase2-note { color: var(--muted); font-size: 0.82rem; margin: 0 0 14px; }
.grocery-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.grocery-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.grocery-group h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.grocery-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.gitem { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.gitem:first-child { border-top: none; }
.gitem input { width: 17px; height: 17px; accent-color: var(--accent); pointer-events: none; }
.gitem.done span { color: var(--muted); text-decoration: line-through; }

/* ---------- Recipes ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar label { color: var(--muted); font-size: 0.88rem; }
select {
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.recipe-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.recipe-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); transform: translateY(-2px); }
.recipe-card h3 { font-size: 1.1rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 0.7rem; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: 2px 9px;
}
.meta-row { color: var(--muted); font-size: 0.82rem; display: flex; gap: 12px; flex-wrap: wrap; }
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: auto; }
.stat { display: flex; flex-direction: column; }
.stat .num { font-weight: 680; font-size: 1.02rem; }
.stat .lbl { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* Recipe detail */
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }
.back-link:hover { color: var(--text); }
.detail-head h2 { font-size: 1.7rem; }
.detail-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; margin-top: 20px; }
.detail-grid h4 { margin-bottom: 10px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ingredients { list-style: none; margin: 0 0 24px; padding: 0; }
.ingredients li { padding: 8px 0; border-top: 1px solid var(--border); font-size: 0.92rem; }
.ingredients li:first-child { border-top: none; }
.steps { margin: 0 0 24px; padding-left: 20px; }
.steps li { padding: 5px 0; }
.notes-box { background: var(--accent-weak); color: var(--accent-text); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.9rem; }
.nutri-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.nutri-table th, .nutri-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.nutri-table th:first-child, .nutri-table td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.nutri-table thead th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Workouts ---------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel h3 { font-size: 1.1rem; margin-bottom: 4px; }
.panel .goal { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }
.pillars { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.pillar { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; }
.pillar h4 { font-size: 0.9rem; margin-bottom: 6px; }
.pillar p { margin: 2px 0; font-size: 0.86rem; color: var(--muted); }
.progress { margin-top: 8px; }
.progress-track { position: relative; height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--muted); opacity: 0.6; }
.progress-legend { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

.session-list { list-style: none; margin: 0; padding: 0; }
.session { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.session:first-child { border-top: none; }
.session .state { width: 22px; height: 22px; border-radius: 999px; flex: none; display: grid; place-items: center; font-size: 0.8rem; border: 1px solid var(--border); color: var(--muted); }
.session .state.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.session .s-main { flex: 1; min-width: 0; }
.session .s-title { font-weight: 600; font-size: 0.92rem; }
.session .s-sub { color: var(--muted); font-size: 0.82rem; }
.type-badge { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; padding: 2px 8px; border-radius: 999px; background: var(--accent-weak); color: var(--accent-text); }

/* ---------- To-dos ---------- */
.todo-group { margin-bottom: 22px; }
.todo-group h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.todo-list { list-style: none; margin: 0; padding: 0; }
.todo { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.todo input { width: 18px; height: 18px; accent-color: var(--accent); pointer-events: none; flex: none; }
.todo.done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo-text { flex: 1; }
.todo-due { font-size: 0.8rem; color: var(--muted); }
.todo-due.soon { color: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .detail-grid { grid-template-columns: 1fr; gap: 8px; }
}

@media (max-width: 640px) {
  .app-header-inner { padding: 10px 16px; }
  .tabs { width: 100%; justify-content: space-between; gap: 2px; }
  .tabs a { padding: 6px 10px; font-size: 0.85rem; }
  .container { padding: 0 16px; }

  .day-nav { display: flex; }
  .week-scroll { overflow: visible; margin: 0; padding: 0; }
  .week-grid { grid-template-columns: 1fr; gap: 0; }
  .day-card { display: none; }
  .day-card.is-selected { display: flex; }

  .meal .meal-name { font-size: 0.98rem; }
  .meal .meal-name-link { font-size: 0.98rem; }
  .gitem { padding: 12px 0; }
  .grocery-groups { grid-template-columns: 1fr; }
}
