:root {
  --ink: #1d2433;
  --muted: #667085;
  --line: #dde3ec;
  --paper: #ffffff;
  --soft: #f6f4fb;
  --brand: #4b2e83;
  --brand-dark: #33205e;
  --brand-blue: #263991;
  --brand-2: #ed1c24;
  --gold: #f5d547;
  --shadow: 0 16px 38px rgba(29, 36, 51, .09);
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background:
    linear-gradient(90deg, rgba(75, 46, 131, .08), rgba(245, 213, 71, .1), rgba(237, 28, 36, .06)),
    rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(29, 36, 51, .06);
  backdrop-filter: blur(12px);
}
.site-header .wrap { width: min(1280px, calc(100% - 32px)); }
.nav {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-width: 0;
}
.brand { display: flex; flex-direction: column; font-weight: 800; letter-spacing: 0; }
.brand-with-logo { flex-direction: row; align-items: center; gap: 10px; min-width: 0; }
.brand-with-logo img { width: 46px; height: 46px; object-fit: contain; flex: 0 0 auto; }
.brand-text { display: grid; min-width: 0; line-height: 1.05; overflow-wrap: anywhere; }
.brand-text small { margin-top: 3px; color: var(--muted); font-size: 13px; font-weight: 650; }
.nav-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  color: #344054;
  font-size: 14px;
  font-weight: 750;
}
.nav-links a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 6px;
}
.nav-links a:not(.btn):hover,
.nav-links a:not(.btn).active {
  background: #fff7d1;
  border-color: rgba(245, 213, 71, .72);
  color: #21163f;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  max-width: 100%;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  font-weight: 750;
  text-align: center;
  cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.nav-admin,
.btn.danger,
.btn.download { background: var(--brand-2); border-color: var(--brand-2); color: white; }
.btn.nav-admin { box-shadow: 0 10px 20px rgba(237, 28, 36, .18); }
.btn.nav-admin:hover,
.btn.danger:hover,
.btn.download:hover { background: #c4121a; border-color: #c4121a; }
.btn.accent { background: var(--gold); border-color: var(--gold); color: #21163f; }
.btn.tool { background: white; border-color: rgba(255, 255, 255, .86); color: var(--brand-dark); }
.btn.tool.active { background: var(--gold); border-color: var(--gold); color: #21163f; }
.btn.flip-nav { min-width: 82px; }

.hero {
  padding: 70px 0 46px;
  background: var(--brand);
  color: white;
  border-bottom: 6px solid var(--gold);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 34px; align-items: end; }
.eyebrow { color: var(--gold); text-transform: uppercase; font-size: 13px; font-weight: 850; }
h1 { margin: 10px 0 18px; font-size: clamp(38px, 6vw, 72px); line-height: .95; letter-spacing: 0; }
.hero p { max-width: 680px; color: rgba(255, 255, 255, .9); font-size: 19px; }
.searchbar { display: flex; gap: 8px; margin-top: 24px; min-width: 0; }
.searchbar input,
input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font: inherit;
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  accent-color: var(--brand);
  flex: 0 0 auto;
}
textarea { min-height: 130px; }
.hero-card {
  padding: 18px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .15);
}
.hero-logo {
  width: min(180px, 52vw);
  height: auto;
  margin: 0 0 16px auto;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, .18));
}

.section { padding: 44px 0; }
.home-section + .home-section { margin-top: 44px; }
.public-shell {
  width: min(1280px, calc(100% - 32px));
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  align-items: start;
  gap: 30px;
}
.public-content { min-width: 0; }
.public-sidebar { display: block; position: sticky; top: 96px; }
.sidebar-card {
  overflow: hidden;
  border: 1px solid rgba(75, 46, 131, .18);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}
