:root {
  --black: #0c0c0c;
  --panel: #f2f2f3;
  --panel-dark: #ececed;
  --text: #111113;
  --text-dim: #8b8b90;
  --text-onblack-dim: #9c9ca1;
  --yellow: #f6a71b;
  --green: #2e9e5b;
  --divider: #e9e9eb;
  --white: #ffffff;
  --r-xl: 28px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-pill: 999px;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.09);
  --tabbar-h: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: var(--black);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
}

h1, h2, h3, .headline {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  margin: 0;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}
button:active { transform: scale(0.96); }

.icon, .li-icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-fill { fill: currentColor; stroke: none; }

#app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--app-height, 100dvh)); /* JS-measured, most reliable in standalone iOS PWA */
  overflow: hidden;
  background: var(--black); /* prevents wrong color showing through on elastic overscroll */
}

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--black);
  padding-bottom: calc(var(--tabbar-h) + max(env(safe-area-inset-bottom), 10px));
}
.screen.active { display: flex; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 20px 40px;
  background: var(--black);
  color: var(--white);
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-family: 'Poppins', sans-serif; font-weight: 800; font-size: 22px; color: var(--white); }
.logo .dot { color: var(--yellow); }
.ver-badge { font-family: 'Inter', monospace; font-size: 8px; font-weight: 700; color: var(--black); background: var(--yellow); padding: 1px 4px; border-radius: var(--r-pill); align-self: flex-start; margin-top: 2px; }
.topbar h1 { font-size: clamp(19px, 6.5vw, 26px); color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--white); flex-shrink: 0; }
.account-btn .icon { width: 26px; height: 26px; }
.account-btn span { font-size: 11px; }

.sheet {
  flex: 1;
  background: var(--white);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  margin-top: -26px;
  padding: 24px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: var(--shadow);
}

.section-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-header h2 { font-size: 19px; }
.link { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 2px; }
.link .icon { width: 16px; height: 16px; }
.subtle { color: var(--text-dim); font-size: 13px; margin-top: -20px; margin-bottom: 4px; }

/* generic gray panel */
.panel { background: var(--panel); border-radius: var(--r-lg); padding: 18px; }
.panel-row { display: flex; align-items: center; gap: 14px; }

/* ---------- Home ---------- */
.cta-row { display: flex; align-items: center; gap: 14px; }
.cta-row .circle-icon { background: var(--white); }
.cta-row strong { font-size: 16px; }

