:root {
  --accent: #ff9500;
  --accent-rgb: 255, 149, 0;
  --bg: #07090d;
  --surface: rgba(22, 28, 40, 0.72);
  --surface-strong: rgba(28, 35, 50, 0.92);
  --border: rgba(255, 255, 255, 0.07);
  --text: #eef3fa;
  --muted: rgba(238, 243, 250, 0.58);
  --good: #30d158;
  --radius: 22px;

  --ion-background-color: var(--bg);
  --ion-text-color: var(--text);
  --ion-toolbar-background: transparent;
  --ion-item-background: transparent;
  --ion-card-background: var(--surface);
  --ion-font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Display", "Segoe UI", Roboto, sans-serif;

  --ion-color-primary: #ff9500;
  --ion-color-primary-rgb: 255, 149, 0;
  --ion-color-primary-contrast: #1a1000;
  --ion-color-primary-contrast-rgb: 26, 16, 0;
  --ion-color-primary-shade: #e08300;
  --ion-color-primary-tint: #ffa01a;
  --ion-color-step-50: #121418;
  --ion-color-step-100: #1d2025;
  --ion-color-step-150: #282b31;
  --ion-color-step-200: #33363d;
  --ion-color-step-250: #3e4149;
  --ion-color-step-300: #494c55;
  --ion-color-step-350: #545761;
  --ion-color-step-400: #5f626d;
  --ion-color-step-450: #6a6d79;
  --ion-color-step-500: #757885;
  --ion-color-step-550: #808391;
  --ion-color-step-600: #8b8e9c;
  --ion-color-step-650: #9699a7;
  --ion-color-step-700: #a1a4b2;
  --ion-color-step-750: #acafbd;
  --ion-color-step-800: #b7bac8;
  --ion-color-step-850: #c2c5d3;
  --ion-color-step-900: #cdd0de;
  --ion-color-step-950: #d8dbe9;
  --ion-border-color: rgba(255, 255, 255, 0.08);
  --ion-color-medium: #8e8e93;
  --ion-color-medium-rgb: 142, 142, 147;
  --ion-color-medium-contrast: #000;
}

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body { position: fixed; width: 100%; }
ion-app { height: 100%; }