.sidebar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-blue));
  color: white;
  font-weight: 900;
  line-height: 1.05;
}
.sidebar-title img { width: 42px; height: 42px; object-fit: contain; flex: 0 0 auto; }
.sidebar-title span { display: grid; }
.sidebar-title small { margin-top: 4px; color: rgba(255, 255, 255, .76); font-size: 12px; font-weight: 750; }
.sidebar-nav { display: grid; gap: 6px; padding: 12px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 6px;
  color: #344054;
  font-weight: 800;
}
.sidebar-nav a:hover,
.sidebar-nav a.active { background: #fff7d1; color: #21163f; }
.sidebar-nav a.active { box-shadow: inset 4px 0 0 var(--brand-2); }
.sidebar-admin { width: calc(100% - 24px); margin: 0 12px 12px; }

.section-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; min-width: 0; }
.section-head h2,
.admin-title h1 { margin: 0; font-size: 26px; line-height: 1.1; }
.muted { color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  min-width: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.card-body { padding: 18px; min-width: 0; }
.thumb { width: 100%; aspect-ratio: 16 / 10; background: #dfe5ee; object-fit: cover; }
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #f1ebff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}
.meta { color: var(--muted); font-size: 13px; }
.content { padding: min(6vw, 44px); background: white; border: 1px solid var(--line); border-radius: 8px; }
.content h1 { color: var(--ink); font-size: clamp(32px, 5vw, 54px); }
.content img { margin: 18px 0; border-radius: 8px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 8px; }
.gallery img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.gallery figcaption { padding: 10px; color: var(--muted); font-size: 13px; }
.gallery-section + .gallery-section { margin-top: 34px; }
.gallery-albums figure { box-shadow: var(--shadow); }
.gallery-albums figcaption strong { color: var(--ink); font-size: 15px; }
.gallery-add-form { display: grid; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.gallery-add-form label { font-size: 13px; }
.gallery-add-form input[type="file"] { min-height: 38px; padding: 8px; font-size: 13px; }
.gallery-add-form .btn { width: 100%; min-height: 38px; }
.gallery-upload-progress {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #d6e4ff;
  border-radius: 6px;
  background: #f5f9ff;
  color: #344054;
  font-size: 13px;
  font-weight: 750;
}
.gallery-upload-progress[hidden] { display: none; }
.gallery-upload-progress div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gallery-upload-progress progress { width: 100%; height: 9px; accent-color: var(--brand); }

.flipbook { width: 100%; min-height: 78vh; border: 1px solid var(--line); border-radius: 8px; background: white; }
.flip-reader {
  max-width: 100%;
  overflow: hidden;
  padding: 16px;
  background: #21163f;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(33, 22, 63, .22);
  --flip-zoom: 1;
}
.flip-reader:fullscreen,
.flip-reader:-webkit-full-screen,
.flip-reader.is-mobile-fullscreen {
  width: 100vw;
  height: 100vh;
  padding: 16px;
  overflow: auto;
  background: #21163f;
}
.flip-reader.is-mobile-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border: 0;
  border-radius: 0;
}
body.flip-fullscreen-lock { overflow: hidden; }
.flip-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-width: 0; }
.flip-tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.flip-status { min-width: 128px; color: white; font-weight: 800; text-align: center; }
.flip-stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  justify-content: center;
  gap: 2px;
  min-height: 68vh;
  max-width: 100%;
  min-width: 0;
  perspective: 1800px;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
}
.flip-reader.single-view .flip-stage { grid-template-columns: 1fr; }
.flip-reader.single-view .flip-page[data-page-left] { display: none; }
.flip-stage.dragging { cursor: grabbing; }
.flip-stage-nav {
  position: absolute;
  top: 50%;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 46px;
  height: 62px;
  min-height: 62px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 8px;
  background: rgba(33, 22, 63, .78);
  color: white;
  font: inherit;
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  cursor: pointer;
  transform: translateY(-50%);
  transition: opacity .16s ease, background .16s ease, transform .16s ease;
}
.flip-stage-nav.prev { left: 12px; }
.flip-stage-nav.next { right: 12px; }
.flip-stage:hover .flip-stage-nav,
.flip-stage:focus-within .flip-stage-nav,
.flip-reader.is-mobile-fullscreen .flip-stage-nav {
  opacity: 1;
}
.flip-stage-nav:hover,
.flip-stage-nav:focus-visible {
  background: rgba(75, 46, 131, .94);
  outline: 0;
  transform: translateY(-50%) scale(1.04);
}
.flip-stage-nav:disabled {
  opacity: 0;
  pointer-events: none;
}
.flip-page {
  display: grid;
  place-items: center;
  min-width: 0;
  max-width: 100%;
  min-height: 68vh;
  overflow: hidden;
  background: white;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(29, 36, 51, .08);
  transform-origin: left center;
}
.flip-page:first-child { transform-origin: right center; }
.flip-reader.zoomed .flip-page { overflow: auto; place-items: start center; }
.flip-page canvas,
.flip-page img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  transform: scale(var(--flip-zoom));
  transform-origin: top center;
  transition: transform .16s ease;
}
.flip-page img { display: none; }
.flip-reader.image-mode .flip-page img { display: block; }
.flip-reader.image-mode .flip-page canvas { display: none; }
.flip-turn-page {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  width: calc(50% - 1px);
  overflow: hidden;
  background: white;
  border-radius: 4px;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .24);
  backface-visibility: hidden;
  transform-style: preserve-3d;
  pointer-events: none;
}
.flip-reader.single-view .flip-turn-page { left: 0; right: 0; width: 100%; }
.flip-turn-page img { width: auto; height: auto; max-width: 100%; max-height: 78vh; }
.flip-turn-page.turn-next { right: 0; transform-origin: left center; }
.flip-turn-page.turn-prev { left: 0; transform-origin: right center; }
.flip-turn-page.turn-next.is-turning { animation: pageTurnNext .72s cubic-bezier(.2, .72, .18, 1) both; }
.flip-turn-page.turn-prev.is-turning { animation: pageTurnPrev .72s cubic-bezier(.2, .72, .18, 1) both; }
.flip-hint { margin-top: 12px; color: rgba(255, 255, 255, .68); text-align: center; font-size: 13px; }
@keyframes pageTurnNext {
  0% { transform: rotateY(0deg); filter: brightness(1); }
  45% { filter: brightness(.92); box-shadow: -24px 18px 42px rgba(0, 0, 0, .26); }
  100% { transform: rotateY(-178deg); filter: brightness(.78); }
}
@keyframes pageTurnPrev {
  0% { transform: rotateY(0deg); filter: brightness(1); }
  45% { filter: brightness(.92); box-shadow: 24px 18px 42px rgba(0, 0, 0, .26); }
  100% { transform: rotateY(178deg); filter: brightness(.78); }
}

