/* ─── APP SHELL (shared across all pages) ────────────────────────────────────── */
html, body {
  height: 100%;
  background: var(--dark);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  /* dvh tracks iOS Safari's collapsing toolbar; vh stays as the fallback */
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--dark);
}

.app--tabbed {
  grid-template-rows: auto auto auto 1fr auto;
}

.bottomnav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  /* Keep nav buttons clear of the iPhone home indicator when installed */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.2px;
  text-transform: uppercase;
  text-decoration: none;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  transition: transform 0.25s var(--ease-precise);
}
.nav-btn.active { color: var(--gold); }
.nav-btn:hover { color: var(--gold); }
.nav-btn:hover svg { transform: translateY(-4px); }
.nav-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* "More" tab dots icon — boxed to the same 22px footprint as the other
   nav-btn svg icons so its label sits at the same baseline. */
.more-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.more-icon span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── BOTTOM NAV "MORE" SHEET (shared across all pages) ──────────────────────
   Mirrors the .sub-overlay/.sub-sheet bottom-sheet pattern (css/subscription.css)
   under its own class names since subscription.css isn't loaded on every page. */
.nav-sheet-overlay {
  position: fixed;
  inset: 0;
  left: max(0px, calc(50vw - 240px));
  right: max(0px, calc(50vw - 240px));
  background: rgba(14, 14, 15, 0.72);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease-precise);
}
.nav-sheet-overlay.open { opacity: 1; pointer-events: auto; }

.nav-sheet {
  position: relative;
  background: var(--card-raised);
  border: 0.5px solid var(--gold-border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  padding: 14px 18px calc(22px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-molten);
  transform: translateY(24px);
  transition: transform 0.28s var(--ease-precise);
}
.nav-sheet-overlay.open .nav-sheet { transform: none; }

.nav-sheet-grabber {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 14px;
}

.nav-sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-sheet-close svg { width: 14px; height: 14px; stroke-width: 2; }
.nav-sheet-close:hover, .nav-sheet-close:focus-visible { color: var(--gold); }
.nav-sheet-close:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.nav-sheet-group + .nav-sheet-group { margin-top: 16px; }

.nav-sheet-title {
  font-family: var(--font-condensed);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 8px 2px;
}

.nav-sheet-row {
  display: flex;
  gap: 8px;
}
.nav-sheet-row.fill .nav-sheet-item { flex: 1; }
.nav-sheet-row.center { justify-content: center; }
.nav-sheet-row.center .nav-sheet-item { flex: 0 0 72px; }

.nav-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 4px 8px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-sheet-item svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
  color: var(--gold);
}
.nav-sheet-item.dim svg { color: var(--muted); }
.nav-sheet-item.active { color: var(--gold); border-color: var(--gold-border); }
.nav-sheet-item.active svg { color: var(--gold); }
.nav-sheet-item:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

@media (prefers-reduced-motion: reduce) {
  .nav-sheet-overlay, .nav-sheet { transition: opacity 0.01s; animation: none; }
  .nav-sheet-overlay.open .nav-sheet { transform: none; }
}

/* ─── PAGE SUB-HEADER (title bar below the topbar, shared by all pages) ─────── */
.page-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.page-subheader-title {
  flex: 1;
  text-align: center;
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 3px;
  color: var(--text);
}
.page-subheader-spacer { width: 44px; flex-shrink: 0; }

/* ─── HEADER ─────────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--page-padding);
  /* Clear the iPhone status bar under black-translucent + viewport-fit=cover */
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── BRAND ──────────────────────────────────────────────────────────────────── */
.brand {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-word span { color: var(--gold); }
.brand-mark { width: 32px; height: 32px; display: block; }
.brand-word { height: 28px; width: auto; display: block; }

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-condensed);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ─── AVATAR & STREAK ────────────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 1.5px solid var(--gold-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gold);
  transition: background 0.15s, border-color 0.15s, transform 0.25s var(--ease-precise);
}
.notif-bell:hover {
  background: rgba(200,150,62,0.2);
  border-color: var(--gold);
  transform: translateY(-4px);
}
.notif-bell svg {
  stroke: var(--gold);
  width: 22px;
  height: 22px;
}
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  background: var(--red, #e05252);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--gold);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.25s var(--ease-precise);
  overflow: hidden;
}

