/* ===== FORGE — Apple-inspired design system. Dark, smooth, fast. ===== */
:root {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --border: #38383a;
  --hair: rgba(255,255,255,.07);
  --text: #ffffff;
  --muted: #98989f;
  --muted-2: #6c6c70;
  --accent: #ff6b00;        /* forge orange */
  --accent-2: #ff9d2e;
  --green: #30d158;
  --blue: #0a84ff;
  --red: #ff453a;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
  --r: 20px;
  --spring: cubic-bezier(.34,1.56,.64,1);
  --ease: cubic-bezier(.4,0,.2,1);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { background: var(--bg); color: var(--text); height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { user-select: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.hidden { display: none !important; }
input, button, textarea, select { font-family: inherit; }
button { cursor: pointer; transition: transform .12s var(--ease); }
button:active { transform: scale(.95); }

#app { display: flex; flex-direction: column; min-height: 100dvh; max-width: 520px; margin: 0 auto; }

/* ---------- Header ---------- */
.app-header { display: flex; align-items: center; justify-content: space-between; padding: calc(16px + var(--safe-top)) 20px 8px; }
.header-left { display: flex; align-items: center; gap: 13px; }
.logo { width: 42px; height: 42px; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #1a0e00; font-weight: 900; font-size: 25px; display: grid; place-items: center; border-radius: 13px; box-shadow: 0 4px 16px rgba(255,107,0,.35); }
.header-titles h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; }
.header-titles p { font-size: 13px; margin-top: 0; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 9px; }
.icon-btn { background: var(--surface); border: none; border-radius: 12px; width: 40px; height: 40px; font-size: 18px; color: var(--text); }
.streak { display: flex; align-items: center; gap: 5px; background: var(--surface); padding: 9px 13px; border-radius: 999px; }
.streak-num { font-weight: 800; font-size: 16px; }
.streak-flame { filter: drop-shadow(0 0 6px rgba(255,107,0,.5)); }

/* ---------- Mission progress ---------- */
.day-progress-wrap { padding: 6px 20px 14px; }
.day-progress-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.day-progress-track { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.day-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .9s var(--ease); }

/* ---------- Views ---------- */
.view { display: none; flex: 1; padding: 0 16px 110px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view.active { display: block; animation: viewIn .4s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.view-h { font-size: 30px; font-weight: 800; letter-spacing: -0.8px; padding: 8px 4px 16px; }
.sub-h { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; margin: 26px 4px 12px; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 4px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; background: var(--surface); border: none; color: var(--muted); padding: 10px 15px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: all .22s var(--spring); }
.chip-active { background: var(--accent); color: #1a0e00; transform: scale(1.04); box-shadow: 0 4px 14px rgba(255,107,0,.3); }
.chip-toggle { margin-left: auto; }
.chip-toggle[data-gym="0"] { opacity: .5; }

/* ---------- Activity rings card (Apple-style) ---------- */
.rings-card { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: var(--r); padding: 20px 18px; margin-bottom: 14px; }
.rings-graphic { flex: 0 0 132px; width: 132px; height: 132px; }
.aring { width: 100%; height: 100%; transform: rotate(-90deg); }
.aring .track { fill: none; stroke-width: 13; }
.aring .t-day  { stroke: rgba(255,107,0,.18); }
.aring .t-prot { stroke: rgba(48,209,88,.18); }
.aring .t-biz  { stroke: rgba(10,132,255,.18); }
.aring .prog { fill: none; stroke-width: 13; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 1s var(--ease); }
.aring .p-day  { stroke: var(--accent); filter: drop-shadow(0 0 5px rgba(255,107,0,.5)); }
.aring .p-prot { stroke: var(--green);  filter: drop-shadow(0 0 5px rgba(48,209,88,.5)); }
.aring .p-biz  { stroke: var(--blue);   filter: drop-shadow(0 0 5px rgba(10,132,255,.5)); }
.rings-stats { flex: 1; display: flex; flex-direction: column; gap: 14px; padding-left: 6px; }
.rstat { display: flex; flex-direction: column; gap: 1px; }
.rlabel { font-size: 13px; color: var(--muted); font-weight: 600; }
.rval { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.rval small { font-size: 13px; font-weight: 600; color: var(--muted-2); letter-spacing: 0; }
.c-day { color: var(--accent); } .c-prot { color: var(--green); } .c-biz { color: var(--blue); }

/* ---------- Focus card ---------- */
.focus-card { background: var(--surface); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; position: relative; overflow: hidden; }
.focus-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(var(--accent), var(--accent-2)); }
.focus-label { font-size: 10px; letter-spacing: 1.8px; color: var(--accent); font-weight: 800; }
.focus-card p { margin-top: 7px; font-size: 15px; line-height: 1.45; }

/* ---------- Checklist ---------- */
.checklist { display: flex; flex-direction: column; gap: 10px; }
.check-item { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 16px; padding: 16px; transition: transform .18s var(--spring), background .3s var(--ease); animation: cardIn .4s var(--ease) both; }
.check-item:active { transform: scale(.97); }
.check-box { width: 27px; height: 27px; flex: 0 0 auto; border: 2px solid var(--surface-3); border-radius: 9px; display: grid; place-items: center; font-size: 15px; color: transparent; transition: all .3s var(--spring); }
.check-body { flex: 1; min-width: 0; }
.check-title { font-size: 15px; font-weight: 600; transition: color .3s; }
.check-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.check-icon { font-size: 21px; transition: transform .3s var(--spring); }
.check-item.done { background: linear-gradient(135deg, rgba(48,209,88,.14), rgba(48,209,88,.05)); }
.check-item.done .check-box { background: var(--green); border-color: var(--green); color: #002b0d; transform: rotate(360deg); }
.check-item.done .check-title { color: var(--muted); text-decoration: line-through; }
.check-item.done .check-icon { transform: scale(1.1); }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Buttons ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 18px; margin-bottom: 12px; }
.ghost-btn { width: 100%; background: var(--surface); border: none; color: var(--muted); padding: 15px; border-radius: 15px; font-weight: 600; font-size: 14px; margin-top: 16px; }
.primary-btn { background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: #1a0e00; border: none; border-radius: 14px; padding: 15px; font-weight: 800; font-size: 15px; box-shadow: 0 4px 16px rgba(255,107,0,.3); }
.round-btn { background: var(--surface-2); color: var(--text); border: none; border-radius: 13px; padding: 13px 18px; font-weight: 700; }
.round-btn.ghost { background: var(--surface); }
.round-btn.danger { background: rgba(255,69,58,.14); color: var(--red); }
.full { width: 100%; }

/* ---------- Segmented ---------- */
.seg { display: flex; background: var(--surface); border-radius: 14px; padding: 4px; gap: 3px; margin-bottom: 18px; }
.seg-btn { flex: 1; background: transparent; border: none; color: var(--muted); padding: 10px; border-radius: 10px; font-weight: 700; font-size: 13px; transition: all .25s var(--ease); }
.seg-active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

/* ---------- Lift list ---------- */
.lift-row { background: var(--surface); border-radius: 16px; padding: 15px 17px; margin-bottom: 10px; transition: transform .18s var(--spring); animation: cardIn .4s var(--ease) both; }
.lift-row:active { transform: scale(.98); }
.lift-top { display: flex; justify-content: space-between; align-items: center; }
.lift-name { font-weight: 700; font-size: 15px; }
.lift-target { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lift-last { font-size: 12px; color: var(--accent); margin-top: 7px; font-weight: 600; }
.lift-warn { font-size: 11px; color: var(--red); margin-top: 7px; }
.lift-done-badge { background: var(--green); color: #002b0d; font-size: 10px; font-weight: 800; padding: 4px 10px; border-radius: 999px; letter-spacing: .5px; }

/* ---------- Box / skill tree ---------- */
.box-week { font-size: 14px; line-height: 1.55; }
.skill-tree { display: flex; flex-direction: column; gap: 9px; }
.skill-node { display: flex; align-items: center; gap: 13px; background: var(--surface); border-radius: 14px; padding: 14px 16px; transition: all .3s var(--ease); animation: cardIn .4s var(--ease) both; }
.skill-node.locked { opacity: .4; }
.skill-node.unlocked { background: linear-gradient(135deg, rgba(255,107,0,.14), rgba(255,107,0,.04)); }
.skill-ico { font-size: 22px; }
.skill-body { flex: 1; }
.skill-title { font-weight: 700; font-size: 14px; }
.skill-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.skill-toggle { background: var(--surface-2); border: none; color: var(--text); border-radius: 10px; padding: 8px 14px; font-size: 12px; font-weight: 700; }
.skill-node.unlocked .skill-toggle { background: var(--accent); color: #1a0e00; }

/* ---------- Timer ---------- */
.timer-card { background: var(--surface); border-radius: 24px; padding: 30px 20px; text-align: center; }
.timer-display { font-size: 72px; font-weight: 800; letter-spacing: -3px; font-variant-numeric: tabular-nums; transition: color .3s; }
.timer-display.rest { color: var(--blue); }
.timer-state { color: var(--muted); margin: 2px 0 22px; font-weight: 600; }
.timer-controls { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.timer-config { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.timer-config label { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.timer-config input { width: 72px; background: var(--surface-2); border: none; color: var(--text); border-radius: 10px; padding: 9px; text-align: center; font-size: 16px; }

/* ---------- Food ---------- */
.macro-head { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 8px; }
.big-ring { --p: 0; width: 172px; height: 172px; border-radius: 50%;
  background:
    radial-gradient(closest-side, var(--bg) 75%, transparent 76% 100%),
    conic-gradient(var(--green) calc(var(--p)*1%), var(--surface-2) 0);
  display: grid; place-items: center; transition: --p 1s var(--ease); position: relative; }
.big-ring-inner { text-align: center; }
.big-ring-inner span { font-size: 44px; font-weight: 800; letter-spacing: -1px; color: var(--green); font-variant-numeric: tabular-nums; }
.big-ring-inner small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.kcal-line { color: var(--muted); font-size: 14px; font-weight: 600; }
.kcal-line span { color: var(--text); }
.quick-foods { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-top: 8px; }
.qf { background: var(--surface); border: none; border-radius: 14px; padding: 13px; text-align: left; transition: transform .15s var(--spring), background .2s; }
.qf:active { background: var(--surface-2); transform: scale(.96); }
.qf-name { font-weight: 700; font-size: 13px; }
.qf-macro { font-size: 11px; color: var(--muted); margin-top: 4px; }
.food-log { display: flex; flex-direction: column; gap: 8px; }
.food-item { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 13px; padding: 12px 15px; animation: cardIn .35s var(--ease) both; }
.food-item small { color: var(--muted); }
.food-del { background: none; border: none; color: var(--red); font-size: 19px; }

/* ---------- Business ---------- */
.biz-goal-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 12px; }
.counter-row { display: flex; justify-content: space-between; align-items: center; }
.counter-label { font-weight: 700; font-size: 15px; }
.counter-sub { font-size: 12px; margin-top: 2px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.step-btn { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); border: none; color: var(--text); font-size: 24px; font-weight: 700; }
.step-val { font-size: 28px; font-weight: 800; min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 0; font-size: 14px; }
.toggle-row input { width: 24px; height: 24px; accent-color: var(--green); }
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-bar { flex: 1; height: 42px; background: var(--surface-2); border-radius: 12px; display: flex; align-items: center; padding: 0 14px; position: relative; overflow: hidden; }
.funnel-fill { position: absolute; inset: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0%; border-radius: 12px; transition: width .9s var(--ease); }
.funnel-label { position: relative; font-weight: 700; font-size: 13px; }
.funnel-num { position: relative; margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Coach ---------- */
.coach-card p { font-size: 14px; line-height: 1.5; margin-bottom: 14px; }
.coach-preview { background: var(--surface); border-radius: 14px; padding: 15px; font-size: 11px; color: var(--muted); white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; margin-top: 10px; line-height: 1.5; }
.coach-preview:empty { display: none; }
.weight-add { display: flex; gap: 8px; margin-bottom: 16px; }
.weight-add input { flex: 1; background: var(--surface-2); border: none; color: var(--text); border-radius: 12px; padding: 13px; font-size: 16px; }
.data-actions { display: flex; flex-direction: column; gap: 9px; }

/* ---------- Bottom nav ---------- */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 520px; margin: 0 auto; display: flex; background: rgba(20,20,22,.8); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); border-top: 1px solid var(--hair); padding: 9px 6px calc(9px + var(--safe-bot)); z-index: 30; }
.nav-btn { flex: 1; background: none; border: none; color: var(--muted-2); font-size: 10px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px; transition: color .25s; }
.nav-btn span { font-size: 21px; filter: grayscale(.6) opacity(.7); transition: all .25s var(--spring); }
.nav-btn.nav-active { color: var(--accent); }
.nav-btn.nav-active span { filter: none; transform: translateY(-2px) scale(1.08); }

/* ---------- Modal sheet ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-sheet { position: relative; width: 100%; max-width: 520px; background: var(--surface); border-top-left-radius: 26px; border-top-right-radius: 26px; padding: 8px 20px calc(26px + var(--safe-bot)); max-height: 90vh; overflow-y: auto; animation: sheetUp .42s var(--spring); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip { width: 40px; height: 5px; background: var(--surface-3); border-radius: 99px; margin: 9px auto 18px; }
.sheet-h { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 16px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; background: var(--surface-2); border: none; color: var(--text); border-radius: 12px; padding: 13px; font-size: 16px; }
.set-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.set-row span { width: 26px; color: var(--muted); font-size: 13px; font-weight: 700; }
.set-row input { flex: 1; background: var(--surface-2); border: none; color: var(--text); border-radius: 11px; padding: 12px; text-align: center; font-size: 16px; }
.rating-row { display: flex; gap: 8px; justify-content: space-between; margin: 6px 0 18px; }
.rate-btn { flex: 1; aspect-ratio: 1; border-radius: 14px; background: var(--surface-2); border: none; color: var(--text); font-size: 22px; transition: all .2s var(--spring); }
.rate-btn.sel { background: var(--accent); transform: scale(1.08); }

/* ---------- Review stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.stat-box { background: var(--surface-2); border-radius: 16px; padding: 16px; animation: cardIn .4s var(--ease) both; }
.stat-num { font-size: 27px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- toast/snack ---------- */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(90px + var(--safe-bot)); max-width: 488px; margin: 0 auto; background: var(--surface-2); border-radius: 16px; padding: 13px 15px; display: flex; align-items: center; gap: 10px; font-size: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.6); z-index: 50; animation: sheetUp .4s var(--spring); }
.toast span { flex: 1; }
.toast button { background: var(--accent); color: #1a0e00; border: none; border-radius: 10px; padding: 9px 15px; font-weight: 800; font-size: 13px; }
.toast .toast-x { background: none; color: var(--muted); padding: 8px; }
.snack { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bot)); background: var(--surface-3); color: var(--text); padding: 12px 20px; border-radius: 999px; font-size: 13px; font-weight: 700; z-index: 120; box-shadow: 0 8px 30px rgba(0,0,0,.6); animation: snackIn .35s var(--spring); }
@keyframes snackIn { from { opacity: 0; transform: translate(-50%, 12px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }

@keyframes pop { 0%{transform:scale(1);} 45%{transform:scale(1.18);} 100%{transform:scale(1);} }
.pop { animation: pop .3s var(--spring); }
canvas { width: 100%; display: block; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
