/* Life OS design system: zinc neutrals, one emerald accent, Geist + Geist Mono. */
:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f2f2f4;
  --surface-3: #e9e9ec;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --line: #e7e7ea;
  --accent: #0d8f63;
  --accent-ink: #ffffff;
  --accent-soft: #e5f4ed;
  --bad: #c2410c;
  --bad-soft: #fdeee6;
  --health: #0d8f63;
  --s1: #3159c7;
  --study: #a16207;
  --personal: #71717a;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 0 rgba(24, 24, 27, .03), 0 18px 36px -24px rgba(24, 24, 27, .16);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --font: "Geist", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0b0d; --surface: #141417; --surface-2: #1c1c20; --surface-3: #26262b;
    --text: #f4f4f5; --text-2: #d4d4d8; --muted: #a1a1aa; --line: #26262b;
    --accent: #34c08f; --accent-ink: #06281b; --accent-soft: #10291f;
    --bad: #fb8a5a; --bad-soft: #2c1810;
    --health: #34c08f; --s1: #7c9cf5; --study: #e0a23a; --personal: #a1a1aa;
    --shadow: 0 0 0 1px rgba(255,255,255,.02); color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -0.035em; }
h2 { font-size: 16px; letter-spacing: -0.02em; }
h3 { font-size: 15px; letter-spacing: -0.015em; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, .stat, .big, .big-timer, .kcal { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
svg.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; }
.view { padding: calc(env(safe-area-inset-top) + 20px) 16px calc(env(safe-area-inset-bottom) + 104px); max-width: 720px; margin: 0 auto; outline: none; }
.nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); z-index: 20;
  display: flex; justify-content: space-between; gap: 2px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); border-radius: 22px;
  box-shadow: 0 12px 32px -12px rgba(24,24,27,.22), inset 0 1px 0 rgba(255,255,255,.5);
  padding: 6px;
}
.nav .brand, .nav .nav-settings { display: none; }
.nav button {
  flex: 1; min-width: 0; background: none; border: 0; padding: 7px 0 6px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 500;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms var(--ease-out);
}
.nav button svg.i { width: 21px; height: 21px; }
.nav button.active { color: var(--text); background: var(--surface-2); }
.nav button.active svg.i { stroke-width: 2.1; }
.nav button:active { transform: scale(0.94); }
@media (min-width: 900px) {
  .nav {
    top: 16px; bottom: 16px; left: 16px; right: auto; width: 224px;
    flex-direction: column; justify-content: flex-start; gap: 2px; padding: 16px 10px; border-radius: 24px;
  }
  .nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; padding: 4px 10px 20px; }
  .nav button { flex: 0 0 auto; flex-direction: row; gap: 12px; padding: 10px 12px; font-size: 14.5px; border-radius: 12px; }
  .nav .nav-settings { display: flex; margin-top: auto; }
  .view { margin-left: 256px; margin-right: 0; padding: 36px 40px 48px; max-width: 1040px; }
}

/* ---------- header ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 20px; }
.head .eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: 42px; height: 42px;
  display: grid; place-items: center; flex-shrink: 0; color: var(--text-2);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: .35; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; min-height: 28px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > .card { margin-bottom: 0; }
.cols { display: block; }
@media (min-width: 900px) {
  .cols { display: grid; grid-template-columns: 1.15fr 1fr; gap: 12px; align-items: start; }
}
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; min-width: 0; }

/* Mission: the one dark surface on the page */
.mission { background: var(--text); color: var(--bg); border: 0; padding: 20px; position: relative; overflow: hidden; }
.mission::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 45%, transparent), transparent 70%); pointer-events: none; }
.mission > * { position: relative; z-index: 1; }
.mission .label { font-size: 12.5px; opacity: .65; display: flex; align-items: center; gap: 8px; }
.mission h2 { font-size: 20px; line-height: 1.25; margin-top: 8px; letter-spacing: -0.03em; max-width: 34ch; position: relative; }
.mission p { font-size: 13.5px; opacity: .75; margin-top: 8px; position: relative; }

/* ---------- buttons ---------- */
.btn {
  border: 0; background: var(--text); color: var(--bg); font-weight: 550; border-radius: 14px; padding: 11px 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; font-size: 14.5px;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface-2); color: var(--text); }
