/* WHOOP iOS recreation — shared foundation.
   Units: 1px here = 1pt on the 390pt-wide iPhone reference screenshots (which are @3x). */

:root {
  --font: 'Figtree', 'Proxima Nova', -apple-system, system-ui, sans-serif;
  --num: 'Barlow', 'DIN Alternate', 'DIN Pro', var(--font);

  --bg: #0f1316;
  --bg-top: #283339;          /* top of the slate app gradient */
  --bg-mid: #161c1f;
  --bg-login-top: #36454d;
  --card: #2a2f33;            /* home cards (sleep planner, key stats) */
  --card-2: #1f262b;          /* sleep-tab stat cards, activity rows */
  --card-3: #30363a;          /* onboarding option tiles */
  --field: #252d33;
  --hairline: rgba(255,255,255,.08);

  --text: #fff;
  --text-2: #a7adb0;          /* body copy on dark */
  --text-3: #80868a;          /* caps section labels */
  --text-4: #50575b;          /* disabled */

  --accent: #00f19f;          /* WHOOP teal — primary outline buttons */
  --green: #16ec06;           /* recovery high */
  --yellow: #ffde00;          /* recovery mid */
  --red: #ff0026;             /* recovery low / destructive */
  --strain: #0093e7;
  --sleep: #7ba1bb;
  --blue-btn: #4aa7e0;
  --orange: #f5a623;
  --coach-grad: linear-gradient(90deg, #f6a39b, #b64bec);

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --track: .12em;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; }
body {
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex-shrink: 0; }

/* ---------- Device shell ---------- */
#device { position: relative; width: 100%; height: 100dvh; overflow: hidden; background: var(--bg); }
#app { position: absolute; inset: 0; overflow: hidden; }
#statusbar, #home-indicator { display: none; }

@media (min-width: 600px) and (min-height: 700px) {
  body { display: grid; place-items: center; background: #e9e9ea; min-height: 100vh; }
  #device {
    width: 390px; height: 844px; border-radius: 54px;
    box-shadow: 0 0 0 11px #1b1b1d, 0 0 0 12px #3a3a3c, 0 30px 60px rgba(0,0,0,.25);
    --sat: 47px; --sab: 34px;
  }
  #statusbar {
    display: flex; position: absolute; z-index: 1000; top: 0; left: 0; right: 0; height: 47px;
    align-items: center; justify-content: space-between; padding: 4px 26px 0 44px;
    pointer-events: none; color: #fff; fill: #fff;
  }
  #statusbar .sb-time { font: 600 16px/1 -apple-system, 'SF Pro Text', system-ui, sans-serif; letter-spacing: -.01em; }
  #statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
  #statusbar .sb-icons svg { fill: currentColor; color: #fff; }
  #home-indicator {
    display: block; position: absolute; z-index: 1000; bottom: 8px; left: 50%; width: 134px; height: 5px;
    margin-left: -67px; border-radius: 3px; background: #fff; pointer-events: none;
  }
  #device.light-ind #home-indicator { background: #000; }
}
@media (prefers-color-scheme: dark) and (min-width: 600px) and (min-height: 700px) {
  body { background: #1c1c1e; }
}

/* ---------- Screens & transitions ---------- */
.screen {
  position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column;
  background: var(--bg);
}
.screen.bg-app { background: linear-gradient(180deg, var(--bg-top) 0, #1b2226 260px, var(--bg-mid) 480px, var(--bg) 100%); }
.screen.bg-login { background: linear-gradient(180deg, var(--bg-login-top) 0, #222c31 300px, #141a1d 560px, #0d1114 100%); }
.screen.bg-step { background: linear-gradient(180deg, #2a363c 0, #1c2428 200px, #141a1d 430px, #0e1313 100%); }
.screen.bg-black { background: #000; }

.scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }
.pad-top { padding-top: var(--sat); }

.anim-push-in   { animation: pushIn .38s cubic-bezier(.2,.8,.2,1) both; z-index: 2; }
.anim-push-out  { animation: pushOut .38s cubic-bezier(.2,.8,.2,1) both; z-index: 1; }
.anim-pop-in    { animation: popIn .38s cubic-bezier(.2,.8,.2,1) both; z-index: 1; }
.anim-pop-out   { animation: popOut .38s cubic-bezier(.2,.8,.2,1) both; z-index: 2; }
.anim-fade-in   { animation: fadeIn .35s ease both; z-index: 2; }
.anim-fade-out  { animation: fadeOut .35s ease both; z-index: 1; }
.anim-up-in     { animation: upIn .42s cubic-bezier(.2,.8,.2,1) both; z-index: 2; }
.anim-up-out    { animation: fadeOut .42s ease both; z-index: 1; }
.anim-down-in   { animation: fadeIn .1s both; z-index: 1; }
.anim-down-out  { animation: downOut .38s cubic-bezier(.4,0,.6,1) both; z-index: 2; }
@keyframes pushIn  { from { transform: translateX(100%); } to { transform: none; } }
@keyframes pushOut { from { transform: none; } to { transform: translateX(-30%); filter: brightness(.6); } }
@keyframes popIn   { from { transform: translateX(-30%); filter: brightness(.6); } to { transform: none; } }
@keyframes popOut  { from { transform: none; } to { transform: translateX(100%); } }
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes upIn    { from { transform: translateY(100%); } to { transform: none; } }
@keyframes downOut { from { transform: none; } to { transform: translateY(100%); } }
@keyframes spin    { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [class*="anim-"] { animation-duration: 1ms !important; } }

/* ---------- Typography ---------- */
.caps { text-transform: uppercase; font-weight: 700; letter-spacing: var(--track); }
.label { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.h-title { font-size: 24px; font-weight: 500; line-height: 1.25; letter-spacing: -.005em; margin: 0; }
.h-sub { font-size: 15px; line-height: 1.35; color: var(--text-2); margin: 6px 0 0; }
.body { font-size: 15px; line-height: 1.35; color: var(--text-2); }
.num { font-family: var(--num); font-weight: 600; font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 48px;
  border: 2px solid var(--accent); border-radius: 26px; color: var(--accent);
  font-size: 12px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase;
  transition: opacity .2s, border-color .2s, color .2s, transform .1s;
}
.btn:active { transform: scale(.98); opacity: .8; }
.btn.white { border-color: #fff; color: #fff; }
.btn.blue { border-color: var(--blue-btn); color: var(--blue-btn); }
.btn.small { height: 36px; font-size: 12px; width: auto; padding: 0 18px; }
.btn:disabled, .btn.disabled { border-color: #3e4245; color: #3e4243; pointer-events: none; }
.btn-text { font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: #fff; padding: 12px; }
.btn-stack { display: flex; flex-direction: column; gap: 14px; padding: 0 40px; }
.footer-btn { padding: 16px 40px calc(var(--sab) + 24px); }

.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: #fff; }
.circle-back {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; display: grid; place-items: center;
}

/* ---------- Step header (onboarding) ---------- */
.step-head {
  display: flex; align-items: center; gap: 6px; padding: calc(var(--sat) + 6px) 16px 0 8px; min-height: calc(var(--sat) + 58px);
  position: relative; z-index: 5;
}
.step-head .t { flex: 1; min-width: 0; }
.step-head .t b { display: block; font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.step-head .t small { display: block; font-size: 11px; color: var(--text-2); letter-spacing: .06em; margin-top: 1px; }
.step-head .skip { font-size: 11px; font-weight: 700; letter-spacing: .12em; padding: 12px 4px 12px 12px; }

/* ---------- Fields ---------- */
.field { margin-bottom: 26px; }
.field label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }
.field input, .field select {
  width: 100%; height: 40px; border: 0; border-bottom: 1px solid #fff; border-radius: 0;
  background: rgba(60,75,84,.45); padding: 0 10px; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
.field.error input { background: #6b0c18; border-bottom-color: var(--red); }
.field .err { color: var(--red); font-size: 11px; margin-top: 6px; }

/* ---------- Cards / rows ---------- */
.card { background: var(--card); border-radius: 12px; }
.row-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: 12px; padding: 0 16px; min-height: 62px; }
.section-label { display: flex; justify-content: space-between; align-items: center; padding: 0 24px; margin: 28px 0 12px; }
.section-label .label { font-size: 11px; }
.link-caps { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #fff; }

/* ---------- App header (Home/Sleep/Recovery/Strain) ---------- */
.app-head { padding-top: var(--sat); flex-shrink: 0; position: relative; z-index: 5; }
.app-head .bar { height: 56px; margin-top: -7px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 20px 0 18px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #cdb79f, #a3907d 70%); background-size: cover; background-position: center; }
.date-nav { display: flex; align-items: center; gap: 28px; font-size: 11.5px; font-weight: 700; letter-spacing: .1em; }
.date-nav button { width: 30px; height: 44px; display: grid; place-items: center; }
.date-nav button:disabled { opacity: .35; }
.battery { justify-self: end; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.tabs { display: flex; justify-content: space-around; padding: 0 18px; height: 40px; margin-top: 5px; }
.tabs button { position: relative; font-size: 11px; font-weight: 700; letter-spacing: .085em; color: #a2a8ab; padding: 0 4px; }
.tabs button.on { color: #fff; }
.tabs button.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: 4px; height: 2px; border-radius: 1px; background: #fff; }

/* ---------- Tab bar ---------- */
.tabbar {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(4, 1fr); background: #0f1317;
  padding: 8px 0 calc(var(--sab) - 4px); position: relative; z-index: 20; border-top: 1px solid rgba(255,255,255,.04);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; height: 50px; color: #7b8285; font-size: 10.5px; font-weight: 500; position: relative; }
.tabbar button.on { color: #fff; }
.tabbar .dot { position: absolute; bottom: -2px; width: 4px; height: 4px; border-radius: 50%; background: var(--red); }

/* ---------- FAB ---------- */
.fab {
  position: absolute; right: 16px; bottom: calc(var(--sab) + 69px); z-index: 30; width: 48px; height: 48px; border-radius: 50%;
  background: #fff; color: #000; display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

/* ---------- Sheets / overlays ---------- */
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.6); z-index: 50; animation: fadeIn .25s both; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; top: calc(var(--sat) + 10px); z-index: 60;
  background: linear-gradient(180deg, #2a3338, #161b1e 40%, #121619); border-radius: 12px 12px 0 0;
  display: flex; flex-direction: column; animation: upIn .4s cubic-bezier(.2,.8,.2,1) both;
}
.sheet .grabber { width: 36px; height: 5px; border-radius: 3px; background: #5b6266; margin: 8px auto 0; }

/* iOS-style system alert */
.ios-alert-wrap { position: absolute; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(0,0,0,.4); animation: fadeIn .2s both; }
.ios-alert {
  width: 270px; border-radius: 14px; background: rgba(242,242,247,.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  color: #000; text-align: center; font-family: -apple-system, system-ui, sans-serif; overflow: hidden; animation: alertIn .25s ease both;
}
.ios-alert h3 { font-size: 17px; font-weight: 600; margin: 19px 16px 2px; line-height: 1.3; }
.ios-alert p { font-size: 13px; margin: 0 16px 19px; line-height: 1.35; }
.ios-alert .acts { display: grid; grid-template-columns: 1fr 1fr; border-top: .5px solid rgba(60,60,67,.3); }
.ios-alert .acts button { height: 44px; font-size: 17px; color: #007aff; font-family: inherit; }
.ios-alert .acts button + button { border-left: .5px solid rgba(60,60,67,.3); }
@keyframes alertIn { from { transform: scale(1.15); opacity: 0; } to { transform: none; opacity: 1; } }

/* Progress segments (carousels) */
.segs { display: flex; gap: 6px; }
.segs i { flex: 1; height: 3px; background: #3a3f42; border-radius: 1px; transition: background .3s; }
.segs i.on { background: #fff; }

/* Full-bleed photo screens */
.photo-bg { position: absolute; inset: 0; background-size: cover; background-position: center top; }
.photo-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,.55) 75%, rgba(0,0,0,.8)); }

/* Spinner (W logo w/ rotating arc) */
.w-spinner { position: relative; width: 58px; height: 58px; }
.w-spinner::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 1s linear infinite; }
.w-spinner img { position: absolute; inset: 15px; width: 28px; height: 28px; }

.hidden { display: none !important; }
.toast {
  position: absolute; left: 50%; bottom: calc(var(--sab) + 96px); transform: translateX(-50%); z-index: 300;
  background: rgba(40,46,50,.96); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; white-space: nowrap;
  animation: fadeIn .2s both;
}

/* Coach ("Ask WHOOP anything") input + gradient W badge */
.coach-input {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 48px; padding: 0 12px; text-align: left;
  background: #0c1011; border: 1.5px solid #000; border-radius: 12px; color: #6b7276; font-size: 15px;
}
.coach-badge { display: inline-grid; place-items: center; border-radius: 50%; padding: 2px; background: linear-gradient(135deg, #f6a39b, #8f6bf0 55%, #3fb3f2); flex-shrink: 0; }
.coach-badge img { width: 100%; height: 100%; border-radius: 50%; background: #0d1012; }

/* iOS wheel picker */
.wheel { position: relative; height: 210px; }
.wheel::before { content: ''; position: absolute; left: 0; right: 0; top: 90px; height: 30px; background: rgba(255,255,255,.1); pointer-events: none; }
.wheel-in { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; }
.wheel-in::-webkit-scrollbar { display: none; }
.wheel-pad { height: 90px; }
.wheel-item { height: 30px; line-height: 30px; padding: 0 16px; font-size: 16px; color: #c9cfd2; scroll-snap-align: center; white-space: nowrap; cursor: pointer; }
.wheel-item.sel { color: #fff; }

/* ?sim — simulate iPhone safe areas + status bar inside a bare 390×844 viewport (used for screenshot comparisons) */
html.sim #device { --sat: 47px; --sab: 34px; }
html.sim #statusbar { display: flex; position: absolute; z-index: 1000; top: 0; left: 0; right: 0; height: 47px; align-items: center; justify-content: space-between; padding: 4px 26px 0 44px; pointer-events: none; color: #fff; }
html.sim #statusbar .sb-time { font: 600 16px/1 -apple-system, 'SF Pro Text', system-ui, sans-serif; }
html.sim #statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
html.sim #statusbar .sb-icons svg { fill: #fff; }
html.sim #home-indicator { display: block; position: absolute; z-index: 1000; bottom: 8px; left: 50%; width: 134px; height: 5px; margin-left: -67px; border-radius: 3px; background: #fff; }
