:root {
  --lt-bg: #f6f4ef;
  --lt-surface: #fff;
  --lt-border: #e0dcd4;
  --lt-text: #1c2420;
  --lt-muted: #5f6b64;
  --lt-accent: #b45309;
  --lt-accent-soft: #fef3e7;
  --lt-lao: #14532d;
  --lt-sidebar-w: 17.5rem;
  --lt-topbar-h: 3.25rem;
}

* { box-sizing: border-box; }
body.lt-app {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--lt-bg);
  color: var(--lt-text);
  line-height: 1.5;
}

/* Topbar */
.lt-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  height: var(--lt-topbar-h);
  padding: 0 0.85rem;
  background: var(--lt-surface);
  border-bottom: 1px solid var(--lt-border);
}
.lt-brand {
  font-weight: 700;
  color: var(--lt-accent);
  text-decoration: none;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lt-topnav { margin-left: auto; }
.lt-topnav a {
  color: var(--lt-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}
.lt-topnav a:hover { color: var(--lt-accent); }

/* Nút đổi ngôn ngữ trên topbar (mobile) */
.lt-topbar-mode {
  display: none;
  flex-shrink: 0;
  margin-left: auto;
}
.lt-mode-toggle--topbar {
  width: auto;
  padding: 0.2rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  gap: 0;
}
.lt-mode-toggle--topbar:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: transparent;
}
.lt-mode-toggle--topbar:active {
  transform: scale(0.94);
}
.lt-mode-toggle--topbar .lt-mode-flag .lt-flag-svg {
  width: 1.65rem;
  box-shadow: none;
}

.lt-menu-btn {
  display: none;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--lt-border);
  border-radius: 8px;
  background: var(--lt-surface);
  cursor: pointer;
}
.lt-menu-icon,
.lt-menu-icon::before,
.lt-menu-icon::after {
  display: block;
  width: 1.1rem;
  height: 2px;
  margin: 0 auto;
  background: var(--lt-text);
  border-radius: 1px;
}
.lt-menu-icon { position: relative; }
.lt-menu-icon::before,
.lt-menu-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.lt-menu-icon::before { top: -5px; }
.lt-menu-icon::after { top: 5px; }

/* Shell: sidebar + content */
.lt-shell {
  display: flex;
  align-items: stretch;
  min-height: calc(100vh - var(--lt-topbar-h));
}

/* Sidebar */
.lt-sidebar {
  flex: 0 0 var(--lt-sidebar-w);
  width: var(--lt-sidebar-w);
  background: var(--lt-surface);
  border-right: 1px solid var(--lt-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--lt-topbar-h);
  align-self: flex-start;
  max-height: calc(100vh - var(--lt-topbar-h));
  overflow: hidden;
  z-index: 30;
}
.lt-sidebar-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.55rem 0.5rem;
  border-bottom: 1px solid var(--lt-border);
  flex-shrink: 0;
}
.lt-mode-switch {
  flex: 1;
  min-width: 0;
}
.lt-mode-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--lt-accent);
  border-radius: 8px;
  background: var(--lt-accent-soft);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  color: var(--lt-text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.lt-mode-toggle:hover {
  background: #f5ebe0;
  border-color: #9a3412;
}
.lt-mode-toggle:active {
  transform: scale(0.98);
}
.lt-mode-flag {
  flex-shrink: 0;
  line-height: 0;
}
.lt-mode-flag .lt-flag-svg {
  display: block;
  width: 1.65rem;
  height: auto;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.lt-mode-label { line-height: 1.25; flex: 1; min-width: 0; }

/* Chế độ học: ẩn/hiện theo lt-mode-vi | lt-mode-lao trên html */
html.lt-mode-vi .lt-show-mode-lao,
html.lt-mode-lao .lt-show-mode-vi,
html.lt-mode-vi .lt-ui-lao,
html.lt-mode-lao .lt-ui-vi {
  display: none !important;
}
html.lt-mode-vi .col-vr {
  display: none !important;
}
html.lt-mode-lao .col-lr {
  display: none !important;
}

.lt-lao-script {
  font-family: "Noto Sans Lao", "Phetsarath OT", sans-serif;
  color: var(--lt-lao);
}
.lt-sidebar-close {
  display: none;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--lt-muted);
}
.lt-sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 0.35rem 0.5rem 0.75rem;
}
.lt-sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lt-sidebar-link {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  margin-bottom: 0.15rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.lt-sidebar-link:hover {
  background: #f5f2ec;
}
.lt-sidebar-link.is-active {
  background: var(--lt-accent-soft);
  box-shadow: inset 3px 0 0 var(--lt-accent);
}
.lt-sidebar-icon {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
}
.lt-sidebar-text { min-width: 0; }
.lt-sidebar-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
}
.lt-sidebar-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--lt-muted);
  margin-top: 0.1rem;
}
.lt-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--lt-topbar-h);
  background: rgba(0, 0, 0, 0.35);
  z-index: 25;
}

/* Main content */
.lt-content {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem 2rem;
  max-width: 52rem;
}
.lt-page-head h1 {
  margin: 0 0 0.35rem;
  font-size: 1.4rem;
}
.lt-lao-title, .lt-lao-sub {
  font-family: "Noto Sans Lao", "Phetsarath OT", sans-serif;
  color: var(--lt-lao);
}
.muted { color: var(--lt-muted); }
.lt-card {
  background: var(--lt-surface);
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--lt-border);
}
.lt-pre {
  background: #f0ebe3;
  padding: 0.75rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
}
.lt-foot {
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  text-align: center;
  border-top: 1px solid var(--lt-border);
  background: var(--lt-surface);
}

/* Mobile: ẩn sidebar, mở bằng nút */
@media (max-width: 900px) {
  .lt-menu-btn { display: flex; align-items: center; justify-content: center; }
  .lt-topbar-mode { display: block; }
  .lt-topnav { margin-left: 0; }

  .lt-sidebar-close {
    display: block;
    position: absolute;
    top: 0.55rem;
    right: 0.45rem;
    margin-left: 0;
    z-index: 1;
  }
  .lt-sidebar-head {
    position: relative;
    flex-wrap: nowrap;
    align-items: stretch;
    padding-right: 2.35rem;
  }
  .lt-mode-switch {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
  }
  .lt-mode-toggle {
    width: 100%;
    min-width: 0;
  }
  .lt-mode-label {
    font-size: 0.78rem;
  }

  .lt-sidebar {
    position: fixed;
    left: 0;
    top: var(--lt-topbar-h);
    bottom: 0;
    height: calc(100vh - var(--lt-topbar-h));
    height: calc(100dvh - var(--lt-topbar-h));
    max-height: none;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }
  body.lt-sidebar-open {
    overflow: hidden;
  }
  body.lt-sidebar-open .lt-sidebar {
    transform: translateX(0);
  }
  body.lt-sidebar-open .lt-sidebar-backdrop {
    display: block;
  }

  .lt-content {
    max-width: none;
    padding: 0.85rem 0.75rem 1.5rem;
  }
}
