/* =====================================================================
 * FlipBook design system v3
 * Modern, mobile-first, "React-like" minimal aesthetic.
 * ===================================================================== */

:root {
  /* Brand */
  --color-primary:        #4f46e5;
  --color-primary-h:      #4338ca;
  --color-primary-soft:   #eef2ff;
  --color-accent:         #0ea5e9;
  --color-success:        #10b981;
  --color-warn:           #f59e0b;
  --color-danger:         #dc2626;

  /* Neutral */
  --color-bg:             #f7f8fc;
  --color-surface:        #ffffff;
  --color-surface-2:      #f3f4f8;
  --color-border:         #e5e7ec;
  --color-border-strong:  #cbd1d9;
  --color-text:           #0f172a;
  --color-text-soft:      #475569;
  --color-muted:          #94a3b8;

  /* Layout */
  --container:            1180px;
  --radius-sm:            8px;
  --radius:               12px;
  --radius-lg:            18px;
  --radius-pill:          999px;

  /* Shadows */
  --shadow-1:             0 1px 2px rgba(15, 23, 42, .05),  0 1px 3px rgba(15, 23, 42, .07);
  --shadow-2:             0 4px 12px rgba(15, 23, 42, .06), 0 8px 30px rgba(15, 23, 42, .04);
  --shadow-3:             0 16px 40px rgba(79, 70, 229, .18);

  /* Type */
  --font-sans:            -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Anim */
  --t:                    .18s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  font-size: 16px;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }

/* Headings */
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 1.4rem + 1.2vw, 2.6rem); font-weight: 800; }
h2 { font-size: clamp(1.4rem, 1.2rem + .8vw, 2rem); font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 700; }
p  { margin: 0 0 .9em; }
a { color: var(--color-primary); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--color-primary-h); }
small { color: var(--color-muted); }
.muted { color: var(--color-text-soft); font-size: .92rem; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 24px 0; }

code { background: #eef2ff; padding: 2px 6px; border-radius: 6px; font-size: .9em; color: #4338ca; }

/* ----- Layout ----- */
.container { max-width: var(--container); margin: 0 auto; padding: 0 18px; }
main.container { padding-top: 24px; padding-bottom: 60px; min-height: 70vh; }
.section { padding: 56px 0; }
.section-tight { padding: 32px 0; }

/* ----- Topbar (public) ----- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; gap: 12px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.15rem; color: var(--color-text);
  letter-spacing: -.01em;
}
.brand .brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  color: #fff; font-size: 1rem;
}
.topbar nav.primary { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar nav.primary a {
  color: var(--color-text-soft); padding: 8px 12px; border-radius: 8px; font-size: .95rem;
}
.topbar nav.primary a:hover { background: var(--color-surface-2); color: var(--color-text); }
.topbar nav.primary .user-email { color: var(--color-muted); padding: 0 4px; font-size: .85rem; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* hamburger */
.nav-toggle {
  display: none; background: none; border: 1px solid var(--color-border);
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  align-items: center; justify-content: center;
}
.nav-toggle:hover { background: var(--color-surface-2); }
.nav-toggle .bar { width: 18px; height: 2px; background: var(--color-text); border-radius: 1px; position: relative; transition: var(--t); }
.nav-toggle .bar::before, .nav-toggle .bar::after { content: ''; position: absolute; left: 0; width: 100%; height: 2px; background: var(--color-text); border-radius: 1px; transition: var(--t); }
.nav-toggle .bar::before { top: -6px; }
.nav-toggle .bar::after  { top:  6px; }

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .topbar nav.primary {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; border-bottom: 1px solid var(--color-border);
    padding: 10px 14px;
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: transform var(--t), opacity var(--t);
  }
  .topbar.is-open nav.primary { transform: none; opacity: 1; pointer-events: auto; }
  .topbar nav.primary a, .topbar nav.primary span.user-email {
    padding: 10px 8px; border-radius: 8px;
    border-top: 1px solid var(--color-surface-2);
  }
  .topbar nav.primary > :first-child { border-top: 0; }
  .topbar nav.primary .user-email { max-width: none; }
}

