/* Elite Rehab app — dark brand theme (black-maroon, Elite red, white pill buttons) */
:root {
  --bg: #0c0406;
  --bg-glow: #2a0a10;
  --card: #150a0c;
  --card-2: #1d0f12;
  --line: #34191e;
  --line-soft: #251216;
  --text: #f6f1f1;
  --muted: #b9a9ab;
  --red: #b3121f;
  --red-deep: #4a0c15;
  --red-bright: #ef4655;
  --radius: 20px;
  --display: "Michroma", "Arial Black", sans-serif;
  --body: "Noto Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 18px; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-family: var(--body); line-height: 1.55;
  background:
    radial-gradient(120% 55% at 50% -5%, var(--bg-glow) 0%, rgba(12,4,6,0) 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--text); }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px max(16px, calc((100% - 620px) / 2 + 16px)); padding-top: max(14px, env(safe-area-inset-top));
  background: rgba(12, 4, 6, .88); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; }
.brand img { height: 20px; width: auto; display: block; }
.help-btn {
  background: var(--red); color: #fff; border: 0; border-radius: 999px; flex: none;
  padding: 9px 18px; font: 700 .85rem var(--body); cursor: pointer;
}

main { max-width: 620px; margin: 0 auto; padding: 24px 16px 72px; }

/* Type */
h1, h2, .display {
  font-family: var(--display); font-weight: 400; text-transform: uppercase;
  letter-spacing: .01em; line-height: 1.15;
}
h1 { font-size: 1.55rem; margin: 6px 0 12px; }
h2 { font-size: 1.1rem; margin: 26px 0 10px; }
h3 { font-family: var(--body); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .85rem; }
.danger { color: var(--red-bright); }
strong { font-weight: 700; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin: 16px 0;
}
.notice {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--red-bright);
  border-radius: 14px; padding: 14px 16px; margin: 16px 0;
}

/* Forms */
label { display: block; font-weight: 700; margin: 16px 0 8px; }
input[type=email], input[type=text], input[type=date], input[inputmode=numeric], select {
  width: 100%; font: 1.05rem var(--body); padding: 15px 16px; border-radius: 14px;
  border: 1.5px solid var(--line) !important; background: #0f0608 !important; color: var(--text);
  color-scheme: dark;
}
input:focus, select:focus { outline: none; border-color: var(--red-bright) !important; box-shadow: 0 0 0 3px rgba(239,70,85,.2); }
.code-input { letter-spacing: .45em; text-align: center; font: 1.6rem var(--display) !important; }
.check { display: flex; gap: 12px; align-items: flex-start; font-weight: 400; margin: 14px 0; color: var(--muted); }
.check input { width: 24px; height: 24px; flex: none; margin-top: 2px; accent-color: var(--red); }
.check a { color: var(--text); }

/* Buttons */
.btn {
  display: block; width: 100%; min-height: 56px; margin-top: 20px; cursor: pointer;
  font: 700 1.05rem var(--body); border-radius: 999px; border: 0;
  background: #fff; color: #0c0406; transition: transform .1s, opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: transparent; color: var(--text); border: 1.5px solid rgba(255,255,255,.85); }
.link { background: none; border: 0; color: var(--muted); font: 1rem var(--body); text-decoration: underline; cursor: pointer; padding: 10px 0; }
.error { color: var(--red-bright); font-weight: 700; margin-top: 12px; }

/* Tags & progress */
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: .85rem;
}
.pill::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--red-bright); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 14px 0 6px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--red), var(--red-bright)); transition: width .3s; }

