:root {
  --blue: #1e88e5;
  --ink: #111;
  --muted: #6b7280;
  --card: #fff;
  --bg: #eceff1;
  --bar: #000;
  --font: "Noto Sans Bengali", "Plus Jakarta Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: #111; }
.reader-app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}
@media (min-width: 520px) {
  .reader-app {
    max-width: 430px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px #000;
  }
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.cat-bar {
  flex: 0 0 auto;
  background: var(--bar);
  padding: calc(env(safe-area-inset-top, 0px) + 2px) 0 0;
  z-index: 20;
}
.cat-scroller {
  display: flex;
  gap: 1.15rem;
  overflow-x: auto;
  padding: .55rem 1rem .5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-scroller::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: 0 0 auto;
  background: none;
  border: 0;
  padding: .15rem 0 .4rem;
  color: #fff;
  font: inherit;
  font-size: .95rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.cat-tab.on {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.new-banner {
  display: none;
  padding: .35rem .75rem 0;
}
.new-banner[hidden] { display: none !important; }
.new-banner:not([hidden]) { display: block; }
.new-banner button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: .4rem;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.stage-clip {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}
.stage {
  height: 100%;
  display: flex;
  will-change: transform;
  transition: transform .28s ease;
}
.cat-pane {
  flex: 0 0 auto;
  height: 100%;
}
.vert {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior-x: none;
}
.cell {
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  padding: .45rem .55rem .2rem;
}

.card {
  height: 100%;
  min-height: 0;
  background: var(--card);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  padding: .7rem .7rem 0;
}
.card-image {
  flex: 1 1 36%;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef2f4;
  border-radius: 12px;
  overflow: hidden;
}
.card-image img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
  opacity: 0;
  transition: opacity .2s ease;
}
.card-image img.is-ready { opacity: 1; }
.ph {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  color: var(--blue);
  font-weight: 700;
}
.card-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .45rem .7rem 0;
}
.brand-chip {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-size: .75rem;
  font-weight: 700;
}
.tool-btns { display: flex; gap: .15rem; }
.icon-btn {
  width: 34px; height: 34px;
  border: 0; background: none;
  color: #222;
  display: grid; place-items: center;
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.card-copy {
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
  padding: .15rem .8rem .35rem;
}
.card-copy h2 {
  margin: 0 0 .35rem;
  font-size: clamp(.92rem, 3.5vw, 1.12rem);
  line-height: 1.35;
  font-weight: 800;
}
.card-copy p {
  margin: 0;
  color: #222;
  font-size: clamp(.78rem, 2.9vw, .9rem);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
}
.card-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .6rem;
  padding: .15rem .8rem .45rem;
}
.meta-line {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35;
  flex: 1;
}
.details-btn {
  flex: 0 0 auto;
  background: var(--blue);
  color: #fff !important;
  border: 0;
  border-radius: 8px;
  padding: .42rem .85rem;
  font: inherit;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
}
.details-btn.disabled { opacity: .45; pointer-events: none; }
.dots {
  display: flex;
  justify-content: center;
  gap: .35rem;
  padding: .15rem 0 .4rem;
}
.dots i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #cfd8dc;
}
.dots i.on { background: var(--blue); }
.sub-ad {
  flex: 0 0 auto;
  max-height: 18%;
  min-height: 52px;
  padding: .15rem 0 .55rem;
}
.sub-ad img {
  width: 100%;
  height: 58px;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  background: #eef2f4;
  opacity: 0;
  transition: opacity .2s ease;
}
.sub-ad img.is-ready { opacity: 1; }

.ad-cell { padding: .45rem .55rem .2rem; }
.ad-frame {
  height: 100%;
  background: #111;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.ad-track {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.ad-slide {
  flex: 0 0 100%;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slide img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}
.ad-slide img.is-ready { opacity: 1; }
.ad-dots {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
}
.ad-dots i { background: rgba(255,255,255,.38); }
.ad-dots i.on { background: #fff; }

.empty-cell {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
}

.tabbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--bar);
  padding: .35rem 0 calc(.45rem + env(safe-area-inset-bottom, 0px));
  z-index: 20;
}
.tab-btn {
  background: none;
  border: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .12rem;
  font: inherit;
  font-size: .68rem;
  cursor: pointer;
}
.tab-btn svg { width: 22px; height: 22px; }
.tab-btn.on { color: var(--blue); }

.jump-top {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 25;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.28);
}
.jump-top[hidden] { display: none !important; }
.jump-top svg { width: 22px; height: 22px; }

.sheet {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  z-index: 30;
  text-align: center;
}

@media (min-height: 800px) {
  .card-copy p { -webkit-line-clamp: 10; }
  .sub-ad img { height: 72px; }
}
@media (max-height: 640px) {
  .card-copy p { -webkit-line-clamp: 4; }
  .sub-ad { max-height: 14%; }
  .sub-ad img { height: 44px; }
}
