/*
 * Mobile-only console layout polish.
 *
 * The console renders a number of views from inline templates.  Keeping this
 * layer in a separate, last-loaded stylesheet lets us repair those templates
 * at the phone breakpoint without changing the desktop composition.
 */

@media (max-width: 768px) {
  :root {
    --mobile-nav-height: 68px;
    --mobile-page-gutter: 10px;
  }

  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-container {
    min-width: 0;
  }

  /* Give the drawer a clear tile hierarchy instead of a long nested list. */
  .sidebar {
    width: min(330px, 88vw) !important;
    max-width: 88vw !important;
  }

  .sidebar-header {
    padding: 16px 16px 14px !important;
  }

  .sidebar-nav {
    padding: 12px 10px calc(var(--mobile-nav-height) + 20px) !important;
  }

  .nav-category {
    margin: 16px 6px 7px !important;
    font-size: 10px !important;
  }

  .nav-drawer {
    margin-bottom: 8px !important;
  }

  .nav-drawer-header {
    min-height: 48px;
    padding: 10px 11px !important;
    border-radius: 12px !important;
  }

  .nav-drawer-title {
    min-width: 0;
    gap: 8px !important;
  }

  .nav-drawer-title > span {
    min-width: 0;
    line-height: 1.3;
  }

  .nav-drawer-body,
  .nav-drawer.open .nav-drawer-body {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
    padding: 8px !important;
    margin: 6px 0 0 !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
    border-radius: 13px !important;
    background: rgba(248, 250, 252, 0.78) !important;
  }

  .nav-drawer:not(.open) .nav-drawer-body {
    display: none !important;
  }

  .nav-drawer-body .nav-link {
    min-width: 0;
    min-height: 66px;
    margin: 0 !important;
    padding: 9px 8px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    gap: 5px !important;
    border-radius: 10px !important;
    white-space: normal !important;
    line-height: 1.28;
    font-size: 11px !important;
  }

  .nav-drawer-body .nav-link .nav-logo-icon {
    width: 19px !important;
    height: 19px !important;
  }

  .nav-drawer-body .nav-link > span:not(.badge) {
    width: 100%;
    overflow-wrap: anywhere;
  }

  .nav-drawer-body .nav-link .badge {
    margin-left: 0 !important;
    align-self: flex-start;
  }

  /* Keep the header useful: title stays visible while verbose controls move
   * into the menu. */
  .topbar {
    height: 58px !important;
    padding: 8px var(--mobile-page-gutter) !important;
    gap: 8px !important;
  }

  .topbar-title {
    min-width: 0 !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    font-size: 14px !important;
    line-height: 1.25 !important;
  }

  .topbar-actions {
    min-width: 0;
    gap: 5px !important;
    flex: 0 0 auto;
  }

  .admin-tenant-switcher-wrap,
  #admin-tenant-switcher-wrap,
  .topbar-btn-portal,
  .topbar-btn-security,
  .topbar-btn-logout {
    display: none !important;
  }

  .topbar-btn-logout {
    display: inline-flex !important;
    width: 35px !important;
    height: 34px !important;
    padding: 0 !important;
    justify-content: center !important;
    font-size: 0 !important;
    color: transparent !important;
    overflow: hidden !important;
    text-indent: -9999px;
  }

  .topbar-btn-logout::before {
    content: "🚪";
    font-size: 16px;
    color: #475569;
    text-indent: 0;
  }

  .topbar-btn-recharge,
  .lang-dropdown-btn {
    width: 35px !important;
    height: 34px !important;
    padding: 0 !important;
    justify-content: center !important;
    gap: 0 !important;
    font-size: 0 !important;
  }

  .topbar-btn-recharge::first-letter,
  .lang-dropdown-btn #topbar-lang-flag {
    font-size: 16px !important;
  }

  .topbar-btn-recharge {
    font-size: 0 !important;
    color: transparent !important;
    overflow: hidden !important;
    text-indent: -9999px;
  }

  .topbar-btn-recharge::before {
    content: "💰";
    font-size: 16px;
    color: #d97706;
    text-indent: 0;
  }

  .lang-dropdown-btn #topbar-lang-name,
  .lang-dropdown-btn > span:last-child {
    display: none !important;
  }

  .content-body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 14px var(--mobile-page-gutter) calc(var(--mobile-nav-height) + 18px) !important;
    overflow-x: clip;
  }

  #view-content > * {
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  #view-content > * > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  /* Inline templates often use desktop ratios.  On a phone, two-column
   * sections become a clean vertical stack; grids with 3+ metric cards retain
   * a compact two-column rhythm. */
  #view-content > [style*="grid-template-columns"] {
    width: 100% !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #view-content > [style*="grid-template-columns"]:has(> .glass-card:nth-child(3)) {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  #view-content [style*="grid-template-columns"]:not(.cs-workbench-grid):not(.im-layout-wrapper) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #view-content [style*="grid-template-columns"]:not(.cs-workbench-grid):not(.im-layout-wrapper):has(> .glass-card:nth-child(3)),
  #view-content [style*="grid-template-columns: repeat(auto-fit, minmax(220px"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  #view-content [style*="grid-template-columns"]:not(.cs-workbench-grid):not(.im-layout-wrapper):not(:has(> .glass-card:nth-child(3))) {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  #view-content > [style*="grid-template-columns"] > .glass-card {
    min-width: 0 !important;
    width: 100% !important;
  }

  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] > .glass-card {
    padding: 13px 12px !important;
    overflow: hidden;
  }

  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] > .glass-card > div:first-child,
  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] > .glass-card > div:first-child > div {
    min-width: 0 !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
  }

  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] > .glass-card .badge {
    max-width: 100%;
    white-space: normal !important;
    text-align: right;
    line-height: 1.2;
  }

  /* First card is the view hero in the console templates.  Stack its title,
   * badge and action so translated labels never squeeze into a thin column. */
  #view-content > .glass-card:first-child > div:first-child {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }

  #view-content > .glass-card:first-child > div:first-child > div:first-child {
    width: 100% !important;
    align-items: flex-start !important;
  }

  #view-content > .glass-card:first-child > div:first-child > div:first-child > div:last-child {
    min-width: 0 !important;
    flex: 1 1 auto !important;
  }

  #view-content > .glass-card:first-child h1,
  #view-content > .glass-card:first-child h2,
  #view-content > .glass-card:first-child h3 {
    font-size: 16px !important;
    line-height: 1.35 !important;
    overflow-wrap: anywhere;
  }

  #view-content > .glass-card:first-child > div:first-child > div:first-child > div:last-child > div:first-child {
    display: block !important;
  }

  #view-content > .glass-card:first-child > div:first-child > div:first-child .badge {
    display: inline-flex !important;
    width: fit-content !important;
    max-width: 100%;
    margin-top: 7px;
    white-space: normal !important;
    line-height: 1.25;
  }

  #view-content > .glass-card:first-child > div:first-child > div:last-child,
  #view-content > .glass-card:first-child > div:first-child > div:last-child .btn {
    width: 100% !important;
    max-width: 100% !important;
  }

  #view-content > .glass-card:first-child > div:first-child > div:last-child .btn {
    justify-content: center !important;
    white-space: normal !important;
    text-align: center;
    line-height: 1.35;
  }

  #view-content > * > .glass-card:first-child {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  #view-content > * > .glass-card:first-child > div:first-child {
    min-width: 0 !important;
  }

  #view-content > * > .glass-card:first-child h1,
  #view-content > * > .glass-card:first-child h2,
  #view-content > * > .glass-card:first-child h3 {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    line-height: 1.35 !important;
  }

  #view-content > * > .glass-card:first-child > div:first-child > div:last-child {
    max-width: 100% !important;
  }

  #view-content > * > .glass-card:first-child > div:first-child > div:last-child .btn {
    max-width: 100% !important;
  }

  #view-content > * > .glass-card:first-child > div:first-child > div:first-child > div:first-child {
    display: block !important;
    min-width: 0 !important;
  }

  #view-content > * > .glass-card:first-child > div:first-child > div:first-child .badge {
    display: inline-flex !important;
    max-width: 100% !important;
    margin-top: 6px;
    white-space: normal !important;
    line-height: 1.25;
  }

  #view-content > div:first-child:has(+ .cs-workbench-grid),
  #view-content > div:first-child:has(+ div[style*="grid-template-columns: 1.1fr 1fr"]) {
    display: block !important;
  }

  #view-content > div:first-child:has(+ .cs-workbench-grid) > *,
  #view-content > div:first-child:has(+ div[style*="grid-template-columns: 1.1fr 1fr"]) > * {
    width: 100% !important;
    max-width: 100% !important;
  }

  /* Inline display:flex on the workbench columns otherwise wins over the
   * original drawer rules.  Keep only the active conversation/profile panel
   * visible until the user explicitly opens it. */
  #cs-col-chat:not(.mobile-active),
  #cs-col-profile:not(.mobile-sheet-open),
  #im-right-panel:not(.mobile-active) {
    display: none !important;
  }

  .glass-card {
    padding: 15px !important;
    border-radius: 13px !important;
  }

  /* Any remaining flex toolbar should wrap inside the card instead of
   * creating a one-pixel horizontal scroll. */
  #view-content [style*="justify-content: space-between"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #view-content [style*="justify-content: space-between"] > * {
    min-width: 0;
  }

  #view-content [style*="display: flex"][style*="gap"] {
    flex-wrap: wrap !important;
    max-width: 100% !important;
  }

  #view-content [style*="display: flex"][style*="gap"] > .btn,
  #view-content [style*="display: flex"][style*="gap"] > a.btn {
    flex: 1 1 150px;
    max-width: 100% !important;
  }

  #view-content .btn {
    max-width: 100%;
    white-space: normal;
    line-height: 1.3;
  }

  /* Some legacy views put the table directly in a card instead of a
   * .table-responsive wrapper.  Make the table itself the touch scroller. */
  #view-content table {
    display: block !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  #view-content table.glass-table {
    min-width: 640px;
  }

  #view-content table:not(.glass-table) {
    min-width: 620px;
  }

  #view-content h1,
  #view-content h2,
  #view-content h3,
  #view-content h4,
  #view-content p,
  #view-content span,
  #view-content button {
    overflow-wrap: anywhere;
  }

  .table-responsive,
  .table-container,
  #view-content .glass-card:has(> .table-responsive),
  #view-content .glass-card:has(> table) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .table-responsive,
  .table-container {
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    border-radius: 10px;
  }

  .glass-table {
    min-width: 640px;
  }

  /* Bottom navigation is a real dock, so content always has breathing room
   * above it and the floating CS control never sits on top of a tab label. */
  .mobile-bottom-nav {
    height: var(--mobile-nav-height) !important;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
    gap: 4px;
  }

  .mobile-nav-item {
    min-width: 0;
    border-radius: 11px;
  }

  .mobile-nav-item.active {
    background: rgba(79, 70, 229, 0.08);
  }

  .mobile-nav-item .mobile-nav-label {
    font-size: 10px !important;
    line-height: 1.15;
  }

  #admin-cs-floating-container {
    bottom: calc(var(--mobile-nav-height) + 64px) !important;
    right: 10px !important;
  }

  #admin-cs-floating-btn {
    max-width: 148px !important;
    padding: 7px 11px !important;
    font-size: 11px !important;
  }

  /* The Copilot panel is modal-like on a phone. Hide the CS pill while it is
     open so the two conversations never stack on top of each other. */
  body:has(#u5-copilot-panel.active) #admin-cs-floating-container {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(8px);
  }

  body:has(.sidebar.mobile-open) #u5-copilot-trigger {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  body:has(.sidebar.mobile-open) #admin-cs-floating-container {
    opacity: 0 !important;
    pointer-events: none !important;
  }

  /* Bottom sheets are easier to use with one hand and keep the header/footer
   * visible while the body scrolls. */
  .modal-overlay {
    padding: 10px !important;
    align-items: flex-end !important;
  }

  .modal-card,
  .modal-card.help-modal-card {
    width: min(100%, 560px) !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 20px) !important;
    margin: 0 !important;
    padding: 15px !important;
    border-radius: 18px 18px 12px 12px !important;
  }

  .modal-header {
    margin-bottom: 10px !important;
    padding-bottom: 10px !important;
  }

  .modal-title {
    font-size: 16px !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow-wrap: anywhere;
  }

  #usdt-recharge-modal .modal-title {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 5px 8px !important;
    line-height: 1.3;
  }

  #usdt-recharge-modal .modal-title > span:nth-child(2) {
    min-width: 0 !important;
    overflow-wrap: anywhere;
  }

  #usdt-recharge-modal .modal-title > .badge {
    grid-column: 2;
    width: fit-content !important;
    max-width: 100%;
    white-space: normal !important;
    line-height: 1.25;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1 1 120px;
  }
}