/* Exercises */
.exercise { padding: 0; overflow: hidden; }
.exercise.done { border-color: rgba(239,70,85,.6); }
.video {
  aspect-ratio: 16/9; display: grid; place-items: center; color: var(--muted); font-size: .9rem;
  background:
    linear-gradient(rgba(239,70,85,.06) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(239,70,85,.06) 1px, transparent 1px) 0 0 / 24px 24px,
    #100608;
  border-bottom: 1px solid var(--line);
}
.video video, .video iframe { width: 100%; height: 100%; border: 0; display: block; }
.ex-body { padding: 18px 20px 20px; }
.ex-top { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.ex-name { font-size: 1.15rem; font-weight: 700; margin: 0; }
.ex-id { font-family: var(--display); color: var(--muted); font-size: .8rem; }
.ex-dose { font-size: 1.05rem; font-weight: 700; color: var(--red-bright); margin: 6px 0 2px; }
.ex-cue { margin: 10px 0 0; color: var(--text); }
.tick {
  margin-top: 16px; width: 100%; min-height: 52px; border-radius: 999px; cursor: pointer;
  font: 700 1rem var(--body); border: 1.5px solid rgba(255,255,255,.85); background: transparent; color: var(--text);
}
.tick[aria-pressed=true] { background: var(--red); border-color: var(--red); color: #fff; }

/* Price */
.price { font-family: var(--display); font-size: 2.6rem; line-height: 1.1; margin-bottom: 6px; }
.price .cur { font-family: var(--body); font-weight: 400; margin-right: .08em; }
.card ul { padding-left: 20px; margin: 14px 0; }
.card li { margin: 6px 0; }
.card li::marker { color: var(--red-bright); }

/* Tabs (segmented control) */
.nav {
  display: flex; gap: 4px; padding: 5px; margin: 0 0 8px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card);
}
.nav button {
  flex: 1; min-height: 44px; border-radius: 12px; border: 0; background: transparent;
  font: 700 .95rem var(--body); color: var(--muted); cursor: pointer;
}
.nav button[aria-current=page] { background: var(--red-deep); color: #fff; }

/* Full plan */
details.card summary { cursor: pointer; list-style: none; line-height: 1.5; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary strong { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: .9rem; display: block; margin-bottom: 4px; }
details.card[open] summary { margin-bottom: 8px; }

/* Help dialog */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); max-width: 520px; width: calc(100% - 32px);
  padding: 24px; background: var(--card-2); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog h2 { margin-top: 0; }
dialog li { margin: 6px 0; }

/* Week strip (calendar) */
.week-head { display: flex; justify-content: space-between; align-items: center; margin: 18px 2px 8px; }
.week-head .link { padding: 0; }
.weekstrip { display: flex; align-items: stretch; gap: 6px; }
.wk-nav {
  flex: none; width: 34px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  color: var(--text); font: 700 1.4rem var(--body); cursor: pointer;
}
.wk-nav:disabled { opacity: .3; cursor: default; }
.wk-days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.wk-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px;
  border-radius: 14px; border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer;
  font-family: var(--body); min-width: 0;
}
.wk-day:disabled { opacity: .3; cursor: default; }
.wk-dow { font-size: .7rem; color: var(--muted); font-weight: 700; }
.wk-num { font: 700 1.05rem var(--body); }
.wk-mark { width: 9px; height: 9px; border-radius: 50%; margin-top: 3px; }
.wk-day.part .wk-mark { border: 2px solid var(--red-bright); }
.wk-day.full .wk-mark { background: var(--red-bright); box-shadow: 0 0 8px rgba(239,70,85,.6); }
.wk-day.today { border-color: var(--line); }
.wk-day.sel { background: var(--red-deep); border-color: var(--red); }
.wk-day.sel .wk-dow { color: #f3c9cd; }

.stats {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); font-size: .9rem; color: var(--muted);
}
.stats strong { color: var(--text); font-family: var(--display); font-weight: 400; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font: 700 .72rem var(--body); text-transform: uppercase; letter-spacing: .06em; color: #1a0a0c; vertical-align: 1px; }
.badge.bronze, .medal.bronze { background: linear-gradient(135deg, #e3a36a, #a8642f); }
.badge.silver, .medal.silver { background: linear-gradient(135deg, #f1f3f5, #9aa1a9); }
.badge.gold, .medal.gold { background: linear-gradient(135deg, #f6dc8a, #c4922c); }
.pill.ahead::before { background: var(--muted); }
.locked { margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--line); color: var(--muted); }
.locked strong { color: var(--red-bright); }

/* Completion celebration */
.celebrate {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(80% 60% at 50% 40%, rgba(74,12,21,.92), rgba(6,2,3,.96));
  animation: fadeIn .25s ease-out;
}
.celebrate.closing { animation: fadeOut .25s ease-in forwards; }
.celebrate-card {
  position: relative; z-index: 2; width: 100%; max-width: 420px; text-align: center;
  background: linear-gradient(180deg, var(--card-2), var(--card)); border: 1px solid var(--line);
  border-radius: 24px; padding: 30px 24px 24px; animation: popIn .45s cubic-bezier(.2,1.4,.4,1);
}
.celebrate-kicker { font: 700 .75rem var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--red-bright); margin: 14px 0 6px; }
.celebrate h2 { font-size: 1.35rem; margin: 0 0 14px; }
.bank { font-size: 1.05rem; margin-bottom: 10px; }
.bank-num { display: block; font: 3.4rem/1.05 var(--display); color: #fff; }
.tier-line { font-weight: 700; margin-bottom: 6px; }
.tier-line.bronze { color: #e3a36a; } .tier-line.silver { color: #e3e6ea; } .tier-line.gold { color: #f2cf6b; }
.burst, .medal {
  width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  font: 2rem var(--display); color: #fff; background: var(--red); box-shadow: 0 0 0 8px rgba(239,70,85,.15), 0 0 40px rgba(239,70,85,.45);
  animation: pulse 1.6s ease-in-out infinite;
}
.medal { color: #1a0a0c; box-shadow: 0 0 0 8px rgba(255,255,255,.08), 0 0 40px rgba(255,210,120,.35); }
.medal span { font-size: 1.7rem; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.confetti i { position: absolute; top: -20px; border-radius: 2px; opacity: .95; animation-name: fall; animation-timing-function: cubic-bezier(.3,.6,.6,1); animation-fill-mode: forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .celebrate, .celebrate-card, .burst, .medal { animation: none; }
}
