*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: oklch(0.985 0.004 250);
  --ink: oklch(0.22 0.02 260);
  --line: oklch(0.88 0.01 250);
  --soft: oklch(0.94 0.006 250);
  --white: oklch(0.99 0 0);
  --live: oklch(0.6 0.21 25);
  /* Height of the host app's like/comment/fav bar drawn over the webview bottom.
     Override per page load with ?bottom=<px>. */
  --host-bottom: 64px;
}

html, body { margin: 0; height: 100%; }
/* the page has its own pull-to-refresh; stop the browser's from reloading the whole page */
html, body { overscroll-behavior-y: contain; }
body {
  background: oklch(0.95 0.006 250);
  color: var(--ink);
  font-family: 'Noto Sans Bengali', 'Hind Siliguri', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.app {
  --h: 55;
  --accent: oklch(0.56 0.14 var(--h));
  --tint: oklch(0.95 0.03 var(--h));
  position: relative;
  max-width: 430px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
}
@media (min-width: 600px) {
  .app { box-shadow: 0 0 40px oklch(0.3 0.03 260 / .08); }
}

.muted { opacity: .6; }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.accent-text { color: var(--accent); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: oklch(0.65 0.17 150); flex: none; }

/* ---------- main screen ---------- */
.main { min-height: 100dvh; display: flex; flex-direction: column; padding-top: 6px; }
/* title: app icon in the batch colour + name */
.top { padding: 4px 20px 4px; display: flex; align-items: center; gap: 10px; }
.logo {
  flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--white);
  background: linear-gradient(145deg, oklch(0.68 0.15 var(--h)), oklch(0.48 0.14 var(--h)));
  box-shadow: inset 0 1px 0 oklch(1 0 0 / .35), 0 4px 10px oklch(0.45 0.13 var(--h) / .35);
}
.top h1 {
  margin: 0; font-size: 22px; font-weight: 700; white-space: nowrap; letter-spacing: -.2px;
  background: linear-gradient(90deg, var(--ink), oklch(0.42 0.13 var(--h)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.seg {
  padding: 5px; border-radius: 30px; background: var(--soft);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
}
.seg button {
  --gh: 250;
  border: none; background: transparent; color: oklch(0.35 0.02 260);
  font-weight: 700; padding: 0 6px; min-width: 0;
  transition: background .25s, box-shadow .25s;
}
.seg button.on {
  background: oklch(0.56 0.14 var(--gh)); color: var(--white);
  box-shadow: 0 4px 12px oklch(0.56 0.14 var(--gh) / .35);
}
.seg-sm button { height: 44px; border-radius: 22px; font-size: 13px; white-space: nowrap; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; }

/* today card: raised, softly lit glass with the batch colour */
.card {
  position: relative; overflow: hidden; isolation: isolate;
  margin: 6px 20px 0; border-radius: 24px; padding: 13px 16px 14px;
  background:
    radial-gradient(130% 100% at 100% 0%, oklch(0.88 0.09 var(--h) / .55), transparent 55%),
    linear-gradient(160deg, oklch(0.98 0.025 var(--h)), oklch(0.93 0.05 var(--h)));
  border: 1px solid oklch(1 0 0 / .8);
  box-shadow:
    inset 0 1px 0 oklch(1 0 0 / .95),
    inset 0 -3px 0 oklch(0.5 0.1 var(--h) / .07),
    0 2px 4px oklch(0.4 0.08 var(--h) / .08),
    0 14px 30px -10px oklch(0.45 0.13 var(--h) / .4);
}
/* soft light blob in the top-right corner */
.card::before {
  content: ''; position: absolute; z-index: -1; right: -40px; top: -50px; width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle, oklch(0.75 0.13 var(--h) / .35), transparent 70%);
}
.card-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; gap: 8px; }
.card-head .muted { opacity: .7; white-space: nowrap; }
.live { display: flex; align-items: center; gap: 6px; white-space: nowrap; }



.today-time { margin: 4px 0 0; line-height: 1.1; white-space: nowrap; }
.today-time b {
  font-size: 38px; font-weight: 700; letter-spacing: -1px;
  background: linear-gradient(180deg, var(--ink) 30%, oklch(0.4 0.12 var(--h)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.today-time small { font-size: 16px; font-weight: 600; opacity: .55; margin: 0 6px 0 3px; }
.today-sub { font-size: 12.5px; font-weight: 600; color: var(--accent); }
/* today's time against today's target */
.tgt-chip {
  flex: none; border: none; padding: 3px 10px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: oklch(1 0 0 / .7); color: oklch(0.4 0.12 var(--h)); box-shadow: 0 1px 2px oklch(0.4 0.08 var(--h) / .12);
}
.tgt-chip u { text-decoration: none; color: var(--accent); }
.tgt-of { font-size: 15px; font-weight: 600; color: oklch(0.45 0.1 var(--h)); margin-left: 2px; }
.tgt { margin-top: 10px; }
.tgt-bar { height: 12px; border-radius: 7px; background: oklch(1 0 0 / .8); box-shadow: inset 0 1px 2px oklch(0.4 0.05 var(--h) / .2); overflow: hidden; }
.tgt-bar i {
  display: block; height: 100%; width: 0; border-radius: inherit; transition: width .6s cubic-bezier(.3, .9, .3, 1);
  background: linear-gradient(90deg, oklch(0.68 0.14 var(--h)), oklch(0.52 0.14 var(--h)));
}
.tgt-ticks { position: relative; height: 15px; margin-top: 3px; font-size: 10px; font-weight: 600; opacity: .55; }
.tgt-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tgt-ticks span:first-child { transform: none; }
.tgt-ticks span:last-child { transform: translateX(-100%); }
.tgt-line { font-size: 12.5px; margin-top: 4px; color: oklch(0.35 0.06 var(--h)); }
.tgt-line b { color: var(--accent); }
/* target reached: the whole card turns gold */
.card.goal { --h: 75; --accent: oklch(0.56 0.14 75); --tint: oklch(0.95 0.03 75); }

/* target sheet: iOS-style slider with hour notches */
.tgt-sheet .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ts-title { font-size: 20px; font-weight: 700; }
.ts-read { text-align: center; line-height: 1.1; margin-top: 4px; white-space: nowrap; }
.ts-read b { font-size: 46px; font-weight: 700; letter-spacing: -1px; color: var(--accent); }
.ts-read small { font-size: 17px; font-weight: 600; opacity: .55; margin: 0 6px 0 3px; }
.ts-sub { text-align: center; font-size: 13px; font-weight: 600; opacity: .65; margin-top: -6px; }
.ts { padding: 4px 14px 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; outline: none; }
.ts-rail { position: relative; height: 44px; }
.ts-track {
  position: absolute; left: 0; right: 0; top: 16px; height: 8px; border-radius: 4px; overflow: hidden;
  background: oklch(0.92 0.006 250); box-shadow: inset 0 1px 2px oklch(0.3 0.02 260 / .12);
}
.ts-track i { display: block; height: 100%; width: 0; background: var(--accent); }
.ts-ticks i { position: absolute; top: 30px; width: 1.5px; height: 5px; margin-left: -.75px; border-radius: 1px; background: oklch(0.7 0.01 250); }
.ts-ticks i.major { height: 10px; width: 2px; margin-left: -1px; background: oklch(0.5 0.02 250); }
.ts-thumb {
  position: absolute; top: 6px; width: 28px; height: 28px; margin-left: -14px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 0 .5px oklch(0 0 0 / .06), 0 3px 8px oklch(0 0 0 / .18), 0 1px 1px oklch(0 0 0 / .12);
  transition: transform .15s;
}
.ts.drag .ts-thumb { transform: scale(1.12); }
.ts:focus-visible .ts-thumb { box-shadow: 0 0 0 3px oklch(0.56 0.14 var(--h) / .35), 0 3px 8px oklch(0 0 0 / .18); }
.ts-labels { position: relative; height: 16px; font-size: 11px; font-weight: 600; opacity: .55; }
.ts-labels span { position: absolute; transform: translateX(-50%); }

.board { margin: 14px 20px 0; }
.board-tabs { margin-bottom: 10px; }
.board-tabs button { height: 38px; border-radius: 19px; font-size: 14px; white-space: nowrap; }
.board-tabs button.on { --gh: var(--h); }
.board-head { font-size: 14px; font-weight: 700; margin-bottom: 4px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0 10px; }
.board-head .muted { font-weight: 500; }
.member { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid oklch(0.92 0.005 250); border-radius: 12px; }
.member.me { background: var(--tint); padding: 8px 10px; margin: 0 -10px; }
.member .av { position: relative; flex: none; }
.member img { width: 38px; height: 38px; border-radius: 50%; display: block; }
/* studying right now: pulsing red ring, red dot and an "এখন পড়ছে" tag */
.member .av.live img { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--live); animation: ring 1.8s ease-out infinite; }
.member .av.live::after {
  content: ''; position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--live); border: 2px solid var(--bg);
}
.member.live:not(.me) { background: linear-gradient(90deg, oklch(0.96 0.03 25), oklch(0.96 0.03 25 / 0)); padding: 8px 10px; margin: 0 -10px; }
.live-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-right: 6px; padding: 0 6px; border-radius: 6px;
  background: var(--live); color: var(--white); font-size: 10.5px; font-weight: 700; line-height: 17px; vertical-align: 1px;
}
.live-tag i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s ease-in-out infinite; }
.member.live .ch { opacity: .85; }