ion-content {
  --background:
    radial-gradient(120% 60% at 50% -10%, rgba(var(--accent-rgb), 0.22) 0%, rgba(var(--accent-rgb), 0) 60%),
    var(--bg);
}
ion-content::part(scroll) { overscroll-behavior: none; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.accent { color: var(--accent); }

/* ---------- App bar ---------- */
.appbar { --background: rgba(7, 9, 13, 0.6); --border-width: 0; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.brand { font-weight: 800; letter-spacing: -0.02em; font-size: 19px; }
.brand .accent { margin-left: 6px; }
ion-segment { --background: rgba(255, 255, 255, 0.06); margin: 0 16px 8px; width: auto; }
ion-segment-button { --indicator-color: var(--accent); --color-checked: var(--ion-color-primary-contrast); font-weight: 700; min-height: 34px; }

/* ---------- Layout ---------- */
.page { padding: 8px 16px 120px; max-width: 560px; margin: 0 auto; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.cardHead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.cardHead h3 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Exercise chooser ---------- */
.exerciseRow { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 14px; scrollbar-width: none; }
.exerciseRow::-webkit-scrollbar { display: none; }
.exChip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font: inherit; font-weight: 700; font-size: 14px;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}
.exChip:active { transform: scale(0.96); }
.exChip ion-icon { font-size: 18px; }
.exChip.active { background: rgba(var(--accent-rgb), 0.18); border-color: rgba(var(--accent-rgb), 0.7); }
.exChip .tag { font-size: 10px; font-weight: 800; letter-spacing: 0.06em; padding: 2px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); color: var(--muted); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(160deg, rgba(var(--accent-rgb), 0.16) 0%, rgba(var(--accent-rgb), 0) 55%),
    var(--surface-strong);
}
.heroTop { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.heroTitle { font-size: 24px; font-weight: 850; letter-spacing: -0.02em; margin-top: 4px; }
.streakBadge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 11px; border-radius: 999px;
  background: rgba(255, 159, 10, 0.14); color: #ffb340;
  font-weight: 800; font-size: 14px; white-space: nowrap;
}
.streakBadge.cold { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.heroBody { display: flex; align-items: center; gap: 18px; margin-top: 16px; }
.ringWrap { position: relative; width: 148px; height: 148px; flex: 0 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ringTrack { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 10; }
.ringFill {
  fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round;
  filter: drop-shadow(0 0 6px rgba(var(--accent-rgb), 0.55));
  transition: stroke-dashoffset 600ms cubic-bezier(.2, .8, .2, 1);
}
.ringCenter { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ringNumber { font-size: 44px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ringLabel { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; margin-top: 4px; text-transform: uppercase; }
.heroSide { flex: 1; min-width: 0; }
.heroStat { margin-bottom: 12px; }
.heroStat .v { font-size: 22px; font-weight: 850; font-variant-numeric: tabular-nums; }
.heroStat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.progressTrack { height: 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.progressFill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 600ms ease; }

.setRow { display: flex; gap: 8px; margin-top: 16px; }
.setChip {
  flex: 1;
  text-align: center;
  padding: 10px 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  font-weight: 850; font-size: 17px; font-variant-numeric: tabular-nums;
}
.setChip small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; margin-top: 2px; }
.setChip.top { background: rgba(var(--accent-rgb), 0.2); color: var(--accent); }

/* ---------- Stats ---------- */
.statGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 12px;
}
.stat .v { font-size: 22px; font-weight: 850; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }

/* ---------- Week ---------- */
.weekDots { display: flex; justify-content: space-between; gap: 6px; }
.dayDot { flex: 1; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); }
.dayDot .d {
  width: 32px; height: 32px; margin: 6px auto 0; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
}
.dayDot.done .d { background: var(--accent); color: var(--ion-color-primary-contrast); }
.dayDot.today .d { border-color: rgba(var(--accent-rgb), 0.8); }
.dayDot ion-icon { font-size: 16px; }

.planLine { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); }
.planLine:last-child { border-bottom: 0; }

/* ---------- Bottom CTA ---------- */
.ctaBar {
  display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(7, 9, 13, 0) 0%, rgba(7, 9, 13, 0.92) 35%);
}
.ctaBar ion-button { margin: 0; height: 56px; font-weight: 800; font-size: 17px; --border-radius: 18px; }
#startTrainingBtn { flex: 1; --box-shadow: 0 10px 30px rgba(var(--accent-rgb), 0.35); }
#sessionBtn { width: 56px; --padding-start: 0; --padding-end: 0; }

