/* ============================================================
   APP SHELL — mobile-first, khung 480px, thanh tab dưới.
   Trên màn hình lớn: canh giữa như một chiếc điện thoại.
   ============================================================ */

.app-body { background: var(--cream-2); }

.app {
  max-width: var(--wrap-app);
  margin-inline: auto;
  min-height: 100dvh;
  background: var(--white);
  position: relative;
  display: flex; flex-direction: column;
  box-shadow: 0 0 60px rgba(28,24,53,.08);
}

/* ---------------- Đầu màn ---------------- */

.app-top {
  position: sticky; top: 0; z-index: 30;
  background: var(--white); border-bottom: 1px solid var(--line-2);
  padding: var(--s-4) var(--s-5);
  display: flex; align-items: center; gap: var(--s-3);
}
.app-top h1 { font-size: 20px; }
.app-top__spacer { margin-left: auto; }

.streak-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  height: 32px; padding-inline: var(--s-3);
  background: var(--lime-wash); color: var(--streak);
  border-radius: var(--r-pill); font-weight: 800; font-size: var(--fs-sm);
}
.avatar {
  width: 36px; height: 36px; border-radius: var(--r-pill);
  background: var(--lime); color: var(--ink);
  display: grid; place-items: center; font-weight: 900;
}

/* ---------------- Vùng nội dung ---------------- */

.screen { flex: 1; padding: var(--s-5) var(--s-5) calc(var(--h-tabbar) + var(--s-10)); }
.screen[hidden] { display: none; }

.blk { margin-bottom: var(--s-8); }
.blk__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--s-4); }
.blk__head h2 { font-size: var(--fs-h3); }
/* Link "xem thêm": lime trên nền trắng chỉ 1.17:1 nên dùng --ink (17.05:1). */
.blk__more { font-size: var(--fs-sm); color: var(--ink); font-weight: 700; }

/* ---------------- Thẻ hôm nay (Home) ---------------- */

.today {
  border-radius: var(--r-lg); overflow: hidden;
  background: var(--navy); color: var(--white); position: relative;
}
.today__art { position: relative; }
.today__art .ph { border-radius: 0; aspect-ratio: 16 / 11; }
.today__tag {
  position: absolute; top: var(--s-4); left: var(--s-4);
  background: var(--lime); color: var(--ink);
  border-radius: var(--r-pill); padding: var(--s-1) var(--s-3);
  font-size: var(--fs-xs); font-weight: 900;
}
.today__body { padding: var(--s-5); }
.today__body h2 { color: var(--white); font-size: 22px; }
.today__meta { display: flex; gap: var(--s-4); margin: var(--s-3) 0 var(--s-5);
               font-size: var(--fs-sm); opacity: .75; }
.today__meta span { display: inline-flex; align-items: center; gap: var(--s-1); }

/* ---------------- Dải ngày (Plan) ---------------- */

.days { display: grid; gap: var(--s-3); }

.day-row {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--white);
  width: 100%; text-align: left;
}
.day-row.is-done   { background: var(--cream); border-color: transparent; }
.day-row.is-today  { border-color: var(--lime-deep); border-width: 2px; box-shadow: var(--sh-lime); }
.day-row.is-locked { opacity: .5; }

.day-row__no {
  flex: 0 0 44px; height: 44px; border-radius: var(--r-md);
  display: grid; place-items: center; font-weight: 900;
  background: var(--cream-2); color: var(--ink-3);
}
/* Ngày đã xong: nền lime nhạt + chữ than. Ngày hôm nay: lime chính + chữ than.
   Cả hai đều là NỀN SÁNG — không chữ trắng. */
.day-row.is-done .day-row__no  { background: var(--lime-soft); color: var(--ink); }
.day-row.is-today .day-row__no { background: var(--lime); color: var(--ink); }
.day-row__txt { flex: 1; min-width: 0; }
.day-row__txt b { display: block; color: var(--ink); font-size: var(--fs-sm); }
.day-row__txt span { font-size: var(--fs-xs); color: var(--ink-3); }
.day-row__end { font-size: var(--fs-xs); color: var(--ink-4); white-space: nowrap; }

