/* FlowFit — mobile-first dark UI, iOS-aware. */
:root {
  --bg:        #0e1116;
  --bg-elev:   #171c24;
  --bg-elev2:  #1f2630;
  --line:      #29313d;
  --text:      #eef2f7;
  --text-dim:  #9aa6b5;
  --text-faint:#6b7585;
  --accent:    #38d39f;
  --accent-ink:#06120d;
  --radius:    18px;
  --radius-sm: 12px;
  --maxw:      560px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font-family: inherit; }
b { font-weight: 700; }

.app-root {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100vh;
  padding: calc(var(--safe-top) + 10px) 18px calc(var(--tab-h) + var(--safe-bottom) + 20px);
}
.hidden { display: none !important; }
.spacer { height: 24px; }

/* ---------------- buttons ---------------- */
.btn {
  appearance: none; border: none; cursor: pointer;
  border-radius: 999px; padding: 15px 22px;
  font-size: 16px; font-weight: 700; letter-spacing: .2px;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  width: 100%;
}
.btn:active { transform: scale(.975); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:active { filter: brightness(1.08); }
.btn.ghost { background: var(--bg-elev2); color: var(--text); }
.btn.big { padding: 17px 22px; font-size: 17px; }
.btn.danger { color: #ff7a7a; background: transparent; border: 1px solid #40242a; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-elev2); color: var(--text); border: none;
  font-size: 22px; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.icon-btn.ghost { background: rgba(255,255,255,.08); }

/* ---------------- headers ---------------- */
.top { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 20px; gap: 12px; }
.top.with-back { justify-content: space-between; }
.greet { margin: 0; color: var(--text-dim); font-size: 14px; font-weight: 600; }
.page-title { margin: 2px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.page-title.center { font-size: 19px; text-align: center; flex: 1; }
.section-label {
  margin: 26px 0 12px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-faint);
}
.streak-pill {
  display: flex; align-items: center; gap: 5px;
  background: linear-gradient(135deg, #ff8a4a22, #ff4a4a22);
  border: 1px solid #3a2a26; color: #ffb48a;
  padding: 8px 13px; border-radius: 999px; font-weight: 800; font-size: 15px;
}
.flame { font-size: 15px; }

/* ---------------- hero ---------------- */
.hero {
  display: block; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; color: var(--text);
  background:
    radial-gradient(130% 120% at 100% 0%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%),
    var(--bg-elev);
  position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent);
}
.hero-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hero-day { font-size: 12px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--accent); }
.hero-focus { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.done-chip { font-size: 12px; font-weight: 800; color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, transparent); padding: 4px 10px; border-radius: 999px; }
.hero-title { margin: 0 0 6px; font-size: 27px; font-weight: 800; letter-spacing: -.6px; }
.hero-blurb { margin: 0 0 14px; color: var(--text-dim); font-size: 14.5px; }
.hero-meta { display: flex; align-items: center; gap: 8px; color: var(--text-faint); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.hero-meta .dot { opacity: .5; }
.hero-cta { display: inline-block; font-weight: 800; color: var(--accent); font-size: 15px; }

.preview-hero {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 4px;
  background:
    radial-gradient(130% 120% at 100% 0%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 60%),
    var(--bg-elev);
}
.preview-hero .hero-day { display: block; margin-bottom: 10px; }
.preview-hero .hero-blurb { margin-bottom: 12px; }

/* ---------------- week list ---------------- */
.week { display: flex; flex-direction: column; gap: 10px; }
.week-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px; color: var(--text); transition: border-color .15s ease, background .15s ease;
}
.week-row:active { background: var(--bg-elev2); }
.week-row.current { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.week-bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--accent); flex: 0 0 auto; }
.week-main { flex: 1; min-width: 0; }
.week-name { display: flex; align-items: center; gap: 8px; }
.week-name b { font-size: 16px; }
.tag-now { font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: 1px; color: var(--accent-ink); background: var(--accent); padding: 2px 7px; border-radius: 6px; }
.week-focus { display: block; color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.check { color: var(--accent); font-weight: 900; font-size: 18px; }
.chev { color: var(--text-faint); font-size: 22px; font-weight: 300; }

/* ---------------- exercise rows ---------------- */
.ex-list { display: flex; flex-direction: column; gap: 8px; }
.ex-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px;
}
.ex-ico {
  width: 40px; height: 40px; border-radius: 10px; background: var(--bg-elev2);
  display: grid; place-items: center; font-size: 19px; flex: 0 0 auto;
}
.ex-body { flex: 1; min-width: 0; }
.ex-body b { display: block; font-size: 15.5px; }
.ex-sub { display: block; color: var(--text-dim); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-target { text-align: right; flex: 0 0 auto; }
.ex-target b { display: block; font-size: 15px; color: var(--accent); }
.ex-target span { font-size: 12px; color: var(--text-dim); }

/* ---------------- sticky footer ---------------- */
.sticky-foot {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 14px 18px calc(14px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  max-width: var(--maxw); margin: 0 auto;
}

/* ---------------- onboarding ---------------- */
.onboard { padding-top: 10px; }
.brand-mark { display: flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: 3px; font-size: 14px; color: var(--text-dim); }
.logo-dot { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, #38d39f, #4a9eff); box-shadow: 0 0 20px #38d39f66; }
.ob-title { font-size: 30px; font-weight: 800; letter-spacing: -.8px; margin: 22px 0 10px; line-height: 1.12; }
.ob-sub { color: var(--text-dim); font-size: 15.5px; margin: 0 0 8px; }
.ob-q { font-size: 17px; font-weight: 800; margin: 28px 0 12px; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid.two { grid-template-columns: 1fr; }
.choice {
  display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer;
  background: var(--bg-elev); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px; color: var(--text); transition: border-color .15s, background .15s, transform .08s;
}
.choice:active { transform: scale(.98); }
.choice.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg-elev)); }
.choice-emoji { font-size: 24px; }
.choice-title { font-weight: 800; font-size: 15px; }
.choice-note { color: var(--text-dim); font-size: 12.5px; }
.field {
  width: 100%; background: var(--bg-elev); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 15px; color: var(--text); font-size: 16px; outline: none; transition: border-color .15s;
}
.field:focus { border-color: var(--accent); }
.field.search { margin-bottom: 4px; }
.onboard .btn.primary { margin-top: 26px; }
.ob-fine { text-align: center; color: var(--text-faint); font-size: 12.5px; margin-top: 14px; }

/* ---------------- player ---------------- */
.player { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: calc(20px + var(--safe-bottom)); }
.pl-top { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.pl-progress { flex: 1; height: 7px; border-radius: 99px; background: var(--bg-elev2); overflow: hidden; }
.pl-progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s ease; }
.pl-count { font-size: 13px; font-weight: 700; color: var(--text-dim); min-width: 42px; text-align: right; }
.pl-body { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 18px; }
.pl-kicker { font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--accent); }
.pl-set { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-top: 6px; }
.pl-ex { font-size: 30px; font-weight: 800; letter-spacing: -.6px; margin: 8px 0 14px; }
.pl-target { margin-bottom: 8px; }
.pl-target b { font-size: 46px; font-weight: 800; color: var(--accent); letter-spacing: -1px; }
.pl-hint { color: var(--text-dim); font-size: 14px; margin: 0 0 6px; }
.timer-num { font-size: 46px; font-weight: 800; color: var(--accent); }
.timer-num.big { font-size: 72px; }
.cues {
  text-align: left; margin: 18px 0 0; padding: 0; list-style: none; max-width: 420px; width: 100%;
}
.cues li {
  position: relative; padding: 9px 0 9px 26px; color: var(--text-dim); font-size: 14.5px; border-top: 1px solid var(--line);
}
.cues li:first-child { border-top: none; }
.cues li::before { content: ''; position: absolute; left: 4px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.swap { margin-top: 16px; width: 100%; max-width: 420px; text-align: left; }
.swap summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 14px; list-style: none; }
.swap summary::-webkit-details-marker { display: none; }
.swap p { color: var(--text-dim); font-size: 13.5px; margin: 10px 0 0; }
.pl-controls { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* rest screen */
.pl-body.rest { justify-content: center; }
.timer-ring {
  width: 190px; height: 190px; border-radius: 50%; display: grid; place-items: center; margin: 10px 0 18px;
  background:
    radial-gradient(closest-side, var(--bg) 78%, transparent 79%),
    conic-gradient(var(--accent) 0, var(--bg-elev2) 0);
  border: 2px solid var(--line);
}
.pl-next { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 22px; }
.pl-next span { color: var(--text-faint); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.pl-next b { font-size: 17px; }
.pl-row { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.pl-row .btn { width: auto; flex: 1; }

/* ---------------- finish ---------------- */
.finish { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.finish-badge {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; font-size: 48px; color: var(--accent-ink);
  background: var(--accent); box-shadow: 0 0 60px color-mix(in srgb, var(--accent) 50%, transparent); margin-bottom: 8px;
  animation: pop .5s cubic-bezier(.2,1.4,.5,1) both;
}
@keyframes pop { from { transform: scale(.3); opacity: 0; } }
.finish h1 { font-size: 28px; font-weight: 800; margin: 6px 0 0; }
.finish-sub { color: var(--text-dim); margin: 0 0 20px; }
.finish-stats { display: flex; gap: 10px; width: 100%; max-width: 420px; margin-bottom: 18px; }
.fstat { flex: 1; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 8px; }
.fstat-ico { display: block; font-size: 20px; }
.fstat b { display: block; font-size: 22px; font-weight: 800; margin-top: 2px; }
.fstat-label { font-size: 11px; color: var(--text-dim); }
.finish-quote { color: var(--text-dim); font-size: 14.5px; font-style: italic; max-width: 360px; margin: 0 0 22px; }
.finish .btn { max-width: 420px; }
.finish .btn.ghost { margin-top: 10px; }

/* ---------------- library ---------------- */
.lib-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.lib-card summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.lib-card summary::-webkit-details-marker { display: none; }
.lib-card[open] summary { border-bottom: 1px solid var(--line); }
.lib-card[open] .chev { transform: rotate(90deg); }
.chev { transition: transform .2s ease; }
.lib-detail { padding: 6px 14px 14px; }
.lib-detail .cues { margin-top: 4px; }
.swap-line { color: var(--text-dim); font-size: 13.5px; margin: 10px 0 0; }
.empty { color: var(--text-faint); text-align: center; padding: 30px 10px; }

/* ---------------- progress ---------------- */
.stat-grid { display: flex; gap: 10px; }
.bstat { flex: 1; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 10px; text-align: center; }
.bstat-ico { display: block; font-size: 22px; }
.bstat b { display: block; font-size: 26px; font-weight: 800; margin-top: 4px; }
.bstat-label { font-size: 12px; color: var(--text-dim); }
.day-dots { display: flex; justify-content: space-between; gap: 6px; }
.ddot-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; }
.ddot {
  width: 100%; aspect-ratio: 1; max-width: 44px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--accent-ink); font-weight: 900;
}
.ddot.on { background: var(--accent); border-color: var(--accent); }
.ddot-lbl { font-size: 11px; color: var(--text-faint); font-weight: 700; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 14px; margin-bottom: 10px; }
.setting > span { font-weight: 600; }
.setting select { width: auto; border: none; background: transparent; text-align: right; padding: 12px 0; color: var(--accent); font-weight: 700; }
.danger { margin-top: 8px; }

/* ---------------- tab bar ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tab-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; max-width: var(--maxw); margin: 0 auto;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px); -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; background: none; border: none; cursor: pointer; color: var(--text-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 8px 0;
}
.nav-ico { font-size: 21px; filter: grayscale(1) opacity(.65); transition: filter .15s; }
.nav-lbl { font-size: 11px; font-weight: 700; }
.tabbar button.on { color: var(--text); }
.tabbar button.on .nav-ico { filter: none; }

/* ---------------- confetti ---------------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall 2.6s linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(540deg); opacity: .2; } }

@media (max-width: 360px) {
  .choice-grid { grid-template-columns: 1fr; }
  .page-title, .ob-title { font-size: 24px; }
}