.btn.ghost { background: none; color: var(--text-2); padding: 6px 8px; min-height: 0; font-weight: 500; border-radius: 10px; }
.btn.ghost svg.i { width: 17px; height: 17px; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 12px; min-height: 36px; font-size: 13.5px; border-radius: 11px; }
.btn.sm svg.i { width: 17px; height: 17px; }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
@media (hover: hover) and (pointer: fine) {
  .btn.secondary:hover, .icon-btn:hover { background: var(--surface-3); }
  .btn.ghost:hover { background: var(--surface-2); }
}

/* ---------- forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=number], input[type=time], input[type=date], input[type=password], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 10px 12px; min-height: 46px; font-size: 16px;
  transition: border-color 160ms ease, background-color 160ms ease;
}
textarea { min-height: 84px; resize: vertical; font-size: 15px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-2); background: var(--surface); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); }

/* ---------- lists / checks ---------- */
.check { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check .box {
  width: 24px; height: 24px; border-radius: 8px; border: 1.75px solid var(--surface-3); background: none; flex-shrink: 0;
  display: grid; place-items: center; color: var(--accent-ink); padding: 0;
  transition: background-color 180ms ease, border-color 180ms ease, transform 160ms var(--ease-out);
}
.check .box svg.i { width: 15px; height: 15px; stroke-width: 2.6; }
.check button.box:active { transform: scale(0.88); }
.check.done .box { background: var(--accent); border-color: var(--accent); }
.check .title { flex: 1; min-width: 0; transition: color 180ms ease; }
.check.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--surface-3); }
.check.score.done .title { color: var(--text); text-decoration: none; }
.check .meta { font-size: 12px; color: var(--muted); }
.check.now { background: var(--surface-2); margin: 0 -18px; padding-left: 18px; padding-right: 18px; border-top-color: transparent; }
.check.now + .check { border-top-color: transparent; }
.x { background: none; border: 0; color: var(--muted); padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.x svg.i { width: 16px; height: 16px; }
.time { font-family: var(--mono); font-size: 12.5px; color: var(--muted); width: 44px; flex-shrink: 0; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.tag.health .dot { background: var(--health); } .tag.square1ai .dot { background: var(--s1); } .tag.study .dot { background: var(--study); } .tag.personal .dot { background: var(--personal); }
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; scrollbar-width: none; }
.pills button { border: 0; background: var(--surface-2); border-radius: 999px; padding: 7px 13px; font-size: 13.5px; white-space: nowrap; transition: background-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out); }
.pills button:active { transform: scale(0.95); }
.pills button.active { background: var(--text); color: var(--bg); }

/* ---------- rings, bars, stats ---------- */
.ring-wrap { display: flex; align-items: center; gap: 20px; }
.ring { position: relative; width: 124px; height: 124px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring .big { font-size: 26px; font-weight: 600; line-height: 1; }
.ring .center .small { margin-top: 4px; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--text); border-radius: 99px; transform-origin: left; }
.macro { flex: 1; min-width: 0; }
.macro .row { justify-content: space-between; font-size: 13px; margin-bottom: 6px; gap: 8px; }
.stat { font-size: 24px; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-top: 4px; }
.score-big { font-family: var(--mono); font-size: 13px; font-weight: 600; background: var(--surface-2); padding: 4px 10px; border-radius: 999px; }
.score-dots { display: flex; gap: 4px; }
.score-dots i { width: 22px; height: 6px; border-radius: 99px; background: var(--surface-3); }
.score-dots i.on { background: var(--accent); }

