/* ==========================================================================
   Jafu E-Paper — reader theme
   The page image is the hero: chrome is a quiet "light table" the newsprint sits on.
   ========================================================================== */
:root {
  --accent: #C8102E;
  --accent-ink: #fff;
  --desk: #E4E7EA;
  --panel: #FFFFFF;
  --panel-2: #F3F5F6;
  --ink: #1A2330;
  --muted: #5D6874;
  --rule: #CDD3D9;
  --rule-2: #E4E8EB;
  --ok: #1E7B4A;
  --warn: #8F6200;
  --err: #B3261E;
  --serif: "Tiro Bangla", "Noto Serif Bengali", "SolaimanLipi", serif;
  --sans: "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 6px;
  --r-sm: 4px;
  --paper-shadow: 0 1px 2px rgba(16, 24, 34, .14), 0 10px 30px rgba(16, 24, 34, .16);
  --tb-h: 52px;
  --fs-story: 19px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --desk: #13171C; --panel: #1C2128; --panel-2: #232A32; --ink: #E6EAEE; --muted: #9AA5B1;
    --rule: #364049; --rule-2: #2A323B; --paper-shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 16px/1.6 var(--sans); }
img { max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--panel); padding: 8px 14px; z-index: 300; border-radius: var(--r-sm); }
.skip:focus { top: 8px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); border-radius: var(--r-sm); font-weight: 600; font-size: 15px; line-height: 1.3; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn .ic { width: 18px; height: 18px; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 6px 12px; font-size: 14px; }
.btn--block { display: flex; width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; background: transparent; color: var(--ink); border-radius: var(--r-sm); cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn--light { color: #fff; }
.icon-btn--light:hover { background: rgba(255,255,255,.12); }

/* ---------- Masthead ---------- */
.masthead { background: var(--panel); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--rule); }
.masthead__inner { max-width: 1600px; margin: 0 auto; padding: 12px 20px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px 28px; }
.brand { text-decoration: none; display: inline-flex; align-items: center; min-height: 48px; }
.brand__logo { max-height: 60px; width: auto; display: block; }
.brand__name { font: 400 38px/1.05 var(--serif); letter-spacing: -.01em; color: var(--ink); }
.masthead__dates { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; font-size: 14px; color: var(--muted); }
.masthead__dates span + span { border-left: 1px solid var(--rule); margin-left: 12px; padding-left: 12px; }
.masthead__dates .d-greg { color: var(--ink); font-weight: 600; }
.masthead__nav { display: flex; align-items: center; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 10px; border: 0; background: none; border-radius: var(--r-sm); text-decoration: none; font-size: 15px; font-weight: 500; cursor: pointer; color: var(--ink); }
.nav-link:hover { background: var(--panel-2); }
.nav-sub { margin-left: 4px; }
.ed-select { padding: 7px 30px 7px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); font-weight: 500; }

/* ---------- Flash / alerts ---------- */
.flashes { max-width: 1600px; margin: 12px auto 0; padding: 0 20px; display: grid; gap: 8px; }
.flash, .alert { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid var(--rule); background: var(--panel); }
.flash--success, .alert--ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 9%, var(--panel)); }
.flash--error, .alert--error { border-color: color-mix(in srgb, var(--err) 45%, transparent); background: color-mix(in srgb, var(--err) 8%, var(--panel)); display: block; }
.flash__x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px; display: grid; }

/* ---------- Reader layout ---------- */
.reader { display: grid; grid-template-columns: 196px minmax(0, 1fr) 300px; gap: 20px; max-width: 1600px; margin: 0 auto; padding: 16px 20px 40px; align-items: start; }
.rail { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; scrollbar-width: thin; }
.rail__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 15px; padding: 2px 2px 10px; }
.rail__link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; }
.rail__link .ic { width: 16px; height: 16px; }
.rail__link:hover { color: var(--accent); }
.rail__x, .rail__head--mobile { display: none; }

