*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { transition: background-color 0.2s ease, color 0.2s ease; }
body, #app, .view, nav, .coach-panel { transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }

:root {
  --bg: #0a0908;
  --surface: #141210;
  --surface2: #1e1b18;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.04);
  --text: #e4dace;
  --text-dim: rgba(228,218,206,0.5);
  --text-muted: rgba(228,218,206,0.25);
  --accent: #9a8256;
  --accent-b: #b89d68;
  --nav-h: 68px;
  --serif: 'Playfair Display', Georgia, serif;
  --cal: #b89d68;
  --pro: #6e9fd4;
  --carb: #6fd48e;
  --fat: #d46f6f;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}


#app {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: var(--nav-h);
}
.view::-webkit-scrollbar { width: 0; }

/* NAV */
nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border2);
  display: flex;
  align-items: flex-start;
  padding-top: 10px;
  z-index: 100;
}

.ni {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 7px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: color 0.2s;
  padding: 0;
}
.ni svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ni.active { color: var(--accent-b); }

/* BACK */
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 20px 24px 0;
}
.back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { color: var(--text); }

/* SYNC DOT */
#sync-dot { position:fixed; top:14px; left:14px; width:6px; height:6px; border-radius:50%; z-index:9998; transition:background 0.4s; }
#sync-dot.sync-ok      { background:#6fd48e; }
#sync-dot.sync-pending { background:#b89d68; animation:pulse 1s ease infinite; }
#sync-dot.sync-offline { background:#d46f6f; }

/* ANIMATIONS */
@keyframes fu { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
.ani { animation: fu 0.3s ease both; }
@keyframes viewSlide { from { transform:translateX(16px); } to { transform:translateX(0); } }
.view-slide-in { animation: viewSlide 0.2s cubic-bezier(0.25,0.46,0.45,0.94) forwards; }

/* SHARED */
.sec-lbl { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--text-muted); padding: 16px 24px 8px; }
.page-head { padding: 48px 24px 28px; }
.page-title { font-family: var(--serif); font-size: 32px; color: var(--text); margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text-dim); }

