:root {
  --accent: #ff5a1f;
  --bg: #f4f4f5;
  --card: #ffffff;
  --ink: #18181b;
  --ink-2: #52525b;
  --ink-3: #a1a1aa;
  --line: #e4e4e7;
  --tabbar-h: 56px;
}

* { box-sizing: border-box; margin: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

/* --- Top bar ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}

.topbar-title { font-size: 20px; font-weight: 700; }

/* --- Feed cards -------------------------------------------------------- */

.view { padding: 12px 12px 24px; display: grid; gap: 12px; }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.act-head { display: flex; align-items: center; gap: 10px; }

.act-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: #fff1ea; color: var(--accent);
  font-size: 19px;
}

.act-title { font-size: 15px; font-weight: 650; line-height: 1.25; }
.act-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }

.act-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.stat .label { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 17px; font-weight: 650; margin-top: 1px; }
.stat .value small { font-size: 12px; font-weight: 500; color: var(--ink-2); }

.empty { text-align: center; color: var(--ink-2); padding: 48px 24px; line-height: 1.5; }
.empty .big { font-size: 40px; display: block; margin-bottom: 12px; }

.load-more {
  border: 0; border-radius: 12px; padding: 12px;
  background: var(--card); color: var(--accent);
  font-size: 15px; font-weight: 600; cursor: pointer;
}

/* --- Health ------------------------------------------------------------ */

.metric-hero { text-align: center; padding: 22px 16px; }
.metric-hero .big-number { font-size: 42px; font-weight: 750; letter-spacing: -0.02em; }
.metric-hero .big-number small { font-size: 20px; font-weight: 500; color: var(--ink-2); }
.metric-hero .when { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.metric-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}
.metric-row:last-child { border-bottom: 0; }
.metric-row .when { color: var(--ink-2); }
.metric-row .delta { font-size: 12.5px; margin-left: 8px; }
.delta.down { color: #16a34a; }
.delta.up { color: #dc2626; }

/* --- Coach chat ---------------------------------------------------------- */

.chat { display: grid; gap: 10px; }
.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px; line-height: 1.4;
}
.bubble.coach { background: var(--card); border-bottom-left-radius: 4px; justify-self: start; }
.bubble.me { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; justify-self: end; }

.chat-input {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
}
.chat-input input {
  flex: 1;
  border: 1px solid var(--line); border-radius: 22px;
  padding: 11px 16px; font-size: 15px;
  background: var(--card);
}
.chat-input button {
  border: 0; border-radius: 50%;
  width: 42px; height: 42px; flex: none;
  background: var(--accent); color: #fff;
  font-size: 18px; cursor: pointer;
}

/* --- Bottom tab bar -------------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}

.tab {
  flex: 1;
  border: 0; background: none;
  display: grid; place-items: center; gap: 2px;
  color: var(--ink-3);
  font-size: 10.5px; font-weight: 600;
  cursor: pointer;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }

/* --- Login ------------------------------------------------------------------ */

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { text-align: center; max-width: 320px; display: grid; gap: 12px; justify-items: center; }
.login-card p { color: var(--ink-2); font-size: 14.5px; }
.login-card form { display: grid; gap: 10px; width: 100%; }
.login-card input {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; text-align: center;
}
.form-error { color: #dc2626; font-size: 14px; }
.login-card button {
  border: 0; border-radius: 12px; padding: 13px;
  background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 650; cursor: pointer;
}