.thumbs { list-style: none; margin: 0; padding: 0 4px 0 0; display: grid; gap: 14px; }
.thumb { display: block; text-decoration: none; }
.thumb__img { display: block; position: relative; background: var(--panel); box-shadow: 0 1px 2px rgba(16,24,34,.15); border: 2px solid transparent; transition: border-color .15s; }
.thumb__img img { display: block; width: 100%; height: auto; }
.thumb:hover .thumb__img { border-color: var(--rule); }
.thumb.is-active .thumb__img { border-color: var(--accent); }
.thumb__cap { display: block; font-size: 13px; color: var(--muted); padding: 4px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb__cap b { color: var(--ink); font-weight: 600; margin-right: 2px; }
.thumb.is-active .thumb__cap, .thumb.is-active .thumb__cap b { color: var(--accent); }
.thumb__lock { position: absolute; right: 6px; top: 6px; background: rgba(26,35,48,.82); color: #fff; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.thumb__lock .ic { width: 15px; height: 15px; }

.stage { min-width: 0; }
.issue-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap; padding: 0 2px 10px; }
.issue-bar__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.issue-bar__title strong { font: 400 22px/1.2 var(--serif); }
.issue-bar__title span { color: var(--muted); }
.issue-bar__nav { display: flex; gap: 14px; font-size: 14px; }
.issue-bar__nav a { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; }
.issue-bar__nav a:hover { color: var(--accent); }
.issue-bar__nav .ic { width: 16px; height: 16px; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--rule-2); }
.tag--warn, .tag--pending { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-color: transparent; }
.tag--active, .tag--published { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--panel)); border-color: transparent; }
.tag--rejected, .tag--cancelled { color: var(--err); background: color-mix(in srgb, var(--err) 10%, var(--panel)); border-color: transparent; }

/* Toolbar */
.toolbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 6px; margin-bottom: 14px; }
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-group + .tb-group { border-left: 1px solid var(--rule-2); padding-left: 6px; }
.tb-group:last-child { margin-left: auto; }
.tb-btn { display: inline-flex; align-items: center; gap: 5px; height: 38px; min-width: 38px; padding: 0 9px; border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; justify-content: center; }
.tb-btn:hover { background: var(--panel-2); }
.tb-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 12%, var(--panel)); color: var(--accent); }
.tb-btn.is-disabled { opacity: .35; pointer-events: none; }
.tb-zoomval { min-width: 58px; font-variant-numeric: tabular-nums; }
.tb-select { height: 38px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); padding: 0 8px; max-width: 220px; font-weight: 500; }
.tb-mobile { display: none; }
.menu { position: relative; }
.menu__list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: 0 8px 24px rgba(16,24,34,.18); min-width: 220px; padding: 6px; z-index: 40; }
.menu__item { display: block; padding: 9px 12px; border-radius: var(--r-sm); text-decoration: none; font-size: 15px; }
.menu__item:hover { background: var(--panel-2); }
.menu__item--accent { color: var(--accent); font-weight: 600; }
.menu__note { margin: 4px 8px 6px; font-size: 14px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.menu__note .ic { width: 16px; height: 16px; }

/* Viewport & sheet */
.viewport { position: relative; outline: none; }
.viewport.is-zoomed { overflow: auto; max-height: calc(100vh - 90px); cursor: grab; border-radius: var(--r); background: color-mix(in srgb, var(--desk) 70%, #000 4%); touch-action: pan-x pan-y; overscroll-behavior: contain; }
.viewport.is-panning { cursor: grabbing; user-select: none; }
.sheet { position: relative; margin: 0 auto; width: 100%; background: #fff; box-shadow: var(--paper-shadow); user-select: none; -webkit-user-select: none; }
.sheet__img { display: block; width: 100%; height: 100%; -webkit-user-drag: none; }
.sheet.is-locked .sheet__img { filter: blur(3px) saturate(.6); }
.sheet.is-loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; pointer-events: none; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.spots { position: absolute; inset: 0; }
.spot { position: absolute; display: block; border: 2px solid transparent; border-radius: 2px; transition: border-color .12s, background-color .12s; cursor: pointer; }
.spot:hover, .spot:focus-visible { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); outline: none; }
.sheet.show-spots .spot { border-color: color-mix(in srgb, var(--accent) 70%, transparent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.spot--ad:hover, .sheet.show-spots .spot--ad { border-style: dashed; }
.spot__tip { position: absolute; left: 6px; top: 6px; max-width: min(340px, calc(100% - 12px)); background: var(--ink); color: var(--panel); font-size: 14px; line-height: 1.35; padding: 5px 9px; border-radius: var(--r-sm); opacity: 0; transform: translateY(-2px); transition: opacity .12s, transform .12s; pointer-events: none; }
.spot:hover .spot__tip, .spot:focus-visible .spot__tip { opacity: 1; transform: none; }
@media (hover: none) { .spot__tip { display: none; } }

.paywall { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 18% 16px 16px; background: linear-gradient(to bottom, rgba(228,231,234,.25), rgba(228,231,234,.75)); }
.paywall__box { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--paper-shadow); padding: 26px 28px; max-width: 420px; text-align: center; }
.paywall__ic { width: 34px; height: 34px; color: var(--accent); }
.paywall__title { font: 400 24px/1.35 var(--serif); margin: 10px 0 6px; }
.paywall__box p { margin: 0 0 16px; color: var(--muted); }
.paywall__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Clip tool */
.clipper { position: absolute; inset: 0; cursor: crosshair; background: rgba(16,24,34,.28); z-index: 5; touch-action: none; }
.clipper.has-rect { background: transparent; }
.clipper__hint { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); background: var(--ink); color: var(--panel); padding: 8px 14px; border-radius: 99px; font-size: 14px; white-space: nowrap; pointer-events: none; }
.clipper__rect { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px rgba(16,24,34,.5); outline: 1px solid rgba(0,0,0,.4); }
.clipper__bar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; background: var(--panel); border: 1px solid var(--rule); padding: 8px; border-radius: var(--r); box-shadow: 0 10px 30px rgba(16,24,34,.25); z-index: 60; }

.page-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 18px 0 0; }
.page-foot__btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r-sm); text-decoration: none; font-weight: 600; }
.page-foot__btn:hover { border-color: var(--ink); }
.page-foot__no { color: var(--muted); font-size: 15px; }