/* HOME */
.h-head { padding: 48px 24px 28px; }
.h-eyebrow { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.h-day { font-family: var(--serif); font-size: 44px; font-style: italic; color: var(--text); line-height: 1.1; }
.h-prog { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.h-prog-track { flex: 1; height: 1px; background: var(--border); overflow: hidden; }
.h-prog-fill { height: 100%; background: var(--accent); transition: width 0.6s ease; }
.h-prog-ct { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.pillars { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 24px 24px; }

.pc {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 24px 12px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  user-select: none;
}
.pc:hover { background: var(--surface2); border-color: var(--border); }

.pc-ring { position: relative; width: 72px; height: 72px; }
.pc-ring > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.pc-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.pc-icon svg { width: 20px; height: 20px; stroke: var(--accent); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.pc-name { font-family: var(--serif); font-size: 17px; color: var(--text); text-align: center; }
.pc-meta { font-size: 10px; color: var(--text-muted); text-align: center; line-height: 1.5; }

/* PILLAR DETAIL */
.pd-head { padding: 20px 24px 24px; display: flex; align-items: flex-start; gap: 18px; border-bottom: 1px solid var(--border2); }
.pd-ring { position: relative; width: 76px; height: 76px; flex-shrink: 0; }
.pd-ring > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.pd-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 14px; color: var(--accent-b); }
.pd-info { flex: 1; padding-top: 4px; }
.pd-name { font-family: var(--serif); font-size: 28px; color: var(--text); margin-bottom: 8px; }
.pd-sep { width: 28px; height: 1px; background: var(--accent); margin-bottom: 10px; }
.pd-desc { font-size: 13px; color: var(--text-dim); line-height: 1.6; }

/* HABIT ROWS */
.hi { display: flex; align-items: center; padding: 15px 24px; border-bottom: 1px solid var(--border2); cursor: pointer; gap: 14px; transition: background 0.15s; }
.hi:hover { background: var(--surface2); }
.hi:last-child { border-bottom: none; }
.hi-info { flex: 1; min-width: 0; }
.hi-name { font-size: 15px; color: var(--text); line-height: 1.3; transition: color 0.2s; }
.hi-streak { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.hi-streak.hot { color: var(--accent); }
.hi-check { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.15); background: none; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; color: transparent; font-size: 11px; transition: all 0.2s; pointer-events: none; }
.habit-del-btn { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid rgba(212,111,111,0.4); background: rgba(212,111,111,0.1); color: #d46f6f; font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: all 0.15s; line-height: 1; }
.habit-del-btn:hover { background: rgba(212,111,111,0.25); border-color: #d46f6f; }
.habit-edit-btn { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid rgba(154,130,86,0.4); background: rgba(154,130,86,0.1); color: var(--accent-b); font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer; transition: all 0.15s; }
.habit-edit-btn:hover { background: rgba(154,130,86,0.25); border-color: var(--accent-b); }
#edit-habit-modal, #edit-name-modal { display: none; position: fixed; inset: 0; z-index: 3000; }
.edit-habit-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.edit-habit-sheet { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); border-radius: 20px 20px 0 0; padding: 28px 24px 40px; }
.edit-habit-title { font-family: var(--serif); font-size: 22px; color: var(--text); margin-bottom: 20px; }
.hi.done .hi-name { color: var(--text-muted); text-decoration: line-through; text-decoration-color: rgba(228,218,206,0.25); }
.hi.done .hi-check { background: rgba(154,130,86,0.18); border-color: var(--accent); color: var(--accent-b); }
@keyframes ck { 0%{transform:scale(1)} 40%{transform:scale(1.3)} 100%{transform:scale(1)} }
.pop { animation: ck 0.22s ease; }

/* ALL HABITS */
.ah-head { padding: 48px 24px 28px; }
.ah-title { font-family: var(--serif); font-size: 32px; color: var(--text); margin-bottom: 4px; }
.ah-sub { font-size: 13px; color: var(--text-dim); }

/* JOURNAL */
.jh { padding: 48px 24px 28px; }
.jh-title { font-family: var(--serif); font-size: 32px; color: var(--text); margin-bottom: 4px; }
.jh-sub { font-size: 13px; color: var(--text-dim); }
.j-body { padding: 0 24px 24px; }
.j-lbl { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--text-muted); padding: 16px 0 10px; }
.j-ta { width: 100%; background: var(--surface); border: 1px solid var(--border2); border-radius: 10px; color: var(--text); font-family: inherit; font-size: 14px; line-height: 1.7; padding: 14px 16px; resize: none; min-height: 90px; outline: none; transition: border-color 0.2s; }
.j-ta:focus { border-color: rgba(154,130,86,0.4); }
.j-ta::placeholder { color: var(--text-muted); }
.j-status { font-size: 11px; color: var(--text-muted); padding: 8px 0 20px; letter-spacing: 0.5px; transition: color 0.3s; }
.j-status.saved { color: var(--accent); }
.j-tog { width: 100%; background: none; border: 1px solid var(--border2); border-radius: 10px; color: var(--text-dim); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; padding: 12px; cursor: pointer; transition: border-color 0.2s; margin-bottom: 16px; }
.j-tog:hover { border-color: var(--border); }
.j-past { display: none; }
.j-past.open { display: block; }
.jp-item { border-bottom: 1px solid var(--border2); padding: 14px 0; }
.jp-item:last-child { border-bottom: none; }
.jp-date { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.jp-field { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); margin: 6px 0 2px; }
.jp-text { font-size: 13px; color: var(--text-dim); line-height: 1.6; white-space: pre-wrap; }

/* STATS */
.sh { padding: 48px 24px 28px; }
.sh-title { font-family: var(--serif); font-size: 32px; color: var(--text); margin-bottom: 4px; }
.sh-sub { font-size: 13px; color: var(--text-dim); }
.s-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 24px 24px; }
.s-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 12px; padding: 20px 16px; }
.s-val { font-family: var(--serif); font-size: 36px; color: var(--accent-b); line-height: 1; margin-bottom: 6px; }
.s-lbl { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }
.ps { padding: 0 24px 24px; }
.ps-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border2); }
.ps-row:last-child { border-bottom: none; }
.ps-name { font-size: 13px; color: var(--text-dim); width: 68px; flex-shrink: 0; }
.ps-track { flex: 1; height: 1px; background: var(--border); overflow: hidden; }
.ps-fill { height: 100%; background: var(--accent); transition: width 0.6s; }
.ps-val { font-size: 11px; color: var(--text-muted); width: 36px; text-align: right; }
.q-block { margin: 0 24px 32px; background: var(--surface); border: 1px solid var(--border2); border-radius: 12px; padding: 24px; text-align: center; }
.q-mark { font-family: var(--serif); font-size: 36px; color: rgba(154,130,86,0.3); line-height: 0.9; margin-bottom: 12px; }
.q-text { font-family: var(--serif); font-size: 15px; font-style: italic; color: var(--text-dim); line-height: 1.7; margin-bottom: 10px; transition: opacity 0.25s; }
.q-auth { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 16px; }
.q-nav { display: flex; align-items: center; justify-content: center; gap: 12px; }
.q-btn { background: none; border: 1px solid var(--border2); color: var(--text-muted); width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 13px; transition: border-color 0.2s, color 0.2s; }
.q-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── WORKOUT ── */
.w-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 20px;
  margin: 0 24px 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.w-card:hover { background: var(--surface2); border-color: var(--border); }