/* who is studying right now: heading + everyone's photo and first name, swiped sideways */
.live-strip { margin-top: 14px; }
.lp-head { display: flex; align-items: center; gap: 8px; padding: 0 20px; font-size: 15px; font-weight: 700; }
.lp-dot {
  flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--live);
  box-shadow: 0 0 0 4px oklch(0.6 0.21 25 / .18); animation: lpPulse 1.6s ease-out infinite;
}
.lp-row {
  display: flex; gap: 12px; padding: 10px 20px 2px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scroll-padding: 0 20px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  /* faded edges hint that there is more to swipe */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
          mask-image: linear-gradient(90deg, transparent, #000 16px, #000 calc(100% - 16px), transparent);
}
.lp-row::-webkit-scrollbar { display: none; }
.lp { flex: none; width: 58px; display: flex; flex-direction: column; align-items: center; gap: 4px; scroll-snap-align: start; }
.lp-av { padding: 2px; border-radius: 50%; border: 2.5px solid var(--live); background: var(--bg); }
.lp-av img { display: block; width: 48px; height: 48px; border-radius: 50%; }
.lp-nm { max-width: 100%; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* on the focus screen: centred while everyone fits, on the dark background */
.focus-live { margin-top: 12px; }
.focus-live .lp-head { justify-content: center; font-size: 14px; font-weight: 600; }
.focus-live .lp:first-child { margin-left: auto; }
.focus-live .lp:last-child { margin-right: auto; }
.focus-live .lp-av { background: oklch(0.24 0.04 var(--h)); }
.focus-live .lp-av img { width: 44px; height: 44px; }
.focus-live .lp-nm { opacity: .85; }
.member .who { flex: 1; min-width: 0; }
.nmrow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.nmrow .nm { min-width: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.batch {
  flex: none; padding: 1px 7px; border-radius: 7px; font-size: 11px; font-weight: 700; white-space: nowrap;
  background: oklch(0.93 0.05 var(--bh)); color: oklch(0.42 0.12 var(--bh));
}
.member .tm { font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; text-align: right; }
.member .ch { font-size: 12px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { font-size: 13px; opacity: .55; padding: 10px 0; }

.actions { margin-top: auto; padding: 18px 20px calc(var(--host-bottom) + 16px); display: flex; gap: 10px; }
/* A long group list scrolls under the start button instead of pushing it off screen. */
.main > .actions { position: sticky; bottom: 0; z-index: 1; background: linear-gradient(oklch(0.985 0.004 250 / 0), var(--bg) 18px); }
.btn { height: 56px; border-radius: 16px; border: none; font-size: 18px; font-weight: 700; transition: background .3s, opacity .2s; }
.btn.primary { flex: 1; background: var(--accent); color: var(--white); }
.btn.primary:disabled { background: oklch(0.82 0.01 250); }
.btn.wide { width: 100%; }
.btn.ghost { width: 96px; flex: none; border: 1.5px solid var(--line); background: transparent; font-size: 16px; font-weight: 600; }
.btn.ghost-dark { width: 110px; flex: none; border: 1.5px solid oklch(1 0 0 / .18); background: transparent; font-size: 16px; font-weight: 600; }
.btn.light { flex: 1; background: oklch(0.97 0.01 250); color: var(--ink); }
.btn.light:disabled { opacity: .6; }
.btn:focus-visible, .seg button:focus-visible, .chips button:focus-visible, .avatars button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* pull-to-refresh spinner, slides down from the top */
.ptr {
  position: fixed; top: 0; left: 50%; z-index: 5; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; background: var(--white); pointer-events: none; opacity: 0;
  box-shadow: 0 4px 14px oklch(0.3 0.03 260 / .2); transform: translate(-50%, -46px);
  transition: transform .25s ease-out, opacity .25s;
}
.ptr.pulling { transition: none; }
.ptr i { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid oklch(0.56 0.14 var(--h) / .45); border-top-color: transparent; }
.ptr.ready i, .ptr.spin i { border-color: var(--accent); border-top-color: transparent; }
.ptr.spin i { animation: spin .7s linear infinite; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; max-width: 430px; margin: 0 auto; z-index: 10;
  display: flex; flex-direction: column;
}
.setup { background: var(--bg); animation: up .3s ease-out; }
.setup-head { padding: 6px 20px 0; display: flex; justify-content: space-between; align-items: center; }
.setup-head h2 { margin: 0; font-size: 24px; font-weight: 700; }
.link { border: none; background: none; font-size: 15px; font-weight: 600; color: oklch(0.45 0.02 260); padding: 8px 0; }
.setup-body { flex: 1; overflow-y: auto; padding: 14px 20px 0; display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 700; }
.avatars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.label .hint { font-size: 12px; font-weight: 600; opacity: .55; margin-left: 4px; }
.label .hint.need { opacity: 1; color: oklch(0.55 0.2 25); }
.avatars button {
  position: relative; aspect-ratio: 1; border-radius: 50%; border: 3px solid transparent; padding: 0;
  background: oklch(0.9 0.05 var(--ah, 250)); transition: transform .2s, opacity .2s, border-color .2s;
}
.avatars img { width: 100%; height: 100%; display: block; border-radius: 50%; }
/* nothing picked yet: a dashed ring invites a tap */
.avatars:not(.picked) button { border: 2px dashed oklch(0.7 0.03 250); }
/* picked: the chosen one is ringed, enlarged and ticked; the rest fade back */
.avatars.picked button:not(.on) { opacity: .45; transform: scale(.9); }
.avatars button.on { border-color: var(--accent); transform: scale(1.06); box-shadow: 0 4px 14px oklch(0.56 0.14 var(--h) / .4); }
.avatars button.on::after {
  content: '✓'; position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--white);
  border: 2px solid var(--bg); font-size: 12px; font-weight: 700; line-height: 1;
}
.input {
  height: 50px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--white);
  padding: 0 14px; font-size: 16px; outline: none; width: 100%;
}
.input:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  height: 30px; padding: 0 10px; border-radius: 15px; border: 1.5px solid var(--line);
  background: var(--white); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chips button.on { background: var(--accent); border-color: var(--accent); color: var(--white); }
/* ---------- leaderboard rows (this week / all-time tabs) ---------- */
.crow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid oklch(0.92 0.005 250); }
.crow.me { background: var(--tint); margin: 0 -10px; padding: 9px 10px; border-radius: 12px; }
.crow .rk { width: 34px; flex: none; text-align: center; font-size: 14px; font-weight: 700; opacity: .7; }
.crow .rk.medal { font-size: 22px; opacity: 1; }
.crow img { width: 38px; height: 38px; border-radius: 50%; flex: none; display: block; }
.crow .who { flex: 1; min-width: 0; }
.crow .sub { font-size: 12px; opacity: .6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow .tm { font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; text-align: right; }
.chart-foot { padding: 16px 0 4px; text-align: center; font-size: 13px; opacity: .7; }
.chart-foot .btn { width: 100%; height: 48px; font-size: 15px; opacity: 1; }

.setup-foot { padding: 14px 20px calc(var(--host-bottom) + 16px); }

.focus {
  background: oklch(0.24 0.04 var(--h)); color: oklch(0.97 0.01 250);
  transition: background .4s; z-index: 11;
}
.focus-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 0; }
.ring-wrap { position: relative; width: min(290px, 74vw, 40dvh); aspect-ratio: 1; }
.tree { position: absolute; inset: 6.2%; border-radius: 50%; background: oklch(1 0 0 / .06); overflow: hidden; }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: oklch(1 0 0 / .1); }
.ring .prog { stroke: oklch(0.78 0.12 var(--h)); stroke-linecap: round; stroke-dasharray: 816.8; transition: stroke-dashoffset .5s linear; }
.clock { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 6px; }
.time { font-size: 60px; font-weight: 600; line-height: 1; letter-spacing: -1px; font-variant-numeric: tabular-nums; transition: opacity .3s; }
.time.dim { opacity: .55; }
.fstate { font-size: 14px; opacity: .6; text-align: center; padding: 0 20px; }
.study { font-size: 15px; font-weight: 500; opacity: .7; text-align: center; line-height: 1.5; padding: 0 24px; overflow-wrap: anywhere; }