/* ----- Buttons ----- */
.btn, .btn-primary, .btn-ghost, .btn-danger, .btn-success {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; cursor: pointer; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; font-size: .94rem; line-height: 1;
  text-decoration: none; transition: all var(--t); white-space: nowrap;
  font-family: inherit;
}
.btn-primary { background: var(--color-primary); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.3); }
.btn-primary:hover { background: var(--color-primary-h); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.btn-ghost { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-danger { background: #fff; color: var(--color-danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-block { width: 100%; }
.lg, .btn-lg { font-size: 1.05rem; padding: 13px 22px; border-radius: 12px; }
.btn-sm   { font-size: .82rem; padding: 6px 12px; border-radius: 8px; }
.btn:disabled, .btn-primary:disabled, .btn-ghost:disabled {
  opacity: .55; cursor: not-allowed; transform: none; box-shadow: none;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ----- Hero ----- */
.hero {
  position: relative; padding: 60px 0 40px; text-align: center;
}
.hero h1 { margin-bottom: 14px; }
.hero .lead { font-size: 1.15rem; color: var(--color-text-soft); max-width: 660px; margin: 0 auto 28px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--color-primary-soft); color: var(--color-primary);
  padding: 6px 14px; border-radius: var(--radius-pill); font-size: .8rem; font-weight: 600;
  margin-bottom: 18px; letter-spacing: .04em; text-transform: uppercase;
}

.hero-bg-deco {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: -1;
}
.hero-bg-deco::before, .hero-bg-deco::after {
  content: ''; position: absolute; width: 380px; height: 380px; border-radius: 50%;
  filter: blur(80px); opacity: .35;
}
.hero-bg-deco::before { background: #818cf8; top: -80px; left: -100px; }
.hero-bg-deco::after  { background: #38bdf8; bottom: -120px; right: -80px; }

/* ----- Feature grid ----- */
.features {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px; padding: 30px 0;
}
.feature {
  background: var(--color-surface); padding: 24px;
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
  transition: transform var(--t), box-shadow var(--t);
}
.feature:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.feature .feature-icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-soft); color: var(--color-primary); font-size: 1.4rem; margin-bottom: 12px;
}
.feature h3 { margin-bottom: 4px; }
.feature p { color: var(--color-text-soft); margin: 0; }

/* ----- Auth + form cards ----- */
.auth-card {
  max-width: 440px; margin: 60px auto; background: var(--color-surface);
  padding: 32px 28px; border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  border: 1px solid var(--color-border);
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 20px; }

.form-card {
  background: var(--color-surface); padding: 24px;
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
}

/* Form fields */
.field { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--color-text-soft); font-weight: 500; }
.field input, .field textarea, .field select,
.auth-card input, .auth-card select, .auth-card textarea,
.form-card input[type=text], .form-card input[type=email], .form-card input[type=password],
.form-card input[type=number], .form-card input[type=date],
.form-card textarea, .form-card select, .form-card input[type=file] {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px;
  border: 1px solid var(--color-border); border-radius: 10px; font-size: .98rem;
  font-family: inherit; background: #fff; color: var(--color-text);
  transition: border-color var(--t), box-shadow var(--t);
}
.field input:focus, .field textarea:focus, .field select:focus,
.auth-card input:focus, .auth-card textarea:focus,
.form-card input:focus, .form-card textarea:focus, .form-card select:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .12);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

.form-card fieldset, .auth-card fieldset { border: 1px solid var(--color-border); border-radius: 10px; padding: 12px 16px; margin: 12px 0; }
.form-card fieldset legend, .auth-card fieldset legend { font-weight: 600; padding: 0 6px; color: var(--color-text-soft); }
.form-card label.radio, .form-card label.checkbox { display: inline-flex; align-items: center; gap: 6px; margin-right: 18px; cursor: pointer; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 10px; margin: 0 0 16px; font-size: .94rem; border: 1px solid; }
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* Page header */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin: 8px 0 24px; flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; }
.page-header > .page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Empty state */
.empty-state {
  text-align: center; background: var(--color-surface); padding: 48px 24px;
  border-radius: var(--radius); box-shadow: var(--shadow-1); border: 1px dashed var(--color-border);
}
.empty-state h3 { color: var(--color-text); margin: 0 0 6px; }
.empty-state p { color: var(--color-text-soft); margin: 0 0 16px; }

