/* ════════════════════════════════════════
   HOME
════════════════════════════════════════ */
/* ════════════════════════════════════════
   BACKGROUND IMAGE MANAGER
════════════════════════════════════════ */
.bg-manager-grid-inner {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding-bottom: 8px;
}

.bg-thumb-wrap {
  position: relative;
  aspect-ratio: 9/16;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface2);
}

.bg-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bg-thumb-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-thumb-num {
  position: absolute;
  bottom: 4px;
  left: 5px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* ════════════════════════════════════════
   HOME BACKGROUND SLIDESHOW
════════════════════════════════════════ */
/* Fixed so it covers the viewport regardless of scroll position.
   display:none collapses even fixed children, so hiding the parent page hides these too. */
#home-bg-slides,
#home-bg-overlay {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

#home-bg-overlay {
  z-index: 2;
  background: rgba(0, 0, 0, 0.72);
}

/* Only shown when home page has the class */
#page-home.home-has-bg #home-bg-slides,
#page-home.home-has-bg #home-bg-overlay { display: block; }

.home-bg-slide {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 1.8s ease;
  transform: scale(1.04);
}
.home-bg-slide.active {
  opacity: 1;
  animation: bgZoom 8s ease forwards;
}

@keyframes bgZoom {
  from { transform: scale(1.04); }
  to   { transform: scale(1); }
}

/* Content must sit above the fixed overlay */
#page-home.home-has-bg .page-header,
#page-home.home-has-bg .page-content {
  position: relative;
  z-index: 3;
}

/* Quote strip */
#home-bg-quote-wrap {
  min-height: 0;
  overflow: hidden;
  transition: min-height 0.4s;
}
.home-has-bg #home-bg-quote-wrap {
  min-height: 44px;
  margin-bottom: 6px;
}

#home-bg-quote {
  font-size: 13px;
  font-style: italic;
  color: rgba(255,255,255,0.75);
  text-align: center;
  letter-spacing: 0.4px;
  padding: 10px 12px;
  transition: opacity 0.4s;
  opacity: 1;
}

/* ════════════════════════════════════════
   HOME
════════════════════════════════════════ */
.iron-logo-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
}

.iron-emblem {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(255, 100, 25, 0.4));
}
.iron-emblem svg { width: 100%; height: 100%; display: block; }

.iron-logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 34px;
  letter-spacing: 7px;
  background: linear-gradient(135deg, #ff6419 0%, #ff9c5e 55%, #ffb87a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(255, 100, 25, 0.45));
}

.iron-tagline {
  font-size: 12px;
  color: var(--text3);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 4px;
}

/* ── Inline link ───────────────────────────────────────────────────────────── */
.quick-link { font-size: 12px; color: var(--accent); font-weight: 600; cursor: pointer; }

/* ── Backup nudge banner ───────────────────────────────────────────────────── */
.backup-banner {
  display: none; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, rgba(251,191,36,.12), rgba(251,191,36,.04));
  border: 1px solid rgba(251,191,36,.25); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 16px;
}
.backup-banner.show { display: flex; }
.backup-banner .bb-text { font-size: 12px; color: var(--text2); line-height: 1.5; }
.backup-banner .bb-text strong { color: var(--yellow); font-size: 13px; }

/* ── Emoji picker ──────────────────────────────────────────────────────────── */
.emoji-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  max-height: 132px; overflow-y: auto; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 8px;
}
.emoji-cell { font-size: 20px; text-align: center; padding: 6px 0; border-radius: 6px; cursor: pointer; background: none; border: none; }
.emoji-cell:hover, .emoji-cell:active { background: var(--surface3); }