.w-card-name { font-family: var(--serif); font-size: 20px; color: var(--text); margin-bottom: 4px; }
.w-card-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.w-card-days { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.w-card.active { border-color: var(--accent); }

.w-day-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 12px;
}
.w-day-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.w-day-arrow {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 22px;
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s, border-color .15s;
}
.w-day-arrow:active { background: var(--surface2); border-color: var(--accent); }
.w-day-badge {
  display: inline-block;
  background: rgba(154,130,86,0.15);
  color: var(--accent-b);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.w-ex {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  margin: 0 24px 10px;
  overflow: hidden;
}
.w-ex-head {
  padding: 14px 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.w-ex-name { font-size: 15px; color: var(--text); font-weight: 500; }
.w-ex-muscle { font-size: 10px; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.w-set {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.w-set-num { width: 24px; color: var(--text-muted); font-size: 11px; }
.w-input {
  width: 56px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 6px 8px;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}
.w-input::-webkit-inner-spin-button { display: none; }
.w-input:focus { border-color: rgba(154,130,86,0.4); }
.w-input-label { font-size: 10px; color: var(--text-muted); }
.w-set-check {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.12);
  background: none;
  color: transparent;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.w-set-check.done { background: rgba(154,130,86,0.18); border-color: var(--accent); color: var(--accent-b); }

.w-add-set {
  padding: 8px 16px 12px;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  letter-spacing: 0.5px;
}
.w-add-set:hover { color: var(--accent-b); }
.w-set-actions { display: flex; gap: 4px; }

.w-finish, .w-action-btn {
  display: block;
  width: calc(100% - 48px);
  margin: 16px 24px 24px;
  padding: 14px;
  background: rgba(154,130,86,0.15);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent-b);
  font-size: 13px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
}
.w-finish:hover, .w-action-btn:hover { background: rgba(154,130,86,0.25); }

.w-hist-item {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border2);
}
.w-hist-date { font-size: 10px; letter-spacing: 2px; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.w-hist-prog { font-size: 14px; color: var(--text); }
.w-hist-vol { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.w-repeat-btn {
  position: absolute; top: 12px; right: 12px;
  background: var(--surface2); border: 1px solid var(--border2); border-radius: 10px;
  color: var(--accent); font-size: 18px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.w-repeat-btn:active { background: var(--accent); color: #fff; }

/* ── DIET ── */
.d-rings {
  display: flex;
  justify-content: space-around;
  padding: 8px 24px 24px;
}
.d-ring-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.d-ring-wrap { position: relative; width: 64px; height: 64px; }
.d-ring-wrap > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.d-ring-val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}
.d-ring-label { font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }

.d-meal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  margin: 0 24px 10px;
  padding: 14px 16px;
}
.d-meal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.d-meal-name { font-size: 14px; color: var(--text); font-weight: 500; }
.d-meal-cal { font-size: 12px; color: var(--accent); }
.d-meal-macros { font-size: 11px; color: var(--text-muted); }
.d-meal-item { font-size: 12px; color: var(--text-dim); padding: 3px 0; border-top: 1px solid var(--border2); margin-top: 6px; }
.d-meal-item:first-of-type { margin-top: 8px; }

.d-del-btn {
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 0 4px;
}
.d-del-btn:hover { color: var(--fat); }

.d-type-btns { display: flex; gap: 8px; padding: 0 24px 16px; flex-wrap: wrap; }
.d-type-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.d-type-btn.active { background: rgba(154,130,86,0.15); border-color: var(--accent); color: var(--accent-b); }

.d-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
.d-input:focus { border-color: rgba(154,130,86,0.4); }
.d-input::placeholder { color: var(--text-muted); }

.d-input-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.d-input-sm {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px;
  text-align: center;
  outline: none;
  width: 100%;
  -moz-appearance: textfield;
}
.d-input-sm::-webkit-inner-spin-button { display: none; }
.d-input-sm:focus { border-color: rgba(154,130,86,0.4); }
.d-input-sm::placeholder { color: var(--text-muted); font-size: 10px; }

.d-items-list { margin: 12px 0; }
.d-fi { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border2); font-size: 13px; color: var(--text-dim); }
.d-fi:last-child { border-bottom: none; }
.d-fi-macros { font-size: 11px; color: var(--text-muted); }

/* Recipe cards */
.d-recipe-grid { padding: 0 24px 24px; }
.d-recipe-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.2s;
}
.d-recipe-card:hover { background: var(--surface2); }
.d-recipe-name { font-size: 15px; color: var(--text); margin-bottom: 4px; }
.d-recipe-macros-row { font-size: 11px; color: var(--text-muted); }
.d-recipe-detail { padding: 0 24px 24px; }
.d-recipe-ing { font-size: 13px; color: var(--text-dim); line-height: 1.8; }
.d-recipe-steps { font-size: 13px; color: var(--text-dim); line-height: 1.7; margin-top: 12px; }
.d-goals-form { padding: 0 24px 24px; }
.d-goals-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border2); }
.d-goals-row:last-child { border-bottom: none; }
.d-goals-label { font-size: 13px; color: var(--text-dim); width: 80px; flex-shrink: 0; }
.d-goals-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  -moz-appearance: textfield;
}
.d-goals-input::-webkit-inner-spin-button { display: none; }
.d-goals-input:focus { border-color: rgba(154,130,86,0.4); }

/* ── LIBRARY ── */
.lib-tabs {
  display: flex;
  gap: 0;
  margin: 0 24px 20px;
  border-bottom: 1px solid var(--border2);
}
.lib-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.lib-tab.active { color: var(--accent-b); border-bottom-color: var(--accent); }

