.dsim-root {
	--dsim-bg: #eef3f6;
	--dsim-panel: #ffffff;
	--dsim-border: #d7e0e6;
	--dsim-primary: #2e86ab;
	--dsim-primary-dark: #1f5f7a;
	--dsim-accent: #f6a623;
	--dsim-danger: #d9534f;
	--dsim-success: #4caf7d;
	--dsim-text: #23343f;
	--dsim-muted: #6b7c86;

	box-sizing: border-box;
	background: var(--dsim-bg);
	border: 1px solid var(--dsim-border);
	border-radius: 12px;
	padding: 16px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	color: var(--dsim-text);
	position: relative;
	overflow: hidden;
}
.dsim-root *, .dsim-root *::before, .dsim-root *::after { box-sizing: border-box; }

.dsim-topbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	margin-bottom: 12px;
}
.dsim-title {
	font-size: 18px;
	font-weight: 700;
	color: var(--dsim-primary-dark);
	margin: 0;
}
.dsim-stats {
	display: flex;
	gap: 14px;
	flex-wrap: wrap;
	font-size: 13px;
}
.dsim-stat {
	background: var(--dsim-panel);
	border: 1px solid var(--dsim-border);
	border-radius: 8px;
	padding: 4px 10px;
	min-width: 90px;
	text-align: center;
}
.dsim-stat b { display: block; font-size: 15px; }

.dsim-comfort-bar-wrap {
	width: 100px;
	height: 8px;
	background: #e3e9ec;
	border-radius: 4px;
	overflow: hidden;
	margin-top: 4px;
}
.dsim-comfort-bar {
	height: 100%;
	background: linear-gradient(90deg, var(--dsim-danger), var(--dsim-accent), var(--dsim-success));
	transition: width .25s ease;
}

.dsim-stage {
	background: var(--dsim-panel);
	border: 1px solid var(--dsim-border);
	border-radius: 10px;
	padding: 14px;
	min-height: 420px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	position: relative;
}

.dsim-btn {
	background: var(--dsim-primary);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 9px 16px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background .15s ease, transform .1s ease;
}
.dsim-btn:hover { background: var(--dsim-primary-dark); }
.dsim-btn:active { transform: scale(.97); }
.dsim-btn.dsim-btn-secondary { background: #8b98a1; }
.dsim-btn.dsim-btn-secondary:hover { background: #6b7880; }
.dsim-btn.dsim-btn-accent { background: var(--dsim-accent); color: #3a2600; }
.dsim-btn.dsim-btn-accent:hover { background: #d88f11; }
.dsim-btn:disabled { opacity: .45; cursor: not-allowed; }

.dsim-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	margin-top: 14px;
}
.dsim-tool {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	background: var(--dsim-panel);
	border: 2px solid var(--dsim-border);
	border-radius: 10px;
	padding: 8px 12px;
	cursor: pointer;
	font-size: 12px;
	min-width: 68px;
	user-select: none;
}
.dsim-tool:hover { border-color: var(--dsim-primary); }
.dsim-tool.active { border-color: var(--dsim-primary); background: #e8f3f8; }
.dsim-tool .dsim-tool-icon { font-size: 22px; }
.dsim-tool:disabled, .dsim-tool.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

.dsim-arch-svg { max-width: 100%; height: auto; touch-action: none; }
.dsim-tooth {
	cursor: pointer;
	transition: transform .12s ease;
}
.dsim-tooth:hover { transform: translateY(-3px); }

.dsim-mouth-label {
	font-size: 12px;
	fill: var(--dsim-muted);
}

.dsim-canvas-wrap {
	position: relative;
	touch-action: none;
	border-radius: 10px;
	overflow: hidden;
	border: 1px solid var(--dsim-border);
	background: #fff5ee;
}
.dsim-canvas-wrap canvas { display: block; cursor: crosshair; max-width: 100%; height: auto; }

.dsim-msg {
	margin-top: 10px;
	font-size: 14px;
	text-align: center;
	min-height: 20px;
	color: var(--dsim-muted);
}
.dsim-msg.warn { color: var(--dsim-danger); font-weight: 600; }
.dsim-msg.good { color: var(--dsim-success); font-weight: 600; }

.dsim-progressbar-wrap {
	width: 260px;
	max-width: 90%;
	height: 14px;
	background: #e3e9ec;
	border-radius: 7px;
	overflow: hidden;
	margin-top: 10px;
	border: 1px solid var(--dsim-border);
}
.dsim-progressbar {
	height: 100%;
	background: var(--dsim-primary);
	width: 0%;
	transition: width .1s linear;
}
.dsim-progressbar.danger { background: var(--dsim-danger); }

.dsim-diagnosis-options {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	justify-content: center;
	margin-top: 14px;
}

.dsim-summary {
	text-align: center;
	max-width: 460px;
}
.dsim-summary h2 { color: var(--dsim-primary-dark); margin-top: 0; }
.dsim-grade-badge {
	display: inline-block;
	font-size: 42px;
	font-weight: 800;
	width: 84px;
	height: 84px;
	line-height: 84px;
	border-radius: 50%;
	background: var(--dsim-accent);
	color: #3a2600;
	margin: 10px auto;
}
.dsim-summary-table {
	width: 100%;
	border-collapse: collapse;
	margin: 14px 0;
	font-size: 14px;
}
.dsim-summary-table td { padding: 6px 8px; border-bottom: 1px solid var(--dsim-border); text-align: left; }
.dsim-summary-table td:last-child { text-align: right; font-weight: 600; }

.dsim-intro { text-align: center; max-width: 480px; }
.dsim-intro h2 { color: var(--dsim-primary-dark); }
.dsim-difficulty-row {
	display: flex;
	gap: 8px;
	justify-content: center;
	margin: 14px 0;
	flex-wrap: wrap;
}
.dsim-difficulty-row label {
	border: 2px solid var(--dsim-border);
	border-radius: 8px;
	padding: 8px 14px;
	cursor: pointer;
	font-size: 13px;
}
.dsim-difficulty-row input { margin-right: 6px; }
.dsim-difficulty-row label:has(input:checked) { border-color: var(--dsim-primary); background: #e8f3f8; }

.dsim-toast {
	position: absolute;
	top: 10px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--dsim-primary-dark);
	color: #fff;
	padding: 8px 16px;
	border-radius: 20px;
	font-size: 13px;
	opacity: 0;
	pointer-events: none;
	transition: opacity .3s ease, top .3s ease;
	z-index: 20;
}
.dsim-toast.show { opacity: 1; top: 18px; }

.dsim-leaderboard {
	background: #ffffff;
	border: 1px solid #d7e0e6;
	border-radius: 10px;
	padding: 16px;
	max-width: 420px;
}
.dsim-leaderboard h3 { margin-top: 0; }
.dsim-leaderboard-list { padding-left: 24px; margin: 0; }
.dsim-leaderboard-list li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
.dsim-lb-name { flex: 1; }
.dsim-lb-score { color: #2e86ab; font-weight: 700; }
.dsim-lb-grade { color: #6b7c86; }

@media (max-width: 520px) {
	.dsim-stats { font-size: 11px; }
	.dsim-stat { min-width: 70px; }
	.dsim-toolbar { gap: 6px; }
	.dsim-tool { min-width: 58px; padding: 6px 8px; }
}
