:root {
	--bg: #f7f7f8;
	--surface: #ffffff;
	--text: #18181b;
	--muted: #71717a;
	--border: #e4e4e7;
	--accent: #ee4d2d;
	--radius: 14px;
	--shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
	--tiktok: #111111;
	--tiktok-text: #ffffff;
	--shopee: #ee4d2d;
	--shopee-text: #ffffff;
	--amazon: #ff9900;
	--amazon-text: #111111;
	--other: #3f3f46;
	--other-text: #ffffff;
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0c0c0e;
		--surface: #18181b;
		--text: #f4f4f5;
		--muted: #a1a1aa;
		--border: #2e2e33;
		--shadow: none;
		--tiktok: #f4f4f5;
		--tiktok-text: #111111;
		--other: #52525b;
		color-scheme: dark;
	}
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; }
img, video { max-width: 100%; display: block; }

.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Header & footer */
.site-header {
	position: sticky;
	top: 0;
	z-index: 10;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	backdrop-filter: blur(10px);
	border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; white-space: nowrap; letter-spacing: -0.01em; }
.search { flex: 1; display: flex; justify-content: flex-end; }
.search input {
	width: 100%;
	max-width: 360px;
	padding: 9px 14px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
}
.site-footer { margin-top: 48px; padding: 24px 0 40px; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--muted); }

/* Home */
.hero h1 { font-size: clamp(1.4rem, 3.5vw, 2rem); line-height: 1.2; margin: 28px 0 16px; letter-spacing: -0.02em; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 20px; scrollbar-width: none; }
.chip {
	flex: none;
	padding: 6px 14px;
	border-radius: 999px;
	border: 1px solid var(--border);
	background: var(--surface);
	text-decoration: none;
	font-size: 0.9rem;
	font-weight: 600;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-shopee.active { background: var(--shopee); color: var(--shopee-text); border-color: var(--shopee); }
.chip-amazon.active { background: var(--amazon); color: var(--amazon-text); border-color: var(--amazon); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; } }

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	box-shadow: var(--shadow);
	display: flex;
	flex-direction: column;
}
.card-media { position: relative; display: block; aspect-ratio: 4 / 5; background: var(--border); }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; }
.placeholder { display: grid; place-items: center; height: 100%; font-weight: 700; color: var(--muted); }
.play {
	position: absolute;
	right: 10px;
	bottom: 10px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: rgb(0 0 0 / 0.6);
}
.play::after {
	content: "";
	position: absolute;
	left: 13px;
	top: 10px;
	border-left: 11px solid #fff;
	border-top: 7px solid transparent;
	border-bottom: 7px solid transparent;
}
.card-body { padding: 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { font-size: 0.95rem; line-height: 1.35; margin: 0; font-weight: 600; }
.card-title a { text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .btn { margin-top: auto; }
.price { font-weight: 800; color: var(--accent); margin: 0; }
.price.big { font-size: 1.5rem; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-tiktok { background: var(--tiktok); color: var(--tiktok-text); }
.badge-shopee { background: var(--shopee); color: var(--shopee-text); }
.badge-amazon { background: var(--amazon); color: var(--amazon-text); }
.badge-other { background: var(--other); color: var(--other-text); }

.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.pager { display: flex; justify-content: space-between; margin: 28px 0; font-weight: 600; }

/* Buttons */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 14px;
	border-radius: 10px;
	border: 1px solid var(--border);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-size: 0.9rem;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
	text-align: center;
}
.btn:hover { filter: brightness(0.95); }
.btn-lg { padding: 14px 18px; font-size: 1rem; width: 100%; }
.btn-tiktok { background: var(--tiktok); color: var(--tiktok-text); border-color: var(--tiktok); }
.btn-shopee { background: var(--shopee); color: var(--shopee-text); border-color: var(--shopee); }
.btn-amazon { background: var(--amazon); color: var(--amazon-text); border-color: var(--amazon); }
.btn-other { background: var(--other); color: var(--other-text); border-color: var(--other); }
.btn-primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn-danger { background: transparent; color: #dc2626; border-color: #dc2626; }

/* Post page */
.back { margin: 20px 0 12px; font-size: 0.9rem; }
.back a { text-decoration: none; color: var(--muted); }
.post { display: grid; gap: 24px; }
@media (min-width: 860px) { .post { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: start; } }
.post-media { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.post-media .media { width: 100%; max-height: 80vh; object-fit: contain; background: #000; }
.embed { position: relative; width: 100%; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-youtube { aspect-ratio: 16 / 9; }
.embed-tiktok { aspect-ratio: 9 / 18; max-width: 380px; margin: 0 auto; }
.post-info h1 { font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.2; margin: 10px 0; letter-spacing: -0.02em; }
.buy-links { display: grid; gap: 10px; margin: 18px 0; }
@media (min-width: 860px) { .post-info { position: sticky; top: 80px; } }
.description p { margin: 0 0 1em; white-space: pre-line; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 0.85rem; color: var(--muted); text-decoration: none; }

/* Admin */
.admin-nav { margin-left: auto; display: flex; gap: 16px; align-items: center; font-size: 0.9rem; }
.admin-nav .muted { display: none; }
@media (min-width: 720px) { .admin-nav .muted { display: inline; } }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 16px; }
.admin-top h1, .admin h1 { margin: 0 0 16px; font-size: 1.6rem; }
.admin-top h1 { margin: 0; }
.flash { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 10px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stats div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stats strong { display: block; font-size: 1.5rem; }
.stats span { color: var(--muted); font-size: 0.85rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .thumb img, .thumb-ph { width: 44px; height: 55px; object-fit: cover; border-radius: 6px; background: var(--border); display: block; }
.admin-table .actions { white-space: nowrap; text-align: right; }
.admin-table .actions a { margin-left: 10px; }
.status { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.status-published { background: #dcfce7; color: #166534; }
.status-draft { background: var(--border); color: var(--muted); }

.errors { background: #fee2e2; color: #991b1b; padding: 4px 14px; border-radius: 10px; margin-bottom: 16px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .form-grid { grid-template-columns: 1.2fr 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.form-grid .panel { margin-bottom: 0; }
.panel h2 { font-size: 1rem; margin: 0 0 12px; }
.post-form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 12px; }
.post-form label.inline { display: inline-flex; gap: 6px; align-items: center; margin-right: 16px; font-weight: 500; }
.post-form input:not([type=radio]):not([type=file]), .post-form select, .post-form textarea {
	display: block;
	width: 100%;
	margin-top: 4px;
	padding: 9px 11px;
	border: 1px solid var(--border);
	border-radius: 8px;
	background: var(--bg);
	color: var(--text);
	font: inherit;
	font-weight: 400;
}
.post-form textarea { resize: vertical; }
.row { display: grid; gap: 12px; }
@media (min-width: 600px) { .row { grid-template-columns: 1fr 1fr; } }
fieldset.status-choice { border: 0; padding: 0; margin: 0; }
fieldset.status-choice legend { font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }
.hint { font-size: 0.82rem; color: var(--muted); margin: -6px 0 10px; }
.upload { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -4px 0 14px; font-size: 0.85rem; }
.upload[hidden] { display: none; }
.upload input[type=file] { max-width: 100%; }
.preview img, .preview video { max-height: 260px; border-radius: 8px; margin-top: 4px; }
.link-row { display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.link-row input, .link-row select { margin-top: 0 !important; }
@media (min-width: 720px) { .link-row { grid-template-columns: 150px 1fr 2fr 80px; align-items: center; } }
.form-actions { display: flex; gap: 10px; margin: 8px 0 32px; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 20px; margin-bottom: 40px; }
