.tlbp-wrapper {
	--tlbp-wood: #8a5a34;
	--tlbp-wood-light: #f3e3d3;
	--tlbp-wood-dark: #5c3a1e;
	--tlbp-good: #c0392b;
	--tlbp-bad: #3a3a3a;
	--tlbp-good-bg: #fdecea;
	--tlbp-bad-bg: #ececec;

	max-width: 720px;
	margin: 0 auto;
	padding: 24px;
	background: #fffaf3;
	border: 1px solid #e7d3b8;
	border-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	color: #2c2c2c;
	box-sizing: border-box;
}
.tlbp-wrapper * { box-sizing: border-box; }

.tlbp-header { text-align: center; margin-bottom: 20px; }
.tlbp-title {
	font-size: 26px;
	margin: 0 0 8px;
	color: var(--tlbp-wood-dark);
	font-weight: 700;
}
.tlbp-desc { font-size: 14px; line-height: 1.6; color: #555; margin: 0 auto; max-width: 560px; }

/* Tabs */
.tlbp-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tlbp-tab {
	flex: 1 1 auto;
	min-width: 140px;
	background: var(--tlbp-wood-light);
	border: 2px solid transparent;
	border-radius: 10px;
	padding: 10px 12px;
	cursor: pointer;
	text-align: center;
	font-weight: 600;
	font-size: 14px;
	color: var(--tlbp-wood-dark);
	transition: all 0.15s ease;
}
.tlbp-tab-sub { display: block; font-weight: 400; font-size: 11px; color: #7a6a5a; margin-top: 4px; }
.tlbp-tab.is-active,
.tlbp-tab:hover {
	background: var(--tlbp-wood);
	color: #fff;
	border-color: var(--tlbp-wood-dark);
}
.tlbp-tab.is-active .tlbp-tab-sub, .tlbp-tab:hover .tlbp-tab-sub { color: #f0e2d0; }

/* Presets */
.tlbp-presets { margin-bottom: 14px; }
.tlbp-presets-label { font-size: 13px; color: #7a6a5a; display: block; margin-bottom: 6px; }
.tlbp-presets-list { display: flex; gap: 6px; flex-wrap: wrap; }
.tlbp-preset-btn {
	background: #fff;
	border: 1px solid #e0c9a8;
	border-radius: 20px;
	padding: 5px 12px;
	font-size: 12px;
	cursor: pointer;
	color: var(--tlbp-wood-dark);
}
.tlbp-preset-btn:hover { background: var(--tlbp-wood-light); }

/* Input */
.tlbp-input-row { display: flex; gap: 10px; margin-bottom: 8px; align-items: stretch; flex-wrap: wrap; }
.tlbp-input-group {
	flex: 1;
	display: flex;
	align-items: stretch;
	border: 2px solid var(--tlbp-wood);
	border-radius: 8px;
	overflow: hidden;
}
.tlbp-input {
	flex: 1 1 auto !important;
	min-width: 0;
	width: auto !important;
	max-width: none !important;
	border: none !important;
	padding: 10px 12px;
	font-size: 16px;
	outline: none;
	background: #fff;
}
.tlbp-unit {
	flex: 0 0 auto !important;
	width: auto !important;
	max-width: 72px !important;
	min-width: 60px;
	border: none;
	border-left: 1px solid #e0c9a8;
	background: var(--tlbp-wood-light);
	padding: 0 8px;
	font-size: 14px;
	-webkit-appearance: menulist;
	appearance: menulist;
}
.tlbp-reset-btn {
	flex: 0 0 auto !important;
	width: auto !important;
	background: #fff;
	border: 2px solid var(--tlbp-wood);
	color: var(--tlbp-wood-dark);
	border-radius: 8px;
	padding: 0 16px;
	cursor: pointer;
	font-weight: 600;
	font-size: 13px;
	white-space: nowrap;
}
.tlbp-reset-btn:hover { background: var(--tlbp-wood-light); }

.tlbp-wrap-notice {
	font-size: 12px;
	color: #a0621f;
	background: #fff4e5;
	border: 1px solid #f0d8b0;
	border-radius: 6px;
	padding: 6px 10px;
	margin: 0 0 14px;
}

/* Ruler */
.tlbp-ruler-outer { margin: 20px 0 8px; user-select: none; }
.tlbp-ruler-track {
	position: relative;
	height: 46px;
	background: linear-gradient(180deg, #d9b988, #c49a68);
	border: 2px solid var(--tlbp-wood-dark);
	border-radius: 6px;
	touch-action: none;
	cursor: grab;
}
.tlbp-ruler-track:active { cursor: grabbing; }
.tlbp-ruler-segments { position: absolute; inset: 0; display: flex; }
.tlbp-segment {
	flex: 0 0 auto;
	height: 100%;
	border-right: 1px solid rgba(0,0,0,0.15);
	transition: background-color 0.15s ease;
}
.tlbp-segment.type-tot { background-color: rgba(192, 57, 43, 0.18); }
.tlbp-segment.type-xau { background-color: rgba(58, 58, 58, 0.18); }
.tlbp-segment.is-current.type-tot { background-color: rgba(192, 57, 43, 0.5); }
.tlbp-segment.is-current.type-xau { background-color: rgba(58, 58, 58, 0.4); }

.tlbp-ruler-handle {
	position: absolute;
	top: -8px;
	width: 4px;
	height: 62px;
	background: var(--tlbp-wood-dark);
	border-radius: 4px;
	transform: translateX(-2px);
	cursor: grab;
}
.tlbp-ruler-handle::before {
	content: '';
	position: absolute;
	top: -8px;
	left: -8px;
	width: 20px;
	height: 20px;
	background: #fff;
	border: 3px solid var(--tlbp-wood-dark);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.tlbp-ruler-handle:active { cursor: grabbing; }
.tlbp-ruler-handle.is-bouncing { animation: tlbp-bounce 0.2s ease; }
@keyframes tlbp-bounce {
	0% { transform: translateX(-2px) scale(1); }
	50% { transform: translateX(-2px) scale(1.15); }
	100% { transform: translateX(-2px) scale(1); }
}

.tlbp-ruler-scale { display: flex; margin-top: 4px; }
.tlbp-scale-mark { flex: 0 0 auto; font-size: 10px; color: #8a6a4a; text-align: left; border-left: 1px solid #d8c3a0; padding-left: 2px; }

/* Result */
.tlbp-result {
	display: flex;
	gap: 14px;
	align-items: center;
	background: #fff;
	border-radius: 10px;
	padding: 16px;
	margin-top: 18px;
	border: 2px solid #eee;
	transition: border-color 0.2s ease, background-color 0.2s ease;
}
.tlbp-result.is-tot { border-color: var(--tlbp-good); background: var(--tlbp-good-bg); }
.tlbp-result.is-xau { border-color: var(--tlbp-bad); background: var(--tlbp-bad-bg); }
.tlbp-result-badge {
	flex: 0 0 auto;
	width: 46px;
	height: 46px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	color: #fff;
	background: #aaa;
}
.tlbp-result.is-tot .tlbp-result-badge { background: var(--tlbp-good); }
.tlbp-result.is-xau .tlbp-result-badge { background: var(--tlbp-bad); }
.tlbp-result-name { margin: 0 0 4px; font-size: 18px; }
.tlbp-result.is-tot .tlbp-result-name { color: var(--tlbp-good); }
.tlbp-result.is-xau .tlbp-result-name { color: var(--tlbp-bad); }
.tlbp-result-meaning { margin: 0; font-size: 13px; color: #555; line-height: 1.5; }
.tlbp-result-suggest {
	margin: 8px 0 0;
	font-size: 13px;
	color: var(--tlbp-wood-dark);
}
.tlbp-suggest-apply {
	margin-left: 6px;
	background: var(--tlbp-wood);
	color: #fff;
	border: none;
	border-radius: 14px;
	padding: 3px 10px;
	font-size: 12px;
	cursor: pointer;
}

/* Footer */
.tlbp-footer { display: flex; gap: 16px; margin-top: 14px; justify-content: center; flex-wrap: wrap; }
.tlbp-link-btn { background: none; border: none; color: var(--tlbp-wood-dark); text-decoration: underline; font-size: 13px; cursor: pointer; padding: 4px; }

.tlbp-history-panel, .tlbp-guide-panel {
	margin-top: 12px;
	background: #faf5ee;
	border: 1px solid #e7d3b8;
	border-radius: 8px;
	padding: 12px 16px;
	font-size: 13px;
}
.tlbp-history-panel h4, .tlbp-guide-panel h4 { margin: 0 0 8px; font-size: 14px; }
.tlbp-history-list { list-style: none; margin: 0; padding: 0; }
.tlbp-history-list li {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px solid #eee;
	cursor: pointer;
}
.tlbp-history-list li:hover { color: var(--tlbp-wood); }
.tlbp-guide-panel ol { margin: 0; padding-left: 18px; line-height: 1.7; }

.tlbp-disclaimer { text-align: center; font-size: 11px; color: #999; margin-top: 16px; }

/* Sticky result trên mobile khi cuộn thước */
@media (max-width: 600px) {
	.tlbp-wrapper { padding: 16px; }
	.tlbp-title { font-size: 22px; }
	.tlbp-tab { min-width: 100%; }
	.tlbp-result.is-sticky {
		position: sticky;
		bottom: 8px;
		z-index: 5;
		box-shadow: 0 4px 14px rgba(0,0,0,0.15);
	}
}
