:root {
	--tr-bg: #f4f6fb;
	--tr-surface: #fff;
	--tr-text: #1d2433;
	--tr-muted: #5f6b80;
	--tr-line: #e2e7f0;
	--tr-primary: #26359a;
	--tr-primary-ink: #fff;
	--tr-accent: #ff8a00;
	--tr-danger-bg: #fdecec;
	--tr-danger: #b42318;
	--tr-radius: 14px;
	--tr-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body.teris {
	background: var(--tr-bg);
	color: var(--tr-text);
	font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}
.teris a { color: var(--tr-primary); text-decoration: none; }
.teris a:hover { text-decoration: underline; }
.tr-wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.tr-main { flex: 1; padding: 28px 0 48px; }
.tr-main--full { padding: 0; display: flex; flex-direction: column; }
.tr-muted { color: var(--tr-muted); margin: 0 0 20px; }
.tr-title { font-size: 1.75rem; line-height: 1.25; margin: 8px 0 8px; }
.tr-subtitle { font-size: 1.15rem; margin: 32px 0 12px; }

/* Header */
.tr-header { background: var(--tr-surface); border-bottom: 1px solid var(--tr-line); position: sticky; top: 0; z-index: 10; }
.tr-header__in { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.tr-brand { display: flex; align-items: center; flex-shrink: 0; }
.tr-brand img { height: 40px; width: auto; display: block; }
.tr-brand__text { font-weight: 700; font-size: 1.2rem; color: var(--tr-text); }
.tr-search { flex: 1; max-width: 420px; margin-left: auto; }
.tr-search input { width: 100%; }
.tr-user { display: flex; align-items: center; gap: 10px; }
.tr-user__name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Forms & buttons */
.teris input[type=text], .teris input[type=password], .teris input[type=search] {
	font: inherit; padding: 10px 12px; border: 1px solid var(--tr-line); border-radius: 10px; background: #fff; color: var(--tr-text);
}
.teris input:focus-visible, .tr-btn:focus-visible, .tr-card:focus-visible, .tr-lesson:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--tr-primary) 35%, transparent); outline-offset: 2px;
}
.tr-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	font: inherit; font-weight: 600; font-size: .95rem; padding: 8px 14px; border-radius: 10px;
	border: 1px solid transparent; cursor: pointer; white-space: nowrap;
}
.tr-btn:hover { text-decoration: none !important; }
.tr-btn--primary { background: var(--tr-primary); color: var(--tr-primary-ink) !important; }
.tr-btn--primary:hover { filter: brightness(1.08); }
.tr-btn--ghost { background: transparent; border-color: var(--tr-line); color: var(--tr-text) !important; }
.tr-btn--ghost:hover { background: var(--tr-bg); }
.tr-btn--block { width: 100%; padding: 12px; margin-top: 8px; }

