:root {
	--bg: #f6f7fb;
	--panel: #ffffff;
	--ink: #222;
	--muted: #6b7280;
	--brand: #2563eb; /* default accent is blue */
	--brand-2: #7c83ff;
	--accent: #ffdfe9;
	--border: #e5e7eb;
	--good: #16a34a;
	--warn: #f59e0b;
	--ctp-accent: #cba6f7; /* default Catppuccin accent (Mocha mauve) */
	--hover-bg: #f9fafb; /* subtle hover for light */
	--badge-bg: #f3f4f6; /* meta badge background */
	--hero-glow: #eef2ff; /* splash hero glow */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
	margin: 0;
	font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
	color: var(--ink);
	background: var(--bg);
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* Theme: Dark (simple) */
[data-theme="dark"] {
	--bg: #0f1115;
	--panel: #151821;
	--ink: #e5e7eb;
	--muted: #9aa4b2;
	--border: #262b36;
	--hover-bg: #1b1f2a;
	--badge-bg: #202431;
	--hero-glow: rgba(255,255,255,0.06);
}

/* Themes: Catppuccin */
[data-theme^="ctp-"] {
	--brand: var(--ctp-accent);
}
[data-theme="ctp-mocha"] {
	--bg: #1e1e2e; /* base */
	--panel: #181825; /* mantle */
	--ink: #cdd6f4; /* text */
	--muted: #a6adc8; /* subtext0 */
	--border: #313244; /* surface0 */
	--ctp-accent: #cba6f7; /* mauve */
	--hover-bg: #232538;
	--badge-bg: #2b2d43;
	--hero-glow: rgba(255,255,255,0.07);
}
[data-theme="ctp-macchiato"] {
	--bg: #24273a;
	--panel: #1e2030;
	--ink: #cad3f5;
	--muted: #a5adcb;
	--border: #363a4f;
	--ctp-accent: #c6a0f6; /* mauve */
	--hover-bg: #232538;
	--badge-bg: #2b2d43;
	--hero-glow: rgba(255,255,255,0.07);
}
[data-theme="ctp-frappe"] {
	--bg: #303446;
	--panel: #292c3c;
	--ink: #c6d0f5;
	--muted: #a5adce;
	--border: #414559;
	--ctp-accent: #ca9ee6; /* mauve */
	--hover-bg: #232538;
	--badge-bg: #2b2d43;
	--hero-glow: rgba(255,255,255,0.07);
}
[data-theme="ctp-latte"] {
	--bg: #eff1f5;
	--panel: #e6e9ef;
	--ink: #4c4f69;
	--muted: #6c6f85;
	--border: #ccd0da;
	--ctp-accent: #8839ef; /* mauve */
	/* Light-friendly surfaces for Latte */
	--hover-bg: #e9edf3; /* subtle hover on light */
	--badge-bg: #dce0e8; /* surface0 */
	--hero-glow: #e9ecf1;
}

.container {
	width: min(1200px, 92vw);
	margin: 0 auto;
}

/* Header */
.site-header { background: transparent; color: var(--ink); }
.header-inner {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 14px 0;
}
.brand { font-weight: 800; color: var(--ink); text-decoration: none; letter-spacing: 0.5px; font-size: 1.25rem; }
.brand-sub { opacity: 0.7; font-weight: 600; }

.top-nav { margin-left: 12px; display: flex; gap: 12px; }
.top-nav a { color: var(--brand); text-decoration: none; opacity: 0.95; font-weight: 600; }
.splash-nav a { color: var(--brand); text-decoration: none; font-weight: 600; }
.top-nav a:hover { text-decoration: underline; }

#moe-repos { margin-left: auto; image-rendering: pixelated; }
.digits-row #moe-repos { height: 100px; }

/* Search bar */
/* Hide advanced search bar on front page to mimic safebooru */
.home .searchbar { display: none; }
.home .main { display: none; }
.splash { text-align: center; padding: 24px 0 0; }
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero { width: 820px; max-width: 90vw; height: 220px; background: radial-gradient(ellipse at center, #eef2ff 0%, transparent 70%); display: flex; align-items: center; justify-content: center; }
.hero { background: radial-gradient(ellipse at center, var(--hero-glow) 0%, transparent 70%); }
.hero-logo { font-size: 2.6rem; color: #6b7280; letter-spacing: 2px; }
.splash-nav { display: flex; gap: 12px; margin: 4px 0 2px; }
.splash-nav a { color: var(--brand); text-decoration: none; font-weight: 600; }
.splash-nav a:hover { text-decoration: underline; }
.splash-search { display: flex; flex-direction: column; gap: 8px; width: min(420px, 70vw); }
.splash-search input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }
.splash-search input { background: var(--panel); color: var(--ink); }
.splash-search .btn { width: 100%; }
.splash-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.splash-meta a { color: var(--brand); font-weight: 600; text-decoration: none; }
.splash-meta a:hover { text-decoration: underline; }
.splash-meta.small { font-size: 0.8rem; }
.splash-meta.tiny { font-size: 0.75rem; }
.digits-row img { height: 100px; image-rendering: pixelated; }
.digits-row { position: relative; display: inline-block; }
.digits-row.error-mask::before,
.digits-row.error-mask::after {
	content: "";
	position: absolute;
	top: 0;
	bottom: 0;
	width: 28.58%; /* mask exactly 2 of the 7 digits on each side */
	background: var(--bg);
	z-index: 2;
	pointer-events: none;
}
.digits-row.error-mask::before { left: 0; }
.digits-row.error-mask::after { right: 0; }
#moe-repos { position: relative; z-index: 1; }
.search-form {
	display: grid;
	grid-template-columns: 1.2fr 1.4fr 0.8fr;
	gap: 12px;
	align-items: end;
	padding: 16px 0;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.8rem; color: var(--muted); }
.field input, .field select {
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--ink);
	outline: none;
}
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(255, 90, 165, 0.15); }
.input-with-button { display: flex; gap: 8px; align-items: stretch; }
.input-with-button input { flex: 1; }

.btn {
	padding: 10px 14px;
	border-radius: 8px;
	border: 1px solid var(--border);
	background: var(--panel);
	color: var(--ink);
	cursor: pointer;
}
.btn:hover { background: var(--hover-bg); }
.btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(0.95); }
.btn.icon { width: 36px; }

