*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body.ep-body {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
	color: #1a1a1a;
	background: #f4f4f4;
	line-height: 1.5;
	-webkit-text-size-adjust: 100%;
}
a { color: inherit; }
img { max-width: 100%; }

.ep-wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.ep-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ep-btn {
	display: inline-block; padding: 9px 16px; border: 1px solid #c8102e; border-radius: 6px;
	background: #c8102e; color: #fff; text-decoration: none; font-size: 14px; cursor: pointer;
}
.ep-btn:hover { background: #a50d26; }
.ep-btn-sm { padding: 6px 12px; background: #fff; color: #1a1a1a; border-color: #cfcfcf; }
.ep-btn-sm:hover { background: #f0f0f0; }

.ep-brand { font-weight: 700; font-size: 18px; text-decoration: none; white-space: nowrap; }
.ep-brand span { color: #c8102e; font-weight: 600; }

/* ---------- home ---------- */
.ep-top { background: #fff; border-bottom: 1px solid #e3e3e3; }
.ep-top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; }
.ep-datef { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ep-datef input, .ep-controls input, .ep-controls select {
	font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid #cfcfcf; border-radius: 6px; background: #fff;
}
.ep-h1 { font-size: 22px; margin: 20px 0 14px; }
.ep-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 32px; }
.ep-card {
	display: flex; flex-direction: column; background: #fff; border: 1px solid #e3e3e3; border-radius: 10px;
	overflow: hidden; text-decoration: none; transition: box-shadow .15s, transform .15s;
}
a.ep-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, .12); transform: translateY(-2px); }
.ep-card-img { display: block; aspect-ratio: 3 / 4; background: #ececec; overflow: hidden; }
.ep-card-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.ep-card-name { padding: 10px 12px 0; font-weight: 700; font-size: 16px; }
.ep-card-meta { padding: 0 12px 12px; font-size: 13px; color: #666; }
.ep-card-off { opacity: .55; }
.ep-empty { text-align: center; padding: 48px 16px; color: #555; }
.ep-foot { text-align: center; padding: 20px; font-size: 13px; color: #777; border-top: 1px solid #e3e3e3; background: #fff; }

@media (min-width: 700px) { .ep-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .ep-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------- reader ---------- */
body.ep-reader-page { overflow: hidden; background: #2b2b2b; }
.ep-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

.ep-bar {
	display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px;
	background: #fff; border-bottom: 1px solid #e3e3e3;
}
.ep-controls { display: flex; gap: 8px; margin-left: auto; }
.ep-actions { display: flex; gap: 8px; }
.ep-preview { background: #fff1cc; color: #7a5a00; padding: 6px 12px; font-size: 13px; text-align: center; }

.ep-reader { flex: 1; min-height: 0; display: flex; flex-direction: column-reverse; background: #2b2b2b; }

.ep-thumbs {
	display: flex; flex-direction: row; gap: 8px; padding: 8px; overflow-x: auto; background: #1f1f1f; flex: none;
}
.ep-thumb { flex: none; width: 56px; text-align: center; text-decoration: none; color: #bbb; font-size: 11px; opacity: .7; }
.ep-thumb img { width: 100%; display: block; border: 2px solid transparent; border-radius: 3px; background: #fff; }
.ep-thumb.is-active { opacity: 1; color: #fff; }
.ep-thumb.is-active img { border-color: #c8102e; }

.ep-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.ep-viewport {
	flex: 1; min-width: 0; overflow: auto; display: flex; -webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}
.ep-viewport img { margin: auto; flex: none; display: block; background: #fff; user-select: none; -webkit-user-drag: none; box-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.ep-viewport.is-zoomed { cursor: grab; }
.ep-viewport.is-dragging { cursor: grabbing; }

.ep-nav {
	position: absolute; top: 50%; transform: translateY(-50%); width: 38px; height: 64px; border: 0; border-radius: 6px;
	background: rgba(0, 0, 0, .45); color: #fff; font-size: 20px; cursor: pointer; z-index: 2;
}
.ep-nav:hover { background: rgba(0, 0, 0, .7); }
.ep-nav:disabled { opacity: .25; cursor: default; }
.ep-nav-prev { left: 8px; }
.ep-nav-next { right: 8px; }

.ep-toolbar {
	position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
	display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
	background: rgba(20, 20, 20, .82); color: #fff; font-size: 13px; white-space: nowrap;
}
.ep-toolbar button { background: transparent; border: 0; color: #fff; font-size: 16px; min-width: 30px; height: 30px; border-radius: 6px; cursor: pointer; }
.ep-toolbar button:hover { background: rgba(255, 255, 255, .18); }
.ep-sep { width: 1px; height: 18px; background: rgba(255, 255, 255, .3); margin: 0 4px; }

/* Desktop: thumbnails become a left sidebar */
@media (min-width: 900px) {
	.ep-reader { flex-direction: row; }
	.ep-thumbs { flex-direction: column; width: 96px; overflow-x: hidden; overflow-y: auto; padding: 10px; }
	.ep-thumb { width: 100%; }
}
@media (max-width: 600px) {
	.ep-controls { margin-left: 0; width: 100%; }
	.ep-controls select, .ep-controls input { flex: 1; min-width: 0; }
	.ep-actions { margin-left: auto; }
	.ep-nav { display: none; } /* swipe on phones */
}

/* ---------- image wrapper + clip tool ---------- */
.ep-imgwrap { margin: auto; flex: none; position: relative; box-shadow: 0 2px 14px rgba(0, 0, 0, .5); line-height: 0; }
.ep-viewport img { margin: 0; box-shadow: none; }

.ep-btn-clip { border-color: #c8102e; color: #c8102e; font-weight: 600; }
.ep-btn-clip.is-on { background: #c8102e; color: #fff; }

.ep-cliplayer { position: absolute; inset: 0; cursor: crosshair; touch-action: none; overflow: hidden; z-index: 3; }
.ep-cliplayer[hidden], .ep-sel[hidden], .ep-clipbar[hidden], .ep-modal[hidden] { display: none; }
.ep-sel { position: absolute; border: 1px dashed #fff; outline: 1px solid rgba(0, 0, 0, .55); box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5); pointer-events: none; }

.ep-viewport.is-clipping { cursor: crosshair; }

/* ---------- share buttons + modal + clip page ---------- */
.ep-share-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.ep-sh {
	display: inline-block; padding: 8px 14px; border: 1px solid #cfcfcf; border-radius: 8px; background: #fff;
	color: #1a1a1a; font: inherit; font-size: 14px; text-decoration: none; cursor: pointer;
}
.ep-sh:hover { background: #f0f0f0; }
.ep-sh-wa { border-color: #25d366; color: #128c4a; background: #effcf3; }
.ep-sh-fb { border-color: #1877f2; color: #1257b3; background: #eef4ff; }
.ep-sh-tw { border-color: #1d9bf0; color: #0f6ca8; background: #eef8ff; }
.ep-sh-in { border-color: #0a66c2; color: #0a4f95; background: #eef5fc; }
.ep-sh-ig { border-color: #e1306c; color: #b3194f; background: #fff0f5; }
.ep-share-note { text-align: center; font-size: 13px; color: #555; min-height: 1em; margin: 0 0 8px; }

.ep-modal {
	position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .75); display: flex;
	align-items: flex-start; justify-content: center; overflow: auto; padding: 16px;
}
.ep-modal-in { position: relative; background: #fff; border-radius: 12px; padding: 18px 16px 16px; width: 100%; max-width: 760px; margin: auto; }
.ep-modal-x { position: absolute; top: 6px; right: 10px; border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: #444; }
.ep-modal-img { text-align: center; margin: 8px 0 14px; }
.ep-modal-img img { max-width: 100%; max-height: 60vh; border: 1px solid #e3e3e3; }
.ep-linkrow { display: flex; gap: 8px; }
.ep-linkrow input { flex: 1; min-width: 0; font: inherit; font-size: 14px; padding: 9px 10px; border: 2px solid #8ab4f8; border-radius: 6px; }

.ep-clip { padding-bottom: 24px; }
.ep-clip-img { text-align: center; margin: 12px 0 18px; }
.ep-clip-img img { max-width: 100%; border: 1px solid #e3e3e3; background: #fff; box-shadow: 0 2px 12px rgba(0, 0, 0, .12); }
.ep-clip .ep-linkrow { max-width: 620px; margin: 0 auto 16px; }
.ep-clip .ep-h1 { text-align: center; font-size: 18px; }

/* Clip mode on phones/tablets: free up screen space so the paper can be selected comfortably */
@media (max-width: 899px) {
	.ep-clip-mode .ep-controls,
	.ep-clip-mode .ep-thumbs,
	.ep-clip-mode .ep-nav { display: none; }
	.ep-clip-mode .ep-bar { padding: 6px 12px; }
}

/* ---------- clip selection box: handles + floating buttons ---------- */
.ep-h { position: absolute; width: 11px; height: 11px; margin: -6px 0 0 -6px; background: rgba(255, 255, 255, .9); border: 1px solid #555; box-sizing: border-box; }
.ep-h-nw { left: 0; top: 0; } .ep-h-n { left: 50%; top: 0; } .ep-h-ne { left: 100%; top: 0; }
.ep-h-e { left: 100%; top: 50%; } .ep-h-se { left: 100%; top: 100%; } .ep-h-s { left: 50%; top: 100%; }
.ep-h-sw { left: 0; top: 100%; } .ep-h-w { left: 0; top: 50%; }
@media (pointer: coarse) { .ep-h { width: 18px; height: 18px; margin: -9px 0 0 -9px; } }

.ep-clipact { position: absolute; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ep-clipact[hidden], .ep-clipmsg[hidden] { display: none; }
.ep-clipact-row { display: flex; gap: 8px; white-space: nowrap; }
.ep-clipact .ep-btn { box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.ep-btn-light { background: #fff; color: #1a1a1a; border-color: #fff; }
.ep-btn-light:hover { background: #eee; }
.ep-clipmsg { background: #fff; color: #b3001b; padding: 4px 10px; border-radius: 6px; font-size: 13px; max-width: 280px; text-align: center; }
@media (max-width: 480px) { .ep-clipact .ep-btn { padding: 8px 12px; font-size: 13px; } }

/* ---------- ads, install button ---------- */
.ep-btn[hidden] { display: none; }
.ep-ad { text-align: center; overflow: hidden; margin: 12px auto; max-width: 100%; }
.ep-ad-reader_top { flex: none; margin: 0; max-height: 120px; background: #fff; border-bottom: 1px solid #e3e3e3; }
@media (max-width: 700px) { .ep-ad-reader_top:not(.ep-ad-mobile) { display: none; } }

/* ---------- full-width reader (no thumbnail sidebar) ---------- */
.ep-reader { flex-direction: column; }
.ep-pagesel {
	font: inherit; font-size: 13px; color: #fff; background: rgba(255, 255, 255, .14);
	border: 0; border-radius: 6px; padding: 4px 6px; cursor: pointer; max-width: 90px;
}
.ep-pagesel option { color: #1a1a1a; background: #fff; }

/* ---------- reader: slide animation, no browser page-zoom, full-width page ---------- */
.ep-app, .ep-viewport { touch-action: pan-x pan-y; }
.ep-cliplayer { touch-action: none; }
.ep-viewport { scrollbar-gutter: stable; }
.ep-stage { overflow: hidden; }
.ep-imgwrap { will-change: transform; }
.ep-ghost {
	position: absolute; z-index: 1; max-width: none; background: #fff; pointer-events: none;
	box-shadow: 0 2px 14px rgba(0, 0, 0, .5); will-change: transform; user-select: none;
}
.ep-toolbar button#ep-zoom-reset { font-size: 13px; padding: 0 8px; }