.book-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 16px;
  margin: 0 24px 10px;
}
.book-title { font-family: var(--serif); font-size: 16px; color: var(--text); margin-bottom: 2px; }
.book-author { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.book-desc { font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.book-card-link { cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.book-card-link:hover { border-color: rgba(154,130,86,0.35); background: var(--surface2); }
.book-link-hint { font-size: 11px; color: var(--accent); margin-top: 8px; letter-spacing: .03em; }
.book-pillar-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: middle;
}

/* ── HOME SUMMARY (legacy, kept for compat) ── */
.h-summary { display: flex; flex-direction: column; gap: 10px; padding: 0 24px 24px; }
.h-sum-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 14px; padding: 16px 18px; cursor: pointer; transition: background 0.2s; }
.h-sum-label { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.h-sum-title { font-family: var(--serif); font-size: 17px; color: var(--text); }

/* ══ HOME REDESIGN ══════════════════════════════════════════════════════ */

/* Hero card */
.hm-hero { padding: 16px 16px 0; }
.hm-hero-card {
  background: linear-gradient(145deg, var(--surface) 0%, rgba(154,130,86,.07) 100%);
  border: 1px solid var(--border2);
  border-radius: 26px;
  padding: 22px 18px 20px;
  position: relative;
  overflow: hidden;
}
.hm-hero-glow {
  position: absolute; top: -50px; right: -50px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.08; pointer-events: none;
}
.hm-hero-row { display: flex; align-items: flex-start; gap: 14px; }
.hm-hero-info { flex: 1; padding-top: 6px; }
.hm-hero-date { font-size: 9px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.hm-hero-name { font-family: var(--serif); font-size: 25px; color: var(--text); line-height: 1.1; margin-bottom: 2px; }
.hm-hero-greet { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.hm-hero-lvl { display: inline-flex; align-items: center; gap: 5px; background: rgba(154,130,86,.12); border: 1px solid rgba(154,130,86,.22); border-radius: 20px; padding: 3px 10px; font-size: 10px; color: var(--accent); font-weight: 700; letter-spacing: .06em; }
.hm-xp-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.hm-xp-track { flex: 1; height: 4px; background: rgba(255,255,255,.07); border-radius: 2px; overflow: hidden; }
.hm-xp-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .6s ease; }
.hm-xp-lbl { font-size: 9px; color: var(--text-muted); white-space: nowrap; }
.hm-score-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.hm-score-badge { display: flex; align-items: baseline; gap: 4px; }
.hm-score-num { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1; }
.hm-score-lbl { font-size: 9px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }
.hm-habits-bar { margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.07); }
.hm-habits-bar-hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; }
.hm-habits-bar-lbl { font-size: 9px; letter-spacing: 2px; text-transform: uppercase; color: var(--text-muted); }
.hm-habits-bar-ct { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.hm-habits-track { height: 6px; background: rgba(255,255,255,.07); border-radius: 3px; overflow: hidden; }
.hm-habits-fill { height: 100%; background: var(--accent-b); border-radius: 3px; transition: width .6s ease; }

/* Pillar strip */
.hm-pillars { display: flex; gap: 4px; padding: 16px 16px 4px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.hm-pillars::-webkit-scrollbar { display: none; }
.hm-pc { flex-shrink: 0; width: 62px; display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 10px 4px; border-radius: 16px; border: 1px solid transparent; transition: all .15s; }
.hm-pc:active { background: rgba(255,255,255,.04); }
.hm-pc-active { border-color: rgba(154,130,86,.25); background: rgba(154,130,86,.06); }
.hm-pc-ring { position: relative; width: 48px; height: 48px; }
.hm-pc-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.hm-pc-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.hm-pc-name { font-size: 8.5px; color: var(--text-muted); text-align: center; text-transform: uppercase; letter-spacing: .4px; }
.hm-pc-streak { font-size: 9px; color: var(--accent); font-weight: 700; }

/* Section heading */
.hm-sec { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px; }
.hm-sec-title { font-size: 9.5px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.hm-sec-link { font-size: 11px; color: var(--accent); cursor: pointer; }

/* Today cards (2-col) */
.hm-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.hm-card { background: var(--surface); border: 1px solid var(--border2); border-radius: 22px; padding: 16px 14px 14px; cursor: pointer; transition: background .15s, border-color .15s; position: relative; overflow: hidden; }
.hm-card:active { background: var(--surface2); }
.hm-card-done { border-color: rgba(154,130,86,.3); }
.hm-card-glow { position: absolute; bottom: -20px; right: -20px; width: 70px; height: 70px; border-radius: 50%; opacity: 0.08; pointer-events: none; }
.hm-card-icon { font-size: 20px; margin-bottom: 10px; }
.hm-card-lbl { font-size: 8.5px; letter-spacing: 1.8px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.hm-card-val { font-family: var(--serif); font-size: 16px; color: var(--text); line-height: 1.25; }
.hm-card-sub { font-size: 10px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.hm-card-status { font-size: 11px; font-weight: 600; margin-top: 10px; }
.hm-card-bar { height: 3px; background: rgba(255,255,255,.06); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.hm-card-fill { height: 100%; border-radius: 2px; }

/* Quest list */
.hm-quest-list { margin: 0 16px; background: var(--surface); border: 1px solid var(--border2); border-radius: 22px; overflow: hidden; }
.hm-quest { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid rgba(255,255,255,.04); }
.hm-quest:last-child { border-bottom: none; }
.hm-quest-ico { width: 36px; height: 36px; background: rgba(255,255,255,.05); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.hm-quest-body { flex: 1; min-width: 0; }
.hm-quest-lbl { font-size: 13px; color: var(--text); line-height: 1.3; }
.hm-quest-xp { font-size: 10px; color: var(--accent-b); font-weight: 700; letter-spacing: .4px; margin-top: 2px; }
.hm-quest-done-row { opacity: .45; }
.hm-quest-done-row .hm-quest-lbl { text-decoration: line-through; }
.hm-quest-cb { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.18); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: transparent; }
.hm-quest-cb-done { background: var(--accent-b); border-color: var(--accent-b); color: var(--bg); }

/* Challenge cards */
.hm-chal-list { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.hm-chal { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; padding: 13px 16px; }
.hm-chal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hm-chal-lbl { font-size: 13px; color: var(--text); }
.hm-chal-ct { font-size: 12px; font-weight: 700; color: var(--accent-b); }
.hm-chal-track { height: 4px; background: rgba(255,255,255,.06); border-radius: 2px; overflow: hidden; }
.hm-chal-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .5s ease; }

/* ── DESCRIBE MEAL ── */
.dm-section {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  padding: 16px;
  margin: 16px 0 4px;
}
.dm-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.dm-icon { color: var(--accent); font-size: 14px; }
.dm-header-text { font-family: var(--serif); font-size: 15px; color: var(--text); flex: 1; }
.dm-header-sub { font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); }
.dm-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding: 12px;
  resize: vertical;
  box-sizing: border-box;
  font-family: inherit;
}
.dm-textarea:focus { outline: none; border-color: var(--accent); }
.dm-textarea::placeholder { color: var(--text-muted); }
.dm-output { margin-top: 4px; }
.dm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border2);
}
.dm-row:last-of-type { border-bottom: none; }
.dm-row-name { font-size: 13px; color: var(--text); flex: 1; }
.dm-row-macros { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.dm-remove {
  background: rgba(212,111,111,0.15);
  border: none;
  border-radius: 50%;
  color: #d46f6f;
  font-size: 16px;
  line-height: 1;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.dm-total { font-size: 12px; color: var(--accent); text-align: right; margin-top: 6px; }
.dm-hint { font-size: 12px; color: var(--text-muted); margin: 10px 0 0; line-height: 1.5; }
.dm-warn { color: #d4916f; }
.h-sum-status { font-size: 12px; color: var(--accent); margin-top: 4px; }

/* ── AI COACH ── */
.coach-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 18px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #0a0908;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(154,130,86,0.4);
  z-index: 900;
  transition: transform 0.18s, box-shadow 0.18s;
}
.coach-fab:hover { transform: scale(1.07); box-shadow: 0 6px 28px rgba(154,130,86,0.55); }
.coach-fab.coach-hidden { display: none; }

.coach-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(10,9,8,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: opacity 0.22s;
}
.coach-overlay.coach-hidden { display: none; }

.coach-panel {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  height: 82vh;
  max-height: 82vh;
  overflow: hidden;
}

.coach-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border2);
  flex-shrink: 0;
}
.coach-hdr-title {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.coach-star { color: var(--accent); }
.coach-hdr-btn {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text-dim);
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.coach-hdr-btn:hover { color: var(--text); border-color: var(--border); }

.coach-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.coach-bubble {
  max-width: 88%;
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
}
.coach-bubble.user {
  background: var(--accent);
  color: #0a0908;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}
.coach-bubble.coach {
  background: var(--surface2);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  border: 1px solid var(--border2);
}
.coach-bubble.coach ul { padding-left: 18px; margin: 6px 0; }
.coach-bubble.coach li { margin-bottom: 4px; }
.coach-bubble.coach strong { color: var(--accent-b); }

.coach-bubble.coach-action {
  background: rgba(154,130,86,0.10);
  border: 1px solid rgba(154,130,86,0.25);
  border-radius: 16px;
  padding: 10px 14px;
  margin: 4px 0;
  max-width: 92%;
}
.coach-action-item {
  font-size: 12px;
  color: var(--accent-b);
  padding: 4px 0;
  line-height: 1.5;
  letter-spacing: 0.02em;
}
.coach-action-item + .coach-action-item {
  border-top: 1px solid rgba(154,130,86,0.12);
  margin-top: 4px;
  padding-top: 8px;
}

.coach-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 12px 15px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  align-self: flex-start;
  width: 56px;
}
.coach-typing span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: coach-bounce 1.2s ease-in-out infinite;
}
.coach-typing span:nth-child(2) { animation-delay: 0.18s; }
.coach-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes coach-bounce { 0%,80%,100%{transform:translateY(0)} 40%{transform:translateY(-6px)} }

.coach-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border2);
  flex-shrink: 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.coach-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  color: var(--text);
  font-size: 14px;
  padding: 11px 14px;
  resize: none;
  overflow: hidden;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}
.coach-input:focus { outline: none; border-color: var(--accent); }
.coach-input::placeholder { color: var(--text-muted); }
.coach-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #0a0908;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}
.coach-send:disabled { opacity: 0.4; cursor: default; }
.coach-send:not(:disabled):hover { transform: scale(1.08); }

.coach-welcome {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-dim);
}
.coach-welcome-star { font-size: 32px; color: var(--accent); margin-bottom: 12px; }
.coach-welcome h3 { font-family: var(--serif); font-size: 20px; color: var(--text); margin-bottom: 8px; }
.coach-welcome p { font-size: 13px; line-height: 1.6; }
.coach-setup-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin: 20px;
  text-align: center;
}
.coach-setup-card h3 { font-family: var(--serif); font-size: 17px; color: var(--text); margin-bottom: 8px; }
.coach-setup-card p { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 12px; }

