/* HomeFit — mobile-first, iPhone-friendly styling */

:root {
  --bg: #0f172a;
  --bg-2: #111c33;
  --surface: #162238;
  --surface-2: #1e2d4a;
  --border: #263859;
  --text: #e2e8f0;
  --subtle: #94a3b8;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --success: #34d399;
  --warn: #f59e0b;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) 16px 12px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--bg) 60%, rgba(15, 23, 42, 0.7));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #022c33;
  font-weight: 800;
  font-size: 14px;
}
.brand-name { font-weight: 600; letter-spacing: 0.2px; }

.top-nav { display: none; gap: 16px; }
.top-nav a { color: var(--subtle); font-size: 14px; }
@media (min-width: 720px) {
  .top-nav { display: flex; }
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 120px 16px;
}

h1 { font-size: 26px; margin: 6px 0 2px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.section-title { margin-top: 24px; }
.eyebrow { color: var(--subtle); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; margin: 0; }
.subtle { color: var(--subtle); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
}

.hero {
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
.hero-stats div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.hero-stats strong { display: block; font-size: 20px; }
.hero-stats span { color: var(--subtle); font-size: 12px; }

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.day-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  transition: transform 0.06s ease;
}
.day-card:active { transform: scale(0.98); }
.day-num { color: var(--accent); font-size: 12px; font-weight: 600; }
.day-card strong { font-size: 15px; }
.day-meta { color: var(--subtle); font-size: 12px; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field > legend { font-size: 13px; color: var(--subtle); }
.field input:not([type="checkbox"]):not([type="radio"]),
.field select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  appearance: none;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
fieldset.field { border: none; padding: 0; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  appearance: none;
  border: none;
  padding: 14px 18px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #022c33;
}
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.inline-form input, .inline-form button { height: 46px; }
.inline-form input {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 16px;
}

/* Exercise lists */
.exercise-list { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.exercise-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.exercise-item.blocked { opacity: 0.55; }
.exercise-item details { width: 100%; }
.exercise-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px;
}
.exercise-item summary::-webkit-details-marker { display: none; }
.ex-head { display: flex; align-items: center; gap: 12px; }
.ex-num {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--bg-2);
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.ex-title { flex: 1; min-width: 0; }
.ex-title strong { display: block; }
.ex-meta { color: var(--subtle); font-size: 12px; }
.ex-done { width: 22px; height: 22px; accent-color: var(--success); }
.ex-body { padding: 0 14px 14px 14px; }
.ex-gif {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: var(--bg-2);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}
.rest-btn { margin-top: 6px; width: 100%; }
.demo-link {
  display: block;
  text-align: center;
  text-decoration: none;
  width: 100%;
  margin-top: 6px;
}

.warn { color: var(--warn); }

/* Workout footer */
.workout-header { margin: 8px 0 12px; }
.back-link { display: inline-block; margin-bottom: 6px; color: var(--subtle); }

.workout-footer {
  position: sticky;
  bottom: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-top: 14px;
}
.timer-box { display: flex; flex-direction: column; }
.timer-label { font-size: 11px; color: var(--subtle); }
.timer-display { font-size: 22px; font-family: ui-monospace, SFMono-Regular, monospace; }

/* Rest overlay */
.rest-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 10, 24, 0.92);
  display: grid; place-items: center;
  z-index: 50;
}
.rest-overlay.hidden { display: none; }
.rest-inner { text-align: center; }
.rest-label { color: var(--subtle); text-transform: uppercase; letter-spacing: 2px; }
.rest-count { font-size: 96px; font-weight: 800; margin: 0; color: var(--accent); font-variant-numeric: tabular-nums; }

/* Bottom nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  color: var(--subtle);
  font-size: 11px;
}
.nav-item .nav-icon { font-size: 22px; line-height: 1; }
.nav-item:hover { color: var(--text); }

/* Library filter */
.filter-bar { display: flex; gap: 8px; margin: 10px 0 14px; }
.filter-bar input, .filter-bar select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}
.filter-bar input { flex: 1; }

/* Progress */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card strong { display: block; font-size: 24px; }
.stat-card span { color: var(--subtle); font-size: 12px; }

.history-list { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.history-meta { text-align: right; display: flex; flex-direction: column; }

#weight-chart { width: 100%; height: auto; }

/* ---------- Profiles ---------- */
.profiles-page h1 { text-align: center; margin-top: 24px; }
.profiles-page > p { text-align: center; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin: 24px 0;
}
.profile-form { margin: 0; }
.profile-tile {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 22px 12px 18px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, border-color 0.15s ease;
  position: relative;
}
.profile-tile:hover,
.profile-tile:focus {
  border-color: var(--accent);
  outline: none;
}
.profile-tile:active { transform: scale(0.97); }
.profile-emoji { font-size: 48px; line-height: 1; }
.profile-name { font-weight: 600; font-size: 15px; color: var(--text); }
.profile-lock {
  position: absolute;
  top: 8px; right: 10px;
  font-size: 13px;
  color: var(--subtle);
}
.profile-add {
  background: var(--bg-2);
  border-style: dashed;
}
.profile-add .profile-emoji { color: var(--accent); }

/* ---------- User chip in header ---------- */
.user-chip-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
}
.user-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.switch-form { margin: 0; }
.switch-btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--subtle);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.switch-btn:hover { color: var(--text); }

/* ---------- Unlock page ---------- */
.unlock-page { max-width: 380px; margin: 0 auto; }
.unlock-hero {
  text-align: center;
  padding: 20px 0 8px;
}
.unlock-emoji { font-size: 72px; line-height: 1; margin-bottom: 8px; }
.unlock-hero h1 { margin: 4px 0; }

/* ---------- Warn / danger cards ---------- */
.warn-card {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warn);
}
.danger-card {
  background: rgba(248, 113, 113, 0.05);
  border-color: rgba(248, 113, 113, 0.3);
}
.btn-danger {
  background: var(--danger);
  color: #300;
}

/* ---------- Blocked page ---------- */
.blocked-page { max-width: 480px; margin: 0 auto; }
.blocked-hero {
  text-align: center;
  padding: 30px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
}
.blocked-emoji { font-size: 64px; line-height: 1; margin-bottom: 10px; }
.blocked-hero h1 { margin: 6px 0; }
.blocked-hero code {
  background: var(--bg-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
}



.eq-tag { color: var(--accent-2); font-size: 11px; text-transform: capitalize; }