/* Right rail panels */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px 14px; margin-bottom: 16px; }
.panel__title { font-size: 16px; font-weight: 600; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--rule-2); }
.sections { list-style: none; margin: 0; padding: 0; }
.sections a { display: flex; align-items: center; gap: 10px; padding: 7px 4px; text-decoration: none; border-bottom: 1px solid var(--rule-2); font-size: 15px; }
.sections li:last-child a { border-bottom: 0; }
.sections a:hover { color: var(--accent); }
.sections a.is-active { color: var(--accent); font-weight: 600; }
.sections__no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: var(--r-sm); background: var(--panel-2); font-size: 13px; font-weight: 600; color: var(--muted); }
.sections a.is-active .sections__no { background: var(--accent); color: var(--accent-ink); }
.sections__lock { width: 15px; height: 15px; margin-left: auto; color: var(--muted); }

/* Calendar */
.cal { user-select: none; }
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.cal__title { font-weight: 600; font-size: 15px; }
.cal__nav { width: 32px; height: 32px; }
.cal__nav[disabled] { opacity: .3; cursor: default; }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal__wd { font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal__d { display: grid; place-items: center; aspect-ratio: 1; font-size: 14px; border-radius: var(--r-sm); color: color-mix(in srgb, var(--muted) 60%, transparent); text-decoration: none; position: relative; }
a.cal__d { color: var(--ink); font-weight: 600; }
a.cal__d::after { content: ""; position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
a.cal__d:hover { background: var(--panel-2); }
.cal__d.is-sel { background: var(--accent); color: var(--accent-ink); }
.cal__d.is-sel::after { background: var(--accent-ink); }
.cal__d.is-today { box-shadow: inset 0 0 0 1px var(--rule); }
.cal__foot { margin-top: 8px; font-size: 13px; text-align: right; }
.cal__foot a { color: var(--muted); }

/* ---------- Ads ---------- */
.ad { text-align: center; margin: 0 0 16px; }
.ad img { display: inline-block; max-width: 100%; height: auto; vertical-align: middle; }
.ad__label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; letter-spacing: .02em; }
.ad-band { max-width: 1600px; margin: 10px auto; padding: 0 20px; }
.ad-below { margin-top: 18px; }
.ad-sticky { display: none; }

/* ---------- Article modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 3vh 16px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(12,17,23,.6); }
.modal__panel { position: relative; width: 100%; max-width: 880px; max-height: 94vh; height: 94vh; display: flex; flex-direction: column; background: var(--panel); border-radius: 8px; box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden; animation: modalIn .18s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 18px; border-bottom: 1px solid var(--rule); }
.modal__meta { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 14px; color: var(--muted); }
.modal__meta b { color: var(--accent); font-weight: 600; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: var(--r-sm); padding: 3px; }
.seg__btn { display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent; padding: 5px 10px; border-radius: 3px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--muted); }
.seg__btn .ic { width: 17px; height: 17px; }
.seg__btn.is-on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,34,.15); }
.modal__body { flex: 1; overflow: auto; padding: 22px 40px 28px; overscroll-behavior: contain; }
.modal__ad:empty { display: none; }
.modal__loading { padding: 60px 0; text-align: center; color: var(--muted); }
.modal__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-top: 1px solid var(--rule); }
.modal__tools { display: flex; gap: 2px; }

.story { max-width: 680px; margin: 0 auto; }
.story__title { font: 400 32px/1.38 var(--serif); margin: 0 0 8px; text-wrap: balance; }
.story__sub { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 0 14px; }
.story__body { font-family: var(--serif); font-size: var(--fs-story); line-height: 1.9; }
.story__body p { margin: 0 0 1em; }
.story__body p.is-speaking { background: color-mix(in srgb, var(--accent) 9%, transparent); box-shadow: -10px 0 0 color-mix(in srgb, var(--accent) 9%, transparent), 10px 0 0 color-mix(in srgb, var(--accent) 9%, transparent); border-radius: 2px; }
.story__audio, .story__video { margin: 0 0 18px; }
.story__audio audio { width: 100%; }
.story__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; }
.media-embed { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: var(--r-sm); overflow: hidden; }
.media-embed iframe, .media-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.tts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 18px; padding: 8px 0; border-top: 1px solid var(--rule-2); border-bottom: 1px solid var(--rule-2); }
.story__actions .tts { margin: 0; padding: 0; border: 0; }
.tts__rate select { height: 34px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); padding: 0 6px; font-size: 14px; }
.tts__note { font-size: 13px; color: var(--muted); flex-basis: 100%; }
.story-img { margin: 0; text-align: center; }
.story-img img { max-width: 100%; height: auto; border: 1px solid var(--rule); background: #fff; }
.story-img figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.story-img--page { margin: 28px 0; }
.locked-note { text-align: center; padding: 26px 16px; border: 1px dashed var(--rule); border-radius: var(--r); margin: 16px 0; }
.locked-note .ic { width: 30px; height: 30px; color: var(--accent); }
.cont { display: flex; justify-content: space-between; gap: 12px; margin: 22px auto 6px; max-width: 680px; flex-wrap: wrap; }
.cont__btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule); background: var(--panel); padding: 10px 14px; border-radius: var(--r-sm); font-weight: 600; cursor: pointer; text-decoration: none; text-align: left; max-width: 100%; }
.cont__btn:hover { border-color: var(--accent); color: var(--accent); }
.cont__btn--next { margin-left: auto; }
.share { display: flex; gap: 2px; align-items: center; }
.share--row, .share--big { flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* Share dialog */
.sheet-dlg { position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet-dlg__backdrop { position: absolute; inset: 0; background: rgba(12,17,23,.55); }
.sheet-dlg__box { position: relative; width: 100%; max-width: 440px; background: var(--panel); border-radius: 8px; padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.sheet-dlg__title { margin: 0 0 12px; font-size: 18px; }
.sheet-dlg__img { display: block; max-height: 220px; margin: 0 auto 12px; border: 1px solid var(--rule); }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel-2); font-size: 14px; }
.sheet-dlg .share--big { margin: 14px 0; }

/* Flip book */
.flip { position: fixed; inset: 0; z-index: 90; background: #1B2027; color: #E6EAEE; display: flex; flex-direction: column; }
.flip__bar { display: flex; align-items: center; gap: 16px; padding: 8px 12px 8px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.flip__title { font: 400 18px var(--serif); flex: 1; }
.flip__no { font-size: 14px; color: #AAB4BF; }
.flip__stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px 8px; }
.flip__book { width: min(1300px, 100%); height: 100%; }
.flip__book .fpage { background: #fff; overflow: hidden; }
.flip__book .fpage img { width: 100%; height: 100%; object-fit: contain; display: block; background: #fff; }
.flip__book .fpage.is-locked img { filter: blur(3px); }
.flip__book .fpage__lock { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font-weight: 600; }
.flip__book .fpage__lock span { background: #fff; padding: 8px 14px; border-radius: 99px; box-shadow: 0 2px 10px rgba(0,0,0,.2); display: inline-flex; gap: 6px; align-items: center; }
.flip__nav { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.flip__nav:hover { background: rgba(255,255,255,.2); }
.flip__hint { text-align: center; font-size: 13px; color: #8F9AA6; margin: 0 0 10px; padding: 0 16px; }

/* Drawers (mobile) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(12,17,23,.5); z-index: 70; }

/* ---------- Generic pages ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 48px; }
.wrap--narrow { max-width: 860px; }
.wrap--read { max-width: 780px; }
.wrap--form { max-width: 460px; }
.page-head { margin: 4px 0 22px; }
.page-head--row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head__title { font: 400 34px/1.25 var(--serif); margin: 0; }
.page-head__sub { margin: 4px 0 0; color: var(--muted); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; margin-bottom: 14px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a + a::before { content: "/"; margin-right: 6px; color: var(--rule); }
.crumbs a:hover { color: var(--accent); }
.story--page { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 30px 36px; max-width: none; }
.story--page .story__title { font-size: 36px; }

.empty { text-align: center; padding: 56px 16px; }
.empty__ic { width: 48px; height: 48px; color: var(--muted); }
.empty__title { font: 400 28px/1.35 var(--serif); margin: 12px 0 8px; }
.empty__code { font: 400 72px/1 var(--serif); color: var(--accent); margin: 0; }
.empty__cal { max-width: 300px; margin: 18px auto; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px; }
.empty__actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.grid-pages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 22px 18px; }
.gp { display: block; text-decoration: none; }
.gp__img { display: block; position: relative; background: #fff; box-shadow: var(--paper-shadow); border: 2px solid transparent; }
.gp:hover .gp__img { border-color: var(--accent); }
.gp__img img { display: block; width: 100%; height: auto; }
.gp__cap { display: flex; justify-content: space-between; gap: 8px; padding: 8px 2px 0; font-size: 14px; }
.gp__cap span { color: var(--muted); }

.month-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.month-pick input, .month-pick select { padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); }
.month-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-bottom: 14px; }
.month-nav > :last-child { justify-self: end; }
.month-nav__title { font: 400 24px var(--serif); margin: 0; text-align: center; }
.month-nav__title small { font: 400 14px var(--sans); color: var(--muted); margin-left: 6px; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.month-grid__wd { text-align: center; font-size: 14px; color: var(--muted); font-weight: 500; }
.month-grid__cell { position: relative; background: var(--panel); border: 1px solid var(--rule-2); border-radius: var(--r-sm); min-height: 90px; padding: 6px; text-decoration: none; overflow: hidden; }
.month-grid__cell.is-blank { background: transparent; border-color: transparent; }
.month-grid__cell.has-issue { border-color: var(--rule); }
.month-grid__cell.has-issue:hover { border-color: var(--accent); }
.month-grid__cell img { display: block; width: 100%; height: auto; margin-top: 4px; box-shadow: 0 1px 2px rgba(16,24,34,.15); }
.month-grid__day { font-size: 14px; font-weight: 600; color: var(--muted); }
.has-issue .month-grid__day { color: var(--ink); }

.search-form { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; margin-bottom: 20px; }
.search-form__main { display: flex; gap: 10px; }
.search-form__main input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--rule); border-radius: var(--r-sm); font-size: 17px; background: var(--panel); }
.search-form__filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.search-form__filters label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.search-form__filters select, .search-form__filters input { padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); color: var(--ink); font-size: 15px; }
.result-count { color: var(--muted); }
.results { list-style: none; margin: 0; padding: 0; }
.result { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.result__img { display: block; background: var(--panel-2); max-height: 170px; overflow: hidden; border: 1px solid var(--rule-2); }
.result__img img { display: block; width: 100%; height: auto; }
.result__lock { display: grid; place-items: center; height: 90px; color: var(--muted); }
.result__title { font: 400 22px/1.4 var(--serif); margin: 0 0 4px; }
.result__title a { text-decoration: none; }
.result__title a:hover { color: var(--accent); }
.result__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.result__snip { margin: 0; color: var(--muted); }
mark { background: color-mix(in srgb, var(--accent) 18%, transparent); color: inherit; padding: 0 1px; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 24px; }
.pager a { min-width: 38px; padding: 6px 10px; text-align: center; border: 1px solid var(--rule); border-radius: var(--r-sm); text-decoration: none; background: var(--panel); }
.pager a.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.clip-view { margin: 0; text-align: center; background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 20px; }
.clip-view img { max-width: 100%; height: auto; box-shadow: var(--paper-shadow); }

/* Forms */
.card-form, .box { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); padding: 24px; }
.box { margin-bottom: 18px; }
.box__title { font-size: 18px; margin: 0 0 12px; }
.card-form__title { font: 400 28px/1.3 var(--serif); margin: 0 0 18px; }
.card-form__alt { text-align: center; margin: 14px 0 0; font-size: 15px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--panel); color: var(--ink); }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { flex: 1 1 200px; margin: 0; }
.alert { margin-bottom: 14px; }
.sub-status { font-size: 17px; }
.sub-status--on b { color: var(--ok); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); font-weight: 600; }

.plans { border: 0; padding: 0; margin: 0 0 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.plan { position: relative; cursor: pointer; }
.plan input { position: absolute; opacity: 0; }
.plan__body { display: grid; gap: 2px; height: 100%; background: var(--panel); border: 2px solid var(--rule); border-radius: var(--r); padding: 18px 20px; }
.plan input:checked + .plan__body { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.plan input:focus-visible + .plan__body { outline: 2px solid var(--accent); outline-offset: 2px; }
.plan__name { font-weight: 600; font-size: 17px; }
.plan__price { font: 400 36px/1.2 var(--serif); }
.plan__dur { color: var(--muted); font-size: 14px; }
.plan__desc { font-size: 14px; margin-top: 6px; }
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.pay__methods { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.pay__methods li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: var(--r-sm); }
.pay__methods span { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Search dialog */
.search-dlg { position: fixed; inset: 0; z-index: 150; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.search-dlg__backdrop { position: absolute; inset: 0; background: rgba(12,17,23,.55); }
.search-dlg__box { position: relative; width: 100%; max-width: 640px; display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 8px; padding: 10px 10px 10px 16px; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.search-dlg__box > .ic { color: var(--muted); }
.search-dlg__box input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 18px; padding: 8px 4px; outline: none; }

/* Footer */
.site-foot { background: var(--panel); border-top: 1px solid var(--rule); margin-top: 24px; }
.site-foot__inner { max-width: 1600px; margin: 0 auto; padding: 28px 20px 18px; display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 24px; font-size: 15px; }
.site-foot__name { font: 400 26px var(--serif); margin-bottom: 4px; }
.site-foot p { margin: 0 0 4px; color: var(--muted); }
.site-foot__links { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.site-foot__links a { text-decoration: none; }
.site-foot__links a:hover { color: var(--accent); }
.social { display: flex; gap: 4px; margin-top: 6px; }
.social a { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--rule); border-radius: 50%; }
.social .ic { width: 18px; height: 18px; }
.site-foot__copy { max-width: 1600px; margin: 0 auto; padding: 12px 20px 22px; border-top: 1px solid var(--rule-2); font-size: 14px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1500px) {
  .toolbar .tb-lbl { display: none; }
}
@media (max-width: 1280px) {
  .reader { grid-template-columns: 168px minmax(0, 1fr) 260px; gap: 16px; }
}
@media (max-width: 1080px) {
  .reader { grid-template-columns: 150px minmax(0, 1fr); }
  .rail--side { position: static; max-height: none; grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; overflow: visible; }
  .rail--side .panel, .rail--side .ad { margin: 0; }
  .tb-lbl { display: none; }
}
@media (max-width: 860px) {
  .masthead__inner { grid-template-columns: 1fr auto; padding: 10px 14px; gap: 4px 12px; }
  .brand__name { font-size: 28px; }
  .brand__logo { max-height: 44px; }
  .masthead__dates { grid-column: 1 / -1; grid-row: 2; font-size: 13px; }
  .masthead__dates span + span { margin-left: 8px; padding-left: 8px; }
  .nav-link span, .nav-link--site { display: none; }
  .nav-link { padding: 8px; }
  .ed-select { max-width: 130px; }

  body.is-reader { padding-bottom: calc(var(--tb-h) + env(safe-area-inset-bottom)); }
  .reader { display: block; padding: 10px 0 20px; }
  .issue-bar { padding: 0 14px 8px; }
  .issue-bar__title strong { font-size: 19px; }
  .viewport.is-zoomed { max-height: calc(100vh - var(--tb-h) - 20px); border-radius: 0; }
  .sheet { box-shadow: 0 1px 3px rgba(16,24,34,.2); }
  .page-foot, .ad-below { padding: 0 14px; }

  .toolbar { position: fixed; top: auto; bottom: 0; left: 0; right: 0; margin: 0; border-radius: 0; border-width: 1px 0 0; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; height: calc(var(--tb-h) + env(safe-area-inset-bottom)); }
  .toolbar::-webkit-scrollbar { display: none; }
  .tb-group { flex: none; }
  .tb-group:last-child { margin-left: 0; }
  .tb-group + .tb-group { padding-left: 2px; }
  .tb-mobile { display: inline-flex; flex-direction: column; gap: 0; font-size: 11px; height: 44px; padding: 0 8px; }
  .tb-mobile .tb-lbl { display: block; line-height: 1.1; }
  .tb-desk { display: none; }
  .tb-select { max-width: 140px; }
  .menu__list { position: fixed; top: auto; bottom: calc(var(--tb-h) + 8px + env(safe-area-inset-bottom)); right: 8px; left: 8px; }

  .rail { position: fixed; top: 0; bottom: 0; z-index: 80; width: min(340px, 86vw); max-height: none; background: var(--desk); padding: 12px 14px 24px; transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .rail--pages { left: 0; transform: translateX(-105%); }
  .rail--side { right: 0; left: auto; transform: translateX(105%); display: block; grid-column: auto; overflow: auto; }
  .rail--side .panel, .rail--side .ad { margin-bottom: 16px; }
  .rail.is-open { transform: none; }
  .rail__x, .rail__head--mobile { display: flex; }
  .thumbs { grid-template-columns: 1fr 1fr; }

  .clipper__bar { bottom: calc(var(--tb-h) + 14px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .ad-sticky { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--panel); border-top: 1px solid var(--rule); text-align: center; padding: 2px 0; }
  .ad-sticky .ad { margin: 0; }
  .ad-sticky .ad__label { display: none; }
  body.is-reader .ad-sticky { bottom: calc(var(--tb-h) + env(safe-area-inset-bottom)); }

  .modal { padding: 0; }
  .modal__panel { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal__head { padding: 6px 6px 6px 14px; flex-wrap: wrap; }
  .modal__meta { flex-basis: calc(100% - 50px); order: 1; font-size: 13px; }
  .modal__head > .icon-btn { order: 2; }
  .seg { order: 3; }
  .modal__body { padding: 18px 18px 24px; }
  .story__title { font-size: 26px; }
  .story--page { padding: 20px 18px; }
  .story--page .story__title { font-size: 28px; }

  .site-foot__inner { grid-template-columns: 1fr; gap: 14px; }
  .wrap { padding: 18px 14px 36px; }
  .page-head__title { font-size: 28px; }
  .result { grid-template-columns: 96px minmax(0, 1fr); gap: 12px; }
  .result__title { font-size: 19px; }
  .pay { grid-template-columns: 1fr; }
  .month-grid { gap: 4px; }
  .month-grid__cell { min-height: 64px; padding: 4px; }
  .month-grid__wd { font-size: 12px; }
  .grid-pages { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px 12px; }
  .search-form__main { flex-direction: column; }
}
@media (max-width: 420px) {
  .masthead__dates .d-alt:last-child { display: none; }
  .flip__nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; color: #000; }
  .masthead__nav, .toolbar, .rail, .ad, .ad-band, .site-foot, .page-foot, .issue-bar__nav, .share, .story__actions, .cont, .crumbs, .skip, .flashes { display: none !important; }
  .reader { display: block; padding: 0; }
  .sheet { box-shadow: none; }
  .story--page { border: 0; padding: 0; }
  .masthead { border: 0; }
}