/* Card grid (flipbook listing) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform var(--t), box-shadow var(--t);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.card-cover {
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; }
.card-cover-placeholder {
  color: rgba(255,255,255,.95); font-weight: 700; font-size: 1rem;
  letter-spacing: .15em;
}
.card-body { padding: 16px; }
.card-body h3 { margin: 0 0 4px; font-size: 1rem; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.card-actions > * { font-size: .82rem; padding: 6px 12px; }

/* Plan banner */
.plan-banner {
  background: linear-gradient(90deg, #eef2ff 0%, #ecfeff 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: .94rem;
  color: var(--color-text);
}
.plan-banner strong { color: var(--color-primary-h); }
.plan-banner .grow { flex: 1; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-pill); font-size: .75rem; font-weight: 600;
  background: var(--color-surface-2); color: var(--color-text-soft); border: 1px solid var(--color-border);
}
.badge-admin { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.badge-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.badge-warn { background: #fef3c7; color: #78350f; border-color: #fcd34d; }
.badge-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.badge-info { background: #dbeafe; color: #1e3a8a; border-color: #bfdbfe; }

/* Share box */
.share-box {
  display: flex; gap: 8px; align-items: center; background: var(--color-surface);
  padding: 10px 14px; border-radius: var(--radius); box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
  margin: 0 0 18px;
}
.share-box strong { white-space: nowrap; }
.share-box input {
  flex: 1; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85rem;
}

/* ----- Footer ----- */
.footer {
  padding: 36px 0 24px; text-align: center; color: var(--color-text-soft);
  border-top: 1px solid var(--color-border); margin-top: 60px;
}
.footer .footer-text { font-size: .9rem; }
.footer a { color: var(--color-text-soft); }
.footer a:hover { color: var(--color-primary); }

/* ----- Viewer (book.php) ----- */
.viewer-body {
  background: #0b1020; color: #fff; min-height: 100vh; margin: 0;
  background-image: radial-gradient(circle at 20% 0%, #1e2a4a 0%, transparent 50%), radial-gradient(circle at 80% 100%, #1c2547 0%, transparent 60%);
}
.viewer-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: rgba(0,0,0,.35); backdrop-filter: blur(6px);
  flex-wrap: wrap; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.viewer-topbar .brand { color: #fff; }
.viewer-topbar .brand .brand-mark { background: linear-gradient(135deg, #818cf8, #38bdf8); }
.viewer-title { font-weight: 600; flex: 1 1 auto; text-align: center; min-width: 200px; }
.viewer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.viewer-body .btn-ghost {
  background: rgba(255,255,255,.05); color: #fff; border-color: rgba(255,255,255,.18);
}
.viewer-body .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.flipbook-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100vh - 80px); padding: 20px;
}
#flipbook-stage { display: flex; align-items: center; justify-content: center; }
#flipbook { margin: 0 auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); border-radius: 4px; }
#flipbook .stf__parent { background: transparent; }
#flipbook .page { background: #fff; }
#loading { color: rgba(255,255,255,.7); font-size: 1.05rem; }

@media (max-width: 600px) {
  .viewer-title { font-size: .95rem; min-width: 100%; order: 3; text-align: left; }
}

/* ----- Pricing ----- */
.pricing-hero {
  text-align: center; padding: 60px 0 24px;
}
.pricing-grid {
  display: grid; gap: 22px; padding: 12px 0 60px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}
.pricing-card {
  position: relative; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 28px 26px; box-shadow: var(--shadow-1);
  display: flex; flex-direction: column;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}
.pricing-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); }
.pricing-card.is-featured {
  border-color: var(--color-primary); box-shadow: var(--shadow-3);
  background: linear-gradient(180deg, #f5f3ff 0%, #fff 80%);
}
.pricing-card.is-current { border-color: var(--color-success); }
.pricing-card h2 { margin: 0 0 6px; font-size: 1.4rem; }
.pricing-card .pricing-tagline { color: var(--color-text-soft); margin: 0 0 18px; min-height: 2.4em; font-size: .94rem; }
.pricing-card .pricing-promo-badge {
  position: absolute; top: -12px; right: 18px;
  background: var(--color-danger); color: #fff;
  padding: 5px 12px; border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
}
.pricing-card .pricing-popular-badge {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--color-primary); color: #fff;
  padding: 6px 14px; border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.pricing-price { margin: 0 0 6px; }
.pricing-price strong { font-size: 2.4rem; color: var(--color-text); font-weight: 800; line-height: 1; }
.pricing-price .strike {
  display: inline-block; color: var(--color-muted); text-decoration: line-through;
  font-size: 1rem; margin-right: 8px;
}
.pricing-cycle { color: var(--color-muted); font-size: .9rem; margin-bottom: 24px; }
.pricing-features { list-style: none; padding: 0; margin: 0 0 24px; flex: 1; }
.pricing-features li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 0; border-bottom: 1px dashed var(--color-border);
  font-size: .94rem; color: var(--color-text);
}
.pricing-features li::before {
  content: "✓"; color: var(--color-success); font-weight: 800; flex-shrink: 0;
  margin-top: 2px;
}
.pricing-features li:last-child { border-bottom: 0; }
.pricing-features li.muted-feat { color: var(--color-muted); }
.pricing-features li.muted-feat::before { content: "—"; color: var(--color-muted); font-weight: 600; }
.pricing-card .btn { margin-top: auto; }

.strike { text-decoration: line-through; color: var(--color-muted); }

/* Demo book embed (landing) */
.demo-section { padding: 30px 0 60px; }
.demo-frame {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2); overflow: hidden;
  border: 1px solid var(--color-border);
  max-width: 920px; margin: 0 auto;
  aspect-ratio: 16 / 10; min-height: 360px;
}
.demo-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 720px) {
  .demo-section { padding: 18px 0 36px; }
  .demo-frame {
    aspect-ratio: auto; min-height: 0;
    height: 70vh; max-height: 540px;
    border-radius: var(--radius-md);
  }
}

/* "How it works" */
.how-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px; counter-reset: step;
}
.how-step {
  background: var(--color-surface); padding: 24px;
  border: 1px solid var(--color-border); border-radius: var(--radius);
  position: relative;
}
.how-step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; top: -14px; left: 18px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.how-step h3 { margin-top: 4px; }