/* ── Today card ────────────────────────────────────────────────────────────── */
.today-card {
  background: linear-gradient(135deg, var(--surface), var(--bg2));
  border: 1px solid var(--border2); border-radius: var(--r-lg);
  padding: 16px; margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.today-main { min-width: 0; }
.today-title { font-weight: 700; font-size: 16px; }
.today-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }
.today-goal { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
.today-goal-controls { display: flex; align-items: center; gap: 8px; }
.goal-step {
  width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text); font-size: 16px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.goal-step:active { transform: scale(0.9); }
.goal-label { font-size: 12px; color: var(--text2); font-weight: 600; min-width: 38px; text-align: center; }

/* ── Progress ring ─────────────────────────────────────────────────────────── */
.ring { position: relative; display: flex; align-items: center; justify-content: center; }
.ring-track, .ring-fill { fill: none; }
.ring-track { stroke: var(--surface3); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dashoffset 0.5s; }
.ring-label { position: absolute; font-weight: 700; color: var(--text); font-size: 13px; }

/* ── Achievements ──────────────────────────────────────────────────────────── */
.badge-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.badge-strip::-webkit-scrollbar { display: none; }
.ach { flex: 0 0 auto; width: 74px; text-align: center; }
.ach-medal {
  width: 54px; height: 54px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  margin: 0 auto 6px; background: var(--surface2); border: 1px solid var(--border2);
  filter: grayscale(1); opacity: 0.4; transition: all 0.2s;
}
.ach.earned .ach-medal {
  filter: none; opacity: 1; background: var(--accent-dim);
  border-color: var(--accent); box-shadow: 0 0 14px var(--accent-glow);
}
.ach-name { font-size: 10px; color: var(--text3); line-height: 1.2; }
.ach.earned .ach-name { color: var(--text2); }

/* ── Insight cards ─────────────────────────────────────────────────────────── */
.insight-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.insight-title { font-size: 12px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; font-weight: 600; margin-bottom: 14px; }

/* heatmap */
.heatmap { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.heatmap::-webkit-scrollbar { display: none; }
.hm-col { display: flex; flex-direction: column; gap: 3px; }
.hm-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--surface2); }
.hm-cell.l2 { background: rgba(255, 100, 25, 0.45); }
.hm-cell.l3 { background: rgba(255, 100, 25, 0.72); }
.hm-cell.l4 { background: var(--accent); }
.hm-legend { display: flex; align-items: center; gap: 5px; justify-content: flex-end; margin-top: 10px; font-size: 10px; color: var(--text3); }

/* trend bars */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 30px; background: linear-gradient(180deg, var(--accent), var(--accent-dim)); border-radius: 6px 6px 0 0; min-height: 3px; transition: height 0.4s; }
.bar-val { font-size: 11px; color: var(--text2); font-weight: 600; }
.bar-lab { font-size: 10px; color: var(--text3); }

/* segmented breakdown */
.seg-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--surface2); margin-bottom: 12px; }
.seg-bar span { height: 100%; }
.seg-legend { display: flex; flex-direction: column; gap: 8px; }
.seg-leg-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.seg-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.seg-leg-row .seg-count { margin-left: auto; color: var(--text3); font-weight: 600; }

/* ranking */
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rank-row:last-child { border-bottom: none; }
.rank-emoji { font-size: 20px; }
.rank-name { flex: 1; font-weight: 500; font-size: 14px; }
.rank-count { color: var(--accent); font-weight: 700; font-size: 14px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

.quick-title {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-weight: 600;
}

.recent-workout-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rw-name { font-weight: 600; font-size: 15px; }
.rw-date { font-size: 12px; color: var(--text3); margin-top: 3px; }

.install-banner {
  background: linear-gradient(135deg, rgba(255,100,25,.12), rgba(255,100,25,.04));
  border: 1px solid rgba(255,100,25,.25);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: none;
}
.install-banner.show { display: block; }
.install-banner-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: var(--accent); }
.install-banner-sub { font-size: 12px; color: var(--text2); line-height: 1.5; }

/* ════════════════════════════════════════
   WORKOUTS
════════════════════════════════════════ */
.workout-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  border-left: 3px solid var(--accent);
}

.workout-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}

.workout-name { font-weight: 700; font-size: 17px; }
.workout-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }

.workout-actions { display: flex; gap: 6px; }

.exercise-list   { display: flex; flex-direction: column; gap: 6px; }

.exercise-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-size: 13px;
  justify-content: space-between;
}

.exercise-chip-left  { display: flex; align-items: center; gap: 10px; }