/* -------------------------------------------------------------------------
 * Ads Copilot workspaces
 *
 * FB, Google and TikTok templates are intentionally desktop-first because
 * their controls are generated at runtime.  These rules are scoped to the
 * ad workspaces and only apply below the phone breakpoint; desktop layout is
 * left untouched.
 * ------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .fb-ads-view-wrapper,
  .google-ads-copilot-container,
  .fb-ads-copilot-container {
    padding: 10px 0 34px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  .fb-ads-view-wrapper > .glass-card,
  .google-ads-copilot-container > .glass-card,
  .fb-ads-copilot-container > .glass-card {
    padding: 13px !important;
    margin-bottom: 12px !important;
  }

  .fb-ads-view-wrapper h2,
  .google-ads-copilot-container h2,
  .fb-ads-copilot-container h2,
  .fb-ads-view-wrapper h3,
  .google-ads-copilot-container h3,
  .fb-ads-copilot-container h3 {
    font-size: 16px !important;
    line-height: 1.35 !important;
  }

  .fb-ads-view-wrapper [style*="grid-template-columns"],
  .google-ads-copilot-container [style*="grid-template-columns"],
  .fb-ads-copilot-container [style*="grid-template-columns"] {
    min-width: 0 !important;
    max-width: 100% !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .fb-ads-view-wrapper > .glass-card:first-child [style*="grid-template-columns"],
  .google-ads-copilot-container > .glass-card:first-child [style*="grid-template-columns"],
  .fb-ads-copilot-container > .glass-card:first-child [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .fb-ads-view-wrapper [style*="justify-content: space-between"],
  .google-ads-copilot-container [style*="justify-content: space-between"],
  .fb-ads-copilot-container [style*="justify-content: space-between"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .fb-ads-view-wrapper [style*="justify-content: space-between"] > *,
  .google-ads-copilot-container [style*="justify-content: space-between"] > *,
  .fb-ads-copilot-container [style*="justify-content: space-between"] > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .fb-ads-view-wrapper [style*="display: flex"],
  .google-ads-copilot-container [style*="display: flex"],
  .fb-ads-copilot-container [style*="display: flex"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .fb-ads-view-wrapper .btn,
  .google-ads-copilot-container .btn,
  .fb-ads-copilot-container .btn {
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }

  .fb-nav-pills-bar,
  .gads-nav-pill,
  .tiktok-subtabs-nav-bar {
    max-width: 100% !important;
  }

  /* Google renders its pill row as an anonymous flex wrapper.  Give that
     wrapper the same touch-scroll treatment as FB/TikTok without changing
     the desktop layout. */
  .google-ads-copilot-container > div:has(> .gads-nav-pill) {
    gap: 6px !important;
    padding: 5px 2px 8px !important;
    margin-bottom: 14px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .google-ads-copilot-container > div:has(> .gads-nav-pill)::-webkit-scrollbar {
    display: none;
  }

  .fb-nav-pills-bar,
  .tiktok-subtabs-nav-bar {
    gap: 6px !important;
    padding: 5px 2px 8px !important;
    margin-bottom: 14px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .fb-nav-pills-bar::-webkit-scrollbar,
  .tiktok-subtabs-nav-bar::-webkit-scrollbar {
    display: none;
  }

  .fb-pill-tab-btn,
  .gads-nav-pill,
  .tiktok-pill-tab-btn {
    flex: 0 0 auto !important;
    min-height: 36px !important;
    padding: 7px 11px !important;
    font-size: 11.5px !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
  }

  .fb-ads-view-wrapper .fb-demo-toggle-btn {
    width: 100% !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #fb-ads-subview-content,
  #google-ads-subview-panel,
  #tiktok-ads-subview-panel {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  #fb-ads-subview-content table,
  #google-ads-subview-panel table,
  #tiktok-ads-subview-panel table {
    display: block !important;
    min-width: 620px !important;
    max-width: none !important;
    overflow-x: auto !important;
  }

  .fb-modal-overlay,
  .fb-modal-mask,
  .tt-modal-overlay,
  .gads-modal-overlay {
    padding: 8px !important;
    align-items: flex-end !important;
  }

  .fb-modal-card,
  .tt-modal-card,
  .gads-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 18px 18px 12px 12px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .fb-modal-card[style*="padding"],
  .tt-modal-card[style*="padding"],
  .gads-modal-card[style*="padding"] {
    padding: 17px 14px !important;
  }

  .fb-modal-card [style*="grid-template-columns"],
  .tt-modal-card [style*="grid-template-columns"],
  .gads-modal-card [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .fb-modal-card .fb-feed-media-box {
    height: 150px !important;
  }

  #lp-builder-modal {
    padding: 8px !important;
    align-items: flex-end !important;
  }

  #lp-builder-modal > div {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 18px 18px 12px 12px !important;
  }

  #lp-builder-modal [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  #fb-ads-help-modal-overlay,
  #tt-ads-help-modal-overlay {
    align-items: flex-end !important;
    padding: 8px !important;
  }

  .u5-guide-modal-overlay {
    align-items: flex-end !important;
    padding: 8px !important;
  }

  .u5-guide-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 18px 18px 12px 12px !important;
  }

  .u5-guide-modal-header,
  .u5-guide-modal-body,
  .u5-guide-modal-footer {
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .u5-guide-modal-header {
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .u5-guide-modal-footer {
    justify-content: flex-start !important;
  }

  .fb-ads-help-dialog,
  .tt-modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
  }
}

