* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, sans-serif; background: #f3f4f6; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: #111827; color: #fff; }
.topbar h1 { font-size: 18px; margin: 0; }
.btn-link { color: #fff; text-decoration: none; background: #2563eb; padding: 6px 12px; border-radius: 6px; font-size: 13px; }

#app { padding: 24px; max-width: 900px; margin: 0 auto; }
.muted { color: #9ca3af; font-size: 13px; }
.error { color: #fecaca; font-size: 13px; }

.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.pub-card { background: #fff; border-radius: 10px; padding: 18px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.08); text-align: center; text-decoration: none; color: inherit; display: block; }
.pub-card:hover { box-shadow: 0 4px 10px rgba(0,0,0,0.12); }

.edition-list { display: flex; flex-direction: column; gap: 10px; }
.edition-row { background: #fff; padding: 14px 18px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; cursor: pointer; text-decoration: none; color: inherit; }

.reader-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.reader-toolbar button { padding: 8px 14px; border: none; border-radius: 6px; background: #2563eb; color: #fff; cursor: pointer; }
.page-nav { display: flex; align-items: center; gap: 10px; }

.page-view { background: #fff; padding: 12px; border-radius: 10px; text-align: center; }
.page-view canvas { max-width: 100%; border: 1px solid #e5e7eb; }

.paywall { background: #111827; color: #fff; padding: 30px; border-radius: 10px; text-align: center; margin-top: 16px; }
.plan-list { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
.plan-card { background: #1f2937; padding: 16px; border-radius: 8px; min-width: 140px; }
.plan-card button { margin-top: 10px; padding: 8px 14px; border: none; border-radius: 6px; background: #2563eb; color: #fff; cursor: pointer; }

.auth-card { background: #fff; padding: 28px; border-radius: 12px; max-width: 340px; margin: 40px auto; }
.auth-card input { width: 100%; padding: 10px; margin-top: 10px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 14px; }
.auth-card button { padding: 10px 16px; border: none; border-radius: 6px; background: #2563eb; color: #fff; font-weight: 600; cursor: pointer; }

/* ---------- Branded auth pages (login / signup) ---------- */
.auth-page-wrap { min-height: 100vh; background: #f3f4f6; display: flex; flex-direction: column; align-items: center; padding: 40px 16px; }
.auth-page-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 24px; }
.auth-page-brand img { max-height: 56px; }
.auth-page-brand h1 { font-size: 22px; margin: 0; color: #111827; }
.auth-page-card {
  background: #fff; width: 100%; max-width: 420px; border-radius: 14px; padding: 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-page-card h2 { margin: 0 0 6px; font-size: 20px; color: #111827; }
.auth-page-card p.auth-subtitle { margin: 0 0 22px; color: #6b7280; font-size: 14px; }
.auth-field { margin-bottom: 16px; }
.auth-field label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.auth-field input {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 14px; box-sizing: border-box;
}
.auth-field input:focus { outline: none; border-color: var(--auth-accent, #c0121a); }
.auth-submit-btn {
  width: 100%; padding: 12px; border: none; border-radius: 8px; background: var(--auth-accent, #c0121a);
  color: #fff; font-weight: 700; font-size: 15px; cursor: pointer; margin-top: 6px;
}
.auth-submit-btn:hover { filter: brightness(0.92); }
.auth-error { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.auth-success { background: #f0fdf4; color: #15803d; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.auth-switch { text-align: center; margin-top: 20px; font-size: 14px; color: #6b7280; }
.auth-switch a { color: var(--auth-accent, #c0121a); font-weight: 600; text-decoration: none; }
.auth-back-link { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-back-link a { color: #6b7280; text-decoration: none; }
.g-recaptcha { margin: 6px 0 16px; }

/* ---------- User dashboard ---------- */
.dash-wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 60px; }
.dash-header { margin-bottom: 24px; }
.dash-header h2 { margin: 0 0 4px; font-size: 22px; }
.dash-header p { margin: 0; color: #6b7280; font-size: 14px; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card { background: #fff; border-radius: 12px; padding: 22px; box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.dash-card h3 { margin: 0 0 16px; font-size: 16px; color: #111827; }
.sub-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.sub-row:last-child { border-bottom: none; }
.sub-row-name { font-weight: 600; font-size: 14px; }
.sub-row-dates { font-size: 12px; color: #6b7280; }
.sub-status { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; }
.sub-status.active { background: #f0fdf4; color: #15803d; }
.sub-status.expired { background: #f3f4f6; color: #6b7280; }
.plan-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.plan-pick-card { border: 1px solid #e5e7eb; border-radius: 10px; padding: 14px; text-align: center; }
.plan-pick-card .plan-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.plan-pick-card .plan-price { font-size: 18px; font-weight: 800; color: var(--auth-accent, #c0121a); margin-bottom: 10px; }
.plan-pick-card button { width: 100%; padding: 8px; border: none; border-radius: 6px; background: var(--auth-accent, #c0121a); color: #fff; font-weight: 600; cursor: pointer; font-size: 13px; }

/* ---------- Edition reader page (thumbnail-sidebar layout) ---------- */
.reader-body { background: #e9e9e9; margin: 0; }

.masthead { background: #c0121a; color: #fff; padding: 14px 24px; text-align: center; }
.masthead-inner { display: flex; align-items: center; justify-content: center; gap: 10px; }
.masthead-logo { height: 32px; width: auto; }
.masthead-title { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }

.edition-info-strip {
  background: #fff; border-bottom: 2px solid #f5a623; padding: 10px 20px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px;
}
.edition-bar {
  background: #fff; border-bottom: 1px solid #ddd; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}
.edition-bar-left { font-size: 14px; color: #333; display: flex; align-items: center; gap: 10px; }
.edition-bar-right { display: flex; align-items: center; gap: 10px; font-size: 13px; }

#page-pager { display: flex; gap: 4px; flex-wrap: wrap; }
.page-num {
  border: 1px solid #ddd; background: #fff; color: #333; padding: 4px 10px;
  border-radius: 4px; cursor: pointer; font-size: 13px;
}
.page-num.active { background: #c0121a; color: #fff; border-color: #c0121a; }

.pill-btn {
  background: #c0121a; color: #fff; text-decoration: none; padding: 6px 14px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}

.reader-layout { display: flex; gap: 16px; padding: 20px; max-width: 1200px; margin: 0 auto; }

.thumb-rail {
  width: 220px; flex-shrink: 0; background: #fff; border-radius: 8px; padding: 14px 10px;
  max-height: 220vh; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
}
.thumb-item { cursor: pointer; text-align: center; padding: 6px; border-radius: 6px; border: 2px solid transparent; }
.thumb-item.active { border-color: #f5a623; background: #fff8ee; }
.thumb-item canvas { width: 100%; height: auto; border: 1px solid #e5e7eb; display: block; }
.thumb-label { font-size: 13px; color: #c0121a; margin-top: 6px; font-weight: 600; }
.thumb-lock {
  width: 100%; aspect-ratio: 3/4; background: #f3f4f6; border: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center; font-size: 28px; color: #9ca3af;
}

.page-stage { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.page-stage-inner { position: relative; background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.page-stage-inner canvas { max-width: 100%; display: block; margin: 0 auto; cursor: zoom-in; }
.page-stage-inner canvas.clip-mode-active { cursor: crosshair; }

.page-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; min-height: 300px; color: #6b7280; font-size: 14px;
}
.spinner {
  width: 36px; height: 36px; border: 4px solid #e5e7eb; border-top-color: #c0121a;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage-nav { display: flex; gap: 10px; }
.stage-nav button { padding: 8px 16px; border: none; border-radius: 6px; background: #c0121a; color: #fff; cursor: pointer; font-weight: 600; }

.zoom-modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,20,20,0.55); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.archive-cal-close-btn {
  position: absolute; top: -14px; right: -14px; z-index: 10;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: #dc2626; color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.archive-cal-card {
  background: #fff; border-radius: 10px; padding: 20px; width: 340px; max-width: 90vw;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3); position: relative;
}
.archive-cal-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.archive-cal-nav {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid #d1d5db; background: #fff;
  color: #c0121a; font-size: 16px; cursor: pointer;
}
.archive-cal-label { font-weight: 700; font-size: 15px; }
.archive-cal-selects { display: flex; gap: 6px; }
.archive-cal-select {
  padding: 4px 6px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 13px;
  font-weight: 600; background: #fff;
}
.archive-cal-weekdays, .archive-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px;
}
.archive-cal-weekdays span { font-size: 12px; color: #6b7280; font-weight: 600; padding-bottom: 6px; }
.archive-cal-day {
  display: block; padding: 8px 0; border-radius: 6px; font-size: 13px; color: #d1d5db;
  text-decoration: none;
}
.archive-cal-day.has-edition {
  background: #16a34a; color: #fff; font-weight: 700; cursor: pointer;
}
.archive-cal-day.has-edition:hover { background: #15803d; }
.archive-cal-hint { font-size: 12px; color: #6b7280; text-align: center; margin: 14px 0 0; }
.zoom-popup-card {
  position: relative; background: #fff; border-radius: 10px; overflow: hidden;
  width: 90vw; height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35);
}
.zoom-close-btn {
  position: absolute; top: 8px; right: 8px; z-index: 10;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: #dc2626; color: #fff; font-size: 18px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.zoom-scroll-area {
  flex: 1; overflow: auto; text-align: center; padding: 20px; background: #f3f4f6;
  min-height: 0; /* required for flex children to actually scroll instead of growing */
}
.zoom-canvas-wrap { position: relative; display: inline-block; }
.zoom-scroll-area canvas {
  max-width: 100%; width: 100%; height: auto; display: block;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.zoom-overlay-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 10;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.45); color: #fff; font-size: 24px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.zoom-overlay-nav:hover { background: rgba(0,0,0,0.65); }
.zoom-overlay-nav-left { left: 14px; }
.zoom-overlay-nav-right { right: 14px; }
.zoom-page-label-overlay {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(0,0,0,0.45); color: #fff; font-size: 13px; font-weight: 600;
  padding: 4px 12px; border-radius: 12px;
}

@media (max-width: 700px) {
  .zoom-modal-backdrop { padding: 6px; }
  .zoom-popup-card { width: 95vw; height: 92vh; }
  .zoom-scroll-area { padding: 10px; }
}


/* ---------- Site home page (publication grid, nav, decorative masthead) ---------- */
.site-body { background: #f4f4f4; margin: 0; }

.topline { height: 4px; background: linear-gradient(90deg, #f5a623, #e8590c); }
.license-grace-banner {
  background: #fef3c7; color: #92400e; text-align: center; padding: 10px 16px;
  font-size: 13px; font-weight: 600;
}

.muted-dark { color: #4b5563; font-size: 13px; }
.login-pill {
  background: #c0121a; color: #fff; text-decoration: none; padding: 8px 16px;
  border-radius: 4px; font-size: 13px; font-weight: 600; border: 1px solid #c0121a;
}

/* Logged-in profile chip + dropdown (reuses .site-nav-dropdown's existing
   JS - click to open, tap outside/scroll/resize to close, fixed-position
   menu so it's never clipped, all already working correctly on both
   mobile and desktop for the main nav dropdowns) */
.profile-dropdown-toggle {
  background: none; border: none; color: #fff; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 999px;
}
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,0.25); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.profile-name { font-size: 13px; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-dropdown .site-nav-caret { color: rgba(255,255,255,0.8); }
.profile-dropdown .site-nav-dropdown-menu a { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }

/* .profile-dropdown-toggle shares the .site-nav-dropdown-toggle class
   (reusing that dropdown's existing JS), but that shared rule is defined
   further down this file and would otherwise win the cascade (equal
   specificity, later source order) - squashing this button's padding
   down to 4px 2px and adding a text-link-style underline border that
   doesn't belong on a rounded avatar pill. Scoping through the
   .profile-dropdown parent gives these the specificity to actually stick,
   on both mobile and desktop. */
.profile-dropdown .site-nav-dropdown-toggle {
  padding: 4px 6px !important; border-bottom: none !important; border-radius: 999px;
}
.profile-dropdown.active .site-nav-dropdown-toggle,
.profile-dropdown.open .site-nav-dropdown-toggle {
  background: rgba(255,255,255,0.15);
}

.site-masthead {
  position: relative; background: #fff; text-align: center; padding: 30px 20px;
  overflow: hidden;
}
.site-title { font-size: 36px; font-weight: 800; color: #e8590c; margin: 0; letter-spacing: 0.5px; }
.site-logo { max-height: 70px; width: auto; }
.masthead-logo-link { text-decoration: none; display: inline-block; }
.masthead-logo-link .site-title { color: #e8590c; }
.corner {
  position: absolute; top: 0; width: 220px; height: 160px;
  background: linear-gradient(135deg, #ec4899 0%, #f97316 60%, #fbbf24 100%);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.corner-left { left: 0; }
.corner-right { right: 0; transform: scaleX(-1); }

/* ---------- Combined nav + login bar: nav on the left, login on the right ---------- */
.main-nav-bar {
  background: #d3141c; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-wrap: wrap; gap: 10px;
}
.site-nav {
  background: none; display: flex; align-items: center; gap: 28px;
  padding: 14px 0; flex-wrap: wrap;
}
.site-nav a {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  padding: 4px 2px; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 4px;
}
.site-nav a.active, .site-nav a:hover { border-bottom-color: #fbbf24; }
.main-nav-login { display: flex; align-items: center; gap: 10px; padding: 10px 0; }

/* ---------- Dynamic navbar dropdown (Theme Setup -> Navbar Setup) ---------- */
.site-nav-dropdown { position: relative; }
.site-nav-dropdown-toggle {
  background: none; border: none; color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  padding: 4px 2px; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit;
}
.site-nav-dropdown.active > .site-nav-dropdown-toggle { border-bottom-color: #fbbf24; }
.site-nav-caret { font-size: 10px; }
.site-nav-dropdown-menu {
  display: none; position: fixed; min-width: 180px;
  background: #fff; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,0.15); overflow: hidden; z-index: 200;
}
.site-nav-dropdown.open .site-nav-dropdown-menu { display: block; }
.site-nav-dropdown-menu a {
  display: block; color: #333 !important; padding: 10px 16px; font-size: 14px; font-weight: 500;
  border-bottom: 1px solid #f0f0f0 !important;
}
.site-nav-dropdown-menu a:last-child { border-bottom: none !important; }
.site-nav-dropdown-menu a:hover, .site-nav-dropdown-menu a.active { background: #f8f8f8; }

@media (max-width: 767px) {
  .site-nav-dropdown-menu { min-width: 200px; max-width: calc(100vw - 24px); }
  .site-nav-dropdown-menu a { padding: 13px 16px; font-size: 15px; }
  .profile-dropdown .site-nav-dropdown-menu { min-width: 170px; }
}

.mobile-nav-toggle {
  display: none; background: none; border: none; color: #1a1a1a; font-size: 22px;
  cursor: pointer; padding: 10px 4px;
}

.site-main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 50px; }

.site-footer {
  background: #c0121a; color: #fff; text-align: center; padding: 14px 20px;
  font-size: 13px;
}
.site-footer p { margin: 0; }
.footer-social { display: flex; justify-content: center; gap: 14px; margin-bottom: 8px; }
.footer-social a { color: #fff; text-decoration: none; font-size: 12px; opacity: 0.9; border-bottom: 1px solid rgba(255,255,255,0.4); }
.footer-social a:hover { opacity: 1; }
.footer-credit { margin-top: 4px !important; font-size: 11px; opacity: 0.8; }

.ad-slot { text-align: center; padding: 10px 20px; background: #fafafa; }
.ad-slot img { max-width: 100%; height: auto; }

/* ---------- Homepage templates (Company Website mode) ---------- */
.home-tpl-hero {
  color: #fff; text-align: center; padding: 80px 24px; border-radius: 0 0 24px 24px;
}
.home-tpl-hero h1 { font-size: 40px; margin: 0 0 12px; font-weight: 800; }
.home-tpl-hero p { font-size: 18px; opacity: 0.9; margin: 0 0 28px; }
.home-tpl-cta {
  display: inline-block; background: #fff; color: #111827 !important; text-decoration: none;
  padding: 14px 32px; border-radius: 999px; font-weight: 700; font-size: 15px;
}
.home-tpl-cta:hover { opacity: 0.9; }
.home-tpl-section { max-width: 900px; margin: 0 auto; padding: 50px 24px; }
.home-tpl-section h2 { font-size: 26px; margin: 0 0 16px; color: #111827; }
.home-tpl-section p { font-size: 15px; line-height: 1.7; color: #374151; }
.home-tpl-contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 20px; margin-top: 10px; }
.home-tpl-contact-grid strong { display: block; color: #111827; margin-bottom: 4px; }
.home-tpl-contact-grid p { margin: 0; color: #6b7280; }

.home-tpl-modern-hero { text-align: center; padding: 70px 24px 50px; }
.home-tpl-modern-logo { max-height: 70px; margin-bottom: 20px; }
.home-tpl-modern-hero h1 { font-size: 36px; margin: 0 0 10px; color: #111827; font-weight: 800; }
.home-tpl-modern-hero p { font-size: 17px; color: #6b7280; margin: 0 0 26px; }
.home-tpl-modern-hero .home-tpl-cta { color: #fff !important; }

@media (max-width: 600px) {
  .home-tpl-hero { padding: 50px 20px; }
  .home-tpl-hero h1 { font-size: 28px; }
  .home-tpl-hero p { font-size: 15px; }
}

/* ---------- Professional template: slider + extra sections ---------- */
.home-tpl-slider {
  position: relative; color: #fff; text-align: center; padding: 100px 24px 70px;
  border-radius: 0 0 24px 24px; min-height: 320px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.home-tpl-slides { position: relative; width: 100%; max-width: 700px; min-height: 130px; }
.home-tpl-slide {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s ease; pointer-events: none;
}
.home-tpl-slide.active { opacity: 1; pointer-events: auto; position: relative; }
.home-tpl-slide h1 { font-size: 38px; margin: 0 0 12px; font-weight: 800; }
.home-tpl-slide p { font-size: 17px; opacity: 0.9; margin: 0; }
.home-tpl-slider .home-tpl-cta { margin-top: 28px; }
.home-tpl-slider-dots { display: flex; gap: 8px; margin-top: 24px; }
.home-tpl-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.4); }
.home-tpl-dot.active { background: #fff; }

.home-tpl-stats {
  display: flex; justify-content: center; gap: 60px; flex-wrap: wrap; padding: 36px 24px;
  background: #fff; text-align: center;
}
.home-tpl-stats strong { display: block; font-size: 32px; font-weight: 800; color: #111827; }
.home-tpl-stats span { font-size: 13px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }

.home-tpl-pubs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.home-tpl-pub-card {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border-radius: 10px;
  background: #f9fafb; text-decoration: none; border: 1px solid #eee; transition: box-shadow 0.15s;
}
.home-tpl-pub-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); }
.home-tpl-pub-card span { color: #111827; font-weight: 700; font-size: 15px; }
.home-tpl-pub-card small { color: #6b7280; font-size: 12px; }

.home-tpl-features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.home-tpl-feature-card { text-align: center; padding: 24px 16px; }
.home-tpl-feature-card i { font-size: 32px; color: var(--auth-accent, #c0121a); margin-bottom: 12px; display: block; }
.home-tpl-feature-card h3 { font-size: 17px; margin: 0 0 8px; color: #111827; }
.home-tpl-feature-card p { font-size: 14px; color: #6b7280; margin: 0; }

@media (max-width: 600px) {
  .home-tpl-slider { padding: 70px 20px 50px; }
  .home-tpl-slide h1 { font-size: 26px; }
  .home-tpl-stats { gap: 30px; }
  .home-tpl-stats strong { font-size: 24px; }
}

/* ---------- Mobile responsiveness ---------- */

.section-heading {
  text-align: center; font-size: 20px; color: #444; margin: 10px 0 24px; position: relative;
}
.section-heading::after {
  content: ''; display: block; width: 60px; height: 3px; background: #e8590c;
  margin: 8px auto 0;
}

.pub-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.pub-thumb-card {
  background: #fff; border-radius: 6px; overflow: hidden; text-decoration: none; color: inherit;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1); display: block; border-bottom: 3px solid #e8590c;
  transition: transform 0.15s ease;
}
.pub-thumb-card:hover { transform: translateY(-3px); }
.pub-thumb-frame { background: #f3f4f6; min-height: 260px; display: flex; align-items: center; justify-content: center; padding: 6px; }
.pub-thumb-frame canvas { max-width: 100%; height: auto; }
.pub-thumb-label { text-align: center; padding: 12px; color: #c0121a; font-weight: 700; font-size: 15px; }
.pub-thumb-sublabel { text-align: center; padding: 0 12px 12px; margin-top: -8px; color: #6b7280; font-size: 12px; }
.pub-thumb-empty .pub-thumb-frame { color: #9ca3af; }

.back-link { display: inline-block; margin-bottom: 14px; color: #c0121a; text-decoration: none; font-size: 13px; }

.static-page { background: #fff; border-radius: 8px; padding: 24px; max-width: 800px; margin: 0 auto; line-height: 1.6; }

.archive-form { display: flex; gap: 10px; justify-content: center; margin-bottom: 20px; flex-wrap: wrap; }
.archive-form select, .archive-form input { padding: 8px 10px; border-radius: 6px; border: 1px solid #d1d5db; }

.archive-layout {
  display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; max-width: 900px; margin: 0 auto;
}
.archive-panel {
  background: #fff; border-radius: 10px; padding: 20px; flex: 1; min-width: 300px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.archive-form-v2 { display: flex; flex-direction: column; gap: 4px; }
.archive-form-label { font-size: 12px; font-weight: 600; color: #6b7280; margin-top: 8px; }
.archive-select-v2 { padding: 8px 10px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 14px; }
.archive-result {
  flex: 0 0 230px; background: #fff; border-radius: 10px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08); display: flex; justify-content: center;
}
.archive-result-grid {
  flex: 1 1 460px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px; align-items: start; justify-content: normal;
}
.archive-result-grid p.muted { grid-column: 1 / -1; text-align: center; }

@media (max-width: 700px) {
  .archive-layout { flex-direction: column; }
  .archive-result { flex: 1 1 auto; width: 100%; }
}
.pill-btn-inline { background: #c0121a; color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; }

/* ---------- Reader toolbar additions: dropdown, fast-forward, clip, archive ---------- */
.mobile-toolbar-arrow {
  display: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #d1d5db;
  background: #fff; color: #c0121a; font-size: 16px; cursor: pointer; align-items: center; justify-content: center;
}
.page-dropdown {
  padding: 8px 12px; border-radius: 6px; border: 1px solid #d1d5db; font-size: 14px;
  min-width: 120px; background: #fff;
}
.edition-label {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; color: #1a1a1a;
}
.pdf-download-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: #dc2626; color: #fff; font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: 6px; text-decoration: none; margin-left: 8px;
}
.pdf-download-btn:hover { background: #b91c1c; color: #fff; }

.ff-btn {
  border: none; background: #c0121a; color: #fff; padding: 6px 10px;
  border-radius: 4px; cursor: pointer; font-weight: 700; margin-left: 6px;
}

.clip-btn {
  background: #f5871f; color: #fff; border: none; padding: 8px 16px;
  border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.clip-btn.active { background: #d9660c; }

.archive-btn {
  background: #c0121a; color: #fff; text-decoration: none; padding: 8px 16px;
  border-radius: 4px; font-weight: 600; font-size: 13px; display: inline-block;
}

.clip-overlay {
  position: absolute; border: 2px dashed #f5871f;
}
.clip-overlay-movable {
  pointer-events: auto; cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); /* dims everything outside the box without extra overlay elements */
}

.clip-handle {
  position: absolute; width: 12px; height: 12px; background: #fff; border: 2px solid #f5871f;
  border-radius: 2px; pointer-events: auto; /* overlay disables pointer-events - handles must re-enable it to be clickable/draggable */
}
.clip-handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.clip-handle-n { top: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.clip-handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.clip-handle-e { top: calc(50% - 6px); right: -6px; cursor: ew-resize; }
.clip-handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }
.clip-handle-s { bottom: -6px; left: calc(50% - 6px); cursor: ns-resize; }
.clip-handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.clip-handle-w { top: calc(50% - 6px); left: -6px; cursor: ew-resize; }

.area-hotspot {
  position: absolute; display: block; z-index: 5;
}
.area-hotspot:hover {
  background: rgba(37, 99, 235, 0.12);
  outline: 1px dashed rgba(37, 99, 235, 0.5);
}

.clip-toolbar {
  position: absolute; display: flex; gap: 6px; margin-top: 4px; z-index: 20;
}
.clip-toolbar button {
  border: none; padding: 6px 12px; border-radius: 4px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.clip-toolbar-share { background: #16a34a; color: #fff; }
.clip-toolbar-cancel { background: #dc2626; color: #fff; }

.share-modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.share-modal { background: #fff; border-radius: 10px; width: 360px; max-width: 92vw; overflow: hidden; }
.share-modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid #eee; font-weight: 700; font-size: 16px;
}
.share-modal-x { border: none; background: none; font-size: 20px; cursor: pointer; color: #6b7280; }
.share-modal-body { padding: 18px; }

.share-preview-frame {
  background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px;
  text-align: center; margin-bottom: 14px;
}
.share-preview-caption { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.share-preview-frame img { max-width: 100%; max-height: 220px; }

#share-url-input {
  width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #d1d5db;
  font-size: 13px; margin-bottom: 14px; color: #2563eb; text-align: center;
}

.share-icon-row { display: flex; gap: 8px; margin-bottom: 14px; }
.share-icon {
  flex: 1; text-align: center; padding: 10px 4px; border-radius: 6px; font-size: 12px;
  font-weight: 700; color: #fff; text-decoration: none;
}
.share-icon.fb { background: #1877f2; }
.share-icon.tw { background: #1da1f2; }
.share-icon.wa { background: #25d366; }
.share-icon.em { background: #6b7280; }

.share-modal-actions { display: flex; gap: 10px; }
.share-action-btn {
  flex: 1; text-align: center; padding: 10px; border-radius: 6px; border: none;
  background: #374151; color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; font-size: 13px;
}

/* ---------- Public clip page ---------- */
.clip-page-wrap { max-width: 480px; margin: 30px auto; text-align: center; padding: 0 16px 40px; }
.clip-branded-header { margin-bottom: 16px; }
.clip-pub-name { font-size: 24px; font-weight: 800; color: #e8590c; }
.clip-edition-meta { font-size: 13px; color: #6b7280; margin-top: 4px; }
.clip-image-frame {
  background: #fff; border-radius: 8px; padding: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  margin-bottom: 18px;
}
.clip-image-frame img { max-width: 100%; }
.clip-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; }
.share-row { display: flex; gap: 8px; justify-content: center; }
.share-row .share-icon { flex: 0 0 auto; padding: 10px 16px; }

@media (max-width: 760px) {
  .reader-layout { flex-direction: column; padding-bottom: 70px; /* room for the fixed bottom bar */ }
  .site-footer { margin-bottom: 60px; /* the footer is outside reader-layout, needs its own clearance from the fixed bar */ }

  /* Thumbnail rail moves to the bottom on mobile instead of appearing above the main page */
  .page-stage { order: 1; }
  .thumb-rail { order: 2; width: 100%; flex-direction: row; max-height: none; overflow-x: auto; overflow-y: hidden; }
  .thumb-item { min-width: 70px; }

  /* Masthead: logo centered, no hamburger - nav now lives directly in the green bar below */
  .site-masthead {
    display: flex; align-items: center; justify-content: center;
    padding: 10px 14px; text-align: center;
  }
  .site-masthead .corner { display: none; }
  .site-logo { max-height: 52px; }
  .site-title { font-size: 20px; }
  .mobile-nav-toggle { display: none !important; }

  .main-nav-login .profile-name { display: none; } /* name hidden on mobile - just the avatar + dropdown, keeps the row compact */
  .main-nav-login .login-pill { padding: 6px 12px; font-size: 12px; }

  /* Compact info strip stays at the top, right under the masthead */
  .edition-info-strip { padding: 8px 12px; font-size: 13px; gap: 8px; }
  .edition-label { font-size: 13px; }

  /* Page controls + actions become a slim fixed bar pinned to the bottom
     of the screen, like a native app's bottom toolbar */
  .edition-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    flex-direction: row; align-items: center; justify-content: space-between;
    padding: 8px 10px; box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }
  .edition-bar-left { gap: 6px; }
  .edition-bar-right { gap: 6px; flex-wrap: nowrap; }

  /* Replace the numbered pager + fast-forward with two simple arrows */
  #page-pager, #ff-btn { display: none; }
  .mobile-toolbar-arrow { display: flex; }

  /* Icon-only action buttons - hide the text label, keep the icon, square shape */
  .edition-bar-right .clip-btn, .edition-bar-right .archive-btn, .edition-bar-right .pdf-download-btn {
    width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center;
    font-size: 17px;
  }
  .edition-bar-right .btn-label { display: none; }

  .masthead-title { font-size: 16px; }

  /* Nav links now shown directly in the green bar - horizontally scrollable
     if they don't all fit, with Login pinned to the right */
  .main-nav-bar { position: relative; flex-wrap: nowrap; padding: 0 12px; }
  .site-nav {
    display: flex !important; position: static; flex-direction: row; flex-wrap: nowrap;
    gap: 18px; overflow-x: auto; overflow-y: hidden; background: none; padding: 12px 0;
    box-shadow: none; border-radius: 0; min-width: 0; flex: 1;
  }
  .site-nav a {
    padding: 4px 2px; border-bottom: 2px solid transparent; width: auto; white-space: nowrap;
    color: #fff; font-size: 13px; font-weight: 600;
  }
  .site-nav a:last-child { border-bottom: 2px solid transparent; }
  .site-nav a.active, .site-nav a:hover { background: none; border-bottom-color: #fbbf24; color: #fff; }
  .site-nav-dropdown { flex-shrink: 0; }
  .site-nav-dropdown-toggle { font-size: 13px; padding: 4px 2px; white-space: nowrap; }
  .main-nav-login { flex-shrink: 0; margin-left: 10px; }

  .page-view canvas { max-width: 100%; }
}

@media (max-width: 700px) {
  .site-title { font-size: 22px; }
  .site-logo { max-height: 40px; }
  .site-masthead { padding: 20px 12px; }
  .corner { width: 100px; height: 70px; }
  .site-nav { gap: 14px; padding: 10px 12px; }
  .site-nav a { font-size: 12px; }
  .topbar-strip { padding: 8px 12px; flex-wrap: wrap; }
  .site-main { padding: 16px 12px 30px; }
  .pub-card-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .pub-thumb-frame { min-height: 160px; }
}