.exercise-chip-thumb {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: var(--surface2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 16px;
}
.exercise-chip-thumb img { width: 100%; height: 100%; object-fit: cover; }

.exercise-chip-name { font-weight: 500; color: var(--text); }
.exercise-chip-meta { font-size: 12px; color: var(--text3); }

.start-btn-wrap { margin-top: 14px; }

/* ════════════════════════════════════════
   EXERCISES — CATEGORY GRID
════════════════════════════════════════ */
.ex-cat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.ex-cat-card:active { background: var(--surface2); border-color: var(--accent); }

.ex-cat-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  background: var(--accent-dim);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ex-cat-info  { flex: 1; min-width: 0; }
.ex-cat-name  { font-size: 17px; font-weight: 600; }
.ex-cat-count { font-size: 12px; color: var(--text3); margin-top: 2px; }

/* ════════════════════════════════════════
   EXERCISES — EXERCISE GRID
════════════════════════════════════════ */
.ex-lib-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ex-lib-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.ex-lib-card:active {
  border-color: var(--accent);
  transform: scale(0.97);
}

.ex-lib-img {
  width: 100%;
  height: 120px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  overflow: hidden;
}

.ex-lib-img img { width: 100%; height: 100%; object-fit: cover; }

.ex-lib-info  { padding: 10px 12px; }
.ex-lib-name  { font-weight: 600; font-size: 13px; line-height: 1.3; }
.ex-lib-cat   { font-size: 11px; color: var(--text3); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

.ex-lib-custom-badge {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
  margin-top: 5px;
  letter-spacing: 0.3px;
}

.ex-detail-img {
  width: 100%;
  border-radius: var(--r-lg);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin-bottom: 16px;
  overflow: hidden;
  min-height: 64px;
}
.ex-detail-img img { width: 100%; height: auto; object-fit: contain; display: block; }
.ex-anim { position: relative; width: 100%; }
.ex-anim img { width: 100%; height: auto; display: block; }
.ex-anim img:last-child { position: absolute; top: 0; left: 0; animation: ex-flip 0.8s step-end infinite; }
@keyframes ex-flip { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

/* ════════════════════════════════════════
   HISTORY
════════════════════════════════════════ */
.history-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-dot {
  width: 42px;
  height: 42px;
  border-radius: var(--r-md);
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.history-info    { flex: 1; min-width: 0; }
.history-name    { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date    { font-size: 12px; color: var(--text3); margin-top: 3px; }
.history-duration { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ════════════════════════════════════════
   IMAGE SEARCH
════════════════════════════════════════ */
.modal-img-search-panel {
  min-height: 82dvh;
  display: flex;
  flex-direction: column;
}

.img-search-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  margin-bottom: 4px;
  min-height: 200px;
}

.img-search-cell {
  aspect-ratio: 1;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  background: var(--surface2);
  transition: border-color 0.15s;
}

.img-search-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-search-cell.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.img-paste-section {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.img-paste-label {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.img-paste-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.img-paste-slot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.img-paste-input {
  flex: 1;
  font-size: 13px;
  padding: 10px 12px;
}

.img-search-label {
  font-size: 10px;
  color: var(--text2);
  text-align: center;
  padding: 4px 4px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Timetable workout picker ─────────────────────────────────────────────── */
.tt-pick-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--border2);
  background: var(--surface);
  cursor: pointer;
  font-size: 15px;
  transition: border-color 0.15s, background 0.15s;
}
.tt-pick-item:active    { background: var(--surface2); }
.tt-pick-selected       { border-color: var(--accent); background: var(--accent-dim); }

/* ════════════════════════════════════════
   TIMETABLE
════════════════════════════════════════ */
.tt-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.tt-row::-webkit-scrollbar { display: none; }

.tt-day {
  flex: 0 0 72px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 10px 6px 12px;
  text-align: center;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tt-day:active { transform: scale(0.96); }

.tt-today {
  border-color: var(--accent);
  background: rgba(255, 100, 25, 0.07);
}

.tt-past {
  opacity: 0.45;
}

.tt-done {
  opacity: 0.55;
}

.tt-day-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.tt-today .tt-day-name { color: var(--accent); }

.tt-day-num {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800; text-transform: uppercase;
  font-size: 22px;
  line-height: 1;
  color: var(--text);
}

.tt-workout {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.2;
  word-break: break-word;
  max-width: 64px;
}
.tt-done .tt-workout {
  text-decoration: line-through;
  color: var(--text3);
}

.tt-rest {
  font-size: 10px;
  color: var(--text3);
  font-style: italic;
}

.tt-check {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 10px;
  color: var(--green);
  font-weight: 700;
}

/* ════════════════════════════════════════
   NOTES
════════════════════════════════════════ */
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.note-card:active { border-color: var(--accent); }

.note-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.note-card-title   { font-weight: 600; font-size: 15px; flex: 1; }
.note-card-date    { font-size: 11px; color: var(--text3); flex-shrink: 0; }
.note-card-preview {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ════════════════════════════════════════
   SETTINGS
════════════════════════════════════════ */
.settings-section { margin-bottom: 28px; }

.settings-label {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-left: 4px;
}

.settings-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-item-label { font-size: 15px; font-weight: 500; }
.settings-item-sub   { font-size: 12px; color: var(--text3); margin-top: 2px; }