@media (max-width: 420px) {
  .fb-ads-view-wrapper,
  .google-ads-copilot-container,
  .fb-ads-copilot-container {
    font-size: 12px;
  }

  .fb-ads-view-wrapper .badge,
  .google-ads-copilot-container .badge,
  .fb-ads-copilot-container .badge {
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.3 !important;
  }

  .fb-ads-view-wrapper [style*="grid-template-columns: repeat(auto-fit"],
  .google-ads-copilot-container [style*="grid-template-columns: repeat(auto-fit"],
  .fb-ads-copilot-container [style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 420px) {
  .nav-drawer-body,
  .nav-drawer.open .nav-drawer-body {
    gap: 6px !important;
    padding: 7px !important;
  }

  .nav-drawer-body .nav-link {
    min-height: 62px;
    padding: 8px 7px !important;
    font-size: 10.5px !important;
  }

  #view-content > [style*="grid-template-columns"]:has(> .glass-card:nth-child(3)),
  #view-content > [style*="grid-template-columns: repeat(auto-fit, minmax(240px"] {
    gap: 8px !important;
  }
}

/* Translation-aware mobile sizing. Thai glyphs and long Vietnamese labels
 * need more line-height and must be allowed to wrap inside controls. */
@media (max-width: 768px) {
  html[lang^="vi"] #view-content,
  html[lang^="th"] #view-content { line-height: 1.45; }

  html[lang^="th"] #view-content { line-height: 1.55; }

  html[lang^="vi"] #view-content .btn,
  html[lang^="th"] #view-content .btn,
  html[lang^="vi"] #view-content button,
  html[lang^="th"] #view-content button {
    min-height: 36px;
    height: auto !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.3;
  }

  html[lang^="vi"] #view-content .badge,
  html[lang^="th"] #view-content .badge,
  html[lang^="vi"] #view-content .chip,
  html[lang^="th"] #view-content .chip {
    height: auto !important;
    min-height: 22px;
    white-space: normal !important;
    overflow-wrap: anywhere;
    line-height: 1.3;
  }

  html[lang^="vi"] #view-content h1,
  html[lang^="th"] #view-content h1,
  html[lang^="vi"] #view-content h2,
  html[lang^="th"] #view-content h2,
  html[lang^="vi"] #view-content h3,
  html[lang^="th"] #view-content h3,
  html[lang^="vi"] #view-content h4,
  html[lang^="th"] #view-content h4 {
    max-width: 100%;
    overflow-wrap: anywhere;
    line-height: 1.3;
  }

  html[lang^="vi"] #view-content .form-label,
  html[lang^="th"] #view-content .form-label,
  html[lang^="vi"] #view-content label,
  html[lang^="th"] #view-content label {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }

  html[lang^="vi"] .nav-drawer-body .nav-link,
  html[lang^="th"] .nav-drawer-body .nav-link {
    min-height: 68px;
    line-height: 1.25;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  html[lang^="th"] .nav-drawer-body .nav-link { min-height: 72px; }

  /* Keep long translated tabs in one intentional horizontal strip. */
  html[lang^="vi"] #view-content .sub-tabs,
  html[lang^="th"] #view-content .sub-tabs,
  html[lang^="vi"] #view-content .tabs,
  html[lang^="th"] #view-content .tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }

  html[lang^="vi"] #view-content .sub-tabs > *,
  html[lang^="th"] #view-content .sub-tabs > *,
  html[lang^="vi"] #view-content .tabs > *,
  html[lang^="th"] #view-content .tabs > * {
    flex: 0 0 auto;
    white-space: nowrap !important;
  }
}