/* CTA banner */
.cta-banner {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; padding: 40px 28px; border-radius: var(--radius-lg);
  text-align: center; box-shadow: var(--shadow-3);
}
.cta-banner h2 { color: #fff; margin: 0 0 6px; }
.cta-banner p { color: rgba(255,255,255,.85); margin: 0 0 18px; }
.cta-banner .btn-primary { background: #fff; color: var(--color-primary); }
.cta-banner .btn-primary:hover { background: #f1f5f9; color: var(--color-primary); }

/* ----- Modal ----- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  z-index: 50; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  opacity: 0; pointer-events: none; transition: opacity var(--t);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }
.modal-card {
  background: var(--color-surface); width: 100%; max-width: 720px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  border: 1px solid var(--color-border);
  transform: translateY(8px); transition: transform var(--t);
}
.modal-backdrop.is-open .modal-card { transform: none; }
.modal-card .modal-head, .modal-card .modal-body, .modal-card .modal-foot {
  padding: 16px 22px;
}
.modal-card .modal-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--color-border); }
.modal-card .modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-card .modal-foot { border-top: 1px solid var(--color-border); display: flex; gap: 10px; justify-content: flex-end; }
.modal-close {
  background: none; border: 0; cursor: pointer; padding: 6px 8px;
  color: var(--color-text-soft); font-size: 1.4rem; line-height: 1;
}
.modal-close:hover { color: var(--color-text); }

/* ----- Tables (used on dashboards) ----- */
.table-wrap { overflow-x: auto; background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow-1); border: 1px solid var(--color-border); }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th { background: var(--color-surface-2); font-weight: 600; color: var(--color-text-soft); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-2); }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 6px 0 26px; }
.stat {
  background: var(--color-surface); padding: 18px 18px;
  border-radius: var(--radius); box-shadow: var(--shadow-1);
  border: 1px solid var(--color-border);
  display: flex; flex-direction: column; gap: 4px;
  transition: transform var(--t), box-shadow var(--t);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.stat .stat-label { color: var(--color-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat .stat-num   { font-size: 1.6rem; font-weight: 800; color: var(--color-text); line-height: 1.1; }
.stat .stat-trend { font-size: .82rem; color: var(--color-text-soft); }
.stat-icon {
  width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-soft); color: var(--color-primary); margin-bottom: 4px; font-size: 1.2rem;
}

/* Toast (success/error after AJAX) */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-2);
  padding: 12px 16px; min-width: 240px; max-width: 360px;
  animation: toast-in .25s ease;
}
.toast.is-error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.toast.is-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.flex-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Mobile fine-tunes */
@media (max-width: 540px) {
  main.container { padding-top: 16px; padding-bottom: 40px; }
  .auth-card { margin: 24px auto; padding: 24px 20px; }
  .form-card { padding: 18px 16px; }
  .pricing-card { padding: 22px 18px; }
  .stat .stat-num { font-size: 1.4rem; }
  .table th, .table td { padding: 10px 10px; font-size: .9rem; }
  .modal-card .modal-head, .modal-card .modal-body, .modal-card .modal-foot { padding: 14px 16px; }
}