/* Cards */
.tr-card { background: var(--tr-surface); border: 1px solid var(--tr-line); border-radius: var(--tr-radius); box-shadow: var(--tr-shadow); }
.tr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tr-cat { display: flex; flex-direction: column; gap: 6px; padding: 18px; color: var(--tr-text) !important; transition: transform .15s, box-shadow .15s; }
.tr-cat:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); text-decoration: none !important; }
.tr-cat__icon {
	width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
	background: color-mix(in srgb, var(--tr-primary) 12%, #fff); color: var(--tr-primary); font-weight: 800; margin-bottom: 6px;
}
.tr-cat:nth-child(3n+2) .tr-cat__icon { background: color-mix(in srgb, var(--tr-accent) 15%, #fff); color: #b35f00; }
.tr-cat:nth-child(3n) .tr-cat__icon { background: #e7f6ec; color: #18794e; }
.tr-cat__name { font-weight: 700; line-height: 1.35; }
.tr-cat__meta { color: var(--tr-muted); font-size: .875rem; }

/* Lessons */
.tr-lessons { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.tr-lesson {
	display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: var(--tr-surface);
	border: 1px solid var(--tr-line); border-radius: 12px; color: var(--tr-text) !important;
}
.tr-lesson:hover { border-color: var(--tr-primary); text-decoration: none !important; }
.tr-lesson__play {
	flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--tr-primary); position: relative;
}
.tr-lesson__play::after {
	content: ""; position: absolute; left: 14px; top: 11px;
	border-left: 11px solid #fff; border-top: 7px solid transparent; border-bottom: 7px solid transparent;
}
.tr-lesson__text { display: flex; flex-direction: column; min-width: 0; }
.tr-lesson__name { font-weight: 600; }
.tr-lesson__path { color: var(--tr-muted); font-size: .85rem; }

.tr-crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .9rem; color: var(--tr-muted); }
.tr-empty { background: var(--tr-surface); border: 1px dashed var(--tr-line); border-radius: var(--tr-radius); padding: 28px; text-align: center; color: var(--tr-muted); margin: 16px 0; }
.tr-alert { background: var(--tr-danger-bg); color: var(--tr-danger); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .95rem; }

/* Login */
.teris-login .tr-main { display: grid; place-items: center; padding: 32px 16px; background: linear-gradient(160deg, #e8f0ff, var(--tr-bg) 60%); }
.tr-login { width: 100%; max-width: 400px; }
.tr-login__card { padding: 28px; display: flex; flex-direction: column; }
.tr-login__card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.tr-login__card label { font-weight: 600; font-size: .9rem; margin: 10px 0 6px; }
.tr-login__card .tr-check { font-weight: 400; display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; }
.tr-login__brand { display: flex; justify-content: center; margin-bottom: 18px; }
.tr-login__brand img { max-height: 70px; max-width: 100%; }

/* Player */
.tr-player { flex: 1; display: flex; flex-direction: column; min-height: calc(100vh - 65px); }
.tr-player__bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--tr-surface); border-bottom: 1px solid var(--tr-line); flex-wrap: wrap; }
.tr-player__title { flex: 1; min-width: 200px; }
.tr-player__title h1 { font-size: 1.1rem; margin: 0; line-height: 1.3; }
.tr-player__path { color: var(--tr-muted); font-size: .8rem; }
.tr-player__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tr-player__frame { flex: 1; width: 100%; min-height: 70vh; border: 0; background: #000; display: block; }
.tr-docs { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tr-content {background: var(--tr-surface); padding: 20px; border-radius: var(--tr-radius); }

/* Quản trị trên giao diện người dùng */
.tr-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tr-lessons__item { position: relative; }
.tr-lesson__edit {
	position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
	font-size: .85rem; font-weight: 600; padding: 4px 10px; border-radius: 8px;
	background: var(--tr-bg); border: 1px solid var(--tr-line); color: var(--tr-text) !important;
}
.tr-lesson__edit:hover { border-color: var(--tr-primary); text-decoration: none !important; }
.tr-lessons__item .tr-lesson { padding-right: 76px; }
.tr-hidden { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.tr-hidden li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 1px dashed var(--tr-line); border-radius: 10px; color: var(--tr-muted); }

.tr-editor { padding: 24px; display: flex; flex-direction: column; gap: 18px; margin-top: 12px; }
.tr-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; border: 0; margin: 0; padding: 0; }
.tr-field--sm { flex: 0 0 140px; }
.tr-field > label, .tr-field legend, .tr-label { font-weight: 600; font-size: .9rem; padding: 0; }
.tr-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.tr-row--top { align-items: stretch; }
.tr-editor input[type=number], .tr-editor textarea {
	font: inherit; padding: 10px 12px; border: 1px solid var(--tr-line); border-radius: 10px; background: #fff; color: var(--tr-text); width: 100%;
}
.tr-editor input[type=text] { width: 100%; }
.tr-editor input[type=file] { font: inherit; }
.tr-pick { flex-basis: 320px; }
.tr-pick__list { max-height: 320px; overflow: auto; border: 1px solid var(--tr-line); border-radius: 10px; padding: 8px 10px; background: #fff; }
.tr-pick__list .tr-check { display: flex; align-items: center; gap: 8px; padding-top: 3px; padding-bottom: 3px; font-size: .92rem; }
.tr-pick__list .tr-check[hidden] { display: none; }
.tr-pick__list em { font-size: .8rem; }
.tr-check { display: flex; align-items: center; gap: 8px; }
.tr-hint { margin: 0; color: var(--tr-muted); font-size: .85rem; }
.tr-link { background: none; border: 0; padding: 0; font: inherit; color: var(--tr-primary); cursor: pointer; }
.tr-link:hover { text-decoration: underline; }
.tr-editor__progress { display: flex; align-items: center; gap: 12px; }
.tr-editor__progress progress { flex: 1; }
.tr-editor__actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--tr-line); padding-top: 16px; }
.tr-alert[hidden] { display: none; }

/* Footer */
.tr-footer { background: #121a2b; color: #c7cfdd; font-size: .9rem; padding: 24px 0; }
.tr-footer strong { color: #fff; }
.tr-footer p { margin: 4px 0 0; }
.tr-footer a { color: #fff; }

@media (max-width: 720px) {
	.tr-header__in { flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
	.tr-search { order: 3; max-width: none; flex-basis: 100%; }
	.tr-user { margin-left: auto; }
	.tr-user__name { display: none; }
	.tr-title { font-size: 1.4rem; }
	.tr-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
	.tr-player__actions .tr-btn { padding: 6px 10px; font-size: .85rem; }
}
