/* ---- Base ---- */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f2430;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --brand: #5b8cff;
  --brand-2: #3f6fe0;
  --danger: #e5484d;
  --border: #2a2f3a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Disable selection / image dragging on protected pages. */
.protected, .protected * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.protected img, .protected canvas {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: filter .15s ease, border-color .15s ease;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn.primary { background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-color: transparent; color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { border-color: #5a2a2c; color: #ffb4b6; }
.btn.danger:hover { background: #3a1f21; }

/* ---- Header / footer ---- */
.site-header { padding: 40px 0 18px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #141823, transparent); }
.brand { margin: 0; font-size: 30px; letter-spacing: .2px; }
.tagline { margin: 6px 0 0; color: var(--muted); }
.site-footer { margin-top: 50px; padding: 26px 0; border-top: 1px solid var(--border); }

/* ---- Gallery grid ---- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  padding: 28px 0;
}
.tile {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.tile:hover { transform: translateY(-3px); border-color: #3a4663; text-decoration: none; }
.thumb {
  position: relative;
  aspect-ratio: 3 / 4;
  background: repeating-linear-gradient(45deg, #1b2030, #1b2030 12px, #20283c 12px, #20283c 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.thumb-canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.has-thumb .thumb-badge { display: none; }
.thumb-badge {
  font-size: 13px; letter-spacing: 3px; color: var(--muted);
  border: 1px dashed #44506e; padding: 6px 10px; border-radius: 8px;
}
.tile-body { padding: 14px 16px 18px; }
.tile-body h3 { margin: 0 0 6px; font-size: 16px; }
.pages { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.muted { color: var(--muted); }
.empty { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---- Viewer ---- */
.viewer-body { background: #0b0d12; }
.viewer-header {
  position: sticky; top: 0; z-index: 10;
  background: rgba(15, 17, 21, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.viewer-header .row { display: flex; align-items: center; gap: 16px; }
.viewer-header .vtitle { margin: 0; font-size: 16px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { white-space: nowrap; }
.viewer { max-width: 900px; margin: 0 auto; padding: 24px 16px 80px; }
.loading { text-align: center; color: var(--muted); padding: 60px 0; }
.page {
  position: relative;
  margin: 0 auto 22px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.page-canvas { width: 100%; height: auto; display: block; border-radius: 6px 6px 0 0; opacity: 0; transition: opacity .25s ease; }
.page-canvas.loaded { opacity: 1; }
.page-num { width: 100%; text-align: center; font-size: 12px; color: #6b7280; padding: 6px 0; background: #f3f4f6; border-radius: 0 0 6px 6px; }
.page-error::after { content: "Could not load this page"; color: var(--muted); font-size: 13px; padding: 20px; }

/* ---- DevTools shield ---- */
.blurred .viewer { filter: blur(20px); pointer-events: none; }
.dt-shield {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8, 10, 14, .96);
  display: flex; align-items: center; justify-content: center; text-align: center;
}
.dt-shield h2 { margin: 0 0 8px; }
.dt-shield p { color: var(--muted); margin: 0; }

/* ---- Cards / centered layouts ---- */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin: 22px 0;
}
.card.narrow { max-width: 420px; text-align: center; }
.big { font-size: 64px; margin: 0 0 6px; }
.error { background: #3a1f21; border: 1px solid #5a2a2c; color: #ffb4b6; padding: 10px 12px; border-radius: 10px; }

/* ---- Print protection: never print preview content ---- */
@media print {
  body.protected, body.viewer-body { display: none !important; }
}