.avatar:hover {
  background: rgba(200,150,62,0.2);
  border-color: var(--gold);
  box-shadow: var(--shadow-focus);
  transform: translateY(-4px);
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold-light);
}

/* Streak alive but today not yet logged — a quiet ember pulse, not a nag. */
.streak-badge.at-risk {
  animation: streakEmber 2.4s var(--ease-precise) infinite;
}
@keyframes streakEmber {
  0%, 100% { border-color: var(--gold-border); }
  50%      { border-color: var(--gold); }
}
@media (prefers-reduced-motion: reduce) {
  .streak-badge.at-risk { animation: none; border-color: var(--gold); }
}

/* ─── STAT CARDS ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--gold);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.badge-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity 0.15s, filter 0.15s, border-color 0.15s;
}

.badge-tile.earned {
  opacity: 1;
  filter: none;
  border-color: var(--gold-border);
}

.badge-tile img {
  width: 40px;
  height: 40px;
}

.badge-name {
  font-family: var(--font-condensed);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
}

.badge-tile.earned .badge-name {
  color: var(--ink-text);
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 14px;
  margin-top: 14px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--gold);
  color: #0E0E0F;
  font-family: var(--font-condensed);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: opacity var(--transition), transform 0.25s var(--ease-precise);
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-4px);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-condensed);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: border-color var(--transition), color var(--transition), transform 0.25s var(--ease-precise);
  margin-top: 8px;
}

.btn-secondary:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-4px);
}

.btn-secondary:focus-visible {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--shadow-focus);
}

.btn-complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(76, 175, 118, 0.3);
  background: rgba(76, 175, 118, 0.1);
  color: var(--green);
  font-family: var(--font-condensed);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background var(--transition), transform 0.25s var(--ease-precise);
  margin-top: 12px;
}

.btn-complete:hover:not(:disabled) {
  background: rgba(76, 175, 118, 0.2);
  transform: translateY(-4px);
}

.btn-complete:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-incomplete {
  margin-top: 12px;
  padding: 4px 10px;
  background: none;
  border: 0.5px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s, transform 0.25s var(--ease-precise);
  white-space: nowrap;
}
.btn-incomplete:hover { border-color: var(--red); color: var(--red); transform: translateY(-4px); }

/* ─── RUN CARD ───────────────────────────────────────────────────────────────── */
.run-card {
  background: rgba(200, 150, 62, 0.05);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 10px;
}