/* Viewer (embed mode hides chrome) */
.viewer-body.viewer-embed {
  padding: 0; margin: 0;
  background: transparent !important;
  background-image: none !important;
  color: var(--color-text);
  min-height: auto;
}
.viewer-body.viewer-embed .viewer-topbar { display: none; }
.viewer-body.viewer-embed .flipbook-wrap { min-height: auto; padding: 0; }
.viewer-body.viewer-embed .btn-ghost {
  background: rgba(0,0,0,.06); color: var(--color-text); border-color: rgba(0,0,0,.08);
}
.viewer-body.viewer-embed .btn-ghost:hover { background: rgba(0,0,0,.12); color: var(--color-text); }

/* Page header (admin and elsewhere) */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }

/* Form-card label spacing */
.form-card label, .form-card .field { display: block; margin-bottom: 14px; font-size: .9rem; color: var(--color-text-soft); font-weight: 500; }
.form-card label > input, .form-card label > textarea, .form-card label > select { margin-top: 6px; }
.form-card label.checkbox > input { margin-top: 0; }

/* Section helpers */
.demo-section h2, .section-tight h2 { font-size: clamp(1.4rem, 2.5vw, 1.9rem); }

/* ---------- Simple viewer (slider/fade effects) ---------- */
.flipbook-wrap { position: relative; }
.simple-viewer {
  position: relative;
  margin: 0 auto;
  background: #0f172a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.4);
}
.simple-track { position: relative; width: 100%; height: 100%; }
.simple-slider .simple-track { display: flex; flex-wrap: nowrap; transition: transform .45s cubic-bezier(.4,0,.2,1); will-change: transform; }
.simple-slider .simple-slide { flex: 0 0 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.simple-slider .simple-slide img {
  width: 100%; height: 100%; object-fit: contain; display: block;
  /* v3.3.11: high-quality downscale for sharp text on mobile */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.simple-fade .simple-track { position: relative; }
.simple-fade .simple-slide {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .5s ease;
}
.simple-fade .simple-slide img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Watermark overlay ---------- */
.flipbook-watermark {
  pointer-events: none;
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  transform: rotate(-22deg);
  opacity: .14;
  z-index: 4;
  overflow: hidden;
}
.flipbook-watermark span {
  font-weight: 700;
  font-size: clamp(.95rem, 1.6vw, 1.5rem);
  color: #0f172a;
  text-align: center;
  align-self: center;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------- Page-effect picker (create/edit form) ---------- */
.effect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.effect-grid label {
  display: block;
  border: 2px solid var(--color-border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--color-surface);
  transition: all .15s ease;
}
.effect-grid label:hover { border-color: var(--color-primary); box-shadow: var(--shadow-1); }
.effect-grid label.is-locked { opacity: .55; cursor: not-allowed; }
.effect-grid label.is-locked:hover { border-color: var(--color-border); box-shadow: none; }
.effect-grid input[type=radio] { margin-right: 6px; }
.effect-grid .effect-name { font-weight: 600; color: var(--color-text); }
.effect-grid .effect-desc { font-size: .82rem; color: var(--color-text-soft); margin-top: 4px; }
.effect-grid .effect-lock { font-size: .78rem; color: var(--color-warn, #b45309); margin-top: 4px; font-weight: 600; }
.effect-grid label:has(input:checked) { border-color: var(--color-primary); background: #eef2ff; }

/* ============================================================
 * v3.2 additions
 * ========================================================== */

/* Share / preview page */
.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}
.share-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.share-card h3 { margin: 0 0 10px; font-size: 1rem; }
.share-row { display: flex; gap: 6px; }
.share-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 8px; background: #f8fafc; }
.share-card textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 8px; background: #f8fafc; font-family: ui-monospace, monospace; font-size: .85rem; resize: vertical; }
.qr-box { display:flex; justify-content:center; align-items:center; padding:8px; background:#fff; border-radius: 10px; margin-bottom:8px; min-height: 200px; }

/* Lead-capture overlay */
.lead-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .85);
  padding: 20px;
}
.lead-card {
  width: 100%; max-width: 420px;
  background: #fff; color: #0f172a;
  border-radius: 16px; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.lead-card h2 { margin: 0 0 6px; font-size: 1.25rem; color: #0f172a; }
.lead-card p, .lead-card .muted { margin: 0 0 16px; color: #475569; }
.lead-card label { display: block; font-size: .9rem; margin: 10px 0 4px; color: #334155; font-weight: 600; }
.lead-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: #0f172a; font-size: 1rem;
}
.lead-card input:focus { outline: 2px solid var(--color-primary, #6d28d9); outline-offset: 1px; }
.lead-card button[type=submit] { color: #fff; }

/* Thumbnails panel */
.thumbs-panel {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: min(280px, 75vw);
  background: rgba(15, 23, 42, .95);
  color: #fff;
  display: flex; flex-direction: column;
  z-index: 50; box-shadow: -10px 0 30px rgba(0,0,0,.3);
}
.thumbs-panel[hidden] { display: none !important; }
.thumbs-panel #thumbsClose {
  position: relative; z-index: 51; pointer-events: auto;
  width: 36px; height: 36px; padding: 0;
}
.thumbs-panel__head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.thumbs-list {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden; padding: 12px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.thumbs-list::-webkit-scrollbar { width: 8px; }
.thumbs-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }
.thumb-item {
  background: rgba(255,255,255,.04);
  border: 2px solid transparent; padding: 0; cursor: pointer;
  border-radius: 6px; overflow: hidden; position: relative; color: #cbd5e1;
  display: flex; flex-direction: column;
  aspect-ratio: 3 / 4;
}
.thumb-item img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: top;
}
.thumb-item span {
  position: absolute; bottom: 2px; right: 4px;
  background: rgba(0,0,0,.7); color: #fff;
  font-size: .65rem; padding: 1px 5px; border-radius: 3px;
  line-height: 1.3;
}
.thumb-item.is-active { border-color: var(--color-primary, #4f46e5); }
.thumb-item:hover { border-color: rgba(255,255,255,.4); }
@media (max-width: 720px) {
  .thumbs-panel { width: min(220px, 70vw); }
  .thumbs-list { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 6px; padding: 8px; }
}

/* Watermark position variants */
.flipbook-watermark.wm-diagonal { /* default — already styled */ }
.flipbook-watermark.wm-footer {
  position: absolute; left: 0; right: 0; bottom: 8px; top: auto;
  display: block; pointer-events: none; text-align: center;
  transform: none;
}
.flipbook-watermark.wm-footer span {
  display: inline-block; padding: 4px 10px; border-radius: 8px;
  background: rgba(15, 23, 42, .35); color: #fff;
  opacity: var(--wm-opacity, .14); font-weight: 600; font-size: .85rem;
}
.flipbook-watermark.wm-corner {
  position: absolute; top: 12px; right: 14px; left: auto; bottom: auto;
  display: block; pointer-events: none; transform: none;
}
.flipbook-watermark.wm-corner span {
  display: inline-block; padding: 4px 10px; border-radius: 8px;
  background: rgba(15, 23, 42, .35); color: #fff;
  opacity: var(--wm-opacity, .14); font-weight: 600; font-size: .85rem;
}
.flipbook-watermark.wm-diagonal { opacity: var(--wm-opacity, .14); }

/* Custom logo in viewer brand */
.brand-logo-img { height: 28px; width: auto; max-width: 110px; border-radius: 6px; object-fit: contain; }

/* Drag & drop upload zone */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s ease;
  background: #fafafa;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--color-primary);
  background: #eef2ff;
}
.dropzone strong { display: block; margin-bottom: 4px; }
.dropzone .muted { font-size: .85rem; }
.dropzone input[type=file] { display: none; }
.upload-progress { margin-top: 12px; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.upload-progress-bar { height: 100%; background: var(--color-primary); width: 0%; transition: width .2s; }
.upload-files { margin-top: 10px; font-size: .85rem; color: var(--color-text-soft); }
.upload-files li { padding: 4px 0; }

/* Site announcement banner */
.announcement-banner {
  background: var(--color-primary);
  color: #fff;
  padding: 8px 16px;
  text-align: center;
  font-size: .9rem;
  position: relative;
}
.announcement-banner.is-success { background: #10b981; }
.announcement-banner.is-warn { background: #f59e0b; color: #1c1917; }
.announcement-banner.is-danger { background: #dc2626; }
.announcement-banner a { color: inherit; text-decoration: underline; }
.announcement-close {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 1rem; padding: 2px 8px;
}

/* Language toggle pill */
.lang-toggle { display: inline-flex; gap: 4px; align-items: center; }
.lang-toggle a { padding: 2px 8px; border-radius: 999px; font-size: .8rem; color: var(--color-text-soft); }
.lang-toggle a.is-active { background: var(--color-primary); color: #fff; }

/* Help / static page formatting */
.legal-page { max-width: 760px; margin: 30px auto; padding: 0 16px; }
.legal-page h1 { margin-bottom: 8px; }
.legal-page h2 { margin-top: 28px; }
.legal-page p, .legal-page li { line-height: 1.6; color: var(--color-text); }
.faq details { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details[open] summary { color: var(--color-primary); }
.footer-links { margin-top: 6px; font-size: .85rem; color: var(--color-text-soft); }
.footer-links a { color: inherit; opacity: .9; }
.footer-links a:hover { opacity: 1; text-decoration: underline; }

/* ===== v3.3 additions ===== */

/* Modal close (used in lead-card etc) */
.lead-card { position: relative; }
.lead-card .modal-close,
.modal-card .modal-close {
  position: absolute; top: 8px; right: 10px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgba(0,0,0,.06);
  font-size: 1.4rem;
  border: 0; cursor: pointer;
  color: var(--color-text-soft);
}
.lead-card .modal-close:hover,
.modal-card .modal-close:hover { background: rgba(0,0,0,.12); color: var(--color-text); }

/* Edit page live preview */
.edit-preview { margin: 16px 0 24px; }
.edit-preview-stage {
  position: relative; aspect-ratio: 16/10; background: #0f172a;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border);
}
.edit-preview-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 720px) {
  .edit-preview-stage { aspect-ratio: 4/5; }
}

/* Profile page grid */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.profile-grid h3 { margin-top: 0; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warn    { background: #fef3c7; color: #92400e; }

/* Page header w/ actions row */
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Discover page */
.discover-search {
  display: flex; gap: 8px; margin-bottom: 18px; max-width: 520px;
}
.discover-search input { flex: 1; }
.discover-card { text-decoration: none; color: inherit; transition: transform .15s ease; }
.discover-card:hover { transform: translateY(-2px); }
.discover-grid h3 { margin: 4px 0 6px; font-size: 1rem; }
.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin: 22px 0; }
.pagination a {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
}
.pagination a.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Stats grid (admin error log) */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-1);
}
.stat-label { font-size: .75rem; color: var(--color-text-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.6rem; font-weight: 700; margin-top: 4px; }

.badge-error { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-notice { background: #dbeafe; color: #1e40af; }
.badge-deprecated { background: #ede9fe; color: #5b21b6; }
.badge-fatal { background: #1f2937; color: #fff; }
.badge-exception { background: #fee2e2; color: #991b1b; }


/* ===== v3.3.2 additions ===== */

/* Subtle viewer spinner replacing "Memuat X/Y" text */
#loading.viewer-spinner {
  text-align: center; padding: 20px;
}
#loading.viewer-spinner .spinner-dot {
  display: inline-block; width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,.15);
  border-top-color: rgba(255,255,255,.6);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.viewer-body.viewer-embed #loading.viewer-spinner .spinner-dot {
  border-color: rgba(0,0,0,.15);
  border-top-color: rgba(0,0,0,.5);
}

/* Stronger embed mode reset — beat all viewer-body defaults */
body.viewer-body.viewer-embed,
.viewer-body.viewer-embed {
  background: transparent !important;
  background-color: transparent !important;
  background-image: none !important;
  color: inherit !important;
  min-height: 0 !important;
  padding: 0 !important; margin: 0 !important;
}
.viewer-body.viewer-embed .flipbook-wrap { background: transparent !important; }

/* ===== v3.3.3 additions ===== */

.viewer-title strong { display: block; }
.viewer-title .viewer-meta {
  display: block; font-weight: 400; font-size: .78rem;
  color: rgba(255,255,255,.7); margin-top: 2px;
}

/* Mobile viewer fixes */
@media (max-width: 720px) {
  .viewer-topbar {
    flex-wrap: wrap; padding: 8px 10px; gap: 6px;
  }
  /* Hide redundant top-left brand on mobile — page title already conveys context. */
  .viewer-topbar .brand { display: none; }
  .viewer-topbar .viewer-title {
    order: 3; flex: 1 1 100%; text-align: left;
    font-size: .95rem; line-height: 1.2;
  }
  .viewer-topbar .viewer-title strong { font-size: .95rem; }
  .viewer-topbar .viewer-title .viewer-meta { font-size: .72rem; }
  .viewer-topbar .viewer-actions { flex-wrap: wrap; gap: 4px; }
  .viewer-topbar .viewer-actions .btn-sm {
    padding: 6px 8px; font-size: .82rem;
  }
  #flipbook-stage { padding: 6px 0; }
  .flipbook-wrap { padding: 0 6px; }
}

/* v3.3.11: rotate book 90° (user-toggled via topbar button). Applied to the
   wrapper so the topbar/controls stay upright. */
.flipbook-wrap.is-rotated #flipbook-stage > #flipbook,
.flipbook-wrap.is-rotated #flipbook-stage > .simple-viewer {
  transform: rotate(90deg);
  transform-origin: center center;
}
.viewer-rotate-btn.is-active {
  background: var(--color-primary, #6366f1) !important;
  color: #fff !important;
}

/* Discover likes */
.discover-card { position: relative; }
.like-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; background: rgba(255,255,255,.92); color: #be123c;
  border: 1px solid rgba(190,18,60,.2); border-radius: 999px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.like-btn:hover { background: #fef2f2; }
.like-btn.liked { background: #be123c; color: #fff; border-color: #be123c; }
.like-btn:active { transform: scale(.92); }
.discover-card .like-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
}
