:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #efebe4;
  --text: #1c1a17;
  --muted: #6d675e;
  --line: #e2ddd4;
  --accent: #e86a1c;
  --accent-ink: #ffffff;
  --accent-soft: #fde6d6;
  --good: #1f8a5b;
  --good-soft: #d9f1e5;
  --warn: #b7791f;
  --warn-soft: #fbefd6;
  --bad: #c2412d;
  --bad-soft: #f9dfda;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --surface-2: #22262e;
    --text: #f1eee9;
    --muted: #9a958d;
    --line: #2b3038;
    --accent: #ff8a3d;
    --accent-ink: #1a1208;
    --accent-soft: #3a2616;
    --good: #4cc38a;
    --good-soft: #15301f;
    --warn: #e5b45a;
    --warn-soft: #33281a;
    --bad: #f07a68;
    --bad-soft: #3a1d18;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Bengali", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand img { border-radius: 7px; }
.sync { font-size: .75rem; color: var(--muted); }
.sync.off { color: var(--warn); }

.view { max-width: 620px; margin: 0 auto; padding: 4px 16px 24px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; text-decoration: none; font-size: .72rem; color: var(--muted);
}
.tabs a .ti { font-size: 1.25rem; line-height: 1; }
.tabs a.on { color: var(--accent); font-weight: 600; }

/* cards & layout */
.stack { display: grid; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; text-decoration: none; display: block; }
.card.tap:active { transform: scale(.99); }
.card.done { opacity: .72; }
.section-title { margin: 22px 0 10px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }

.hero { padding: 14px 0 6px; }
.hero h1 span { color: var(--accent); }
.progress { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent; white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
button.chip { cursor: pointer; }
button.chip.on { background: var(--accent); color: var(--accent-ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.big { min-height: 58px; font-size: 1.1rem; border-radius: 16px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.notice { border-radius: 14px; padding: 12px 14px; font-size: .9rem; display: flex; gap: 10px; align-items: flex-start; }
.notice.info { background: var(--accent-soft); }
.notice.good { background: var(--good-soft); }
.notice.warn { background: var(--warn-soft); }
.notice .x { margin-left: auto; background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 0 4px; }

/* session cards */
.sess-head { display: flex; gap: 12px; align-items: flex-start; }
.sess-num {
  flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800;
}
.done .sess-num { background: var(--good-soft); color: var(--good); }
.sess-moves { margin-top: 8px; font-size: .88rem; color: var(--muted); }

/* exercise rows */
.block { margin-top: 18px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.block-head h3 { font-size: .95rem; }
.ex {
  display: grid; grid-template-columns: 76px 1fr auto; gap: 12px; align-items: center;
  padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px;
}
.thumb {
  position: relative; width: 76px; height: 50px; border-radius: 9px; overflow: hidden; background: var(--surface-2);
  display: block;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after {
  content: "▶"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: .9rem; text-shadow: 0 1px 4px rgba(0,0,0,.6); background: rgba(0,0,0,.15);
}
.ex-name { font-weight: 600; line-height: 1.25; }
.ex-meta { font-size: .8rem; color: var(--muted); }
.ex-dose { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; font-size: .9rem; }
.ex-actions { display: flex; gap: 6px; margin-top: 6px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-size: .8rem; font-weight: 600; cursor: pointer; }
.cues { grid-column: 1 / -1; margin: 2px 0 0; padding-left: 18px; font-size: .85rem; color: var(--muted); }
.lvl { letter-spacing: 1px; color: var(--accent); font-size: .7rem; }

/* history */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 14px 8px; }
.stat b { display: block; font-size: 1.6rem; letter-spacing: -0.02em; }
.cal { display: grid; grid-template-columns: auto repeat(7, 1fr); gap: 4px; align-items: center; font-size: .7rem; max-width: 300px; margin: 0 auto; }
.cal .d { aspect-ratio: 1; border-radius: 5px; background: var(--surface-2); }
.cal .d.on { background: var(--accent); }
.cal .d.today { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal .d.future { opacity: .35; }
.log-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }

/* library */
.search {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit;
}
.hscroll { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }

/* settings */
.field { display: grid; gap: 8px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field label, .field .lab { font-weight: 600; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; cursor: pointer; color: var(--muted);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.levels { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; font-size: .9rem; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
textarea { width: 100%; min-height: 70px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; padding: 10px; }

/* bottom sheet */
.sheet {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-body {
  width: 100%; max-width: 620px; max-height: 82vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

/* player */
.player {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) max(16px, calc((100vw - 680px) / 2)) calc(16px + env(safe-area-inset-bottom));
}
.p-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.p-top { display: flex; align-items: center; gap: 10px; }
.p-top .bar { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.p-top .bar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.p-x { background: none; border: 0; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; color: var(--muted); }
.p-main { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 10px; overflow-y: auto; padding: 10px 0; }
.p-kind { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.p-kind.rest { color: var(--good); }
.p-name { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.p-dose { font-size: 1.15rem; font-weight: 700; color: var(--muted); }
.p-clock { font-size: 5.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1; }
.p-clock.small { font-size: 3rem; }
.p-clock.low { color: var(--accent); }
.p-cues { list-style: none; padding: 0; margin: 4px auto 0; font-size: .95rem; color: var(--muted); max-width: 420px; display: grid; gap: 4px; }
.p-next { font-size: .9rem; color: var(--muted); }
.p-next b { color: var(--text); }
.counter { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 6px; }
.counter button {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  font-size: 1.6rem; font-weight: 700; cursor: pointer;
}
.counter output { font-size: 2.6rem; font-weight: 800; min-width: 80px; font-variant-numeric: tabular-nums; }
.p-controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 10px; }
.p-list { list-style: none; padding: 0; margin: 0 auto; text-align: left; display: grid; gap: 6px; max-width: 380px; width: 100%; }
.p-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.playing-card {
  margin: 4px auto; width: 120px; height: 168px; border-radius: 14px; background: #fff; color: #111;
  border: 1px solid var(--line); display: grid; place-items: center; font-size: 2.6rem; font-weight: 800;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.playing-card.red { color: #c62828; }
.rate { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate button { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.rate button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.flash { animation: flash .5s; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--bg); } }

@media (min-width: 700px) {
  .p-name { font-size: 2.6rem; }
}

/* music */
.mixes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mix {
  display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 0 0 10px; cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; min-width: 0;
}
.mix.on { border-color: var(--accent); }
.mix-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--surface-2); }
.mix-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mix-len { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.75); color: #fff; font-size: .7rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.mix-title { padding: 0 8px; font-size: .78rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mix-sub { padding: 0 8px; font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mix.on .mix-sub::before { content: "▶ selected · "; color: var(--accent); font-weight: 700; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.dock {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.dock-video { flex: none; width: 96px; height: 54px; border-radius: 8px; overflow: hidden; background: #000; }
.dock-video iframe, .dock-yt { width: 96px !important; height: 54px !important; display: block; }
.dock-info { flex: 1; min-width: 0; }
.dock-title { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: 1rem; }

/* iPad / Mac: use the extra room */
@media (min-width: 860px) {
  .view { max-width: 1080px; padding: 8px 32px 40px; }
  .topbar { padding-left: max(32px, calc((100vw - 1080px) / 2 + 32px)); padding-right: max(32px, calc((100vw - 1080px) / 2 + 32px)); }
  .sess-grid { grid-template-columns: repeat(2, 1fr); align-items: stretch; }
  .sess-grid .card { height: 100%; }
  .lib-grid { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 12px; align-items: start; }
  .stats { max-width: 640px; }
  .tabs { padding-left: calc((100vw - 560px) / 2); padding-right: calc((100vw - 560px) / 2); }
  .p-name { font-size: 3rem; }
  .p-clock { font-size: 7.5rem; }
  .p-cues { font-size: 1.05rem; }
  .btn.big { min-height: 64px; }
  .dock-video, .dock-video iframe, .dock-yt { width: 128px !important; height: 72px !important; }
}
@media (max-width: 420px) {
  .mixes { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .mix-title { font-size: .72rem; }
}


/* login */
.gated .tabs { display: none; }
.login { max-width: 380px; margin: 6vh auto 0; text-align: center; display: grid; gap: 14px; }
.login img { margin: 0 auto; border-radius: 16px; }
.login form { text-align: left; }
