html, body { height: 100%; margin: 0; }
body { font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#viewer { position: fixed; inset: 0; }

.mv {
	position: relative;
	overflow: hidden;
	color: #222;
	background: #1a1a2e; /* nuit (bg=… pour changer) */
	user-select: none;
}
.mv.dragging { outline: 3px dashed #c33; outline-offset: -12px; }
.mv-canvas, .mv-canvas canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.mv-labels { position: absolute; inset: 0; pointer-events: none; }
.mv-label {
	position: absolute; left: 0; top: 0;
	padding: 3px 7px; border-radius: 4px;
	background: rgba(20, 20, 20, .85); color: #fff;
	font-size: 12px; white-space: nowrap;
}

.mv button, .mv select {
	font: inherit; color: inherit; cursor: pointer;
	background: rgba(255, 255, 255, .82); border: 1px solid rgba(0, 0, 0, .15);
	border-radius: 6px; padding: 4px 7px;
	font-size: .75em; /* 13px → ~10px */
}
.mv button:hover { background: #fff; }
.mv button.active { background: #2b2b2b; color: #fff; border-color: #2b2b2b; }

/* ---- Bouton hamburger + menu ---- */
.mv .mv-menu-btn {
	position: absolute; left: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 30;
	width: 38px; height: 38px; padding: 0; display: grid; place-items: center;
	border-radius: 8px; font-size: 13px; box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.mv.menu-open .mv-menu-btn { background: #2b2b2b; color: #fff; }

.mv-menu {
	position: absolute; left: 12px; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 30;
	width: 220px; max-height: calc(100% - 68px); overflow-y: auto;
	padding: 6px; border-radius: 10px;
	background: rgba(255, 255, 255, .94); box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
	opacity: 0; visibility: hidden; transform: translateY(-6px);
	transition: opacity .15s, transform .15s, visibility .15s;
}
.mv.menu-open .mv-menu { opacity: 1; visibility: visible; transform: none; }
.mv-menu-head { display: none; }
.mv-menu-section { display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.mv-menu-section + .mv-menu-section { border-top: 1px solid rgba(0, 0, 0, .08); }
.mv-menu-title { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #888; padding: 4px 8px 2px; }
.mv .mv-menu-section > button {
	display: flex; justify-content: space-between; align-items: center;
	width: 100%; text-align: left; background: none; border: 0; padding: 6px 8px;
}
.mv .mv-menu-section > button:hover { background: rgba(0, 0, 0, .06); }
.mv .mv-menu-section > button.active { background: none; color: inherit; font-weight: 600; }
.mv .mv-menu-section > button.active::after { content: "✓"; color: #c33; }
.mv-light select { margin: 2px 8px; }
.mv-light label { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 8px; font-size: .75em; }
.mv-light input[type=range] { width: 110px; }
.mv-menu-hint { font-size: 10px; color: #888; padding: 6px 8px 2px; border-top: 1px solid rgba(0, 0, 0, .08); }
.mv-backdrop { display: none; }

.mv-views {
	display: grid; grid-template-columns: repeat(3, 30px); grid-template-areas: ". top ." "left front right" ". bottom back";
	gap: 3px; padding: 4px 8px 6px;
}
.mv-views button { padding: 5px 0; }
.mv-views [data-view=top] { grid-area: top; }
.mv-views [data-view=left] { grid-area: left; }
.mv-views [data-view=front] { grid-area: front; }
.mv-views [data-view=right] { grid-area: right; }
.mv-views [data-view=bottom] { grid-area: bottom; }
.mv-views [data-view=back] { grid-area: back; }

.mv-stats {
	position: absolute; left: 60px; top: calc(12px + env(safe-area-inset-top, 0px)); min-width: 250px;
	padding: 8px 10px; border-radius: 10px;
	background: rgba(20, 20, 20, .82); color: #eee;
	font-variant-numeric: tabular-nums;
}
.mv-stats-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 4px; }
.mv-stats-head button { background: none; border: 0; color: #aaa; font-size: 16px; padding: 0 4px; }
.mv-stats-table { border-collapse: collapse; width: 100%; }
.mv-stats-table th { text-align: left; font-weight: 400; color: #aaa; padding: 1px 12px 1px 0; white-space: nowrap; }
.mv-stats-table td { text-align: right; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-stats-table tr.total td { font-weight: 700; color: #ffd27a; }
.mv-stats-actions { display: flex; gap: 6px; margin-top: 8px; }
.mv-stats-actions button { background: rgba(255, 255, 255, .12); color: #eee; border-color: rgba(255, 255, 255, .2); padding: 3px 8px; }

.mv-progress {
	position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
	width: 260px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .15);
}
.mv-progress-bar { height: 100%; width: 0; border-radius: 3px; background: #d4a843; transition: width .1s; }
.mv-progress.indeterminate .mv-progress-bar { width: 30% !important; animation: mv-slide 1s infinite ease-in-out; }
@keyframes mv-slide { from { margin-left: 0; } to { margin-left: 70%; } }

.mv-message {
	position: absolute; left: 50%; top: 40%; transform: translateX(-50%);
	max-width: 80%; padding: 12px 16px; border-radius: 8px; background: rgba(255, 255, 255, .9); text-align: center;
}

.mv .mv-badge {
	font-size: 13px;
	position: absolute; right: 12px; top: 12px;
	width: 26px; height: 26px; padding: 0; border-radius: 50%;
	font-weight: 700; line-height: 1; background: #2b2b2b; color: #fff; border: 2px solid #fff;
	box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.mv .mv-badge:hover { background: #c33; }

.mv-logo {
	position: absolute; left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 5;
	width: 30px; height: 30px; opacity: .55; transition: opacity .15s;
}
.mv-logo:hover { opacity: 1; }
.mv-logo img { display: block; width: 30px; height: 30px; }

.mv-modal {
	position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
	background: rgba(20, 20, 30, .45); backdrop-filter: blur(2px);
}
.mv-modal-card {
	max-width: 400px; padding: 22px 24px 20px; border-radius: 12px;
	background: #fff; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); font-size: 14px; line-height: 1.5;
}
.mv-modal-kicker { margin: 0 0 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #c33; font-weight: 600; }
.mv-modal-card h2 { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.mv-modal-card p { margin: 0 0 10px; color: #444; }
.mv-modal-reason { color: #888; }
.mv-modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.mv .mv-modal-actions button { font-size: 13px; padding: 8px 14px; }
.mv .mv-modal-actions .mv-modal-primary { background: #2b2b2b; color: #fff; border-color: #2b2b2b; }

.mv-hd {
	position: absolute; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 6;
	display: grid; gap: 5px; min-width: 190px; padding: 8px 12px; border-radius: 8px;
	background: rgba(20, 20, 30, .7); color: #f5f0e8; font-size: 12px; pointer-events: none;
}
.mv-hd-bar { display: block; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.mv-hd-bar b { display: block; height: 100%; width: 0; background: #d4a843; transition: width .15s; }
.mv-hd.done .mv-hd-text::before { content: "✓ "; color: #d4a843; }

[hidden] { display: none !important; }

/* Mobile : panneau latéral glissant */
@media (max-width: 600px), (pointer: coarse) and (hover: none) {
	.mv-stats { font-size: 11px; min-width: 0; left: 60px; right: 12px; }
	.mv-menu {
		left: 0; top: 0; bottom: 0; width: min(80vw, 300px); max-height: none; border-radius: 0;
		padding: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
		opacity: 1; transform: translateX(-100%); transition: transform .25s ease, visibility .25s;
		background: #f7f7f7;
	}
	.mv.menu-open .mv-menu { transform: none; }
	.mv-menu-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; padding: 6px 8px 10px; font-size: 15px; }
	.mv .mv-menu-head button { background: none; border: 0; font-size: 22px; padding: 0 6px; }
	.mv .mv-menu-section > button, .mv-light label { font-size: 14px; padding: 10px 8px; }
	.mv-menu-title { font-size: 11px; }
	.mv-menu-hint { display: none; } /* pas de clavier sur mobile */
	.mv-views { grid-template-columns: repeat(3, 40px); }
	.mv-views button { padding: 9px 0; font-size: 13px; }
	.mv.menu-open .mv-menu-btn { visibility: hidden; }
	.mv-backdrop {
		display: block; position: absolute; inset: 0; z-index: 29; background: rgba(0, 0, 0, .35);
		opacity: 0; visibility: hidden; transition: opacity .25s, visibility .25s;
	}
	.mv.menu-open .mv-backdrop { opacity: 1; visibility: visible; }
}