.run-card-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.run-card-desc {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────────── */
.prog-progress {
  margin-top: 12px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
}

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ─── TOGGLE ─────────────────────────────────────────────────────────────────── */
.toggle {
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  border: none;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.toggle.active {
  background: var(--gold);
}

.toggle.active::after {
  transform: translateX(18px);
}

/* ─── PHASE BADGE ────────────────────────────────────────────────────────────── */
.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.phase-badge--p1 {
  background: rgba(200, 150, 62, 0.1);
  color: var(--gold);
  border: 1px solid rgba(200, 150, 62, 0.25);
}

.phase-badge--p2 {
  background: rgba(74, 144, 217, 0.1);
  color: var(--blue);
  border: 1px solid rgba(74, 144, 217, 0.2);
}

/* ─── SESSION LOG DROPDOWN (shared — used in Log page & Analytics) ──────────── */
.an-ex-picker { display: flex; flex-direction: column; gap: 10px; }
.an-ex-dropdown { position: relative; }
.an-ex-dropdown-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; background: var(--card);
  border: 0.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13px; font-family: var(--font-body);
  cursor: pointer; text-align: left; transition: border-color 0.15s;
}
.an-ex-dropdown-trigger:hover,
.an-ex-dropdown-trigger.open { border-color: var(--gold-border); color: var(--text); }
.an-ex-chevron { flex-shrink: 0; transition: transform 0.2s; }
.an-ex-dropdown-trigger.open .an-ex-chevron { transform: rotate(180deg); }
.an-ex-dropdown-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 0.5px solid var(--gold-border);
  border-radius: var(--radius-sm); max-height: 260px; overflow-y: auto; z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.an-ex-dropdown-list::-webkit-scrollbar { width: 4px; }
.an-ex-dropdown-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.an-ex-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; transition: background 0.1s;
  font-size: 13px; color: var(--text);
}
.an-ex-dropdown-item:hover    { background: rgba(200,150,62,0.08); }
.an-ex-dropdown-item.selected { color: var(--gold); }
.an-ex-item-check {
  width: 18px; height: 18px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--card);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--gold); flex-shrink: 0;
}
.an-ex-dropdown-item.selected .an-ex-item-check { background: var(--gold-dim); border-color: var(--gold-border); }
.an-ex-dropdown-empty { padding: 16px 14px; font-size: 13px; color: var(--muted); text-align: center; }
.an-ex-dropdown-none { border-bottom: 0.5px solid var(--border); color: var(--muted) !important; font-style: italic; }
.an-ex-dropdown-none.selected { color: var(--text) !important; font-style: normal; }
.an-ex-dropdown-ctrl { padding: 8px 12px; border-bottom: 0.5px solid var(--border); display: flex; justify-content: flex-end; }
.an-ex-ctrl-btn {
  background: none; border: 0.5px solid var(--gold-border);
  color: var(--gold); font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  letter-spacing: 0.5px; transition: background 0.15s, transform 0.25s var(--ease-precise);
}
.an-ex-ctrl-btn:hover { background: var(--gold-dim); transform: translateY(-4px); }
.an-ex-no-data { margin-left: auto; font-size: 10px; color: var(--muted); font-style: italic; padding-right: 2px; }

/* Week rows inside dropdown */
.an-week-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer;
  border-bottom: 0.5px solid var(--border); transition: background 0.1s;
}
.an-week-row:hover { background: rgba(255,255,255,0.04); }
.an-week-row--active .an-week-row-label { color: var(--gold); }
.an-week-row-arrow { font-size: 9px; color: var(--muted); width: 10px; flex-shrink: 0; }
.an-week-row-info  { flex: 1; min-width: 0; }
.an-week-row-label { font-size: 13px; font-weight: 600; color: var(--text); display: block; }
.an-week-row-meta  { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
.an-week-row-check { font-size: 13px; color: var(--gold); width: 16px; text-align: center; }
.an-session-nested-item { padding-left: 28px !important; background: rgba(0,0,0,0.15); align-items: flex-start !important; }
.an-session-nested-item:last-child { border-bottom: 0.5px solid var(--border); }
.an-session-nested-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.an-session-nested-day  { font-size: 13px; font-weight: 600; color: var(--text); }
.an-session-nested-focus{ font-size: 11px; color: var(--muted); }

/* Session detail cards */
.an-session-detail-card {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 8px;
}
.an-session-detail-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px;
}
.an-session-detail-exercises {
  display: flex; flex-direction: column; gap: 5px;
  border-top: 0.5px solid var(--border); padding-top: 10px;
}
.an-session-detail-ex { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.an-session-detail-ex-name { color: var(--text); font-weight: 500; }
.an-session-detail-ex-meta { color: var(--muted); font-size: 11px; }
.an-session-detail-notes { margin-top: 10px; font-size: 11px; color: var(--muted); font-style: italic; border-top: 0.5px solid var(--border); padding-top: 8px; }
.an-session-row-left  { display: flex; flex-direction: column; gap: 2px; }
.an-session-row-title { font-size: 13px; font-weight: 600; color: var(--text); }
.an-session-row-meta  { font-size: 11px; color: var(--muted); }
.an-session-row-dur   { font-family: var(--font-display); font-size: 20px; color: var(--gold); }

/* Empty state & dropdown description */
.an-empty-state {
  text-align: center; padding: 24px; font-size: 13px;
  color: var(--muted); line-height: 1.6;
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: 12px; margin-top: 8px;
}
.an-dropdown-desc { margin: 4px 0 0 2px; font-size: 11px; color: var(--muted); line-height: 1.4; }