/* ═══ REST TIMER ═══════════════════════════════════════════════════════════ */
.rt-bar {
  position: sticky;
  bottom: 80px;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid rgba(154,130,86,0.3);
  border-radius: 16px;
  margin: 12px 24px;
  padding: 12px 16px;
  z-index: 10;
}
.rt-row { display: flex; align-items: center; gap: 12px; }
.rt-time {
  font-family: var(--serif);
  font-size: 24px;
  color: var(--accent-b);
  font-weight: 700;
  min-width: 52px;
}
.rt-track { flex: 1; height: 5px; background: rgba(255,255,255,0.06); border-radius: 3px; overflow: hidden; }
.rt-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.rt-skip {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 11px; padding: 5px 12px; border-radius: 100px; cursor: pointer;
  transition: background 0.15s;
}
.rt-skip:active { background: var(--surface2); }
.rt-done {
  text-align: center; font-size: 12px; letter-spacing: 2px;
  text-transform: uppercase; color: var(--accent-b); font-weight: 700;
  animation: rt-pulse 0.5s ease;
}
@keyframes rt-pulse { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.rt-presets {
  display: flex; align-items: center; gap: 8px; padding: 8px 24px 16px; justify-content: center;
}
.rt-preset-btn {
  background: var(--surface); border: 1px solid var(--border2); color: var(--text-dim);
  font-size: 12px; padding: 7px 14px; border-radius: 100px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.rt-preset-btn:active { background: var(--surface2); border-color: var(--accent); color: var(--accent-b); }

/* ═══ SLEEP TRACKING ═══════════════════════════════════════════════════════ */
.sl-q-row { display: flex; gap: 6px; }
.sl-q-btn {
  flex: 1; padding: 10px; text-align: center; font-size: 16px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 12px;
  color: var(--text-dim); cursor: pointer; transition: all 0.15s;
}
.sl-q-btn.active { background: rgba(154,130,86,0.15); border-color: var(--accent); color: var(--accent-b); }
.sl-bars { display: flex; gap: 4px; align-items: flex-end; height: 80px; }
.sl-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; }
.sl-bar-val { font-size: 9px; color: var(--text-muted); height: 14px; }
.sl-bar-track { flex: 1; width: 100%; background: rgba(255,255,255,0.04); border-radius: 4px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.sl-bar-fill { border-radius: 4px; transition: height 0.3s; min-height: 2px; }
.sl-bar-day { font-size: 9px; color: var(--text-muted); height: 14px; text-transform: uppercase; }

/* ═══ HEATMAP ══════════════════════════════════════════════════════════════ */
.hm-heatmap { display: flex; align-items: center; gap: 6px; padding: 8px 24px 16px; overflow-x: auto; }
.hm-heat-label { font-size: 9px; color: var(--text-muted); flex-shrink: 0; }
.hm-heat-grid {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  gap: 2px;
}
.hm-heatcell { width: 10px; height: 10px; border-radius: 2px; }
.hm-heat-0 { background: rgba(255,255,255,0.04); }
.hm-heat-1 { background: rgba(154,130,86,0.2); }
.hm-heat-2 { background: rgba(154,130,86,0.4); }
.hm-heat-3 { background: rgba(154,130,86,0.65); }
.hm-heat-4 { background: rgba(154,130,86,0.9); }

/* ═══ HOME QUOTE ═══════════════════════════════════════════════════════════ */
.hm-quote {
  margin: 0 16px 16px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 22px;
}
.hm-quote-text {
  font-family: var(--serif); font-size: 14px; font-style: italic;
  color: var(--text-dim); line-height: 1.65; margin-bottom: 8px;
}
.hm-quote-auth { font-size: 11px; color: var(--text-muted); }

/* ═══ SPARKLINE ════════════════════════════════════════════════════════════ */
.w-sparkline { flex-shrink: 0; opacity: 0.8; }

/* ═══ LIGHT THEME ══════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:       #faf8f5;
  --bg2:      #f4f1ec;
  --surface:  #ffffff;
  --surface2: #f0ece4;
  --border:   rgba(0,0,0,0.08);
  --border2:  rgba(0,0,0,0.05);
  --accent:   #7a6840;
  --accent-b: #9a8256;
  --accent-c: #6b5930;
  --text:     #1a1810;
  --text-dim: #5c5648;
  --text-muted: #9a9488;
}
[data-theme="light"] nav {
  background: rgba(250,248,245,0.9) !important;
}
[data-theme="light"] .coach-panel {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .coach-bubble.coach {
  background: #f4f1ec;
  border-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .w-input {
  background: #f4f1ec;
  border-color: rgba(0,0,0,0.08);
  color: #1a1810;
}
[data-theme="light"] .hm-heat-0 { background: rgba(0,0,0,0.04); }
[data-theme="light"] .hm-heat-1 { background: rgba(122,104,64,0.15); }
[data-theme="light"] .hm-heat-2 { background: rgba(122,104,64,0.30); }
[data-theme="light"] .hm-heat-3 { background: rgba(122,104,64,0.50); }
[data-theme="light"] .hm-heat-4 { background: rgba(122,104,64,0.75); }
[data-theme="light"] .ob-welcome, [data-theme="light"] .ob-wrap {
  background: #faf8f5;
}

/* ═══ ONBOARDING GENDER ═══════════════════════════════════════════════════ */
.ob-gender-row { display: flex; gap: 16px; justify-content: center; margin-top: 24px; }
.ob-gender-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 24px;
  padding: 24px 32px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.ob-gender-card.active {
  border-color: var(--accent);
  background: rgba(154,130,86,0.08);
}
.ob-gender-card:active { transform: scale(0.97); }

/* ═══ FOOD PHOTO SCAN ═════════════════════════════════════════════════════ */
.photo-scan-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(154,130,86,0.15), rgba(154,130,86,0.06));
  border: 1.5px dashed var(--accent); border-radius: 16px;
  color: var(--accent); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.2s, transform 0.15s;
}
.photo-scan-btn:active { transform: scale(0.97); }
.photo-scan-btn svg { flex-shrink: 0; }
.photo-preview {
  margin-bottom: 16px; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--border2); position: relative;
}
.food-photo-img {
  width: 100%; display: block; border-radius: 16px;
  max-height: 220px; object-fit: cover;
}
.photo-preview .spinner-overlay {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,0.45); border-radius: 16px;
  color: var(--accent); font-size: 13px; font-weight: 600;
  gap: 8px;
}
.photo-preview .spinner-overlay::before {
  content: ''; width: 20px; height: 20px;
  border: 2.5px solid rgba(154,130,86,0.3);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ HABIT CHECK ANIMATION ═══════════════════════════════════════════════ */
.hi-check { position: relative; overflow: visible; }
.hi.done .hi-check::after {
  content: ''; position: absolute; inset: -8px; border-radius: 50%;
  background: rgba(154,130,86,0.25);
  animation: ripple-out 0.5s ease-out forwards;
  pointer-events: none;
}
@keyframes ripple-out {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}
@keyframes check-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  50% { transform: scale(0.9); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.pop { animation: check-bounce 0.35s ease !important; }

/* ═══ SKELETON LOADING ════════════════════════════════════════════════════ */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-card { height: 120px; margin: 8px 16px; }
.skel-row { height: 52px; margin: 4px 24px; border-radius: 8px; }
.skel-circle { width: 72px; height: 72px; border-radius: 50%; margin: 12px auto; }
.skel-bar { height: 14px; margin: 8px 24px; width: 60%; }

/* ═══ UNDO TOAST ══════════════════════════════════════════════════════════ */
.undo-toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 20px; display: flex; align-items: center; gap: 14px;
  z-index: 2500; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: toast-in 0.3s ease;
  max-width: 360px; width: calc(100% - 48px);
}
.undo-toast-text { flex: 1; font-size: 13px; color: var(--text); }
.undo-toast-btn {
  background: none; border: none; color: var(--accent-b); font-weight: 700;
  font-size: 13px; cursor: pointer; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 4px 8px; white-space: nowrap;
}
@keyframes toast-in {
  0% { transform: translateX(-50%) translateY(20px); opacity: 0; }
  100% { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ═══ QUICK-LOG FAB ═══════════════════════════════════════════════════════ */
.quick-log-fab {
  position: fixed; bottom: calc(var(--nav-h) + 20px); left: max(16px, calc(50% - 240px + 16px));
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 1500;
  box-shadow: 0 4px 20px rgba(154,130,86,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}
.quick-log-fab:active { transform: scale(0.92); }
.quick-log-fab.open { transform: rotate(45deg); }
.quick-log-menu {
  position: fixed; bottom: calc(var(--nav-h) + 82px); left: max(16px, calc(50% - 240px + 16px));
  display: flex; flex-direction: column; gap: 8px; z-index: 1500;
  animation: fab-in 0.2s ease;
}
.quick-log-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 10px 16px; cursor: pointer;
  font-size: 13px; color: var(--text); font-weight: 600;
  white-space: nowrap; transition: background 0.15s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.quick-log-item:active { background: var(--accent); color: #fff; }
@keyframes fab-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ═══ EVENING REMINDER BANNER ═════════════════════════════════════════════ */
.evening-banner {
  margin: 0 16px 12px; padding: 14px 18px;
  background: linear-gradient(135deg, rgba(184,157,104,0.12), rgba(184,157,104,0.04));
  border: 1px solid rgba(184,157,104,0.2); border-radius: 16px;
  display: flex; align-items: center; gap: 12px;
  animation: fade-in 0.4s ease;
}
.evening-banner-text { flex: 1; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.evening-banner-text strong { color: var(--accent-b); }
.evening-banner-close {
  background: none; border: none; color: var(--text-muted); font-size: 18px;
  cursor: pointer; padding: 4px;
}
@keyframes fade-in { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ═══ STREAK MILESTONE TOAST ══════════════════════════════════════════════ */
.streak-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg); border: 2px solid var(--accent);
  border-radius: 24px; padding: 32px 40px; text-align: center;
  z-index: 5000; box-shadow: 0 0 80px rgba(154,130,86,0.3);
  animation: streak-pop 0.5s cubic-bezier(0.17,0.67,0.35,1.5);
}
.streak-toast-icon { font-size: 48px; margin-bottom: 8px; }
.streak-toast-title { font-family: var(--serif); font-size: 24px; color: var(--accent-b); }
.streak-toast-sub { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.streak-toast-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 4999; }
@keyframes streak-pop {
  0% { transform: translate(-50%,-50%) scale(0.3); opacity: 0; }
  100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
}

/* ═══ EMPTY STATES ════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center; padding: 48px 32px;
}
.empty-state-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state-title { font-family: var(--serif); font-size: 18px; color: var(--text); margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 20px; }
.empty-state-btn {
  display: inline-block; padding: 12px 24px; background: var(--accent);
  color: #fff; border: none; border-radius: 12px; font-size: 13px;
  font-weight: 600; cursor: pointer; letter-spacing: 0.5px;
}

/* ═══ PULL TO REFRESH ═════════════════════════════════════════════════════ */
.ptr-indicator {
  text-align: center; padding: 12px; font-size: 11px;
  color: var(--accent); letter-spacing: 1px;
  text-transform: uppercase; font-weight: 600;
}

/* ═══ ANIMATED AVATAR BREATHING ══════════════════════════════════════ */
.hm-hero-card svg { animation: avatar-breathe 3s ease-in-out infinite; transform-origin: bottom center; }
@keyframes avatar-breathe {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.02) translateY(-1px); }
}

/* ═══ QUICK-LOG FAB Z-INDEX ══════════════════════════════════════════ */
.quick-log-fab { z-index: 900; }

/* ═══ OFFLINE BANNER ═════════════════════════════════════════════════ */
.offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 2000;
  padding: 8px 16px; font-size: 12px; text-align: center;
  background: rgba(30,27,24,0.95); color: var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.3px;
}

/* ═══ WORKOUT ELAPSED TIMER ══════════════════════════════════════════ */
.workout-elapsed-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 100px; font-size: 13px;
  background: var(--surface2); color: var(--accent-b);
  font-variant-numeric: tabular-nums; font-weight: 600;
  margin-right: 24px; margin-top: 16px;
}
.workout-elapsed-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-b); animation: pulse-dot 1.5s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══ SEARCH INPUT ═══════════════════════════════════════════════════ */
.search-input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text); font-size: 13px; outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); }