/* ---------- meals / runs ---------- */
.meal { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.meal:first-child { border-top: 0; }
.meal img, .meal .ph { width: 48px; height: 48px; border-radius: 13px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; display: grid; place-items: center; color: var(--muted); }
.meal .info { flex: 1; min-width: 0; }
.meal .name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meal .sub { font-size: 12.5px; color: var(--muted); font-family: var(--mono); letter-spacing: -0.02em; }
.meal .kcal { font-weight: 600; }

/* ---------- training ---------- */
.ex { border-top: 1px solid var(--line); padding: 14px 0; }
.ex:first-of-type { border-top: 0; padding-top: 2px; }
.ex .spec { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 10px; }
.set {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 8px 6px; text-align: center; font-size: 12.5px; color: var(--muted);
  transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}
.set:active { transform: scale(0.95); }
.set b { display: block; font-family: var(--mono); font-size: 15px; color: var(--text); letter-spacing: -0.03em; }
.set.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.set.done b { color: var(--accent); }
.timer-bar {
  position: sticky; top: calc(env(safe-area-inset-top) + 8px); z-index: 5; display: flex; align-items: center; gap: 12px;
  background: var(--text); color: var(--bg); border-radius: 18px; padding: 10px 10px 10px 16px; margin-bottom: 12px;
  box-shadow: 0 12px 30px -12px rgba(24,24,27,.4);
}
.timer-bar .t { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.timer-bar .btn.secondary { background: color-mix(in srgb, var(--bg) 14%, transparent); color: var(--bg); }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.week .d {
  text-align: center; font-size: 11px; padding: 9px 2px; border-radius: 12px; background: var(--surface-2); color: var(--muted); border: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: transform 160ms var(--ease-out);
}
.week .d:active { transform: scale(0.94); }
.week .d.today { background: var(--text); color: color-mix(in srgb, var(--bg) 70%, transparent); }
.week .d.today b { color: var(--bg); }
.week .d.done { background: var(--accent-soft); color: var(--accent); }
.week .d b { display: block; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 2px; }

/* ---------- focus timer ---------- */
.timer-card { text-align: center; padding: 22px 18px 18px; }
.big-timer { font-size: 60px; font-weight: 500; text-align: center; margin: 10px 0 16px; line-height: 1; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.live .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); animation: pulse 1.8s var(--ease-out) infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.streak { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; }
.streak i { height: 28px; border-radius: 7px; background: var(--surface-2); }
.streak i.on { background: var(--accent); }
.streak i.part { background: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }

/* ---------- goals ---------- */
.horizon { margin-bottom: 24px; }
.horizon-title { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 10px; }
.horizon-title h2 { font-size: 15px; }
.goal {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; margin-bottom: 8px;
  transition: transform 160ms var(--ease-out), border-color 160ms ease;
}
.goal:active { transform: scale(0.985); }
@media (hover: hover) and (pointer: fine) { .goal:hover { border-color: var(--surface-3); } }
.goal .row { margin-bottom: 10px; align-items: flex-start; }
.goal .t { font-weight: 550; flex: 1; line-height: 1.35; }
.card .goal { border-color: var(--line); box-shadow: none; }

/* ---------- sheet + toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(9,9,11,.42); z-index: 40; opacity: 0; visibility: hidden; transition: opacity 260ms ease, visibility 0s linear 260ms; }
.sheet-backdrop.open { opacity: 1; visibility: visible; transition: opacity 260ms ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 26px 26px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 20px);
  transform: translateY(100%); visibility: hidden;
  transition: transform 420ms var(--ease-drawer), visibility 0s linear 420ms;
}
.sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet.open { transform: translateY(0); visibility: visible; transition: transform 420ms var(--ease-drawer); }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: 520px; border-radius: 24px; padding: 22px; opacity: 0; transform: translate(-50%, -48%) scale(0.97); transition: transform 240ms var(--ease-out), opacity 200ms ease, visibility 0s linear 240ms; }
  .sheet::before { display: none; }
  .sheet.open { opacity: 1; transform: translate(-50%, -50%); transition: transform 240ms var(--ease-out), opacity 200ms ease; }
}
.sheet h2 { margin-bottom: 16px; font-size: 19px; letter-spacing: -0.03em; }
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translate(-50%, 12px) scale(0.98); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 14px; font-weight: 500; font-size: 14px; z-index: 60;
  transition: transform 300ms var(--ease-out), opacity 200ms ease; max-width: calc(100% - 32px); box-shadow: 0 12px 30px -12px rgba(24,24,27,.45);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.empty { text-align: center; color: var(--muted); padding: 14px 8px; font-size: 14px; }
.preview-img { width: 100%; max-height: 240px; object-fit: cover; border-radius: 16px; margin-bottom: 14px; display: block; }
.item-row { display: grid; grid-template-columns: 1fr 72px 60px 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.item-row input { min-height: 42px; padding: 8px 10px; }

/* skeleton while a photo is being estimated */
.skel { display: grid; gap: 8px; margin: 4px 0 14px; }
.skel i { height: 42px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel i:nth-child(2) { width: 82%; } .skel i:nth-child(3) { width: 64%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- entrance (only when switching tabs) ---------- */
.enter .card, .enter .horizon, .enter .head { animation: rise 420ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.enter .ring circle.arc { animation: draw 900ms var(--ease-out) both 120ms; }
@keyframes draw { from { stroke-dasharray: 0 100; } }
.enter .bar > i { animation: grow 700ms var(--ease-out) both 150ms; }
@keyframes grow { from { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .enter .card, .enter .horizon, .enter .head, .enter .ring circle.arc, .enter .bar > i { animation: none; }
  .sheet, .sheet.open, .toast { transition: opacity 150ms ease; }
  .live .pulse, .skel i { animation: none; }
}