.actions { display: none; }
.hint { margin: 0 0 14px; color: var(--muted); font-size: 0.9rem; }

/* Main */
.main { padding: 16px 0 40px; }
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.sidebar { position: sticky; top: 8px; align-self: start; }
.side-section { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 12px; }
.side-section { background: var(--panel); }
.side-section h3 { margin: 6px 6px 10px; font-size: 0.9rem; color: var(--muted); }
.tag-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; gap: 6px; max-height: 380px; overflow: auto; }
.tag-list li a { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: inherit; }
.tag-list li a:hover { background: var(--hover-bg); }
.tag-list .count { color: var(--muted); font-size: 0.75rem; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 16px; color: var(--muted); }

.grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
	gap: 14px;
}

.card {
	position: relative;
	display: block;
	background: var(--panel);
	border: 1px solid var(--border);
	border-radius: 10px;
	overflow: hidden;
	text-decoration: none;
	color: inherit;
}
.card .thumb {
	aspect-ratio: 16 / 9;
	background-size: cover;
	background-position: center;
}
.card .content { padding: 10px 12px 12px; }
.card .title { font-weight: 700; font-size: 0.98rem; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .desc { color: var(--muted); font-size: 0.88rem; height: 40px; overflow: hidden; }
.meta { display: flex; gap: 6px; font-size: 0.74rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; align-items: center; }
.badge { background: var(--badge-bg); border: 1px solid var(--border); border-radius: 999px; padding: 1px 6px; font-size: 0.7rem; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { background: transparent; border: 1px solid var(--brand); color: var(--brand); border-radius: 999px; padding: 2px 8px; font-size: 0.72rem; }
.tag:hover { background: var(--hover-bg); }

/* Socials */
.socials-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.social { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; text-decoration: none; color: inherit; }
.social:hover { background: var(--hover-bg); }
.social img { width: 28px; height: 28px; object-fit: contain; image-rendering: auto; }
.social span { font-weight: 600; }

.site-footer { border-top: 1px solid var(--border); color: var(--muted); padding: 12px 0; text-align: center; margin-top: auto; }
.site-footer a { color: var(--brand); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 900px) {
	.search-form {
		grid-template-columns: 1fr 1fr;
	}
	.actions { grid-column: 1 / -1; }
	.layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
	.search-form { grid-template-columns: 1fr; }
}