/* ---------------- Lưới thẻ bài tập ---------------- */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }

.wcard { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--white); text-align: left; }
.wcard .ph { border-radius: 0; aspect-ratio: 4 / 3; }
.wcard__body { padding: var(--s-3); }
.wcard__body b { display: block; font-size: var(--fs-sm); color: var(--ink); line-height: 1.3; }
.wcard__body span { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------------- Thử thách ---------------- */

.chal {
  display: flex; gap: var(--s-4); align-items: center;
  padding: var(--s-4); border-radius: var(--r-lg);
  border: 1px solid var(--line); background: var(--white); width: 100%; text-align: left;
}
.chal__ring {
  flex: 0 0 56px; height: 56px; border-radius: var(--r-pill);
  display: grid; place-items: center; font-weight: 900; color: var(--ink);
  background: conic-gradient(var(--lime) var(--p,0%), var(--line-2) 0);
  position: relative;
}
.chal__ring::after { content:""; position:absolute; inset:5px; background:var(--white); border-radius:inherit; }
.chal__ring b { position: relative; z-index: 1; font-size: var(--fs-sm); }
.chal__txt { flex: 1; }
.chal__txt b { display: block; color: var(--ink); }
.chal__txt span { font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------------- Tiến trình ---------------- */

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); }
.kpi { background: var(--cream); border-radius: var(--r-md); padding: var(--s-4); text-align: center; }
.kpi b { display: block; font-size: 24px; font-weight: 900; color: var(--ink); }
.kpi span { font-size: var(--fs-xs); color: var(--ink-3); }

.week { display: flex; gap: var(--s-2); justify-content: space-between; }
.week__d { flex: 1; text-align: center; }
.week__dot {
  height: 40px; border-radius: var(--r-md); background: var(--cream);
  display: grid; place-items: center; font-size: var(--fs-xs); color: var(--ink-4);
  margin-bottom: var(--s-1);
}
/* Ô ngày trong tuần đã tập: nền lime sáng, số màu than (14.55:1). */
.week__d.on .week__dot { background: var(--lime); color: var(--ink); font-weight: 900; }
.week__d span { font-size: 10px; color: var(--ink-4); }

.badges { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-3); }
.badge { text-align: center; opacity: .35; }
.badge.on { opacity: 1; }
.badge__ico { font-size: 28px; }
.badge span { display: block; font-size: 10px; color: var(--ink-3); line-height: 1.25; }

/* ---------------- Cộng đồng ---------------- */

.post { padding: var(--s-4) 0; border-bottom: 1px solid var(--line-2); }
.post__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-3); }
.post__name { font-weight: 800; color: var(--ink); font-size: var(--fs-sm); }
.post__sub { font-size: var(--fs-xs); color: var(--ink-4); }
.post p { font-size: var(--fs-sm); color: var(--ink-2); margin: 0 0 var(--s-3); }
.post__acts { display: flex; gap: var(--s-6); font-size: var(--fs-xs); color: var(--ink-3); }
.post__acts button { display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--fs-xs); color: inherit; }

.checkin-box {
  display: flex; gap: var(--s-3); align-items: center;
  padding: var(--s-4); border-radius: var(--r-lg); background: var(--lime-wash);
  margin-bottom: var(--s-5);
}
.checkin-box p { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); flex: 1; }

.lb-row { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3) 0;
          border-bottom: 1px solid var(--line-2); }
.lb-row b { flex: 0 0 24px; color: var(--ink-4); }
.lb-row span { flex: 1; color: var(--ink); font-size: var(--fs-sm); }
.lb-row i { font-style: normal; font-size: var(--fs-xs); color: var(--ink-3); }

/* ---------------- Hồ sơ ---------------- */