/* ═══ TREND BADGES ═══════════════════════════════════════════════════ */
.trend-badge {
  font-size: 10px; font-weight: 700; padding: 2px 6px;
  border-radius: 6px; margin-top: 4px; display: inline-block;
}
.trend-up { color: #4ade80; background: rgba(74,222,128,0.1); }
.trend-down { color: #f87171; background: rgba(248,113,113,0.1); }
.trend-flat { color: var(--text-dim); background: var(--surface2); }

/* ═══ HABIT MOVE BUTTONS ═════════════════════════════════════════════ */
.habit-move-btn {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-dim); font-size: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.habit-move-btn:disabled { opacity: 0.25; cursor: default; }
.habit-move-btn:active:not(:disabled) { background: var(--accent); color: #fff; }

/* ═══ SCHEDULE DAY PICKER ═══════════════════════════════════════════ */
.sched-day-row { display: flex; gap: 6px; }
.sched-day-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border2);
  color: var(--text-dim); font-size: 11px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.sched-day-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ═══ FOOD SEARCH RESULTS ═══════════════════════════════════════════ */
.food-result {
  padding: 10px 14px; border-radius: 10px;
  background: var(--surface2); border: 1px solid var(--border2);
  cursor: pointer; transition: border-color 0.15s;
}
.food-result:active { border-color: var(--accent); }
.food-result-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.food-result-macros {
  font-size: 11px; color: var(--text-dim); margin-top: 2px;
}

/* ═══ PLATE CALCULATOR ══════════════════════════════════════════════ */
.plate-chip {
  display: inline-block; padding: 4px 10px; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 12px;
  font-weight: 700; margin: 3px 4px 3px 0;
}

/* ═══ PROGRESS PHOTOS ══════════════════════════════════════════════ */
.progress-photo-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.progress-photo-card {
  background: var(--surface); border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.05); cursor: pointer;
  transition: transform 0.15s;
}
.progress-photo-card:active { transform: scale(0.97); }
.progress-photo-img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block;
}
.progress-photo-date {
  padding: 8px 10px 4px; font-size: 11px; color: var(--text-dim);
}
.progress-photo-note {
  padding: 0 10px 8px; font-size: 11px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w-ex-info {
  padding: 8px 0 4px; border-bottom: 1px solid rgba(255,255,255,0.04);
  margin-bottom: 4px;
}