/* ---------- Training ---------- */
.trainingWrap { height: 100%; display: flex; flex-direction: column; }
.trainingTop { padding: 12px 16px 0; }
.trainingTopRow { display: flex; justify-content: space-between; align-items: flex-end; }
.bigLabel { font-weight: 900; font-size: 20px; font-variant-numeric: tabular-nums; }
.trainingStrip { display: flex; gap: 8px; margin-top: 12px; }
.setPill {
  flex: 1; text-align: center;
  padding: 8px 0; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.setPill.active { border-color: var(--accent); color: var(--text); background: rgba(var(--accent-rgb), 0.14); }
.setPill.done { background: rgba(48, 209, 88, 0.16); color: var(--good); }

.tapArea {
  flex: 1;
  margin: 14px 16px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background:
    radial-gradient(80% 60% at 50% 40%, rgba(var(--accent-rgb), 0.22) 0%, rgba(var(--accent-rgb), 0) 70%),
    var(--surface);
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  position: relative; overflow: hidden;
  transition: transform 90ms ease;
}
.tapArea:active { transform: scale(0.985); }
.tapArea.resting { background: radial-gradient(80% 60% at 50% 40%, rgba(10, 132, 255, 0.2) 0%, rgba(10, 132, 255, 0) 70%), var(--surface); }
.tapArea.pulse::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(var(--accent-rgb), 0.35), transparent 60%);
  animation: pulse 380ms ease-out forwards;
  pointer-events: none;
}
@keyframes pulse { from { opacity: 1; transform: scale(0.8); } to { opacity: 0; transform: scale(1.3); } }
.tapInner { text-align: center; padding: 14px; }
.sessionRing { position: relative; width: min(60vw, 32vh, 260px); aspect-ratio: 1; margin: 0 auto; }
.sessionRing .ringFill { stroke-width: 8; transition: stroke-dashoffset 250ms ease; }
.sessionRing .ringTrack { stroke-width: 8; }
.tapArea.resting .ringFill { stroke: #0a84ff; filter: drop-shadow(0 0 6px rgba(10, 132, 255, 0.55)); }
.tapCount { font-size: clamp(56px, 9vh, 88px); font-weight: 900; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.tapHint { margin-top: 6px; font-weight: 800; letter-spacing: 0.12em; font-size: 13px; color: var(--muted); }
.tapMeta { margin-top: 14px; font-size: 13px; color: var(--muted); max-width: 300px; margin-left: auto; margin-right: auto; line-height: 1.4; }

.motionBox { margin-top: 12px; }
.motionStatus { font-size: 12px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.motionStatus .dot { width: 8px; height: 8px; border-radius: 50%; background: #8e8e93; }
.motionStatus.live .dot { background: var(--good); box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.2); }
.motionStatus.wait .dot { background: #ffd60a; }
.motionMeter { height: 6px; width: 160px; margin: 8px auto 0; border-radius: 6px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.motionMeter > div { height: 100%; width: 0; background: var(--accent); transition: width 100ms linear; }

.trainingBottom {
  padding: 10px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(7, 9, 13, 0.85);
  backdrop-filter: blur(10px);
}
.bottomRow { display: flex; gap: 10px; align-items: center; }
.bottomRow ion-button { margin: 0; height: 48px; --border-radius: 14px; font-weight: 800; }
.repBtns { display: flex; gap: 10px; margin-bottom: 10px; }
.repBtns ion-button { flex: 1; }

.swipeBtn {
  position: relative; overflow: hidden; isolation: isolate;
  flex: 1; height: 58px; border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  display: flex; align-items: center;
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.swipeFill { position: absolute; inset: 0; width: 0; background: rgba(var(--accent-rgb), 0.25); border-radius: 999px; pointer-events: none; }
.swipeKnob {
  position: absolute; top: 50%; left: 7px;
  width: 44px; height: 44px; transform: translate(0, -50%);
  border-radius: 999px; background: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  z-index: 2; cursor: grab; touch-action: none;
  display: grid; place-items: center;
}
.swipeChev { width: 10px; height: 10px; border-right: 2.5px solid rgba(0, 0, 0, 0.65); border-top: 2.5px solid rgba(0, 0, 0, 0.65); transform: rotate(45deg); margin-left: -3px; pointer-events: none; }
.swipeLabel { position: relative; z-index: 1; width: 100%; text-align: center; font-weight: 800; padding-left: 40px; color: var(--muted); pointer-events: none; }

/* ---------- Lists / modals ---------- */
ion-list.inset { background: transparent; }
ion-item { --background: transparent; --border-color: var(--border); }
.historyItem .title { font-weight: 800; }
.planCurrent { --background: rgba(var(--accent-rgb), 0.1); border-left: 3px solid var(--accent); }
.emptyState { text-align: center; padding: 48px 24px; color: var(--muted); }
.emptyState ion-icon { font-size: 44px; color: var(--accent); opacity: 0.8; }

ion-modal::part(content) { background: var(--bg); }
ion-modal ion-toolbar { --background: var(--bg); }

ion-alert.dark-alert { --background: #1c2230; --backdrop-opacity: 0.65; }
.dark-alert .alert-title, .dark-alert .alert-message { color: var(--text); }
.dark-alert .alert-button { color: var(--accent); }

.recordBlock { text-align: center; padding: 18px; border-radius: 18px; background: rgba(255, 255, 255, 0.04); margin-bottom: 12px; }
.bigNumber { font-size: 60px; font-weight: 900; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* ---------- Engagement ---------- */
.small { font-size: 13px; }
.heroMsg { margin: 10px 0 0; font-size: 14px; color: var(--muted); font-weight: 600; }
.dayDot.future .d { opacity: 0.45; }

.weekGoalRow { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.weekGoalNum { font-size: 22px; font-weight: 850; font-variant-numeric: tabular-nums; }

.invite { display: flex; align-items: center; gap: 12px; padding: 14px 10px 14px 14px; border-color: rgba(10, 132, 255, 0.4); background: linear-gradient(135deg, rgba(10, 132, 255, 0.16), rgba(10, 132, 255, 0.04)), var(--surface); }
.inviteIcon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(10, 132, 255, 0.2); color: #64b5ff; font-size: 20px; flex: 0 0 auto; }
.inviteText { flex: 1; min-width: 0; }
.inviteTitle { font-weight: 800; }

.badgeRow { display: flex; flex-wrap: wrap; gap: 8px; }
.miniBadge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); font-size: 13px; font-weight: 700;
}
.miniBadge.earned { background: rgba(var(--accent-rgb), 0.16); color: #ffc46b; }
.miniBadge ion-icon { font-size: 16px; }

.achSection { margin-bottom: 22px; }
.achSection h2 { margin: 0 0 10px; }
.badgeGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge {
  border-radius: 18px; padding: 14px 12px; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.badgeIcon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; margin-bottom: 4px; }
.badge.earned .badgeIcon { background: radial-gradient(circle at 35% 30%, #ffc46b, var(--accent)); color: #1a1000; box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.35); }
.badge.locked .badgeIcon { background: rgba(255, 255, 255, 0.06); color: var(--muted); }
.badge.locked .badgeName, .badge.locked .badgeDesc { opacity: 0.6; }
.badgeName { font-weight: 800; font-size: 14px; }
.badgeDesc { font-size: 12px; color: var(--muted); line-height: 1.3; }
.badgeStatus { font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.badge.earned .badgeStatus { color: #ffc46b; }
.badge .progressTrack { width: 80%; height: 4px; margin-top: 6px; }

/* Celebration */
.celebrate { position: relative; text-align: center; padding-top: 18px; }
.celebrate > * { animation: rise 420ms cubic-bezier(.2, .8, .2, 1) both; }
.celebrate > *:nth-child(2) { animation-delay: 60ms; }
.celebrate > *:nth-child(3) { animation-delay: 120ms; }
.celebrate > *:nth-child(n+4) { animation-delay: 180ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.celebrateBurst {
  width: 92px; height: 92px; margin: 0 auto 12px; border-radius: 50%;
  display: grid; place-items: center; font-size: 46px; color: #1a1000;
  background: radial-gradient(circle at 35% 30%, #ffd08a, var(--accent));
  box-shadow: 0 0 0 10px rgba(var(--accent-rgb), 0.14), 0 12px 40px rgba(var(--accent-rgb), 0.45);
  animation: pop 520ms cubic-bezier(.2, 1.4, .4, 1) both;
}
.celebrateBurst.soft { background: radial-gradient(circle at 35% 30%, #9fd0ff, #0a84ff); box-shadow: 0 0 0 10px rgba(10, 132, 255, 0.14), 0 12px 40px rgba(10, 132, 255, 0.35); }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate h1 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -0.02em; outline: none; }
.celebrateHeadline { margin: 8px 0 0; font-weight: 800; color: var(--accent); }
.celebrateMsg { margin: 4px auto 18px; max-width: 320px; }
.celebrate .statGrid { text-align: left; }
.celebrateBlock { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 14px; margin-bottom: 10px; }
.celebrateBlock .cardHead { margin-bottom: 8px; }
.celebrateBlock .progressFill { transition: width 900ms cubic-bezier(.2, .8, .2, 1); }
.celebrateBlock > * + * { margin-top: 6px; }
.targetLine { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.targetLine.ok { color: var(--good); }
.streakLine { margin: 0 0 10px; }
.nextBlock .mono { font-weight: 700; }

.confetti { position: absolute; inset: -20px 0 auto 0; height: 0; pointer-events: none; z-index: 5; }
.confetti span { position: absolute; top: 0; width: 8px; height: 14px; border-radius: 2px; animation: fall 2.2s cubic-bezier(.3, .6, .5, 1) forwards; }
@keyframes fall { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 0 520px; } }

/* Weekly recap */
.recapNav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.recapHero { text-align: center; padding: 10px 0 18px; }
.goalChip { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); font-weight: 700; font-size: 14px; }
.goalChip.met { background: rgba(48, 209, 88, 0.16); color: var(--good); }
.recapHighlight { font-size: 20px; font-weight: 850; margin: 6px 0; }
.timeline { display: flex; gap: 8px; height: 110px; align-items: stretch; margin-top: 10px; }
.tlDay { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tlBarWrap { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.tlBar { width: 100%; border-radius: 6px; background: rgba(255, 255, 255, 0.08); }
.tlBar.on { background: var(--accent); }
.tlLabel { font-size: 11px; font-weight: 700; color: var(--muted); }
.recapClosing { font-weight: 700; text-align: center; margin: 18px 0 6px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .confetti { display: none; }
}