.prof-head { text-align: center; padding: var(--s-6) 0 var(--s-8); }
.prof-head .avatar { width: 72px; height: 72px; font-size: 28px; margin: 0 auto var(--s-4); }
.prof-head h2 { font-size: var(--fs-h3); }
.prof-head p { font-size: var(--fs-sm); color: var(--ink-3); margin: var(--s-1) 0 0; }

.menu { border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; }
.menu a, .menu button {
  display: flex; align-items: center; gap: var(--s-4); width: 100%;
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line-2);
  font-size: var(--fs-sm); color: var(--ink-2); text-align: left;
}
.menu a:last-child, .menu button:last-child { border-bottom: 0; }
.menu a:hover, .menu button:hover { background: var(--cream); }
.menu .ico { width: 24px; text-align: center; }
.menu .chev { margin-left: auto; color: var(--ink-4); }

/* ---------------- Thanh tab dưới ---------------- */

.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--wrap-app);
  height: calc(var(--h-tabbar) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255,255,255,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 40;
}
.tab {
  display: grid; place-items: center; gap: 2px;
  font-size: 10px; color: var(--ink-4); font-weight: 600;
}
.tab__ico { font-size: 20px; line-height: 1; }
.tab.is-on { color: var(--ink); }
.tab.is-on .tab__ico { filter: none; }
.tab.is-on::before {
  content: ""; position: absolute; margin-top: -30px;
  width: 28px; height: 3px; border-radius: var(--r-pill); background: var(--lime-deep);
}

/* ---------------- Trình phát bài tập (toàn màn) ---------------- */

.player {
  position: fixed; inset: 0; z-index: 100;
  background: var(--ink); color: var(--white);
  display: flex; flex-direction: column;
}
.player[hidden] { display: none; }
.player__stage { flex: 1; position: relative; display: grid; place-items: center; }
.player__stage .ph {
  position: absolute; inset: 0; border-radius: 0;
  background: linear-gradient(160deg, #2A2A33, #16161B);
  color: #B0B0BC;
}
.player__close {
  position: absolute; top: var(--s-5); left: var(--s-5); z-index: 2;
  width: 40px; height: 40px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.15); color: var(--white);
  display: grid; place-items: center; font-size: 20px;
}
.player__now { position: relative; z-index: 2; text-align: center; }
.player__now b { display: block; font-size: 44px; font-weight: 900; letter-spacing: -.03em; }
.player__now span { opacity: .6; font-size: var(--fs-sm); }

.player__foot { padding: var(--s-6) var(--s-5) var(--s-10); background: var(--ink); }
.player__bar { height: 4px; border-radius: var(--r-pill); background: rgba(255,255,255,.18); margin-bottom: var(--s-5); }
.player__bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--lime); transition: width 1s linear; }
.player__ctrl { display: flex; align-items: center; justify-content: center; gap: var(--s-8); }
.player__btn { width: 56px; height: 56px; border-radius: var(--r-pill);
               background: rgba(255,255,255,.14); color: var(--white);
               display: grid; place-items: center; font-size: 22px; }
.player__btn--main { width: 76px; height: 76px; background: var(--lime); color: var(--ink); font-size: 28px; }

/* ---------------- Màn chúc mừng ---------------- */

.done-sheet {
  position: fixed; inset: 0; z-index: 110; background: rgba(28,24,53,.55);
  display: grid; place-items: end center;
}
.done-sheet[hidden] { display: none; }
.done-card {
  background: var(--white); width: 100%; max-width: var(--wrap-app);
  border-radius: var(--r-xl) var(--r-xl) 0 0; padding: var(--s-10) var(--s-6) var(--s-8);
  text-align: center;
}
.done-card .big { font-size: 56px; line-height: 1; margin-bottom: var(--s-4); }
.done-card h2 { margin-bottom: var(--s-2); }
.done-card p { color: var(--ink-3); font-size: var(--fs-sm); }
.done-stats { display: flex; justify-content: center; gap: var(--s-8); margin: var(--s-6) 0 var(--s-8); }
.done-stats b { display: block; font-size: 22px; color: var(--ink); }
.done-stats span { font-size: var(--fs-xs); color: var(--ink-3); }
