/* ============================================================
   JimFit Guide Web Reader v2 — shell chrome only.
   The injected template pages bring their own design CSS
   (tokens/base/content/workout/... from design/pipeline/css).
   Shell rules use `html body` / `.stage` specificity so they win
   over the injected preview backdrop (base.css body background).
   ============================================================ */

html, html body {
  margin: 0;
  padding: 0;
  background: #0e0e11;
  overflow-x: hidden; /* scaled sheet must never cause horizontal scroll */
}

html body {
  font-family: "Open Sans", system-ui, sans-serif;
  color: #eee;
  min-height: 100vh;
}

/* ---- Top bar ---- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: rgba(14,14,17,0.92);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 50;
  backdrop-filter: blur(6px);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; }
.tb-center { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.tb-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}
.tb-page { font-size: 12px; color: #9a9aa2; white-space: nowrap; }

.tbtn {
  background: rgba(255,255,255,0.07);
  color: #eee;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.tbtn:hover { background: rgba(255,255,255,0.14); }

.lang-switch { display: flex; border: 1px solid rgba(255,255,255,0.16); border-radius: 8px; overflow: hidden; }
.lang-btn {
  background: transparent;
  color: #aaa;
  border: 0;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lang-btn.active { background: #c9a227; color: #111; }

/* ---- Stage (sheet host) ---- */
#stageWrap {
  padding: 66px 0 76px;
  width: 100%;
}
.stage {
  width: 100%;
  display: flex;
  justify-content: center;
  /* transform wrapper for fit-width mobile scaling */
}
.sheet-scale {
  width: 100%;
  transform-origin: top center;
}
.stage .sheet {
  /* neutralise the print-preview look inside the app */
  margin: 0 auto !important;
  box-shadow: 0 4px 30px rgba(0,0,0,0.55) !important;
}
.stage-loading {
  color: #888;
  text-align: center;
  padding: 60px 0;
}