.site-footer { margin-top: 36px; padding: 26px 0; background: #111827; color: rgba(255, 255, 255, .88); text-align: center; }
.admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin-side { padding: 22px; background: var(--brand-dark); color: white; }
.admin-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.admin-brand img { width: 44px; height: 44px; object-fit: contain; }
.admin-brand h2 { margin: 0; }
.admin-user-card {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
  padding: 10px 12px !important;
  border-radius: 8px;
  background: rgba(255, 255, 255, .08);
}
.admin-user-card img { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: white; }
.admin-user-card span { display: grid; color: white; line-height: 1.15; }
.admin-user-card small { margin-top: 3px; color: rgba(255, 255, 255, .68); font-size: 12px; }
.profile-preview { display: flex; align-items: center; gap: 14px; }
.profile-preview img { width: 86px; height: 86px; border: 1px solid var(--line); border-radius: 50%; background: white; object-fit: cover; }
.admin-side a { display: block; padding: 10px 12px; border-radius: 6px; color: rgba(255, 255, 255, .84); font-weight: 700; }
.admin-side a:hover,
.admin-side a.active { background: rgba(255, 255, 255, .1); color: white; }
.admin-side a.logout-link { margin-top: 8px; color: #ffd7dc; }
.admin-side a.logout-link:hover { background: rgba(237, 28, 36, .22); color: white; }
.admin-main { min-width: 0; padding: 28px; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; min-width: 0; }
.panel { margin-bottom: 18px; padding: 18px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: #344054; font-weight: 750; }
label:has(input[type="checkbox"]) { display: inline-flex; align-items: center; justify-content: flex-start; gap: 8px; width: fit-content; min-height: 42px; }
table { width: 100%; overflow: hidden; border-collapse: collapse; background: white; border: 1px solid var(--line); border-radius: 8px; }
th,
td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f8fafc; color: #475467; font-size: 13px; }
.notice { margin-bottom: 14px; padding: 12px 14px; border-radius: 6px; background: #ecfdf3; color: #067647; font-weight: 700; }
.error { background: #fff1f3; color: #b42318; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.tox.tox-tinymce { min-height: 520px !important; }
.tox .tox-edit-area,
.tox .tox-edit-area iframe { min-height: 400px !important; }
.logo-preview { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; }
.logo-preview img { width: 38px; height: 38px; object-fit: contain; }

.login-page {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(75, 46, 131, .95), rgba(38, 57, 145, .92)),
    url("../img/hero-pattern.svg") center / 320px;
}
.login-wrap { width: min(100% - 32px, 440px); min-height: 100vh; margin: 0 auto; d