/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
	--bg: #0f0f13;
	--surface: #1a1a22;
	--surface2: #222230;
	--border: #2e2e3e;
	--accent: #6c63ff;
	--accent-hover: #857dff;
	--text: #e8e8f0;
	--text-muted: #888899;
	--radius: 12px;
	--font: 'Pretendard', 'Noto Sans KR', system-ui, sans-serif;
}

body {
	background: var(--bg);
	color: var(--text);
	font-family: var(--font);
	min-height: 100vh;
	line-height: 1.6;
}

/* ── Header ── */
.site-header {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: 0 24px;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 100;
}

.site-header .logo {
	font-size: 1rem;
	font-weight: 700;
	color: var(--text);
	text-decoration: none;
	display: flex;
	align-items: center;
	gap: 8px;
}

.site-header .logo span {
	color: var(--accent);
}

/* ── Buttons ── */
.btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 18px;
	border-radius: 8px;
	border: none;
	cursor: pointer;
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
	transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
	background: var(--accent);
	color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
	background: var(--surface2);
	color: var(--text);
	border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-ghost {
	background: transparent;
	color: var(--text-muted);
	border: 1px solid var(--border);
}

.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Main container ── */
.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 32px 24px;
}

/* ── Page title bar ── */
.page-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 32px;
}

.page-header h1 {
	font-size: 1.5rem;
	font-weight: 700;
}

.page-header p {
	color: var(--text-muted);
	font-size: 0.875rem;
	margin-top: 4px;
}

/* ── Card grid (index) ── */
.card-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 20px;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	cursor: pointer;
	transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
	text-decoration: none;
	color: inherit;
	display: block;
}

.card:hover {
	border-color: var(--accent);
	transform: translateY(-3px);
	box-shadow: 0 8px 24px rgba(108, 99, 255, 0.15);
}

/* Thumbnail: scale down a full 1280×800 page into card width */
.card-thumbnail {
	width: 100%;
	height: 180px;
	overflow: hidden;
	background: #fff;
	position: relative;
}

.card-thumbnail iframe {
	width: 1280px;
	height: 800px;
	transform: scale(0.218);   /* 280 / 1280 ≈ 0.218 */
	transform-origin: top left;
	border: none;
	pointer-events: none;
}

.card-info {
	padding: 14px 16px;
	border-top: 1px solid var(--border);
}

.card-info .card-title {
	font-size: 0.95rem;
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.card-meta {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 6px;
	font-size: 0.78rem;
	color: var(--text-muted);
}

.card-meta .dot { opacity: 0.4; }

/* ── Empty state ── */
.empty {
	text-align: center;
	padding: 80px 24px;
	color: var(--text-muted);
}

.empty .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty h2 { font-size: 1.1rem; margin-bottom: 8px; color: var(--text); }

/* ── Loading skeleton ── */
.skeleton {
	background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
	background-size: 200% 100%;
	animation: shimmer 1.4s infinite;
	border-radius: 6px;
}

@keyframes shimmer {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* ── Submit form ── */
.form-card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	padding: 32px;
	max-width: 860px;
}

.form-row {
	display: grid;
	grid-template-columns: 1fr 2fr;
	gap: 16px;
	margin-bottom: 20px;
}

@media (max-width: 600px) {
	.form-row { grid-template-columns: 1fr; }
}

.form-group {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-bottom: 20px;
}

label {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

input[type="text"],
textarea {
	background: var(--bg);
	border: 1px solid var(--border);
	border-radius: 8px;
	color: var(--text);
	font-family: var(--font);
	font-size: 0.9rem;
	padding: 10px 14px;
	transition: border-color 0.15s;
	width: 100%;
	outline: none;
}

input[type="text"]:focus,
textarea:focus {
	border-color: var(--accent);
}

textarea {
	font-family: 'JetBrains Mono', 'Fira Code', 'Menlo', monospace;
	font-size: 0.82rem;
	resize: vertical;
	min-height: 300px;
	line-height: 1.7;
}

.form-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

/* char counter */
.char-count {
	font-size: 0.78rem;
	color: var(--text-muted);
	margin-left: auto;
}

.char-count.warn { color: #f59e0b; }
.char-count.over { color: #ef4444; }

/* ── Preview pane (submit page) ── */
.preview-pane {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	overflow: hidden;
	max-width: 860px;
	margin-top: 24px;
}

.preview-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid var(--border);
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--text-muted);
}

.preview-pane iframe {
	width: 100%;
	height: 500px;
	border: none;
	background: #fff;
}

/* ── View page ── */
.view-bar {
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	padding: 10px 20px;
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.view-bar .view-title {
	font-weight: 700;
	font-size: 1rem;
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.view-bar .view-meta {
	font-size: 0.8rem;
	color: var(--text-muted);
	white-space: nowrap;
}

.render-frame {
	width: 100%;
	height: calc(100vh - 56px - 53px); /* full height minus header + bar */
	border: none;
	background: #fff;
}

/* source viewer */
.source-overlay {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 200;
	background: rgba(0, 0, 0, 0.85);
	backdrop-filter: blur(4px);
}

.source-overlay.visible { display: flex; flex-direction: column; }

.source-overlay-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	font-size: 0.875rem;
	font-weight: 600;
}

.source-overlay pre {
	flex: 1;
	overflow: auto;
	padding: 24px;
	font-family: 'JetBrains Mono', 'Fira Code', monospace;
	font-size: 0.8rem;
	line-height: 1.75;
	color: #c9d1d9;
	tab-size: 2;
	white-space: pre-wrap;
	word-break: break-all;
}

/* ── Toast notification ── */
.toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%) translateY(80px);
	background: var(--surface2);
	border: 1px solid var(--border);
	border-radius: 8px;
	padding: 10px 20px;
	font-size: 0.875rem;
	transition: transform 0.3s ease;
	z-index: 999;
	pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: #22c55e; color: #22c55e; }
.toast.error { border-color: #ef4444; color: #ef4444; }

/* ── Responsive ── */
@media (max-width: 480px) {
	.container { padding: 20px 16px; }
	.form-card { padding: 20px 16px; }
}