/* ---- Bottom audio bar ---- */
.audiobar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: rgba(14,14,17,0.95);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 50;
  backdrop-filter: blur(6px);
}
.playbtn {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: #c9a227;
  color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.playbtn:hover { filter: brightness(1.1); }
.time { font-size: 12px; color: #bbb; font-variant-numeric: tabular-nums; min-width: 38px; text-align: center; }
.seek {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 5px;
  border-radius: 3px;
  background:
    linear-gradient(#c9a227,#c9a227) 0/var(--fill,0%) 100% no-repeat,
    rgba(255,255,255,0.15);
  outline: none;
  cursor: pointer;
}
.seek::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #c9a227;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: #26262c;
  color: #eee;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  z-index: 80;
}

/* ---- TOC modal ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* [hidden] must always win — display:flex above otherwise keeps the
   empty modal visible and its full-screen overlay eats every click */
.modal[hidden] { display: none !important; }
.modal-panel {
  width: min(520px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: #17171b;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-head h2 { margin: 0; font-size: 16px; }
.toc-list { overflow-y: auto; padding: 8px 8px 16px; }
.toc-section-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #c9a227;
  padding: 14px 10px 6px;
}
.toc-item {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #ddd;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.toc-item:hover { background: rgba(255,255,255,0.07); }
.toc-item.current { background: rgba(201,162,39,0.18); color: #ffd75e; }
.toc-num { color: #77777f; min-width: 28px; text-align: right; font-variant-numeric: tabular-nums; }
.toc-item.current .toc-num { color: #ffd75e; }

@media (max-width: 560px) {
  .tb-hide-sm { display: none; }
  .tb-title { font-size: 12px; max-width: 34vw; }
}

/* ---- Interactivity layer (2026-08-26): links, page jumps, QR taps ---- */
.jf-pagelink {
  color: inherit;
  font-weight: 600;
  text-decoration: underline dotted;
  text-decoration-color: var(--gold, #c9a227);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.jf-pagelink:hover {
  color: var(--gold, #c9a227);
  text-decoration-style: solid;
}
a.jf-ext {
  color: inherit;
  text-decoration: underline dotted;
  text-decoration-color: var(--gold, #c9a227);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  cursor: pointer;
  overflow-wrap: anywhere;
}
a.jf-ext:hover {
  color: var(--gold, #c9a227);
  text-decoration-style: solid;
}
a.jf-qr {
  display: inline-block;
  cursor: pointer;
  border-radius: 8px;
  transition: box-shadow .18s ease, transform .18s ease;
}
a.jf-qr:hover {
  box-shadow: 0 0 0 3px rgba(201, 162, 39, .4);
  transform: translateY(-2px);
}
a.jf-qr img { display: block; }
.jf-tocrow {
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s ease;
}
.jf-tocrow:hover {
  background: rgba(201, 162, 39, .08);
}
.jf-tocrow:hover .toc-label {
  color: var(--gold, #c9a227);
}
html.mobile-reflow a.jf-ext { word-break: break-all; }

/* ---- Fase A: reading progress bar ---- */
.read-progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, .07);
}
.read-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--gold, #c9a227);
  transition: width .35s ease;
}

/* ---- Fase A: playback speed button ---- */
.speedbtn {
  min-width: 46px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: transparent;
  color: #ddd;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.speedbtn.active {
  color: #111;
  background: var(--gold, #c9a227);
  border-color: transparent;
}

/* ---- Fase A: desktop prev/next chevrons ---- */
.navchev {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  width: 46px;
  height: 64px;
  border: none;
  border-radius: 12px;
  background: rgba(20, 20, 24, .72);
  color: #eee;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .8;
  backdrop-filter: blur(6px);
  transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.navchev:hover { background: var(--gold, #c9a227); color: #111; opacity: 1; }
.nav-left { left: 10px; }
.nav-right { right: 10px; }
.navchev[disabled] { opacity: .12; pointer-events: none; }
@media (max-width: 760px) { .navchev { display: none; } }

/* ---- Fase A: continue-reading toast ---- */
.cont-toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #191922;
  color: #eee;
  border: 1px solid rgba(201, 162, 39, .5);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
}
.cont-toast[hidden] { display: none !important; }
.cont-btn {
  border: none;
  background: var(--gold, #c9a227);
  color: #111;
  font-weight: 700;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

/* ---- Fase A: first-run coach mark ---- */
.coach {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 8, 10, .78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.coach[hidden] { display: none !important; } /* [hidden] beats author CSS — TOC lesson! */
.coach-card {
  max-width: 360px;
  width: 100%;
  background: #17171d;
  border: 1px solid rgba(201, 162, 39, .45);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55);
}
.coach-card h3 { margin: 0 0 10px; font-size: 18px; color: #fff; }
.coach-card ul { margin: 0 0 16px; padding-left: 18px; color: #ccc; font-size: 13.5px; line-height: 1.7; }
.coach-ok {
  width: 100%;
  border: none;
  background: var(--gold, #c9a227);
  color: #111;
  font-weight: 800;
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  cursor: pointer;
}

/* ---- Fase A: search in TOC ---- */
.toc-search { padding: 10px 14px 4px; }
.search-input {
  width: 100%;
  box-sizing: border-box;
  background: #101014;
  border: 1px solid rgba(255, 255, 255, .14);
  color: #eee;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  outline: none;
}
.search-input:focus { border-color: var(--gold, #c9a227); }
.search-results { overflow: auto; max-height: calc(85vh - 130px); }
.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: #ddd;
  padding: 10px 16px;
  cursor: pointer;
}
.search-hit:hover { background: rgba(201, 162, 39, .09); }
.sh-title { font-size: 13.5px; font-weight: 600; color: #fff; }
.sh-title mark, .sh-snip mark { background: var(--gold, #c9a227); color: #111; border-radius: 3px; padding: 0 2px; }
.sh-snip { font-size: 12px; color: #999; margin-top: 3px; line-height: 1.45; overflow-wrap: anywhere; }
.search-empty { padding: 16px; color: #888; font-size: 13px; }

/* ============================================================
   Phase 2 (2026-08-28): free preview mode — lock screen,
   locked TOC items, preview badge, unlock modal.
   ============================================================ */

/* ---- Topbar preview badge ---- */
.preview-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #111;
  background: var(--gold, #c9a227);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.preview-badge[hidden] { display: none; }

/* ---- Stage lock screen ---- */
.lock-stage {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 28px 16px;
  box-sizing: border-box;
}
.lock-card {
  width: min(560px, 100%);
  background: #17171b;
  border: 1px solid rgba(201, 162, 39, .4);
  border-radius: 16px;
  padding: 34px 28px;
  text-align: center;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .5);
}
.lock-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .14em;
  color: #111;
  background: var(--gold, #c9a227);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 18px;
}
.lock-icon { font-size: 44px; line-height: 1; margin-bottom: 12px; }
.lock-title { margin: 0 0 6px; font-size: 22px; color: #fff; }
.lock-pagename { color: #ffd75e; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.lock-section { color: #9a9aa2; font-size: 12.5px; margin-bottom: 14px; }
.lock-section strong { color: #ddd; }
.lock-teaser { color: #ccc; font-size: 14px; line-height: 1.6; margin: 0 0 22px; }
.lock-buy {
  display: inline-block;
  background: var(--gold, #c9a227);
  color: #111;
  font-weight: 800;
  font-size: 15px;
  border-radius: 10px;
  padding: 13px 26px;
  text-decoration: none;
  margin-bottom: 10px;
}
.lock-buy:hover { filter: brightness(1.1); }
.lock-sub { color: #9a9aa2; font-size: 12px; margin-bottom: 16px; }
.lock-note {
  color: #6f6f78;
  font-size: 11.5px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 14px;
}

/* ---- Locked TOC items ---- */
.toc-item.locked { color: #77777f; }
.toc-item.locked .toc-num { color: #5a5a62; }
.toc-item.locked:hover { background: rgba(255, 255, 255, .04); }
.toc-lock { margin-left: auto; font-size: 11px; opacity: .8; }

/* ---- Unlock modal (locked TOC tap) ---- */
.lock-modal .modal-panel { width: min(480px, 92vw); }
.lock-modal-body { padding: 18px; overflow-y: auto; max-height: calc(85vh - 60px); }
.lock-modal-body .lock-card {
  box-shadow: none;
  border: none;
  background: transparent;
  padding: 8px 4px;
}

/* ---- Search preview note ---- */
.search-preview-note {
  padding: 8px 16px;
  color: #8a8a92;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}

/* ---- Phase 3: license unlock form ---- */
.unlock-form {
  margin-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.unlock-label { width: 100%; font-size: 12px; color: #9a9aa2; margin-bottom: 2px; }
.unlock-input {
  flex: 1 1 220px;
  min-width: 0;
  background: #101014;
  border: 1px solid rgba(255, 255, 255, .16);
  color: #eee;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.unlock-input:focus { border-color: var(--gold, #c9a227); }
.unlock-btn {
  background: transparent;
  color: var(--gold, #c9a227);
  border: 1px solid var(--gold, #c9a227);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.unlock-btn:hover { background: rgba(201, 162, 39, .12); }
.unlock-btn[disabled] { opacity: .5; cursor: wait; }
.unlock-msg { width: 100%; font-size: 12px; min-height: 16px; color: #9a9aa2; }
.unlock-msg.unlock-err { color: #ff8a80; }

@media (max-width: 560px) {
  .preview-badge { font-size: 9px; padding: 2px 7px; }
  .lock-card { padding: 26px 18px; }
  .lock-title { font-size: 19px; }
}