.circle-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.club-card { display: flex; align-items: center; gap: 14px; }
.club-thumb { width: 56px; height: 56px; border-radius: var(--r-md); object-fit: cover; flex-shrink: 0; background: #444; }
.club-info strong { display: block; font-size: 17px; margin-bottom: 2px; }
.club-info .open { color: var(--green); font-weight: 600; font-size: 14px; }

.busy-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 16px; }
.busy-head strong { font-size: 16px; }
.busy-head span { color: var(--text-dim); font-size: 13px; }
.busy-chart { display: flex; align-items: flex-end; justify-content: space-between; height: 70px; gap: 6px; }
.busy-bar-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.busy-bar { width: 6px; border-radius: 4px; background: #d7d7da; }
.busy-bar-wrap span { font-size: 12px; color: var(--text-dim); }
.busy-bar-wrap.now .busy-bar { background: var(--yellow); }
.busy-bar-wrap.now span { color: var(--yellow); font-weight: 700; }

.banner {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  height: 150px;
  background: linear-gradient(135deg, #333, #555);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  color: var(--white);
}
.banner::before { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(0,0,0,.55), rgba(0,0,0,.05) 60%); }
.banner-text { position: relative; z-index: 1; }
.banner-text strong { display: block; font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 20px; }
.banner-text span { font-size: 13px; opacity: .9; }

.hscroll { display: flex; gap: 14px; overflow-x: auto; margin: 0 -20px; padding: 0 20px 4px; scroll-snap-type: x proximity; }
.hscroll::-webkit-scrollbar { display: none; }

.class-card { flex: 0 0 180px; scroll-snap-align: start; }
.class-card img { width: 100%; height: 120px; border-radius: var(--r-md); object-fit: cover; background: #555; display: block; }
.class-card .cc-body { padding-top: 8px; position: relative; }
.class-card strong { font-size: 14.5px; display: block; line-height: 1.25; }
.class-card .cc-sub { font-size: 12.5px; color: var(--text-dim); }
.fav-btn { position: absolute; top: -132px; right: 8px; width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; }
.fav-btn .icon { width: 16px; height: 16px; color: #333; }
.fav-btn.active .icon { color: #e0483e; fill: #e0483e; }

/* ---------- Workouts ---------- */
.carousel { display: flex; gap: 14px; overflow-x: auto; margin: 0 -20px; padding: 0 20px; scroll-snap-type: x mandatory; }
.carousel::-webkit-scrollbar { display: none; }
.carousel-slide {
  flex: 0 0 100%; scroll-snap-align: start; height: 190px; border-radius: var(--r-lg);
  background: linear-gradient(135deg,#2b2b2b,#111); background-size: cover; background-position: center;
  position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 18px; color: var(--white);
}
.carousel-slide::before { content:""; position:absolute; inset:0; background: linear-gradient(0deg, rgba(0,0,0,.6), rgba(0,0,0,.05) 55%); }
.carousel-slide .cs-text { position: relative; z-index: 1; }
.carousel-slide strong { font-family:'Poppins',sans-serif; font-size: 20px; display:block; }
.carousel-slide span { font-size: 13px; opacity: .9; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.dots span { width: 18px; height: 4px; border-radius: 2px; background: var(--panel-dark); }
.dots span.active { background: var(--black); }

.brand-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.brand-wordmark { font-family: 'Poppins', sans-serif; font-weight: 800; font-style: italic; font-size: 20px; letter-spacing: -0.5px; }

.tile-card { flex: 0 0 150px; scroll-snap-align: start; border-radius: var(--r-md); overflow: hidden; height: 100px; position: relative; background: linear-gradient(135deg,#333,#111); background-size: cover; background-position: center; display: flex; align-items: flex-end; padding: 10px; }
.tile-card::before { content:""; position:absolute; inset:0; background: linear-gradient(0deg, rgba(0,0,0,.55), transparent 60%); }
.tile-card span { position: relative; z-index: 1; color: var(--white); font-weight: 700; font-size: 15px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-tile { background: var(--panel); border-radius: var(--r-lg); padding: 16px; display: flex; align-items: center; gap: 12px; }
.grid-tile .circle-icon { background: var(--white); color: var(--yellow); }
.grid-tile span { font-weight: 700; font-size: 14.5px; }

.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 24px 10px; color: var(--text-dim); font-size: 14px; }
.empty-state .icon-fill { color: #e0483e; width: 30px; height: 30px; }
.empty-state .icon { width: 26px; height: 26px; color: var(--text-dim); }

/* ---------- Book ---------- */
.search-row { display: flex; gap: 10px; }
.search-input { flex: 1; background: var(--panel); border-radius: var(--r-pill); padding: 13px 18px; color: var(--text-dim); font-size: 14.5px; }
.club-pill { background: var(--yellow); border-radius: var(--r-pill); padding: 8px 16px; font-weight: 700; font-size: 13px; text-align: center; line-height: 1.2; flex-shrink: 0; }

.date-row { display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 4px 20px; }
.date-row::-webkit-scrollbar { display: none; }
.date-pill { flex: 0 0 auto; width: 56px; padding: 10px 0; border-radius: var(--r-md); text-align: center; color: var(--text-dim); font-size: 13px; }
.date-pill .num { display: block; font-weight: 700; font-size: 16px; margin-top: 2px; color: var(--text); }
.date-pill.active { background: var(--black); color: var(--white); }
.date-pill.active .num { color: var(--white); }

.filter-row { display: flex; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); margin-top: 4px; }
.filter-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 0; font-size: 14px; font-weight: 600; }
.filter-btn:first-child { border-right: 1px solid var(--divider); }

.outline-btn { border: 1.5px solid var(--black); border-radius: var(--r-pill); padding: 13px 26px; font-weight: 700; font-size: 14.5px; }

/* ---------- Performance ---------- */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { border-radius: var(--r-lg); padding: 18px; min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; }
.stat-card.dark { background: var(--black); color: var(--white); }
.stat-card.light { background: var(--panel); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-pill { border-radius: var(--r-pill); padding: 6px 14px; font-weight: 800; font-size: 17px; }
.stat-card.dark .stat-pill { background: var(--yellow); color: var(--black); }
.stat-card.light .stat-pill { background: var(--white); }
.stat-card .stat-label { font-size: 12.5px; opacity: .65; }
.stat-card .stat-value { font-weight: 700; font-size: 15px; margin-top: 2px; }

.goal-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 30px 16px; text-align: center; }
.ring-btn { width: 48px; height: 48px; border-radius: 50%; border: 2px solid #cfcfd1; display: flex; align-items: center; justify-content: center; color: var(--text); }
.goal-card strong { font-size: 16px; max-width: 220px; }

.body-diagrams { display: flex; justify-content: center; gap: 18px; }
.body-thumb { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.body-slot { width: 30vw; max-width: 130px; }
.body-slot svg { width: 100%; height: auto; display: block; }
.body-thumb span { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }

.muscle-modal { background: rgba(17,17,17,.94); align-items: center; justify-content: center; }
.muscle-modal .icon-btn { position: absolute; top: calc(env(safe-area-inset-top) + 14px); left: 18px; }
.muscle-big { width: 62vw; max-width: 280px; }
.muscle-big svg { width: 100%; height: auto; display: block; }
.muscle-caption { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 40px); color: var(--white); font-family: 'Poppins', sans-serif; font-weight: 700; font-size: 20px; }

.row-card { display: flex; align-items: center; gap: 14px; }
.row-card .sq-icon { width: 46px; height: 46px; border-radius: var(--r-md); background: var(--white); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.row-card strong { font-size: 15.5px; flex: 1; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + max(env(safe-area-inset-bottom), 10px));
  padding-bottom: max(env(safe-area-inset-bottom), 10px);
  background: var(--white);
  box-shadow: 0 -2px 14px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  z-index: 5;
}
.tab-btn { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--text-dim); }
.tab-btn span { font-size: 11px; font-weight: 600; }
.tab-btn.active { color: var(--text); }
.tab-btn.active .icon { color: var(--yellow); }
.qr-tab-btn {
  flex: 0 0 62px; height: 62px; border-radius: 50%; background: var(--black); color: var(--white);
  display: flex; align-items: center; justify-content: center; margin: 0 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
  transform: translateY(-14px);
}
.qr-tab-btn .icon { width: 26px; height: 26px; }

/* ---------- Modals shared ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  visibility: hidden;
  transition: transform .32s cubic-bezier(.32,.72,0,1), opacity .25s ease;
}
.modal.up { transform: translateY(100%); background: var(--white); }
.modal.up.open { transform: translateY(0); visibility: visible; }
.modal.right { transform: translateX(100%); background: var(--white); }
.modal.right.open { transform: translateX(0); visibility: visible; }
.modal.fade { opacity: 0; }
.modal.fade.open { opacity: 1; visibility: visible; }

.modal-header { display: flex; align-items: center; padding: calc(env(safe-area-inset-top) + 14px) 18px 14px; flex-shrink: 0; position: relative; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--white); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.modal-title { position: absolute; left: 0; right: 0; text-align: center; font-family: 'Poppins',sans-serif; font-weight: 700; font-size: 17px; pointer-events: none; }
.modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 20px 40px; }

/* ---------- Account modal ---------- */
.profile-card { background: var(--black); color: var(--white); border-radius: var(--r-lg); padding: 18px; display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-card .logo { font-size: 24px; }
.profile-card .pc-text { flex: 1; min-width: 0; }
.profile-card strong { display: block; font-size: 16.5px; }
.profile-card span { font-size: 13px; color: var(--text-onblack-dim); }

.pill-btn { width: 100%; background: var(--panel); border-radius: var(--r-pill); padding: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 700; font-size: 14.5px; margin-bottom: 22px; }

.list-section h3 { font-size: 13px; text-transform: none; color: var(--text-dim); font-weight: 700; margin: 0 0 4px; letter-spacing: .2px; }
.list-section h3.dark-h { color: var(--text); font-size: 17px; font-family: 'Poppins',sans-serif; margin-bottom: 6px; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--divider); }
.list-row .li-icon { width: 22px; height: 22px; color: var(--text); flex-shrink: 0; }
.list-row span.lbl { flex: 1; font-size: 15px; font-weight: 500; }
.list-row .icon.chev { width: 18px; height: 18px; color: #c6c6c8; }

.logout-btn { width: 100%; border: 1.5px solid var(--black); border-radius: var(--r-pill); padding: 15px; font-weight: 700; font-size: 15px; margin-top: 24px; }
.wordmark-footer { text-align: center; margin-top: 26px; }
.wordmark-footer .logo { font-size: 20px; letter-spacing: .5px; }
.wordmark-footer .ver { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- My details ---------- */
.details-block { margin-bottom: 8px; }
.details-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.details-block-head h3 { font-size: 17px; font-family: 'Poppins',sans-serif; }
.edit-pill { background: var(--panel); border-radius: var(--r-pill); padding: 8px 16px; font-weight: 700; font-size: 13px; }
.field-row { padding: 14px 0; border-bottom: 1px solid var(--divider); display: flex; align-items: center; justify-content: space-between; }
.field-row .fl { min-width: 0; }
.field-row label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.field-row .val { font-size: 15px; color: var(--text); letter-spacing: .5px; }
.plain-lines p { margin: 0 0 10px; font-size: 15.5px; }
.divider-line { height: 1px; background: var(--divider); margin: 22px 0; }

/* ---------- QR modal ---------- */
.qr-modal { background: #0a0a0a; color: var(--white); }
.qr-modal .modal-header .icon-btn { background: transparent; box-shadow: none; }
.qr-modal .modal-header .icon-btn .icon { color: var(--white); width: 24px; height: 24px; }
.qr-modal .modal-title { color: var(--white); font-size: 19px; }
.qr-body { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 10px 24px 30px; gap: 30px; }
.viewfinder { width: 100%; max-width: 340px; aspect-ratio: 5/6; border-radius: var(--r-lg); overflow: hidden; border: 3px solid rgba(255,255,255,.9); position: relative; background: #111; flex-shrink: 0; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.viewfinder.reject { animation: reject-flash .5s ease; }
@keyframes reject-flash { 0%,100% { border-color: rgba(255,255,255,.9); } 40% { border-color: #e0483e; } }
.qr-hint { color: var(--text-onblack-dim); font-size: 13.5px; text-align: center; }
.flash-btn { width: 52px; height: 52px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.5); display: flex; align-items: center; justify-content: center; margin-top: auto; }
.flash-btn .icon { color: var(--white); width: 22px; height: 22px; }
.flash-btn.on { background: var(--yellow); border-color: var(--yellow); }
.flash-btn.on .icon { color: var(--black); }

/* ---------- Success modal ---------- */
.success-modal { background: var(--green); color: var(--white); align-items: center; justify-content: center; text-align: center; padding: 40px; }
.success-modal .check-circle { width: 84px; height: 84px; border-radius: 50%; border: 3px solid var(--white); display: flex; align-items: center; justify-content: center; margin-bottom: 26px; }
.success-modal .check-circle .icon { width: 42px; height: 42px; }
.success-modal h2 { font-size: 26px; margin-bottom: 10px; }
.success-modal p { font-size: 15px; opacity: .9; max-width: 260px; }
.success-modal .tap-hint { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 30px); font-size: 12.5px; opacity: .75; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px); transform: translate(-50%, 12px); background: rgba(20,20,20,.92); color: var(--white); padding: 10px 18px; border-radius: var(--r-pill); font-size: 13.5px; opacity: 0; pointer-events: none; transition: transform .25s ease, opacity .25s ease; z-index: 40; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 480px) {
  #app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,.4); }
}
