@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

*,
*::before,
*::after {
	box-sizing: border-box;
}

body {
	margin: 0;
	padding-top: 36px;
	min-height: 100vh;
	font-family: "Inter", Arial, sans-serif;
	background: #050608;
	color: #f1f5f9;
	overflow-x: hidden;
}

#bg-canvas {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	z-index: 0;
	pointer-events: none;
}

.alert-warning {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	padding: 8px 12px;
	font-size: 0.76rem;
	text-align: center;
	color: #f6cd57;
	background: rgba(39, 30, 3, 0.96);
	border-bottom: 1px solid #4d3c08;
	z-index: 1000;
}

.app-shell {
	position: relative;
	z-index: 1;
	width: min(1600px, 96vw);
	min-height: 84vh;
	margin: 12px auto 16px;
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	gap: 16px;
}

.app-sidebar {
	padding: 22px;
	border-radius: 12px;
	background: rgba(14, 16, 23, 0.94);
	border: 1px solid rgba(122, 130, 156, 0.2);
	box-shadow: 0 16px 36px rgba(0, 0, 0, 0.44);
}

h1 {
	margin: 0 0 10px;
	font-size: 1.62rem;
	letter-spacing: -0.02em;
}

.description {
	margin: 0 0 10px;
	line-height: 1.5;
	font-size: 0.83rem;
	color: #a5b0c2;
}

.description b {
	color: #e2e8f0;
}

.description a {
	color: #bca7ff;
	text-decoration: none;
}

.description a:hover {
	text-decoration: underline;
}

.description-muted {
	color: #7f8ca4;
	margin-bottom: 16px;
}

#ref-input-row {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

#ref-input-row.hidden {
	display: none;
}

.input-label {
	font-size: 0.72rem;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: #7f8ca4;
	font-weight: 600;
}

#ref-select {
	width: 100%;
	font-family: inherit;
	font-size: 0.82rem;
	padding: 9px 11px;
	border-radius: 8px;
	border: 1px solid #2c3350;
	background: #0a0c13;
	color: #ecf2ff;
	outline: none;
	transition:
		border-color 0.16s,
		box-shadow 0.16s;
	appearance: none;
	background-image:
		linear-gradient(45deg, transparent 50%, #7f8ca4 50%),
		linear-gradient(135deg, #7f8ca4 50%, transparent 50%);
	background-position:
		calc(100% - 16px) calc(50% - 2px),
		calc(100% - 11px) calc(50% - 2px);
	background-size:
		5px 5px,
		5px 5px;
	background-repeat: no-repeat;
	padding-right: 30px;
}

#ref-select:focus {
	border-color: #7c3aed;
	box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.viewer-host {
	min-width: 0;
	padding: 12px;
	border-radius: 12px;
	background: rgba(12, 14, 20, 0.93);
	border: 1px solid rgba(122, 130, 156, 0.18);
	box-shadow: 0 16px 36px rgba(0, 0, 0, 0.44);
}

/* ==================== Mobile App Bar (≤768px) ==================== */

#mobile-appbar {
	display: none;
}

body.is-mobile #mobile-appbar {
	position: sticky;
	top: 0;
	z-index: 100;
	display: flex;
	align-items: center;
	gap: 8px;
	height: 56px;
	padding: 0 8px;
	background: rgba(14, 16, 23, 0.97);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid #1f2439;
}

body.is-mobile #appbar-back,
body.is-mobile #appbar-menu {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	background: transparent;
	border: none;
	color: #cbd5f5;
	cursor: pointer;
	border-radius: 8px;
	transition: background 0.12s;
}

body.is-mobile #appbar-back[hidden] {
	display: none;
}

body.is-mobile #appbar-back:hover,
body.is-mobile #appbar-menu:hover {
	background: rgba(124, 58, 237, 0.14);
}

body.is-mobile #appbar-back:active,
body.is-mobile #appbar-menu:active {
	background: rgba(124, 58, 237, 0.24);
}

body.is-mobile #appbar-title {
	flex: 1;
	margin: 0;
	font-size: 1.02rem;
	font-weight: 600;
	letter-spacing: -0.01em;
	color: #f1f5f9;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* ==================== Mobile Bottom Sheet (≤768px) ==================== */

.sheet-backdrop {
	display: none;
}

.sheet {
	display: none;
}

body.is-mobile .sheet-backdrop {
	display: block;
	position: fixed;
	inset: 0;
	z-index: 1499;
	background: rgba(0, 0, 0, 0.55);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s ease-out;
}

body.is-mobile .sheet-backdrop.open {
	opacity: 1;
	pointer-events: auto;
}

body.is-mobile .sheet {
	display: flex;
	flex-direction: column;
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 1500;
	max-height: 80dvh;
	padding: 4px 18px 20px;
	padding-bottom: var(--sab, 20px);
	background: #0e1017;
	border-top: 1px solid #1f2439;
	border-radius: 18px 18px 0 0;
	box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.55);
	transform: translateY(100%);
	transition: transform 0.25s ease-out;
	overflow-y: auto;
}

body.is-mobile .sheet.open {
	transform: translateY(0);
}

body.is-mobile .sheet[hidden],
body.is-mobile .sheet-backdrop[hidden] {
	display: none;
}

.sheet-grabber {
	flex-shrink: 0;
	width: 40px;
	height: 4px;
	margin: 8px auto 14px;
	background: #2c3350;
	border-radius: 999px;
}

body.is-mobile #sidebar-mount h1 {
	font-size: 1.4rem;
	margin-top: 0;
}

body.is-mobile #sidebar-mount .sidebar-btn {
	min-height: 44px;
}

/* ==================== Mobile Shell (≤768px) ==================== */

@media (max-width: 768px) {
	body {
		padding-top: 0;
	}

	.app-shell {
		grid-template-columns: 1fr;
		width: 100%;
		margin: 0 auto 12px;
		gap: 0;
	}

	.app-sidebar {
		display: none;
	}

	.viewer-host {
		padding: 10px;
		border-radius: 0;
		border-left: none;
		border-right: none;
	}
}

/* ==================== Tablet Polish (>768px and ≤980px) ==================== */

@media (max-width: 980px) and (min-width: 769px) {
	.app-shell {
		grid-template-columns: 240px minmax(0, 1fr);
	}
}

/* ==================== Tiny phones (≤480px) — kill remaining padding ==================== */

@media (max-width: 480px) {
	.viewer-host {
		padding: 8px;
	}
}