/* tree */
.sway { transform-origin: 125px 205px; }
.sway.on { animation: sway 4s ease-in-out infinite; }
.pop { transition: transform .5s cubic-bezier(.3, 1.4, .5, 1); }
.sprout { transition: opacity .4s; }

.scrim {
  position: fixed; inset: 0; max-width: 430px; margin: 0 auto; z-index: 20;
  background: oklch(0.22 0.02 260 / .45); display: flex; align-items: flex-end;
}
.sheet {
  width: 100%; background: oklch(0.99 0.003 250); border-radius: 28px 28px 0 0;
  padding: 26px 22px calc(var(--host-bottom) + 18px);
  display: flex; flex-direction: column; gap: 14px; animation: up .35s ease-out;
}
.gained { font-size: 30px; font-weight: 700; line-height: 1.2; }
.done-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.done-stats > div { padding: 10px 12px; border-radius: 14px; background: var(--tint); display: flex; flex-direction: column; gap: 2px; }
.done-stats span { font-size: 12px; opacity: .65; }
.done-stats b { font-size: 17px; color: var(--accent); }
.note { font-size: 14px; line-height: 1.5; opacity: .8; }
.sheet .btn { height: 54px; font-size: 17px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--host-bottom) + 90px); transform: translateX(-50%); z-index: 30;
  max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 14px;
  background: oklch(0.25 0.02 260); color: var(--white); font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px oklch(0.2 0.02 260 / .25); animation: up .25s ease-out;
}

@keyframes ring { 0% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--live), 0 0 0 4px oklch(0.6 0.21 25 / .5); }
                  100% { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--live), 0 0 0 11px oklch(0.6 0.21 25 / 0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; } }
@keyframes lpPulse { 0% { box-shadow: 0 0 0 0 oklch(0.6 0.21 25 / .45); } 100% { box-shadow: 0 0 0 8px oklch(0.6 0.21 25 / 0); } }
@keyframes sway { 0%, 100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast { animation-name: toastUp; }
@keyframes toastUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sway.on, .setup, .sheet, .toast, .member .av.live img, .live-tag i, .lp-dot { animation: none; }
}
@media (max-width: 360px) {
  .top h1 { font-size: 19px; }
  .today-time b { font-size: 34px; }
}
