:root {
	--bg: #0f1115;
	--panel: #171a21;
	--panel-2: #1e222b;
	--line: #2a2f3a;
	--text: #e7eaf0;
	--muted: #9aa3b2;
	--primary: #2b7fff;
	--primary-d: #1f6ae0;
	--ok: #2ecc71;
	--err: #ff6b6b;
}

* {
	box-sizing: border-box;
}

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

.muted {
	color: var(--muted);
}
.error {
	color: var(--err);
	min-height: 1.2em;
	margin: 6px 0 0;
}
[hidden] {
	display: none !important;
}

.btn {
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--text);
	padding: 8px 14px;
	border-radius: 8px;
	font-size: 14px;
	cursor: pointer;
	transition:
		background 0.12s,
		border-color 0.12s,
		opacity 0.12s;
}
.btn:hover {
	border-color: #3a4150;
}
.btn--primary {
	background: var(--primary);
	border-color: var(--primary);
	color: #fff;
}
.btn--primary:hover {
	background: var(--primary-d);
}
.btn--primary:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.btn--ghost {
	background: transparent;
}
.btn--accent {
	background: #1f9d55;
	border-color: #1f9d55;
	color: #fff;
}
.btn--accent:hover {
	background: #197a43;
	border-color: #197a43;
}
.btn--accent:disabled {
	opacity: 0.55;
	cursor: not-allowed;
}
.icon-btn {
	background: transparent;
	border: 0;
	color: var(--muted);
	font-size: 18px;
	cursor: pointer;
	padding: 4px 8px;
}
.icon-btn:hover {
	color: var(--text);
}

.login {
	min-height: 100vh;
	display: grid;
	place-items: center;
	padding: 20px;
}
.login-card {
	width: 360px;
	max-width: 100%;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 14px;
	padding: 28px;
}
.login-card h1 {
	margin: 0 0 4px;
	font-size: 22px;
}
.login-card label {
	display: block;
	margin: 16px 0 6px;
	font-size: 13px;
	color: var(--muted);
}
.login-card input {
	width: 100%;
	padding: 10px 12px;
	border-radius: 8px;
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--text);
}
.login-card .btn {
	width: 100%;
	margin-top: 18px;
}

.app {
	display: flex;
	flex-direction: column;
	height: 100vh;
}
.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 16px;
	background: var(--panel);
	border-bottom: 1px solid var(--line);
}
.topbar-left {
	display: flex;
	align-items: baseline;
	gap: 12px;
}
.topbar-left strong {
	color: var(--primary);
	letter-spacing: 0.5px;
}
.topbar-page {
	color: var(--muted);
	font-size: 14px;
}
.topbar-right {
	display: flex;
	align-items: center;
	gap: 10px;
}
.status {
	font-size: 13px;
	color: var(--muted);
	min-width: 90px;
	text-align: right;
}
.status.ok {
	color: var(--ok);
}
.status.err {
	color: var(--err);
}

.layout {
	flex: 1;
	display: flex;
	min-height: 0;
}
.sidebar {
	width: 250px;
	background: var(--panel);
	border-right: 1px solid var(--line);
	padding: 16px;
	overflow: auto;
	flex-shrink: 0;
}
.sidebar h2 {
	font-size: 13px;
	text-transform: uppercase;
	color: var(--muted);
	margin: 0 0 10px;
}
.page-list {
	list-style: none;
	margin: 0 0 18px;
	padding: 0;
}
.page-list li {
	padding: 9px 12px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 14px;
	color: var(--text);
	margin-bottom: 2px;
}
.page-list li:hover {
	background: var(--panel-2);
}
.page-list li.active {
	background: var(--primary);
	color: #fff;
}
.hint {
	font-size: 12px;
	color: var(--muted);
	line-height: 1.5;
}

.viewport {
	flex: 1;
	min-width: 0;
	background: #fff;
	position: relative;
}
.empty {
	display: grid;
	place-items: center;
	height: 100%;
	color: #888;
}
#frame {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #fff;
}

.drawer {
	position: fixed;
	top: 0;
	right: 0;
	width: 420px;
	max-width: 100%;
	height: 100vh;
	background: var(--panel);
	border-left: 1px solid var(--line);
	z-index: 40;
	display: flex;
	flex-direction: column;
	box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
}
.drawer-head,
.modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px;
	border-bottom: 1px solid var(--line);
}
.drawer-head h2,
.modal-head h2 {
	margin: 0;
	font-size: 16px;
}
.drawer-body {
	padding: 16px;
	overflow: auto;
}
.field {
	margin-bottom: 16px;
}
.field label {
	display: block;
	font-size: 12px;
	color: var(--muted);
	margin-bottom: 6px;
}
.field input,
.field textarea {
	width: 100%;
	padding: 9px 11px;
	border-radius: 8px;
	resize: vertical;
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--text);
	font: inherit;
}

.modal {
	position: fixed;
	inset: 0;
	z-index: 50;
	display: grid;
	place-items: center;
	padding: 24px;
}
.modal-card {
	width: 760px;
	max-width: 100%;
	max-height: 86vh;
	background: var(--panel);
	border: 1px solid var(--line);
	border-radius: 14px;
	display: flex;
	flex-direction: column;
}
.modal-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
	flex-wrap: wrap;
}
.tabs {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}
.tabs button {
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--muted);
	padding: 6px 12px;
	border-radius: 20px;
	font-size: 13px;
	cursor: pointer;
}
.tabs button.active {
	background: var(--primary);
	border-color: var(--primary);
	color: #fff;
}
.modal-alt {
	padding: 12px 16px;
	border-bottom: 1px solid var(--line);
}
.modal-alt label {
	display: block;
	font-size: 12px;
	color: var(--muted);
	margin-bottom: 6px;
}
.modal-alt input {
	width: 100%;
	padding: 8px 11px;
	border-radius: 8px;
	border: 1px solid var(--line);
	background: var(--panel-2);
	color: var(--text);
}
.img-grid {
	padding: 16px;
	overflow: auto;
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
	gap: 12px;
}
.img-cell {
	border: 1px solid var(--line);
	border-radius: 10px;
	overflow: hidden;
	cursor: pointer;
	background: var(--panel-2);
	transition:
		border-color 0.12s,
		transform 0.1s;
}
.img-cell:hover {
	border-color: var(--primary);
	transform: translateY(-2px);
}
.img-cell img {
	width: 100%;
	height: 90px;
	object-fit: cover;
	display: block;
	background: #fff;
}
.img-cell span {
	display: block;
	padding: 6px 8px;
	font-size: 11px;
	color: var(--muted);
	word-break: break-all;
}

.scrim {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.55);
	z-index: 30;
}
